Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
stevenabrooks / update.rb
Created January 14, 2014 21:47
rake task for heroku
desc "Pings PING_URL to keep a dyno alive"
task :dyno_ping do
require "net/http"
uri = URI("YOUR SITE")
response = Net::HTTP.get_response(uri)
end
@stevenabrooks
stevenabrooks / angularmodule.js
Created January 8, 2014 15:46
angular.js module for app
angular.module("User", ["ngResource"])
function UserController($scope, $resource) {
User = $resource("/users.json")
$scope.users = User.query();
$scope.addUser = function() {
entry = User.save({name:$scope.newUser.name})
$scope.users.push(entry);
$scope.newUser.name = ';'
@stevenabrooks
stevenabrooks / angularview.html
Created January 8, 2014 15:40
View for angular.js app
<div ng-controller="UserController">
<ul>
<li ng-repeat="user is users">
{{ user.name }}
</li>
</ul>
<form>
<input type="text" ng-model="newUser.name" placeholder="name">
<button ng-click="addUser()">Add User</button><br>
<span>{{newUser.name}}</span>
@stevenabrooks
stevenabrooks / AngularController.rb
Created January 8, 2014 15:33
Angular JS User Controller
class UsersController < ApplicationController
respond_to :json
def index
respond_with User.all
end
def create
respond_with User.create(params[:user])
end
require 'fis/test'
include Fis::Test
class Dog
attr_accessor :name, :species, :colors, :fur_length
def initialize(attributes_hash)
attributes_hash.each { |k,v| self.send ("#{k}=").to_sym, v }
end
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<meta charset="UTF-8" />
<meta name="viewport" content ="width=device-width, minimum-scale=1.0, initial-scale=1.0">
<title>The Flatiron School</title>
<link rel='stylesheet' href="/css/style.css" type='text/css' media='all' />
<!-- # views/students/students.erb -->
<!-- Begin Title Content -->
<div class="page-title">
<h2>Every Story Has Villains</h2>
<h3>We're <%= @students.size %> people on a journey to learn to smell code.</h3>
</div>
<!-- End Title Content -->
hash.each do |key, value|
hash.delete(key) if value.nil?
end
big_array = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
big_array.inject(:lcm)
class MyApp
def call(env)
puts "hello from MyApp"
[200, {}, ["Hello"]]
end
end
class ContentType
def initialize(app)
@app = app