Skip to content

Instantly share code, notes, and snippets.

@ccorcos
ccorcos / gist:fc277c67cef88f4a0b06
Created July 24, 2014 18:11
Resize text areas in Meteor rendered to fit content
Template.name.rendered = ->
# resize the text areas
Meteor.defer ->
$('.content').on( 'change keyup keydown paste cut', 'textarea',
-> $(this).height(0).height(this.scrollHeight)).find('textarea').change()
$('textarea').trigger('change')
@ccorcos
ccorcos / symmetric_crypto.coffee
Created November 6, 2014 02:29
AES symmetric encryption crypto node.js
crypto = require "crypto"
key = "this is my password. Make it as long as you want. But its hashed into 512 bytes."
text = "This is the text. as long as you want it"
hash = (utf8String)->
hasher = crypto.createHash('sha512')
hasher.update(utf8String, 'utf8')
hexString = hasher.digest('hex')
return hexString
@ccorcos
ccorcos / decorators.py
Created November 18, 2014 04:57
example of how python decorators, *args and **kwargs work
# An example of how to make decorators and also how *args and **kwargs work.
from functools import partial
def wrapping(func):
def wrapper(func, *args, **kwargs):
# print "wrapper"
# print func
# print args
# printwrappergs
@ccorcos
ccorcos / theano_test.py
Created November 20, 2014 22:57
theano shape error
import theano
import theano.tensor as T
import numpy
# The model basically looks like this:
#
# o_t a_t
# | |
# | |
@ccorcos
ccorcos / untitled
Created December 19, 2014 02:30
breadth first search find coffeescript
match = (obj, properties) ->
for k,v of properties
if not k of obj
return false
else if v instanceof Object
if not match obj[k], v
return false
else if obj[k] isnt v
return false
return true
@ccorcos
ccorcos / gist:6cf8c9b44bd4ce836c39
Created March 9, 2015 00:34
How to use tracker autorun to queue up events
var a = {}
var b = new ReactiveVar(1);
var c = new ReactiveVar(2);
var needsUpdate = new Tracker.Dependency()
Tracker.autorun(function(){
a.b = b.get()
needsUpdate.changed()
})
export function makePayment(loanId, amount, paymentMethodId) {
return dispatch => {
dispatch(makePaymentSent())
fetch(`/api/loans/${loanId}/payments`, {
headers: new Headers({
'Content-Type': 'application/json',
}),
credentials: 'same-origin',
method: 'POST',
body: JSON.stringify({
export function makePayment(loanId, amount, paymentMethodId) {
return dispatch => {
dispatch(makePaymentSent())
fetch(`/api/loans/${loanId}/payments`, {
headers: new Headers({
'Content-Type': 'application/json',
}),
credentials: 'same-origin',
method: 'POST',
body: JSON.stringify({
// api.js
export function makePayment(loanId, amount, paymentMethodId) {
return fetch(`/api/loans/${loanId}/payments`, {
headers: new Headers({
'Content-Type': 'application/json',
}),
credentials: 'same-origin',
method: 'POST',
body: JSON.stringify({
'amount': amount,
// api.js
export function makePayment(loanId, amount, paymentMethodId) {
return fetch(`/api/loans/${loanId}/payments`, {
headers: new Headers({
'Content-Type': 'application/json',
}),
credentials: 'same-origin',
method: 'POST',
body: JSON.stringify({
'amount': amount,