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
/* ASDFPixelSort for video frames v1.0
Original ASDFPixelSort by Kim Asendorf <http://kimasendorf.com>
https://github.com/kimasendorf/ASDFPixelSort
Fork by dx <http://dequis.org> and chinatsu <http://360nosco.pe>
Randomization modifications by Dan-O
-- Usage:
1. Split a video into a series of pictures with ffmpeg:
$ ffmpeg -i "input.mov" -an -f image2 "frame_%06d.png"
2. Change `String basedir` in this script to point to where the images are located.
3. Tweak things, that's what's most fun, isn't it?
#!/usr/bin/env node
'use strict';
var realist = require('realist'),
fs = require('fs'),
colors = require('colors'),
read = require('fs').readFileSync,
join = require('path').join,
_ = require('lodash'),
pm http GET https://registry.npmjs.org/npm
npm http 304 https://registry.npmjs.org/npm
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! error rolling back npm@2.0.0 { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/npm' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm'
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm']
npm ERR! errno: 3,
novafabricaGlobalSearch = {
searchField: null,
searchListContainer: null,
list: null,
searchUrl: null,
autoCompleteVars: null,
_createAutoList: function(json) {
var self = novafabricaGlobalSearch;
@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 {