Skip to content

Instantly share code, notes, and snippets.

function tempRedirect(req, res) {
var filename = req.params[0];
var params = {
Bucket: S3_BUCKET,
ResponseContentDisposition: 'inline; filename=' + filename.replace(/,/, '_'),
Key: checkTrailingSlash(getFileKeyDir(req)) + filename
};
var s3 = new aws.S3(s3Options);
s3.getSignedUrl('getObject', params, function(err, url) {
res.redirect(url);
const MAX_WIDTH = 512
const applyBilinearInterpolation = (srcCanvasData, destCanvasData, scale) => {
function inner(f00, f10, f01, f11, x, y) {
const unX = 1.0 - x
const unY = 1.0 - y
return (f00 * unX * unY + f10 * x * unY + f01 * unX * y + f11 * x * y)
}
let i
let j
@eagsalazar
eagsalazar / action_creator.js
Last active March 27, 2016 20:34
Async middleware with Redux example
export const getFeedItem = feedItemId => (
{
type: GET_FEED_ITEM,
ajax: true,
payload: {
type: 'get',
route: `/feed/${feedItemId}`,
pending: GET_FEED_ITEM_PENDING,
success: GET_FEED_ITEM_SUCCESS,
failure: GET_FEED_ITEM_FAILURE,
@eagsalazar
eagsalazar / eventable.coffee
Last active December 20, 2015 22:48
Add events to regular js objects using coffeescript. .on, .off, and event chaining with bailout when callback returns false.
class app.Eventable
callbackRegistry = {}
@off: (event, callback) ->
callbacks = callbackRegistry[event]
callbackRegistry[event] = _.without(callbacks, callback)
@on: (event, callback) ->
if typeof callback == "function"
@eagsalazar
eagsalazar / gist:5847040
Created June 24, 2013 00:16
Grunt file for building www for phonegap/cordova
module.exports = (grunt) ->
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-jade')
grunt.loadNpmTasks('grunt-contrib-sass')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-copy')
customer = Stripe::Customer.create({
description: "Foo Bar",
email: "[email protected]",
card: nil,
plan: 'super_awesome_plan',
coupon: 'super_awesome_coupon'
})
class Schedule
include Mongoid::Document
include Mongoid::Timestamps
OPTIONS_FOR_TIMEZONES = [
['Pacific Time (GMT -8:00)', "Pacific Time (US & Canada)"],
['Eastern Time (GMT -5:00)', "Eastern Time (US & Canada)"],
['Central Time (GMT -6:00)', "Central Time (US & Canada)"],
['Mountain Time (GMT -7:00)', "Mountain Time (US & Canada)"],
→hi, anyone there?
Chris Winslett: Hello, how may I assist you?
→I think my problem is actually with mongoid
→I just added this issue on their github: https://github.com/mongoid/mongoid/issues/2125
→Any thoughts on that? I know you guys work with the mongoid guys for their testing
Chris Winslett: Are you running Mongo locally?
Chris Winslett: Actually -- turn on logging for Mongoid.
→no, I'm using mongohq
→:-)
Chris Winslett: :) What operations are happening after you 'create!' ?
Started POST "/hooks/subscriptions" for 127.0.0.1 at 2012-06-03 14:29:17 -0400
Processing by HooksController#subscriptions as XML
Parameters: {"object"=>"event", "type"=>"charge.succeeded", "created"=>1326853478, "livemode"=>false, "id"=>"evt_00000000000000", "data"=>{"object"=>{"object"=>"charge", "failure_message"=>nil, "currency"=>"usd", "disputed"=>false, "card"=>{"fingerprint"=>"8ox7KKeBx8logIox", "type"=>"Visa", "object"=>"card", "address_zip"=>nil, "country"=>"US", "last4"=>"4242", "address_line1"=>nil, "exp_month"=>1, "address_line2"=>nil, "cvc_check"=>"pass", "exp_year"=>2013, "address_country"=>nil, "address_zip_check"=>nil, "name"=>"Flim Flam", "address_state"=>nil, "id"=>"cc_00000000000000", "address_line1_check"=>nil}, "paid"=>true, "invoice"=>"in_00000000000000", "created"=>1338674115, "refunded"=>false, "livemode"=>false, "fee"=>0, "amount_refunded"=>0, "description"=>nil, "id"=>"ch_00000000000000", "amount"=>2900, "fee_details"=>[{"type"=>"stripe_fee", "currency"=>"usd", "application"=>nil,
{"object"=>"event", "type"=>"charge.succeeded", "created"=>1326853478, "livemode"=>false, "id"=>"evt_00000000000000", "data"=>{"object"=>{"object"=>"charge", "failure_message"=>nil, "currency"=>"usd", "disputed"=>false, "card"=>{"fingerprint"=>"8ox7KKeBx8logIox", "type"=>"Visa", "object"=>"card", "address_zip"=>nil, "country"=>"US", "last4"=>"4242", "address_line1"=>nil, "exp_month"=>1, "address_line2"=>nil, "cvc_check"=>"pass", "exp_year"=>2013, "address_country"=>nil, "address_zip_check"=>nil, "name"=>"Flim Flam", "address_state"=>nil, "id"=>"cc_00000000000000", "address_line1_check"=>nil}, "paid"=>true, "invoice"=>"in_00000000000000", "created"=>1338674115, "refunded"=>false, "livemode"=>false, "fee"=>0, "amount_refunded"=>0, "description"=>nil, "id"=>"ch_00000000000000", "amount"=>2900, "fee_details"=>[{"type"=>"stripe_fee", "currency"=>"usd", "application"=>nil, "amount"=>0}], "customer"=>"cus_00000000000000"}}, "hook"=>{"object"=>"event", "type"=>"charge.succeeded", "created"=>1326853478, "livemode"=>fa