On Github chrisuehlinger / TJFL
Original Sentence: If you finish your work quickly, you can play games.
Thai Understanding: If you finish your work quickly, you can play games.
Original Sentence: It is integral that you close your curly braces, or function execution could continue outside your function block.
Thai Understanding: It is integral that you close your curly braces, or function execution could continue outside your function block.
Original Sentence: The "return type" specifies the type of value the function will return.
Original Sentence: The "return type" specifies the type of value the function will return.
Re-phrased Sentence: What does "return type" mean? "Return type" tells the kind of thing the function will give back.
Thai Understanding: What does "return type" mean? "Return type" tells the kind of thing the function will give back.
Original Sentence: If we concatenate our JavaScript files, our page will load faster.
How it sounds: If we concatenate our JavaScript files, our page will load faster.
Original Sentence: If we combine our JavaScript files, our page will load faster.
How it sounds: If we combine our JavaScript files, our page will load faster.
This is part 1 in a series on setting up your personal space on the web:
Setting up a personal space on the web is easily one of the best things I’ve done this year. If you’re new to Web Design/Development and you want to know what the single best thing you can do is, I’m going to lay it all out for you right here.
So before we get started, a few disclaimers:
These are my suggestions. There’s a lot of flexibility here. You can use different tools, different hosting, whatever. Some of this stuff may seem complicated or excessive. I’ll try and cover the “why” of each step in an aside, in case you’re curious. However, some of these tools have entire books dedicated to them, so I’ll try and redirect you to a better source if you’re still puzzled. I’m assuming some familiarity with these tools (especially Git). If something seems crazy, I’ll link to more documentation, but I’m going to be moving at a bit of a brisk pace. None of these steps matter, as long as in the end you achieve the following:You need to have a place on the web that you can call your own. Ideally, it should be:
I posit that the best way to do this is to get an octopress blog on github pages on a personal domain, and then develop all your projects with a gh-pages branch so you can share them easily. After about a year of having this easy publishing at your disposal, you’ll suddenly realize that you now have an easily shareable online portfolio. Awesome.
If you want to see the code for my personal website (which should include the file with this blog post) I’ve uploaded it here. This is the kind of thing you’re going to end up with at the end of all this.
For this first part, all you need is a terminal (I use the Mac OS X Terminal that comes with any Mac), and an install of git (which comes with every Mac).
You should also have your text editor of choice. Any text editor will do, although I highly reccomend Sublime Text and/or Brackets.
So Github is a great website that lets you upload your code to share with others. There are tons of great codebases on there, and you could spend days just poring over the code in some of the really great projects. However, what we’re really interested in here is Github Pages.
Basically, Github will host your site for free. Yes. Free. The catch is that your site has to be static. It has to be a folder full of html, css, javascript and image files that the server can throw at someone if they ask for them by name. No database, no backend logic, just a folder full of files.
There are huge advantages to having a site like this. Even if you don’t use Github Pages, you can easily find cheap hosting for a static site. There’s also the fact that static sites are really cheap and easy to serve, so your site can stand up to monstrous amounts of traffic. As of today, I’ve never heard of anyone’s Github Pages site going down due to too many requests, and Github never comes after your credit card.
And it gets better. With Github Pages you can easily make a page for any of your projects. If one of your Github repositories has a branch called gh-pages, and that branch has an index.html file, you can easily get to it at {yourname}.github.io/{repository-name}. These project pages are the best part of this whole thing, so let’s get that squared away right now.
To start out, go to Github and make a new respository. Call it HelloWeb, decide whether you want a README file and a .gitignore file (you can start with one or make one later, it doesn’t really matter) …alright good. Now go into your Terminal, find a nice cozy part of your hard drive (I recommend making a ~/Development directory to keep all your dev stuff in) and type the following command:
1
git clone https://github.com/{yourname}/HelloWeb
This will download the git repository and store it in a directory named HelloWeb. USe the command cd HelloWeb to go inside the repository. Now, you’ll start off on the master branch, so you’ll need to make a gh-pages branch where you’ll be doing your coding.
1 2
git branch gh-pages git checkout gh-pages
So far so good, now fire up your text editor and make a file in ~/Development/HelloWeb called index.html. You can keep it simple:
1 2 3 4
<h1>Hello!</h1> <script> alert('Hello Hello!'); </script>
Save that, head back to the Terminal, and add this file to your repository:
1
git add index.html
Now make a commit to “save” what you’ve done:
1
git commit -am "Added index.html"
Now push the gh-pages branch up to GitHub (they take care of setting up a lot of the remote stuff)
1
git push origin gh-pages
Now go to {yourname}.github.io/HelloWeb. There’s your page! (It may take a minute or so the first time)
The hard part is done. You have an HTML file on your computer. You can put any HTML, CSS or Javascript in there, and it will show up, as you wrote it, to anyone, on any computer, anywhere in the world (if they visit your website).
Feel that? That’s what power feels like.
Now let’s try something else. Let’s take someone else’s project, make some changes to it, and upload it to our site.
Let’s say you really like the game 2048, and you want to make a spinoff that works a little differently. A lot of my projects start off like this— I’ll see something cool, imagine a different way it could work, make some changes, and then share it (giving credit to the person who had the idea of course).
You may have noticed, 2048 is on a github.io domain. The guy who made it pushed it to the gh-pages branch of a repo named “2048”. This will be pretty easy. First, go to https://github.com/gabrielecirulli/2048 and click the button in the upper right part of the screen labeled “Fork”.
Once you’ve forked the repo (that is, you’ve made a personally copy of it that is now under your name) download it to your ~/Development/ directory:
1 2 3
git clone https://github.com/{yourname}/2048 cd 2048 git checkout gh-pages
Ready to go? Alright, make a change to one of the files in there. Do anything. Make the background pink. Use CSS filters to make the numbers blurry. Put your name on the page as an <h1>, anything. When you’re done, do this:
1 2 3
git add {any new files you made if you made any} git commit -am "{write a description of your change}" git push origin gh-pages
Boom. It’s up there. Now you can show anyone your “Pink, blurry, personally branded 2048”. If you go to http://chrisuehlinger.com/2048/ you’ll see my version. I tried to write an AI that would beat the game. I did that because I was bored one afternoon, and now it’s part of my portfolio, and I can bring it up on my iPhone in the middle of an interview.
So now you’ve got an easy way to publish anything you do. But what would really help would be a centralized site with a blog, and a portfolio page, and other goodies. I’ll cover that in my next post.
You’re going to want a way to run your site on your computer, so you don’t need to push to Github every time you want to check if somethings working. I highly reccomend the Node.js module http-server. If you already have the Node package manager npm, type this to install the package:
1
npm install -g http-server
Then go to the directory where the HTML files are and type:
1
http-server -p 1234
Your website should now appear at http://localhost:1234. Anytime you change something, just refresh the page and you’ll see the change.
I also HIGHLY reccomend the node app called ungit. It’s a GUI that makes it much easier to use git. To install it, type:
1
npm install -g ungit
Go to the directory where your repository is and type:
1
ungit
Now visiting http://localhost:9000 will show you the app.
This is a continuation of my post on getting your personal space on the web set up.
So at this point, you should be able to visit {yourname}.github.io/HelloWeb or {yourname}.github.io/2048 and see the pages you made. But what if you visit plain old {yourname}.github.io? You get a 404 error. We need to get you set up with a github.io repository and a Jekyll static site.
This is going to get a bit more in depth, but stick around and you’ll have a really solid personal portfolio.
So, Github Pages lets you upload static pages that get served up from your github.io subdomain. One thing I didn’t cover, is that if you make a repository called {yourname}.github.io and push it to Github, they will magically take whatever is in there and serve it up at your site.
If you have a file in this repository called index.html that file now be displayed if you go to {yourname}.github.io (it has to be in the master branch, which is the default one, NOT the gh-pages branch). If you have a file called about.html, it will be visible at {yourname}.github.io/about.html. If you have folder called contact that contains a file called index.html, it will be visible at {yourname}.github.io/contact/.
But we can do a bit better than just plain old HTML, and that’s where Jekyll comes in.
Static pages sound cool, until you start to miss a lot of the cool things you get with dynamic websites:
Fortunately, there’s Jekyll, a static site generator that gives you a lot of this stuff. You can read about it here.
I was really confused when I first heard of Jekyll, so here’s a quick rundown of how it works:
You download some ruby tools You make a directory full of templates You make some pages (using either html or markdown) Jekyll “compiles” everything together, slotting all your pages into the templates (so they all have the same header, or whatever) and arranging the posts in your _posts directory so that their URLs will correspond to the dates when they were posted. It puts this compiled site into the _site directoryEven better, when you do a git push, Github will handle steps 4-5 on their own and will serve up the _site directory automatically.
But before you go racing after Jekyll, I want to stop you (for better or worse) from making the same mistake I did.
So as you start learning about a lot of cool web technologies, your Jekyll configuration will get more and more complicated.
Let’s say you want to use Sass instead of plain old CSS, or you want to use Haml instead of HTML? What if you have a Grunt workflow that does all kinds of crazy stuff to your javascript every time you save?
Well, Jekyll has tons of plugins to accomodate for a lot of this stuff, but unfortunatel Github will only run a few certain plugins with their automatic Jekyll thing. They’ve gotten better about supporting Sass and Coffeescript, but there’s no guaruntee they’ll ever have all the things you need.
But wait… what if you wrote your site in one branch, compiled it with Jekyll using all the plugins you want, switched back to the master branch and selectively copied over the _site directory to the master root directory then pushed to Github?
If you were as confused and revolted by that last sentence as I was, you’ll be glad that the Octopress guys have figured this all out for us. The truth is, if you stick with Jekyll and don’t use Octopress, you’ll end up making it yourself (and if you’re like me, it won’t be nearly as well thought out).
Alright, we’ve covered a lot of ground without coding anything. That bugs me. Let’s get to work.
You may have done some of this stuff before, this is just to make sure you’re on track.
So I’m working on a Retina MacBook Pro; these instructions will be tailored to Mac OS X users.
First, get homebrew up and running. homebrew is basically the package manager that contains all the other package managers. It allows you to keep all your programming related stuff organized and up to date. Getting it set up is a bit of a task, so I’ll let the homebrew guys themselves explain it.
Once you have homebrew, use it to grab a bunch of important things:
1 2 3 4
brew install git brew install ruby brew install rbenv brew install node
git is a version control system that helps you organize your code.
Ruby is a programming language that has a bunch of useful tools we’re going to use. We won’t actually be writing any Ruby code today. Ruby comes with gem, a package manager for stuff that’s made using ruby. rbenv is a tool that let’s you keep track of which version of Ruby you want to use in which folder (this may seem overkill, but we need rbenv in order to install Octopress).
Node.js is a framework for making things with javascript. The Node package manager is called npm, and has lots of good javascript related stuff.
Now that you have ruby and gem, let’s grab a bunch of other things we’ll need:
1 2
gem install bundler gem install jekyll
Bundler is a special ruby package installer (I’m not sure why ruby needs a package manager AND an installer… there’s a joke about ruby packages and lightbulbs in here somewhere) and Jekyll is needed so you can compile Jekyll sites locally on your computer.
So I’d reccomend starting with the Octopress documentation, this is a little complicated.
Once you’re all set up, check out some of the Octopress themes available. In my opinion, too many people stick with the default theme. Right now I’m using a modified version of the mnmlpress theme, although that may change by the time you read this.
Chances are good you won’t become famous. Sorry.
However, once you share something on the web, you never know when someone might randomly see it, post it on social media site, and drive thousands of people to your site over the course of a day or so. If you haven’t done your preparation, you won’t even know that this happened. If you’ve properly prepared, this opportunity could net you a new job, a bajillion twitter followers or even just a bunch of people saying “Thanks”.
You want people to be able to easily contact you if they like your stuff. Easily is an understatement. The very INSTANT their brain chemicals form into “like” configuration, they should be able to contact you with 0 effort. You don’t need a floating “social media iceberg” on the side of your page, but you should definitely have:
Set up Disqus and put your Disqus ID in your _config.yml file. Octopress will add Disqus comments to the bottom of your posts. It’s super easy, and often the most direct way you can receive feedback.
Since you’ll no doubt have tons of projects accessible on your site, organizing them into a “portfolio” page and linking to that page in your header is also SO WISE.
Octopress comes with Google Analytics bundled in. You should set up a Google Analytics account, and put your Google Analytics ID in your _config.yml file. You should also make sure you include the Google Analytics “magic javascript snippet” in EVERY HTML file in every project you post.
Do all this stuff NOW. Making stuff people like is hard enough, turning those likes into meningful connections doesn’t have to be.
Hopefully you now have a personal space on the web where you can post anything. You still have to make cool things, there’s no getting around that. But now:
If you’re feeling uninspired, here are a bunch of the outlandish things you can do with just HTML, CSS and Javascript:
I hope these articles have helped, good luck!