Skip to content

Instantly share code, notes, and snippets.

View kljensen's full-sized avatar
😵‍💫
0101010101

k⃝͡yl͜e j⃝͡en͜s͜en kljensen

😵‍💫
0101010101
  • ᒪ̊Λ̸̊ṅ̊̇ï̊̈ä̊̇̈k̊̇̈̊ë̊̈̇̊ä゚̈̇̊𖦹゚ Ꮥ̊͜͡ᑌ̊͜͡ᑭ̊͜͡Ɛ̊͜͡ᖇ̊͜͡ᑕ̊͜͡ᒪ̊͜͡ᑌ̊͜͡Ꮥ̊͜͡Ƭ̊͜͡Ɛ̊͜͡ᖇ̊ ⟳ ✧゚꩜
  • /dev/null
View GitHub Profile
@kljensen
kljensen / .gitignore
Last active August 29, 2015 13:57
NewHaven.io NLP Tutorial
.ipynb*
build*
venv*
refs*
*.pyc
tmp*
@kljensen
kljensen / posgresql-word-count-upsert.sql
Created December 12, 2013 21:09
Shows how to increment multiple word counts in Postgresql using a single round trip to the database
WITH
to_be_upserted (word, count) AS (
VALUES
('fudge', 1),
('baz', 1),
('foo', 2),
('bar', 2),
('bucket', 1)
),
updated AS (
@kljensen
kljensen / mongoose-encrypted-schematype-field.md
Last active June 6, 2023 13:25
Encrypt a text field in Mongoose MongoDB ORM

Encrypting text fields in Mongoose is easy using Node's built-in crypto module. You might want to do this if you're using MongoDB as a service (see the recent MongoHQ security breach); or, if you're storing OAuth tokens that could, in the wrong hands, screw with somebody's account on a 3rd party service. (Of course, you should never encrypt passwords: those should be hashed.)

Imagine you have a Mongoose model like that shown below, which is modified only slighly from the example on the MongooseJS homepage.

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');

var User = mongoose.model('User', {
 name: String,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kljensen
kljensen / Procfile
Created October 7, 2013 17:44
How I get verbal notification of code reloads while developing locally... see the "watchmedo....say" part.
web: env REDIS_MAX_CONNECTIONS=27 gunicorn --pid /tmp/ss-gunicorn.pid -k gevent 'manage:create_and_config_app()'
redis: redis-server bin/config/redis.conf
watchdog:watchmedo shell-command --patterns="*.py;*.yaml" --recursive --command='kill -HUP $(cat /tmp/ss-gunicorn.pid) && say "code reloaded, dude."'
@kljensen
kljensen / users_online.py
Created October 2, 2013 14:39
Keep track of which users are currently online in your Python app using Redis
#
# Demo script showing how to track which users are currently
# online and what URL they're looking at using py-Redis and
# ZSETs.
#
# Record that a user is online with
# mark_user_id_active(5, url="http://foo.com/my/url/woot")
#
# And get a list of which users are online, and what URL they're
# looking at with get_active_user_urls().
@kljensen
kljensen / moments.coffee
Last active December 24, 2015 03:59
My script for calculating the statistical moments of an array in coffeescript
moments = (arr, doMedian=false) ->
length = arr.length
sum = arr.reduce (t, s) -> t + s
mean = sum / length
averageDeviation = 0.0
averageDeviation = 0.0
standardDeviation = 0.0
variance = 0.0

Mac OS Python Installation for Scientific Computing

This gist describes how to install the basic tools you'll need to do scientific computing with Python on Mac OS X. These have been tested with Mac OS X 10.6 and 10.7.

Your Mac comes with Python installed by in /usr/bin/; however, you probably don't want to use that Python because it is rarely updated and, it's not a good idea to mess with that which OS X has installed.