Skip to content

Instantly share code, notes, and snippets.

View FotoVerite's full-sized avatar

Matthew Bergman FotoVerite

View GitHub Profile
def apply_coupons
applied_coupons = []
active_coupons = family.family_coupons.active.order(:created_at).map(&:coupon).flatten
total = self.subtotal
while !total.zero? && !active_coupons.empty?
active_coupons.filter { |c| c.coupon_type == "permanent_percent" }.each do |coupon|
total = total * coupon.amount / 100.0.to_i
applied_coupons.push(coupon)
active_coupons -= [coupon]
end
@FotoVerite
FotoVerite / concat
Created June 30, 2013 19:48
Stream Adventure Solution to Concat
var stream = require('stream');
var liner = new stream.Transform( { objectMode: true } );
liner._buffer = '';
liner._transform = function (chunk, encoding, done) {
var self = this;
var data = chunk.toString();
this._buffer = this._buffer + data
done();
@FotoVerite
FotoVerite / GetSecureNow
Created June 12, 2013 17:33
Get Secure Now Resources.
http://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
http://blog.cloudflare.com/cloudflare-prism-secure-ciphers
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
@FotoVerite
FotoVerite / robot.js
Created December 5, 2012 07:22
Zolmeister
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@FotoVerite
FotoVerite / robot.js
Created December 5, 2012 07:22
Zolmeister
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (robot.parentId) {
robot.ahead(1);
robot.turnGunRight(1);
}
else {
@FotoVerite
FotoVerite / gist:2005568
Created March 9, 2012 07:52
Refactor of session_module
module SessionMethods
protected
def admin_logged_in?
unless current_user(Admin)
return false
else
return true
end
foreman:
nginx: 1
riak: 1
unicorn: 1
sidekiq: 1
nginx:
daemon: 'off'
listen: 8080
pid: tmp/pids/nginx.pid
path: /Users/fotoverite/github/generalassembly
Most of you who know me, know I can be very loud and more than a bit obnoxious. I know I've been very loud the past few days about SOPA.
We all know what is at stake. I won't talk down to you or think you don't realize how this concerns us. We are being fucking lazy.
We are so concerned with our day to day lives that we are forgetting how much Federal government can affect us and or interest.
What we do today could be made much more difficult to do well without good reason.
But more importantly, even if it doesn't, nothing much of substance will have changed. Because we were not the ones to stop it.
We, beyond anyone else, know how amazing the web is. How important it is to our lives and our communities. We have power, people.
We command million dollar businesses, we bring so much and money to the cities and states we reside in. We need to use this.
We need to call our representatives; but more than that, we need to state that we matter.
@FotoVerite
FotoVerite / gist:1438474
Created December 6, 2011 15:00
Jitsu vows fail
mismatch in remote request :
{ method: 'GET',
uri: 'http://api.mockjitsu.com:90210/apps/mickey/example-app',
headers:
{ Authorization: 'Basic bWlja2V5OnBvaXV5dHJld3E=',
'Content-Type': 'application/json' } }
{ method: 'GET',
uri: 'http://api.mockjitsu.com:90210/apps/mickey/jitsu',
headers: