Open Government

This was an assignment for class, Open Source Software.  

I’ll be summarizing “How the Internet will (one day) transform government” by Clay Shirky

https://www.ted.com/talks/clay_shirky_how_the_internet_will_one_day_transform_government

The main point that Shirky was making is that communication has fundamentally changed and our government should reflect that.  Open government, as it works today, is only open one way, with information going from government to constituents.  The open source model, by contrast, allows information to go both ways, from government to constituents and people to the government.  The ability for people to directly communicate with their government and with other people makes the communication two way, allowing more access for everyone involved.  

 

I have some experience with communicating with my government.  I call my senator, Ted Cruz, on a near-weekly basis, usually telling his staffers that I appreciate their work but I disagreed or agreed with some platforms or positions.  I’m kind to the staffers and tell them what I think, but they usually say very little about the Senator’s positions.  I would love to be able to have Ted Cruz, or more likely his staffers, to answer me directly.  Our communication is me calling them and they noting the call but otherwise not saying much.  The only direct communication I’ve received has been in the form of a Christmas card.  Government can and should do better to communicate directly with us, the people.  

 

I do not, however, want us to get to a government transparency as seen in the book, The Circle.  There, government officials wear a camera that shows all of their meetings and all of their conversations for anyone to see.  That’s a level of transparency that leads to privacy issues for all involved, which is a separate conversation!  

Learning AngularJS

I’ve been learning more front end development as I don’t feel that I actually know enough to call myself ‘full-stack’.  I know HTML/CSS pretty solidly and vanilla Javascript, but the frameworks have always been vaguely mysterious.  I am working though Code School to learn Angular and lucky for me, it’s set up a lot like Ruby on Rails.  Putting so much stuff in the HTML tags feels a lot like Bootstrap.

I’m also working on 100 days of code, but have already fallen off.  Coding while sick is a dangerous thing to do, folks.

New Job!

I just wanted to let everybody know I got a job at Cetec ERP as a software engineer intern.  It has been super fun so far, and a little stressful learning new processes, business requirements, and a new web framework: Perl Catalyst.

 

I’ll be there for 3 months, ending in February 2017.  I graduate with my BS in Computer Science in March 2017.

 

 

Chromebook OpenVPN

I recently got a new job and had the pleasure/torture of being assigned a Chromebook and needing to get it onto the VPN. This is easy on a Mac, which everybody else has, but since the ChromeOS is so lightweight, it was more challenging. I eventually got it to work though, so here are my directions!

If you don’t already, you’ll need some text editor (not Google Docs) and I had good luck with Caret and you’ll need some sort of sftp system and a shell.  I also recommend using developer mode for the Chromebook, as it makes for a lot less hassle long term.  You can also dual boot into linux, but I don’t do that as ChromeOS in developer mode has been enough for me to be pretty happy!

Network

First, have a read on Errietta’s blog and get an idea on how this will work.  I tried her directions and they weren’t entirely sufficient, but I got 90% there.
First go into your OpenVPN directory and build a key:
./build-key client1my

which will build a key and a certificate (.key and .crt) but they will be generated in the directory that the file vars specifies. I had to run:

openssl pkcs12 -export -in client1.crt -inkey client1.key -certfile ca.crt -name MyClient -out client.p12

Go into your openvpn/ccd directory and copy the most recent file . Don’t forget to increment both IPs in the file by 1 (so you don’t have conflicts later on!)

You should now have a client.p12 file.  Share this with the Chromebook in Google Docs.

 

On the Chromebook

Navigate to chrome://settings/certificates (in the browser) and in the Authorities tab, click ‘Import’ and select the ca.crt file (in the ‘shared with you’ section of Google Docs!)  You will be asked if you want to trust the ca, click on ‘trust this certificate for identifying websites’ and leave the rest blank.

Now navigate to chrome://settings/certificates and click on “your certificates” and then “import and bind to device” (NOTE: NOT JUST IMPORT, IT MUST BE IMPORT AND BIND TO DEVICE) and select the .p12 file from earlier.  You should see your (hardware-backed) by the certificate name.

ONC File

First, make your .onc file, as can be seen here: https://github.com/syedaali/configs/blob/master/openvpn-sample.onc and you will need to upload it.  In a browser tab, open chrome://net-internals and along the left side of the page, click on “ChromeOS” then click on the “choose file” button in the line “Import ONC File”

DO NOT PANIC IF NOTHING HAPPENS!  (I panicked and it was unnecessary!)

After a few short moments, the name you gave your network name should appear in the OpenVPN/L2TP screen (click on the wifi icon near your profile icon in the lower right corner of the Chromebook screen, click on VPN, and the file with your name on it should appear there!)

Fill in your password and leave OTC and group name blank.

 

Congrats, you’re all done!

Facebook User Authentication Using OmniAuth

Introduction

OmniAuth is a Ruby on Rails library that provides standardized multi-provider authentication for web applications.  It makes login easy for user by allowing them to  use usernames and passwords from other websites to log into your app.  OmniAuth works on a number of providers, such as Amazon, Github, and Facebook.  A full list of provider strategies can be viewed here: https://github.com/omniauth/omniauth/wiki/List-of-Strategies

Each strategy is released as its own ruby gem and all of them can be found on RubyGems.

👍🏽OmniAuth works with Ruby web projects, so you will need to have either Sinatra or Rails installed in your project before beginning👍🏽

For the purposes of this guide, we will be looking specifically at the Facebook strategy for OmniAuth Facebook log in, as it is one of the more popular and also one of the more complex user authentication processes.  We will also be focusing on Rails, but most of the information will be the same or translatable for Sinatra projects.

😺NOTE: In code examples, things that say YOUR_APP, YOUR-APP, or YOUR_FACEBOOK_APP_ID (and the like) will need to be replaced with whatever your app is called (the directory name, most likely) or your Facebook App ID.  If things aren’t working, be sure to check those!😺

Installing

First you will need to add the following line to your Gemfile

gem ‘omniauth-facebook’

Any additional OmniAuth strategies will need to be added individually.  Be sure that you install it after the Rails or Sinatra gem in your Gemfile.  After you have entered the gem, run bundle install the the terminal (in your app’s directory!)

The database now needs to be migrated as well as letting Rails know what information will need to be required, which we will accomplish by the following command in the terminal (again in your app’s directory):

rails g migration AddOmniauthToUsers provider:string uid:string

Then you will need to migrate the database, which can be done in Rails by this command in the terminal:

rake db:migrate

Get Facebook Information

Next you will need to register your app with Facebook and get log in credentials.  Go to https://developers.facebook.com/ and click on “Add A New App” in the dropdown in the upper right corner of the page.  Enter the name you wish to display on your app, a contact email, and select a category that best fits what your app does.

Click on Settings on the left side of the page and here you will see your App ID and  App Secret key.

screen-shot-2016-11-17-at-8-00-42-am

For my project, I used a localhost alternative, lvh.me.  lvh.me is a domain that is set up to point to 127.0.0.1, which is localhost.   This made the Facebook callbacks easier to work with and I highly recommend using it, but if you prefer trying localhost directly, that’s up to you!

Add your app’s domain name in App Domains.  I’ll be using lvh.me, followed by the port number.  Click on ‘Add Platform’ at the bottom of the page and select ‘Website’ followed by entering your Site URL.  The Site URL and the App Domain will need to match.

In the root directory of your Rails project find (or if you don’t have it yet, create) a .env file.   On a new line add FACEBOOK_APP_SECRET=YOUR_APP_SECRET replacing YOUR_APP_SECRET with your App Secret key. There are no spaces and no quotation marks, brackets, or braces.

 You will now use the OmniAuth::Builder Rack middleware to build the list of strategies and what needs your app has for the use authentication in config/initializers/omniauth.rb:

Replace 'YOUR_FACEBOOK_APP_ID' with the App ID on your Facebook Developer dashboard and keep the single quote marks intact.

👍🏽Your App Secret key should remain private, so if you are using a public Git service, such as Github, remember to add your .env file to .gitignore.  👍🏽

 

Adding CoffeeScript

One other file that will need to be added, if you don’t already have it, is a app/assets/javascripts/facebook.js.coffee

Add the following to that file:

 

 

This adds callback information to our app so that we send the right information to Facebook’s API and return the information given to us in a manner that we can work with.   It also separates the JavaScript code from the rest of our code, which makes everything easier to read.

 

Integrating OmniAuth Facebook Into Application

OmniAuth was intentionally designed to be extremely agnostic as far as what providers you use and what information you can get from those providers.  In the Facebook API we can get several different pieces of information from the user’s profile.

Option Keywords Default Value Description
callback_url/ callback_path If you wish to have a server-side flow, you can specify a custom callback URL. This should be specified in your Facebook app configuration (in ‘Advanced’ settings)
display page How the authentication page shows up to the user. https://developers.facebook.com/docs/reference/dialogs/oauth/
image_size square Displaying user profile image. https://developers.facebook.com/docs/graph-api/reference/user/picture/
locale Specify which location should be used when acquiring user information. https://developers.facebook.com/docs/internationalization/
scope email A list of permissions that you may request from the user. https://developers.facebook.com/docs/reference/login/
secure_image_url false If you set this to true the user profile image url will be returned in the auth hash

 

As an example, if you wanted to get a user’s home town you would put in the same config/initializers/omniauth.rb:

 

 

Any additional requests can be added below as a separate line in the same middleware.

Logging

In the same config/initializers/omniauth.rb, we will add a logger at the top of the file:

OmniAuth.config.logger = Rails.logger

This will allow us to view the logs of OmniAuth communicating between the app and the Facebook Graph API.

Using OmniAuth

One way to utilize OmniAuth is by linking it in a button to ask users to log in:

 

 

Which gives us a button that looks like this, with some styling:

screen-shot-2016-11-19-at-11-27-39-am

 

Trying It Out

Try clicking the button or link to log into the site.   The first time I tried this, I got this error:

 

screen-shot-2016-11-19-at-5-06-54-pm

 

This error was solved by entering the correct site on the Facebook Developers and making sure the Facebook Login Settings are set correctly:

 

screen-shot-2016-11-19-at-10-15-31-pm

screen-shot-2016-11-19-at-5-44-08-pm

 

👍🏽Remember to restart your Rails server if nothing else is working!👍🏽

 

Conclusion

By now you should be able to log into your site using the Facebook OmniAuth gem.  OmniAuth is an easy way to use the Facebook API in Ruby web applications.

 

More information about OmniAuth and the Facebook API can be viewed at:

The Github page for OmniAuth-Facebook: https://github.com/mkdynamic/omniauth-facebook

Using the Facebook JavaScript SDK: https://coderwall.com/p/jwcrpq/facebook-javascript-sdk-with-coffeescript

Using the Facebook API: https://developers.facebook.com/

Deploying Rails to Heroku

While deploying an initial version of Crapper Keeper, I ran into a problem with Heroku.  Deploying to Heroku is super easy, since you just have to deploy a Github branch and the site is live a few moments later.  My app, which was running well locally, suddenly was having database problems.

Crapper Keeper is a Ruby on Rails app.  Rails comes with SQLite out of the box, but Heroku doesn’t support SQLite.  So after a lot of searching, I was able to find a way to change the database from SQLite to PostgreSQL.  One guide I found handy was on Stack Overflow and here.

One tip, that I forgot, was that you have to make the database but then also remember to migrate the database, using rake db:migrate

Crapper Keeper

Crapper Keeper is a consumer inventory system built with Ruby on Rails backend, Bootstrap frontend and and iOS app. Uses OmniAuth with Facebook login, Postgres database, deployed on Heroku.  Users login using Facebook, enter the location where they are keeping items to be tracked and can upload or take a picture of the item. Users can search for the item name or can browse through containers.

This is a work in progress, check out the site to see what step I’m on!  Code can be viewed on Github.

screen-shot-2016-09-27-at-10-40-21-am

How To Find Freelance Clients

First, I’m going to irritate you:

I was at an interview yesterday and my freelance business came up, since it’s the only programming work experience I have.  The developers interviewing me seemed really intrigued and a little confused on how I find freelance clients.  I’m not going to lie, when I first started freelancing in May 2015, I was looking around and couldn’t find a client in sight.  Now, in September 2016, I turn work down all the time because I’m just too busy with other clients.  I was ALWAYS irritated when reading blogs when the author bragged about turning down work…and here I am telling you just that.  There are a few things that I did that really changed my business for the better and I’m going to try to communicate that to you.  Some of it is magic/luck/#blessed, but I really don’t think that’s the only contributing factor.

Networking

I know, you have been told to get out there and network.  Usually it’s left just at that – go talk to people.  Let me fill you in on a mistake I made.

DO NOT GO NETWORKING WITH PEOPLE LIKE YOU

This was the single biggest mistake I made when trying to find clients.  I would go to https://www.meetup.com/ and look for tech meetups to go to.  DUMMY – tech people can make their own websites.  They don’t need you and they definitely won’t pay you well for something they could do just as easily.  No, instead I want you to go put on your big girl pants, grab a stack of business cards and go to a small business meetup.  Go to the chamber of commerce.  Go to coworking meetups.  Go to the farmer’s market and chat people up.  That’s where you’ll find your first clients.

I know small business meetups sound scary.  You’re a developer, not a small business person.  Actually, you can be both.  As a freelancer, you aren’t quite a small business, but you can talk their talk and understand their needs.  Remember, you are not working as a developer.  You are solving problems for people.  You just happen to use code to solve those problems.

Cold Calling/Emailing

One of my first clients was a local shop.  I was browsing their website and noticed all their image links were broken.  I knew exactly what was wrong, so I sent a quick email to the shop owner telling them what was wrong and how they could fix it.  The shop owner said they didn’t know what the hell I was talking about, but if I came into the shop with my laptop they would pay me to fix it.  I got a ton of business from that owner, because every time one of his small business friends complained about their website, he would tell them to contact me.

Cold Emailing (let’s be honest, you’re much more likely to email than to call) isn’t going to have as high of a success rate as meeting people face to face, but it works often enough that it’s worth trying.  To be clear, you need to address a problem, not say things that are asshole-y or smug.  Say the links are broken, not that a 12 year old could make a better site.  Say the site is not responsive (more on this in a bit) don’t say that the site is complete garbage.  Somebody, and that somebody is likely the owner, spent a lot of time trying to get a website up.  That’s what they heard businesses need.  Let them know, respectfully, that you can make a better site for them.  Again, you are solving a problem.

Freelance Job Boards

90% of them are crap.  Upwork, Freelancer, whatever.  They are crap.  Freelancers are racing to go be the cheapest option because they believe (and a lot of clients on those boards back up this belief) that you can compete on price alone.  That’s nonsense.  If you want, you can bid on a few projects to 1: discover that it’s a race to the bottom and 2: find out I’m right about it being mostly crap.  If you have no portfolio, then go ahead.  Honestly, making a site for you Aunt Gertrude for free will be a better experience, but go ahead and try it out.

There are some freelance job boards, however, that are not total garbage.  In Austin we have Austin Freelance Gigs, which has a lot of great jobs that pop up at all hours of the day and night.  People can tag you in job postings so you see it (again, knowing people is key to freelancing!) or you can just set aside some time to check the page.  You do have to practice some diligence to make sure you aren’t spending all your time on Facebook, but it’s a nice way to find local jobs.

Technical Jargon

This was something that took me WAY too long to figure out.  The people you are helping are not tech wizards.  Many of them will tell you straight up that they are not tech savvy at all.  Knowing that they are not tech savvy, don’t try to impress people by using jargon and concepts they have never heard nor cared about.  Treat them with respect.  If you notice their site isn’t responsive, tell them that it isn’t mobile phone friendly.  Tell them that it affects search results.  Tell them how many people use their phones for checking on websites.  Those are the problems they care about – they do not care about which framework you’ll use or what library you’ll use.  When looking for jobs, remember that Jane Businesswoman isn’t going to ask for a React JS frontend with a Ruby on Rails backend.  She’s going to ask for a site that runs on a single page and can be done quickly.  You aren’t selling Ruby on Rails, WordPress, or any tech stack.  YOU ARE SOLVING A PROBLEM!

Now What?

I would love to hear your questions or other comments about looking for clients.  There is so much work out there, you just have to be found.  Leave a comment!

Add Constraints

Adding constraints to elements in your app helps your app look consistent between different devices that run iOS.  You can have a button that is centered in an iPhone 6 and is also centered in an iPad Pro.  You can also have that button be centered depending on if you are viewing in portrait vs. landscape mode.

Add Constraints

In your project, select the element to which you will add constraints.  You can select it in the view controller navigation on the left side of Xcode.  See it below, the button is highlighted.

Screen Shot 2016-09-06 at 12.06.00 PM

Next click on the bar graph button on the bottom right of the view board.  You can see a menu pops up.

Screen Shot 2016-09-06 at 12.06.12 PM

Then you can click both Horizontally and Vertically in Constraint buttons on the left, then click the bottom button that says “Add 2 constraints”

Screen Shot 2016-09-06 at 12.06.29 PM

Now your element is both vertically and horizontally aligned!  Pretty neat and pretty easy!

What Makes a Good App?

I’ve been brainstorming new app ideas and I’ve been coming up with a list of qualities that makes for a good app.

  • Thumb/finger friendly buttons
  • Doesn’t use up all my battery life
  • Doesn’t use up all of my data
  • Runs fast enough that I don’t give up and switch to something else
  • Does something that would be harder to do without the app —> MAKES LIFE EASIER

I feel like that last point is where we get hung up as app developers.  It’s fun making apps!  It’s fun adding functionality!  But is it easier to do whatever it is we are doing on the app than it is on the website or using some other tool.  That’s the real pickle we’re in.