Skip to content

Instantly share code, notes, and snippets.

View cadwallion's full-sized avatar
⚒️
Building all the things

Andrew Nordman cadwallion

⚒️
Building all the things
View GitHub Profile
@cadwallion
cadwallion / gist:1409963
Created November 30, 2011 17:41
Writing custom warden strategies
# For more information on Warden strategies, read this: https://github.com/hassox/warden/wiki/Strategies
class SuperCoolWardenStrategy
def valid?
# you have access to env and request
# return true/false if this is strategy should run or not
# if it returns false, it will move onto the next strategy in the list
# defaults to true if you don't write this method
end
def authenticate!
module Maestro
class Bootstrap
attr_reader :project_name, :org_name, :app_type
def initialize project_name, org_name, options = {}
@project_name = project_name
@org_name = org_name
@app_type = options[:type]
end
@cadwallion
cadwallion / Address.cs
Created February 11, 2012 15:01
C# AddressBook
using System;
class Address {
public string name;
public string address;
public Address(string name, string address) {
this.name = name;
this.address = address;
}
@cadwallion
cadwallion / tree_solver.rb
Created March 28, 2012 21:47
Programmatic Double-Elimination Bracket Generation
# This takes a bracket size and generates the loser's bracket side of a double-elimination tournament
class TreeSolver
attr_reader :size
def initialize options = {}
@size = options[:size] || 32
@levels = 0
calculate_levels
@starting_point = options[:starting_point] || 2
end
@cadwallion
cadwallion / deck.rs
Last active March 11, 2018 19:42
Card Display
enum Card {
Heart(i32),
Spade(i32),
Diamond(i32),
Club(i32),
}
impl Card {
fn value_to_string(&self, value: i32) -> String {
match value {
@cadwallion
cadwallion / beer_menu.thor
Created May 15, 2012 18:50
Ruck beer list scraper
#!/usr/bin/env ruby
# A Thor-based commandline tool for all BeerMenu.
# Based on @jsteiner's Ruby equivalent of @jlet's Python Ruck
# beer list scraper
# @jsteiner's Original: https://gist.github.com/2703889
# @jlet's Original: ttps://gist.github.com/2659721
require 'open-uri'
require 'nokogiri'
@cadwallion
cadwallion / gist:1260003
Created October 3, 2011 19:32
Cures Cancer
function real_fib(n) {
var i;
var fibs = new Array(0, 1);
for(i=0; i<n; i++) {
fibs.push(fibs[0] + fibs[1]);
fibs.shift();
}
return fibs[0];
}
@cadwallion
cadwallion / config.log
Last active December 26, 2015 02:49
JFFI build failure on ARM
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libffi configure 3.0.10, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ /root/jffi/jni/libffi/configure --disable-static --with-pic=yes --disable-dependency-tracking
## --------- ##
## Platform. ##
@cadwallion
cadwallion / gist:7010014
Created October 16, 2013 15:46
JRuby FFI Failure on Raspberry Pi
root@raspberrypi:~/brewby# jruby -J-Xmx200m bin/brewby start --config ~/.testbrewbyrc --recipe examples/brewby_recipe.rb
LoadError: Could not load FFI Provider: (NotImplementedError) FFI not available: null
See http://jira.codehaus.org/browse/JRUBY-4583
require at org/jruby/RubyKernel.java:1082
(root) at /usr/local/rvm/rubies/jruby-1.7.5/lib/ruby/shared/ffi/ffi.rb:69
require at org/jruby/RubyKernel.java:1082
(root) at /usr/local/rvm/rubies/jruby-1.7.5/lib/ruby/shared/ffi.rb:1
require at org/jruby/RubyKernel.java:1082
(root) at /usr/local/rvm/rubies/jruby-1.7.5/lib/ruby/shared/ffi.rb:1
require at org/jruby/RubyKernel.java:1082
@cadwallion
cadwallion / course.rb
Last active December 25, 2015 06:58
Coursify examples
class Course < ActiveRecord::Base
include Coursify::Publishable
include Coursify::Enrollable
enrollable_by :user
has_many :lessons
end