Skip to content

Instantly share code, notes, and snippets.

View chrishough's full-sized avatar
😸
How can I help you?

Chris Hough chrishough

😸
How can I help you?
View GitHub Profile
@slindberg
slindberg / if-all-exists.js
Last active August 29, 2015 13:57
Bound conditional Handlebars helpers for Ember
import ifConditionHelper from 'myapp/helpers/if-condition';
/**
* Logical AND Existence Conditional Block
*
* Usage: {{#if-all-exists field1 field2}}Either field1 or field2 is truthy{{/if-all-exists}}
*
* Executes the given block if all arguments are defined
*/
export default function() {

Your Rails Config

config.i18n.railties_load_path

no docs for i18n.railties_load_path found in rails guides

["/Users/schneems/.gem/ruby/2.1.2/gems/will_paginate-3.0.4/lib/will_paginate/locale/en.yml", "/Users/schneems/.gem/ruby/2.1.2/gems/devise-3.2.4/config/locales/en.yml", "/Users/schneems/Documents/projects/codetriage/config/locales/devise.en.yml", "/Users/schneems/Documents/projects/codetriage/config/locales/en.yml"]
@jc00ke
jc00ke / compose.rb
Last active August 29, 2015 14:08
# do
class CString
def initialize(string)
@string = string.to_s
end
def to_s
"comp:to_s - #{@string}"
end
end
@donpdonp
donpdonp / arbitrage.rb
Last active August 29, 2015 14:12
cointhink arbitrage
module Arbitrage
// exchanges: [ exchange, ... ]
// exchange: { name: "Name", markets: [ market, ...] }
// market: { buy: '<currency code>', sell: '<currency code>', offers: [offer, ...] }
// offer: { quantity: 1.0, price: 2.0 }
def calc(exchanges)
bids = asks = []
exchanges.each do |exchange|
bids += exchange.bid_market('btc').offers.sort(&:price)
asks += exchange.ask_market('btc').offers.sort(&:price)
@btjones
btjones / _config.yml
Created August 27, 2012 15:44
This is a Jekyll plugin that uses the file path to set a page variable. Then, we can use that page variable as a key to access directory wide config variables in _config.yml. This example uses the file structure conferences/[CONFERENCE_KEY].
# conference config
conferences:
conference1: {
name: Conference 1 Wow!,
date: Jan 1-6 2013
}
conference2: {
name: Conference 2 Neato!!,
date: Dec 15-20 2013
}
@codenamev
codenamev / gist_on_tumblr.js
Created September 6, 2012 14:19
Embed GitHub gist on your Tumblr
// REQUIRES:
// http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js
// http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js
// Based on: https://gist.github.com/1395926
$(document).ready(function() {
$('.gist').each(function(i) {
var file_separator = $(this).text().indexOf('#');
if (file_separator != -1) {
var gist_url = $(this).text().slice(0, file_separator);
var gist_file = $(this).text().slice(file_separator).replace("#file_", "?file=");
@gutenye
gutenye / ember-with-middleman.md
Last active December 10, 2015 01:58
Write Ember.js App With Middleman

I. Create a Middleman project with middleman-ember-template

$ middleman init hello --template=ember

II. Install ember.js package

$ bower install ember
@wobh
wobh / stream_printer.rb
Last active March 10, 2016 19:08
StreamPrinter
# Stream of consciousness development. Copy/Paste into pry or irb.
require 'stringio'
def stream_print(stream, object)
stream << object.to_str if object.respond_to?(:to_str)
stream
end
io = StringIO.new
@pehrlich
pehrlich / full_error_messages.rb
Created February 4, 2013 23:51
Print out full error messages for nested models
module FullErrorMessages
extend ActiveSupport::Concern
# includes errors on this model as well as any nested models
def all_error_messages
messages = self.errors.messages.dup
messages.each do |column, errors|
if self.respond_to?(:"#{column}_attributes=") && (resource = self.send(column))
messages[column] = resource.errors.messages
end
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end