Skip to content

Instantly share code, notes, and snippets.

View lightscalar's full-sized avatar

Matthew J. Lewis lightscalar

View GitHub Profile
@lightscalar
lightscalar / git_tips.md
Last active September 27, 2015 21:47
Git Tips

Some Useful Git Tips

Configuration

Turn on command line colors. Just do this:

git config color.ui true

Also, and this is a huge time saver: to stage all deleted for files for GIT deletion, simply call:

@lightscalar
lightscalar / Rake_Tasks.md
Created February 10, 2012 00:07
Find all the rake tasks...

To find all rake tasks that are available:

rake -P | grep rake

If you want to reset the database (migrations & all), for example:

rake db:migrate:reset
@lightscalar
lightscalar / Owning.md
Created April 16, 2012 17:47
Owning LinkedKegs

I was having some problems installing mongodb. I did the following:

brew update
brew install mongodb

This proceeded just fine, could not symlink, with the error:

@lightscalar
lightscalar / angularjs-rails.md
Created July 9, 2012 15:01
Angular JS & Rails :: Playing Together

Rails & Angular :: Playing Together

0. What is this?

This is a quick writeup on how I get Rails & Angular up and running and working together, and how I set up the test environment so that I can test both back-end Rails as well as front-end JavaScript. This is a work in progress, and I make no guarantees to its accuracy or up-to-dateness.

I will walk through putting together a simple application shell running angular.js together with a Rails-based back-end authentication system.

1. Getting Started.

@lightscalar
lightscalar / angular_directive.md
Created July 20, 2012 22:07
An Angular Directive: The Swear Jar

A Simple Angular Directive: The Swear Jar

Angular.js is a powerful clientside JS framework that aims to enhance HTML for web applications. I think it already an excellent and feature-complete framework and it is only going to get better. But it is a new framework, and its documentation is currently in a state of flux, often riddled with outdated references to beta versions, and sometimes just damn confusing.

I struggled with understanding how to make a directive and after too many hours, I succeeded. I am writing up my thoughts on the matter here for my future self, and all who happen upon this gist.

In honor of the effort it took to learn how to build a proper directive in Angular, I will be creating a widget that I call a swear jar — an HTML element that may be included as any other element would — i.e., by writing `````` — and that, when clicked by a profane programmer, adds a dollar

@lightscalar
lightscalar / pandas.md
Last active December 14, 2015 00:39
Useful things related to PANDAS

Useful PANDAS Stuff

Installation & Upgrade

In order to upgrade pandas on OSX (or *NIX), use pip:

sudo pip install pandas --upgrade
@lightscalar
lightscalar / matplotlib.md
Created April 12, 2013 13:26
How to make things look nice in matplotlib.

Changing Fonts, etc.

To change the fonts on the plots to something nice,

    # Set the fonts to be something nice.
    font = {'family': 'helvetica', 'weight': 'light', 'size': 18}
    matplotlib.rc('font', **font)
@lightscalar
lightscalar / ruby-2.0.0.md
Created May 8, 2013 12:33
How to upgrade cleanly to ruby 2.0 via RVM

Upgrading to ruby 2.0:

$ rvm remove 2.0.0 # get rid of unsuccessful installation
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm install ruby-2.0.0
$ rvm --default use ruby-2.0.0
@lightscalar
lightscalar / postgres.md
Created May 8, 2013 13:37
Getting POSTGRES launched

After installing the latest & greatest:

To have launchd start postgresql at login:

    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

Then to load postgresql now:

    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@lightscalar
lightscalar / ruby_array.md
Last active December 17, 2015 05:28
Ruby Array Tricks

Suppose you have an array of multiple (i.e., more than two) ruby arrays,

ary = [[1,2,3,4], [4,5,6,7], [8,9,10,11]]

To zip together these arrays in an element-wise fashion, we can use the array's zip method:

zipped_ary = ary[0].zip(*ary.last(ary.size-1)) # => [[1,4,8], [2,5,9], [3,6,10], [4,7,22]]