This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
" Vim Cucumber | |
" | |
" To install, put this in your .vim directory and source it. | |
" If you use Janus, place in your .vim/plugins directory and restart vim | |
function! Cuke() | |
let cmd = "cucumber --no-color %" | |
execute ":! " . cmd | |
endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# activerecord/lib/active_record/associations/builder/belongs_to.rb automagically creates | |
# the private methods for you if you include counter_cache in your belongs_to association. | |
# We simply override the basic behavior of these with our own conditions. | |
# | |
# For more information, check out: | |
# https://github.com/rails/rails/blob/733bfa63f5d8d3b963202b6d3e9f00b4db070b91/activerecord/lib/active_record/associations/builder/belongs_to.rb | |
# Lines 23 - 44 | |
class Inventory < ActiveRecord::Base | |
belongs_to :user, counter_cache:true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PgSearchable | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def searchable_on(*args) | |
@@search_columns = args | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#application.html.haml | |
%html(ng-app) | |
#event.js | |
function EventCtrl($scope){ | |
$scope.current_user = { | |
name: "Scotty Moon", | |
email: "[email protected]" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sinatra JSON API Example</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script> | |
<script src="/controllers.js"></script> | |
</head> | |
<body ng-controller='ThingController'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ThingController($scope, $http) { | |
var baseUrl = 'http://sinatra-api-example.scottymoon.c9.io'; | |
$http.get(baseUrl + '/things').success(function(data) { | |
$scope.things = data; | |
}); | |
$scope.create = function(thing) { | |
$http.post(baseUrl + '/things', thing).success(function(thing){ | |
$scope.things.unshift(thing); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity implements View.OnClickListener { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
Button clickMe = (Button) findViewById(R.id.button_name); | |
clickMe.setOnClickListener(this); | |
} | |
@Override | |
public void onClick(View view) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"total_pages": 5, | |
"page": { | |
"number": 1, | |
"content": [ | |
{ | |
"type": "text", | |
"value": "Aliquam ut dui eu purus ultrices mollis. Nullam mattis, leo vitae accumsan rhoncus, nisl urna tincidunt lacus, ac fermentum ante neque at metus. Sed at eros hendrerit, lacinia augue et, facilisis velit. Praesent est metus, faucibus id mi quis, aliquet tempus urna. Suspendisse pellentesque <b>leo ut ligula luctus</b> ultrices. Sed at ultrices velit. In et leo turpis. Duis accumsan ante non nunc elementum, vitae dapibus metus pellentesque. Cras id tempor eros. Vivamus et scelerisque eros, sit amet laoreet lorem. <br/> Curabitur nisi nulla, congue et enim et, iaculis dictum lacus. Mauris id libero neque. Nulla condimentum dignissim nunc rhoncus mattis. Sed pellentesque nec ante at aliquam. Aliquam et dignissim ante. Sed sed tellus non turpis lacinia rutrum sit amet sit amet ligula. Integer enim mauris, ornare ut dapibus in, tempor ac justo. Donec condimentum sit amet metus eget euismod. Donec hen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/ruby | |
WATER = 22.2593 | |
WATER_MEASUREMENT = "ml" | |
COFFEE = 0.04493 | |
COFFEE_MEASUREMENT = "g" | |
def get_water_weight(coffee) | |
(coffee.to_f * WATER).ceil.to_s + WATER_MEASUREMENT | |
end |
OlderNewer