How to keep your ass healthy as a developer

I once read an article about some recent research on preventing negative effects of sitting. I don’t have the link now but there are a lot of articles on this topic, and you can Google them if you are interested. So, what was it all about?

I’m sure, you know that prolonged sitting has negative effects on your health. Sitting is a new smoking, as they say nowadays. Different studies have shown that sitting for extended periods of time increases risks of a number of health issues, among which are heart disease, diabetes and cancer, to say nothing of some ‘lighter’ stuff like hemorrhoids and prostatitis.

As a developer, and previously a civil engineer working at the office, I sit a lot. So, the health risks associated with sitting have always concerned me. That’s why the article I mentioned above interested me in the first place.

What that article suggested, based on some recent study, is that to prevent most of the negative effects of sitting all you have to do is to walk for 2 minutes every hour. It didn’t explain why it was so, but for me it made a lot of sense. And here is why.

It is easy to imagine that when you sit, some of your internal organs are compressed and blood doesn’t flow normally in some parts of your body. That might cause no harm if you sit for just a short period of time. But if you sit for prolonged periods of time it is once again easy to imagine that some negative processes start to occur in the compressed part of your body. Like some cells dying off. Or whatever. I’m sure it’s more complicated than that.

But what if you don’t wait till something bad starts to happen in your body and start walking after one hour of sitting? Then you blood starts to flow normally, your internal organs relax. And maybe 2 minutes of walking are really just enough to prevent some of the negative processes in your body from happening. Then you can sit for another hour and repeat.

On the other hand, if you tried to offset the negative effects of sitting by just doing some exercises after work hours, it wouldn’t help. Because by that time you would have already done the damage to your body from uninterrupted hours of sitting.

How I implemented this in my life

I just have the alarms in my iPhone set for every hour of my work day. When the alarm goes off, I would stand up, immediately set a timer for 2 minutes, and start walking around the office. At first I was a little self-conscious. What would my colleagues think of me wandering here and there 8 times per day instead of sitting and working like everyone else? But I figured that my health is more important to me than what anybody’s opinion of me might be, so I kept doing my little ritual. The funny thing is nobody cared. I never had to explain myself. Well, actually, I did explain what I was doing to one of my colleagues, but I really didn’t have to, because he didn’t ask me.   

And now that I work from home I do just the same thing. I use alarms and timers and walk for 2 minutes every hour. I suggest you try it if you are interested in staying healthy.

Facebooktwitterredditpinterestlinkedinmail

Is programming a right choice for you? (career advice)

Can you become an iOS developer?  Or a any other type of programmer? No. You can’t. Just kidding.

If you are not a programmer yet and are only thinking about going into IT, then this article is for you. You see, when I was in that situation (when I worked as a civil engineer) I had my doubts. I wasn’t sure if the IT was the right thing for me. And I had invested a bunch of years into my engineering career already. Do I just throw all those years away?

Also, when I’d chosen my first career I thought it would be a perfect fit for me. I was wrong. What if I was likewise mistaken about programming? What if I was deluding myself for the second time?

As it turned out, programming is a much better fit for me than engineering. But the funny thing is that it now  seems to me, if I only knew the things I know now, let’s say several years ago, the transition to programming could have become unnecessary. I could have made it in engineering. I could have found an interesting and fulfilling job there.

Now I think that whether you are fulfilled at your job or not doesn’t depend only on the type of work you are doing. It has more to do with your whys. I spent most of my twenties not knowing what I want from life. I didn’t have any goals. Now I do have goals. And I imagine that if I started out not as an engineer but as a programmer right from the beginning, without goals, I might have become just as miserable a programmer as I was engineer. And on the other hand if I had goals right from the get go, I could have ended up a pretty good engineer, fulfilled with my work. Who knows?

So, if you are in a similar situation, if you don’t like your job or profession, ask yourself, is your job really a problem or maybe the problem is you, or more precisely your lack of goals.

Having said that, I still don’t know what whys I could have found for myself in the field of construction engineering. But I can tell you some of my programming whys.

Benefits of being a programmer

When I finally quit my engineering job and decided to learn iOS development I was considering two major benefits programming was going to bring into my life.

First is location independence. Second is the potential to make passive income. First one needs no explanation. If you are a programmer, theoretically you can work from anywhere in the world. All you need is a laptop and internet connection. As of now, I’m not sure if traveling is that important for me. I’d say that I like the idea of freedom to travel anywhere I want anytime I want more than I actually like traveling.

As for passive income, my thoughts were as follows. In order to make money you provide value to the marketplace. And if you want to get money passively all you need to do is to build a system that will provide value to the marketplace passively. And what is software? It is exactly that. A system that provides value passively. When it comes to providing value, software doesn’t differ much from any other thing made by man. Almost everything people create is designed to be useful in one way or another. But software, on top of that, is also designed to  work passively. Basically it works on its own and doesn’t require much maintenance once built. So, if you are interested in building streams of passive income it wouldn’t hurt you to learn programming. Basically every programmer is a professional creator of money machines. Ironically most of the programmers have to work just for their wages making money machines for other people.

Other benefits of programming

So, those were two things that excited me about becoming a programmer. Later I found other benefits of being a programmer. Like this one: I discovered that as a programmer you can show your work easily. You can build something – a site, an app – release it and share it with the world. Now everybody can see what you are capable of doing.

It wasn’t like that in engineering. Theoretically I could have stolen some CAD drawings from my previous employer to present them on my next job interview. Or I could have created some fake project. But it’s too much work and it would still be something fake. In construction engineering you can’t just create something on your own. Some authority has to approve your creation, otherwise it doesn’t count.

The situation in programming is totally different. For example, when I was learning iOS development, I spent one year unemployed, but I still had a lot to show for that year, because during that year I created several apps. Apart from being able to show your work easily you can work on your own projects just for the sake of honing your craft. For example, in the company I currently work for, we haven’t started using Swift yet. So I write my own apps in Swift. That’s how I keep my skills up to date with what is going on in the industry. Also, creating something on your own is just so interesting and fulfilling in itself. I found out that no matter how many hours a day I overwork on my main job I always have energy left for my own projects.

Basically what I’m trying to say here is that programming as an industry provides a very friendly environment for a creative type of person. And with a little bit of hard work your can get everything you ever wanted: autonomy (did I mention, I work from home?), location independence, money, creativity, heck, you can even start your business and be your own boss. I want all of that. That’s what motivates me to do my job.

If all those things motivate you too, than programming might be a good choice for you. Anyway, you need to know you whys. Without them you are going to be miserable in any profession.

Is programming a good fit for you?

I can’t tell you that. But I can tell you how I found the answer to that question for myself. Maybe you’ll even get something useful out of it. At first I had doubts. I wasn’t completely new to programming. I have programmed some stuff occasionally all through my life. It was just for fun and it wasn’t systematic. All I knew was that I liked to code. But I wondered if I would feel the same about programming if I was forced to code every day for 8 hours. There was no obvious answer to that. Also, how would I feel if I had to work on projects I might not necessarily care much about. So, I spent a lot of time hesitating.

But when I finally made a decision and started my new career, I found out that programming was a much better fit for me than I’d ever imagined. The demands this profession puts on a person matched a number of my personal qualities. Here is a list of them.

  1. I’m smart. OK, it might sound arrogant. What I mean by that is that I can figure things out. Like in a geeky way. I may be dumb in many other ways, but when it comes to learning new stuff, it just comes naturally to me. All through my school and university years I was a good student. All the cheaters in the class copied my homework. And working as a programmer can be compared to being a student. You just show up, do your tasks and get good grades. I’ve done that successfully for many years. So, if you were not good at school, maybe, just maybe, programming might not be your thing.
  2. I like to learn. Remember, I told you that in my twenties I didn’t know what I wanted to do with my life? In that period of time I had a hobby which was to learn languages. I’d learn Spanish, French, Armenian languages to various degrees. I even started to learn Chinese language. Then it all ended when I decided to learn programming. I figured why learn languages that you don’t even use when you can learn programming languages and get paid for it.
  3. Technical background. Sometimes in my work I take on tasks of such difficulty that I wonder if I’d be able to solve them without my technical education. But I have to say, such tasks are very rare. Most of the time you can just google your way to the solution of a problem.
  4. Communication skills. I always knew that I was an introvert. And it was so bad that people actually made remarks to me about that. They asked me why I rarely smiled and why I didn’t talk much, which made me uncomfortable. When I started working in an IT company all that changed. There are so many weird people in IT that I feel like a normal person for the first time in my life. In my new profession I had to deal with people who couldn’t talk normally. Usually you talk to such a person not because you want to but because you need to get some piece of information from him. And he just can’t express his thoughts. He doesn’t even look you in the eye when he talks. You can see how painful it is for him to talk to you and you start wishing you didn’t have to deal with that person in the first place. So, communication is important in programming. And I have just enough communication skills for this job.

I realise that this entire post was about me. But I wrote it hoping that it could be useful to other people also. Even though I’m talking here about me and my experiences, you can still get some insights from this article. You can compare your situation with mine or your personal qualities with mine and try to figure out if programming might be the right choice for you.

And finally I’d like to talk about another benefit I get from programming. And it is recognition. When I started working as an iOS developer, my colleagues immediately started to praise me for my work. They were surprised at how good my code was and how fast I could write it. They praised me so much that it even made me feel uncomfortable. For some time I even thought they were kidding or making fun of me. But they were not. It just so happens that programming is such a good fit for me, that I can actually realise my potential in this profession and not be indistinguishable from the masses like I was in my previous job.

I can give you an advice. If you want to change your profession or you are a young person just trying to figure out what you want to become when you grow up, pick a field not just by the benefits it can bring you. Pick a field that matches your personal qualities. Pick a field where you can become the best. And don’t aim to be average. Aim to be the best in your field. If you doubt that you can be the best in your field, probably you picked the wrong field. Whatever your pick, hard work is required. But it is better to work hard to become the best, than to work hard to be average.

But then again I already told you that I feel I could have made it in engineering if I only acted differently. Maybe this whole career picking is not that important. Maybe you just have to pick something and put in the hard work.

Here is a good book you can read on this topic.

Facebooktwitterredditpinterestlinkedinmail

Xcode crushes every time you open it. How to fix it?

I had this problem today when I decided to open Xcode and start working. It just crushed every time I tried to open it. What to do in this situation? Easy. Just delete xcuserdata from the project. To do this:

  1. go to your project folder in Finder
  2. right click .xcodeproj file (or .xcworkspace file if you use Cocoapods) and choose Show Package Contents
  3. delete xcuserdata folder
Facebooktwitterredditpinterestlinkedinmail

How to calculate height of a multiline String in Swift

Yesterday I spent like 2 hours trying to find answer to this question. Eventually I had to figure it out on my own using a bunch of Stackoverflow answers, each of which, if used alone, didn’t produce the desired result.

So, here is what I came up with. It works!

 

Facebooktwitterredditpinterestlinkedinmail

Popping to specific view controller (Objective-C)

I just wrote this piece of code for the project I’m currently working on.

You can use it if you know for sure that view controller of SpecificController class exists somewhere in the Navigation stack. Otherwise your app will crush when index goes down to -1.

 

Facebooktwitterredditpinterestlinkedinmail

How to save an image to photo library (Swift snippet)

This is how I did it in Sigma app with Swift 3.0

 

Facebooktwitterredditpinterestlinkedinmail

How to send an image via email (Swift snippet)

This is how I did it in Sigma app with Swift 3.0.

First you import MessageUI. Then you declare that your class adopts MFMailComposeViewControllerDelegate protocol. Then implement these two methods.

 

Facebooktwitterredditpinterestlinkedinmail

How to implement social sharing in your iOS app (Twitter and Facebook)

socialsharing

Just yesterday I implemented social sharing in my new app called Sigma. Here is how I did it in two easy to follow steps.

First, I added Social.framework to my project and imported it to my view controller.

Second, I wrote this code for Twitter (it’s in Swift 3.0):

 

And this code for Facebook:

 

That’s it!

Facebooktwitterredditpinterestlinkedinmail

How to add custom fonts to your Xcode project

To add custom fonts to your project you need to go through a few easy steps.

First, download the fonts you need. Usually, they are .ttf or .otf files. Drag and drop the files to the Project Navigator. It is best to put them all in one group named Fonts.

screen-shot-2016-11-04-at-19-59-11

Go to project’s Build Phases and make sure the files are included in Copy Bundle Resources.

screen-shot-2016-11-04-at-19-51-14

Then go to your Info.plist file and add the file names to the array called Fonts provided by application.

screen-shot-2016-11-04-at-19-50-35

At this point you can use your new fonts in your project. But there is one more thing, though. To use the fonts programmatically you need to know their names. Their names are not the same as the names of font files you just included into your project. Filenames can be anything ending with .otf or .ttf. Font names on the other hand look like these:

BebasNeueBold, BebasNeueBook, BebasNeueRegular, BebasNeue-Light, ProximaNova-Regular, ProximaNova-Bold, ProximaNova-Light, HelveticaNeue-Light, HelveticaNeue-Bold, CenturyGothic-Bold, CenturyGothic, MyriadPro-Regular

So, how do you know the proper font names? Just print all the font names to the console. Use this snippet:

 

Facebooktwitterredditpinterestlinkedinmail

Transparent navigation bar snippet

Put this code into viewDidLoad method of a view controller where you want to have transparent navigation bar.

Swift 3.0

 

Objective-C

 

Facebooktwitterredditpinterestlinkedinmail