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
@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
@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)
@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

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"]
@Arcovion
Arcovion / config.rb
Created May 8, 2014 12:33
Middleman extension to manage multiple directories
class Middleman::Extensions::DirManager < Middleman::Extension
register :dir_manager
option :dirs, {source: 'pages', destination: '', add: [], remove: ['', 'pages']}
def manipulate_resource_list resources
[options.dirs].flatten.each do |opts|
# Remove pages if specified
opts[:remove].each do |dir|
resources.reject! do |page|
Dir.glob(normalise(dir) + '/*', File::FNM_DOTMATCH).include? page.source_file
@seenmyfate
seenmyfate / Capfile
Created April 23, 2014 07:55
Capistrano v3 custom Submodule Strategy example
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/scm'
require 'capistrano/git'
class Capistrano::Git < Capistrano::SCM
module SubmoduleStrategy
include DefaultStrategy
def release
@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() {
@icyleaf
icyleaf / ar_migrate.rb
Last active October 13, 2023 03:21
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default

Guide to loading/error events and substates

In addition to the techniques described in the Asynchronous Routing Guide, the Ember Router provides powerful yet overridable conventions for customizing asynchronous transitions between routes by making use of error and loading substates.

loading substates

@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active April 14, 2024 14:27
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"