Skip to content

Instantly share code, notes, and snippets.

View lightscalar's full-sized avatar

Matthew J. Lewis lightscalar

View GitHub Profile
@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 / 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 / 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 / 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 / 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:

<html>
<link rel="stylesheet" href="styles.css" type="text/css">
<body>
<p>Hello</p>
</body>
</html>
@lightscalar
lightscalar / rails.test.frameworks.md
Created September 17, 2011 18:58
Setting up my test environment with RSPEC/GUARD/SPORK

Add the following gems to your gem file:

group :development, :test do
  gem 'jasmine'
  gem 'jasminerice'
  gem 'database_cleaner'
  gem 'capybara'
  gem 'rspec', ">= 2.5.0"
 gem "rspec-rails", "&gt;= 2.5.0"
@lightscalar
lightscalar / no_test_files
Created July 31, 2011 15:35
How to avoid generating test files when running a Rails generator...
rails g controller sample_controller new --no-test-framework
@lightscalar
lightscalar / Using Different Paths in Devise
Created October 23, 2010 15:38
Or: How to leave my UsersController the hell alone
We're working in a Rails 3 App with devise attached to the user model
In routes.rb, if we write:
devise_for :users, :path => 'u'
Then we can obviate all the problems with nested resources. Now users will be directed to /u/sign_in and so forth.
time.strftime( string ) => string
Formats time according to the directives in the given format string. Any text not listed as a directive will be passed through to the output string.
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation