Skip to content

Instantly share code, notes, and snippets.

View cableray's full-sized avatar

Garrett cableray

View GitHub Profile
const defaultSnapshot = {
token: '',
myInnerInfo: { login: '', type: '' },
myDisplayInfo: { login: '', type: '' },
loginInfo: { login: '', type: '' },
loginList: [],
loading: false,
logined: false,
}
@cableray
cableray / solution.ex
Created December 28, 2017 06:17
Brainf**k interpreter from code wars
defmodule Brainluck do
defstruct data: <<0>>, data_pointer: 0,
output: <<>>,
instructions: "", inst_pointer: 0,
input: <<>>,
skip_depth: 0,
block_stack: []
def brain_luck(program, inputs) do
%Brainluck{instructions: program, input: inputs} |> process
@cableray
cableray / apple_record.rb
Last active July 8, 2017 19:05 — forked from sj26/apple_record.rb
How to do STI without separate controller per child: Utilize descendent tracking and override model_name so they use the same URL helpers and parameters as their base class. Makes things like responders and form_for work as expected, while preserving things like to_partial_path.
class AppleRecord < Record
end
@cableray
cableray / pre-commit
Created September 3, 2015 20:34
my focus prevention pre-commit hook
#!/usr/bin/env ruby
# vim: set syntax=ruby
begin
require 'colorize'
rescue LoadError
class String
def fake_color(*)
self
end
require 'jade'
module ResourceBrowser
class Engine < ::Rails::Engine
isolate_namespace ResourceBrowser
config.assets.enabled = true
end
end
@cableray
cableray / index.html.haml
Created March 26, 2013 02:46
HAML Error: The line [#7] was indented 2 levels deeper than the previous line.
%h1.page-heading= "Rating Panels for #{@image.name}"
- if @image.rating_panels.empty?
.alert no rating panels for this image
- @image.rating_panels.each do |panel|
.row-fluid.panel-listing
%h1= panel.name
%p= panel.description
%hr
@cableray
cableray / board.rb
Created January 10, 2013 07:30
solver for boggle
require "ffi/aspell"
module Soggle
class Board
attr_reader :height, :width
def initialize(board,speller=::FFI::Aspell::Speller.new("en_US"))
@board=parse(board)
@[email protected]
@[email protected]
@cableray
cableray / api_routing_spec.rb
Created December 3, 2012 22:25
api routing
require 'spec_helper'
describe Api do
describe "routing" do
it "routes to entry point" do
['1','v1'].each do |version_spec|
get("api/#{version_spec}").should route_to 'api/v1/entry_point#index'
end
end
end
module CheetahCub
class Transaction
attr_reader :transaction_delegate
delegate :save, to: :transaction_delegate
# def save
# transaction_delegate.save
# end
def initialize
@transaction_delegate = Config.module_prefix::Transaction.new
end
@cableray
cableray / gist:3914787
Created October 18, 2012 21:16
Meteor error
Error: A method named '/users/insert' is already defined
at app/packages/livedata/livedata_server.js:843:15
at Function._.each._.forEach (app/packages/underscore/underscore.js:84:24)
at _.extend.methods (app/packages/livedata/livedata_server.js:841:7)
at Meteor.Collection._defineMutationMethods (app/packages/mongo-livedata/collection.js:379:19)
at new Meteor.Collection (app/packages/mongo-livedata/collection.js:104:8)
at app/server/users.coffee.js:3:9
at /Users/cableray/Dev/meteor/fae_chess/.meteor/local/build/server/server.js:107:21
at Array.forEach (native)
at Function._.each._.forEach (/Users/cableray/Dev/meteor/fae_chess/.meteor/local/build/server/underscore.js:76:11)