Skip to content

Instantly share code, notes, and snippets.

View katylava's full-sized avatar
🐢

katy lavallee katylava

🐢
View GitHub Profile
var fs = require('fs');
var request = require('request');
request.post({ body: "^xa^cfa,50^fo100,100^fdHello World^fs^xz", encoding: null, url: 'http://api.labelary.com/v1/printers/8dpmm/labels/4x6.75/0/' }, function(err, resp, body) {
if (err) {
return console.log(err);
}
console.log('headers', resp.headers);
console.log('status', resp.statusCode);
@katylava
katylava / es.sh
Created December 12, 2013 16:27
Install elasticsearch on Ubuntu 12/13
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
@katylava
katylava / dates.md
Last active December 28, 2015 13:19

Datetimes and Timezones and DST, oh my!

This is an example of how to generate occurrences from python-dateutil's rrule module, and convert them properly to UTC before saving to the database, particularly if your input is localized to a timezone that observes daylight savings. This assumes your server time is localized, otherwise if it's UTC you probably won't run into these problems.

Note: US daylight savings in 2014 started on March 9

squares = [
(1, 1, 1), (2, 4, 3), (3, 9, 5), (4, 16, 7), (5, 25, 9), (6, 36, 11),
(7, 49, 13), (8, 64, 15), (9, 81, 17), (10, 100, 19), (11, 121, 21),
(12, 144, 23), (13, 169, 25), (14, 196, 27), (15, 225, 29), (16, 256, 31),
(17, 289, 33), (18, 324, 35), (19, 361, 37), (20, 400, 39), (21, 441, 41),
(22, 484, 43), (23, 529, 45), (24, 576, 47), (25, 625, 49), (26, 676, 51),
(27, 729, 53), (28, 784, 55), (29, 841, 57), (30, 900, 59), (31, 961, 61),
(32, 1024, 63), (33, 1089, 65), (34, 1156, 67), (35, 1225, 69),
(36, 1296, 71), (37, 1369, 73), (38, 1444, 75), (39, 1521, 77),
(40, 1600, 79), (41, 1681, 81), (42, 1764, 83), (43, 1849, 85),
primes = [
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139,
149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293,
307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383,
389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,
571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647,
653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743,
@katylava
katylava / spndrinking.md
Last active October 7, 2015 12:48
Supernatural Drinking Game

Supernatural Drinking Game

BEWARE SPOILERS
This is for people re-watching the series.


Drink when:

@katylava
katylava / gist:1316377
Created October 26, 2011 13:41
nltk spaceships
In [21]: texts = [text1, text2, text3, text4, text5, text6, text7, text8, text9]
In [22]: for t in texts:
....: print "%d spaceship(s) in %s" % (t.count('spaceship'), t)
....:
0 spaceship(s) in <Text: Moby Dick by Herman Melville 1851>
0 spaceship(s) in <Text: Sense and Sensibility by Jane Austen 1811>
0 spaceship(s) in <Text: The Book of Genesis>
0 spaceship(s) in <Text: Inaugural Address Corpus>
0 spaceship(s) in <Text: Chat Corpus>
@katylava
katylava / gist:969152
Created May 12, 2011 18:30
silly jeffrey
JeffJeffdyJefe
hi
1:28
Ben sucks and I hate him
1:28
I'm so glad he's not in here
1:28sduniphin
lol me too.
1:28JeffJeffdyJefe
I could do his job
1051:57 > git ass sitelet/media/images/
git: 'ass' is not a git command. See 'git --help'.
Did you mean one of these?
add
stash
@katylava
katylava / set_psql_default_utf8.sql
Created January 4, 2011 18:44
make sure new database are created with encoding UTF8
UPDATE pg_database SET datistemplate=FALSE WHERE datname='template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH owner=postgres template=template0 encoding='UTF8';
UPDATE pg_database SET datistemplate=TRUE WHERE datname='template1';