Skip to content

Instantly share code, notes, and snippets.

View rubyonrailstutor's full-sized avatar

JD rubyonrailstutor

View GitHub Profile
# the controller
angular.module('Lunch.controllers', [])
.controller('LunchCtrl', ($scope, LunchMates) ->
# angular no longer 'unwraps' promises
LunchMates.getLunchMates().then (data) ->
$scope.lunchers = data
)
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"font_size": 21.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage",
"Jade",
"Haml"
],
startup, version: 2221 osx x64 channel: stable
executable: /Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2
working dir: /
packages path: /Users/jd/Library/Application Support/Sublime Text 2/Packages
settings path: /Users/jd/Library/Application Support/Sublime Text 2/Settings
PackageSetup not required
catalogue loaded
found 9 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 6 files for base name Main.sublime-menu
@rubyonrailstutor
rubyonrailstutor / gist:176579deb58cd7bf3b58
Last active August 29, 2015 14:01
Example of a good gist
# a good gist is a very few, small pieces of easily digestible code
# please break long, heavily commented files into smaller chunks, with clearly defined questions
# and all the context required to communicate to a user what is happening
def longest_string(list)
longest_so_far = list.first
for item in list
if item > longest_so_far
longest_so_far = item
end
@rubyonrailstutor
rubyonrailstutor / classmodule.rb
Created June 23, 2012 23:08
class, modules and evolution
#TO CREATE A NEW CLASS
module EvolutionarySkills
def breed_rapidly(howrapid)
puts newspecies.*(howrapid)
end
end
class SomeNewAnimal
include EvolutionarySkills
@rubyonrailstutor
rubyonrailstutor / blocksprocslambda
Created June 23, 2012 23:16
Blocks, Procs and Lambda
#HOW A LAMBDA WORKS
var1 = lambda {|x,y| puts x + y}
var1.call(1,0)
#running the above will result in 1
#HOW YIELD WORKS
def method1
yield
end
method1{ puts "this is a yield block"}
@rubyonrailstutor
rubyonrailstutor / prototype.html
Created June 27, 2012 00:21
prototype in js description
<html>
<head>
<script type="text/javascript">
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};
@rubyonrailstutor
rubyonrailstutor / psql
Created July 20, 2012 23:21
psql code
development:
adapter: postgresql
encoding: unicode
database: url_development
pool: 5
username: jd
password:
host: localhost
port: 5432
@rubyonrailstutor
rubyonrailstutor / gist:3716447
Created September 13, 2012 18:27
google oauth problem
Following steps at https://developers.google.com/accounts/docs/OAuth2WebServer
Step 1. submit a get request to the google api endpoint, below is example of my (seemingly) correctly formed get request
https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://mail.google.com/+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&client_id=XXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=http://localhost:4567/oauth2callback&access_type=online
Step 2. receive a callback that contains an authorization code, below is the url I'm receiving back.
http://localhost:9393/oauth2callback?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
@rubyonrailstutor
rubyonrailstutor / gist:3746568
Created September 18, 2012 22:59
env variables
app.rb calls
use OmniAuth::Builder do
provider :twitter, ENV['TWITTER_CONSUMER_KEY'], ENV['TWITTER_CONSUMER_SECRET']
end
and cat ~/.bashrc
is