Skip to content

Instantly share code, notes, and snippets.

View rubyonrailstutor's full-sized avatar

JD rubyonrailstutor

View GitHub Profile
@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
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
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"font_size": 21.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage",
"Jade",
"Haml"
],
# the controller
angular.module('Lunch.controllers', [])
.controller('LunchCtrl', ($scope, LunchMates) ->
# angular no longer 'unwraps' promises
LunchMates.getLunchMates().then (data) ->
$scope.lunchers = data
)
@rubyonrailstutor
rubyonrailstutor / gist:8342139
Created January 9, 2014 21:13
real time angular d3 piechart
angular.module('CrowdSound').directive 'csChart', () ->
restrict: "E"
scope:
question: "="
index: "="
link: (scope, element, attrs) ->
scope.data = []
class PieChart
constructor: (element) ->
@rubyonrailstutor
rubyonrailstutor / gist:6904104
Last active December 25, 2015 02:39
d3 stuff
angular.module('CrowdSound').directive 'csPie', () ->
restrict: "E"
scope:
question: "="
index: "="
link: (scope, element, attrs) ->
scope.data = []
class PieChart
constructor: (element, data) ->
.factory("Session", () ->
Session =
user: "john"
show_user: () ->
console.log @new_auth.user
connection: new Firebase("https://pitchclub.firebaseIO.com/rooms")
new_auth: {}
login: () ->
firebase = new Firebase("https://pitchclub.firebaseIO.com/rooms")
return_user = {}
@rubyonrailstutor
rubyonrailstutor / excerpt
Created June 20, 2013 04:46
excerpt from ~/.bash_profile
if [ -d /Applications/MacVim.app/ ]; then
# use MacVim over built-in Mac OS version
export PATH="/Applications/MacVim.app/Contents/MacOS:$PATH"
alias mvim='MacVim'
alias vim='Vim'
alias vi='Vim'
export EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim'
alias vimdiff="Vim -d"
fi
@rubyonrailstutor
rubyonrailstutor / gist:5491678
Last active December 16, 2015 20:19
some rails code trying to make foundation work
//layouts/application.html.erb
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
class Company < ActiveRecord::Base
attr_accessible :cb_url, :name, :url
validates_presence_of :name, :cb_url
validates_uniqueness_of :name
has_many :events, :uniq => true
end
@records = Company.joins(:events).where(:events => { :date => ("2013-1-22")..("2013-3-22") } ).count
1.9.3p374 :002 > @records = Company.joins(:events).where(:events => { :date => ("2013-1-22")..("2013-3-22") } ).count