Skip to content

Instantly share code, notes, and snippets.

View rubyonrailstutor's full-sized avatar

JD rubyonrailstutor

View GitHub Profile
@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
@rubyonrailstutor
rubyonrailstutor / process_datum
Created April 18, 2013 23:49
this sounds greek to me...
def process_datum
self.raw_data.each do |datum|
company = Company.where(name: datum[1]).first_or_create(url: datum[2], cb_url: datum[3])
a = datum[0].split("/").each_with_index {|e,i| e.insert(0,"20") if i == 1}.reverse.map {|e| e.to_i}
date = Date.new(a[0], a[1])
event = Event.where(funding_type: datum[4], date: date, value: datum[5]).first_or_create
end
end
@rubyonrailstutor
rubyonrailstutor / gist:5246679
Last active December 15, 2015 10:38
my top bar
%nav.top-bar
%ul.title-area
%li.name
%h1
= link_to "RubyWhiteBelts", root_path
%li.toggle-topbar.menu-icon
%a{:href=>"#"}
%span Menu
%section.top-bar-section
%ul.right
@rubyonrailstutor
rubyonrailstutor / tictactoe.rb
Created October 19, 2012 23:35
threadflip interview
require 'rspec'
class TicTacToe
attr_accessor :board, :turns
def initialize
@turns = 0
@board = []
9.times do
@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