Skip to content

Instantly share code, notes, and snippets.

View katylava's full-sized avatar
🐢

katy lavallee katylava

🐢
View GitHub Profile
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

@katylava
katylava / importS3Csv.gs
Last active August 7, 2023 14:37
Google Apps Script to import a CSV, stored securely on S3, to a Google Spreadsheet
var AWS_KEY = '<your key>';
var AWS_SECRET = '<your secret>';
function generateS3Url(bucket, path) {
var expiresDt = Math.floor(Date.now() / 1000) + (60 * 60 * 24); // can be up to 7 days from now
var stringToSign = 'GET\n\n\n' + expiresDt + '\n/' + bucket + '/' + encodeURIComponent(path);
var hmac = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_1, stringToSign, AWS_SECRET, Utilities.Charset.UTF_8);
var signed = encodeURIComponent(Utilities.base64Encode(hmac));
@katylava
katylava / Dockerfile
Last active March 27, 2023 18:09
docker-compose with Django and ipdb
FROM python:3.5.1
MAINTAINER Katy Lavallee <katylava@gmail.com>
RUN mkdir -p /dockeripdb/
ENTRYPOINT ["/usr/local/bin/python"]
WORKDIR /dockeripdb/
ENV PYTHONPATH /dockeripdb/
ENV DJANGO_SETTINGS_MODULE dockeripdb.settings
@katylava
katylava / copy-to-psql.py
Created December 8, 2010 17:42
script to load csv file into new postgres table
#!/usr/bin/env python
import re
from subprocess import call
def load_csv_psql(db, infile, table, tmpdir='/tmp'):
tmpfile = '%s/%s' % (tmpdir, infile)
call(['cp', infile, tmpfile])
columns = map(variablize, file(infile).readline().split(','))
Verifying my Blockstack ID is secured with the address 1NL1QgCqCFReoZGoE26UZwC2QJQJ3jJA4 https://explorer.blockstack.org/address/1NL1QgCqCFReoZGoE26UZwC2QJQJ3jJA4
@katylava
katylava / Array.reduce.js
Last active October 5, 2018 14:50
convert array of name/value objects to a single object with with matching name/value properties
// we have an array of objects,
var myArray = [ { name: 'a', value: 1 }, { name: 'b', value: 2 }, { name: 'c', value: 3 } ];
// we want an object like { a: 1, b: 2, c: 3 }
// accumulator is an object, we'll set it to an empty object
// initially, when we call the reducer
// currentValue is the value of the current array element.
@katylava
katylava / loldict
Created December 1, 2011 19:46
Dictionary of Katy's LOLs
LOL = Actually laughed out loud, as witnesses can attest
lol = Laughed out loud, but perhaps not loud enough for anyone to hear
LOFL = "laughing out fucking loud"... as in "OMG THAT WAS HI-FUCKING-LARIOUS"
limh = "laughing in my head"
lolz = "hehe"
lulz = "that was cute and funny"
l. o. l. = sarcastic, as in "ha ha aren't you funny you little shit"
@katylava
katylava / README.md
Last active August 24, 2017 18:36
go get private repo

Problem

> go get github.com/myorg/private-repo

# cd .; git clone https://github.com/myorg/private-repo mygopath/src/github.com/myorg/private-repo
Cloning into 'mygopath/src/github.com/myorg/private-repo'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/myorg/private-repo: exit status 128
@katylava
katylava / 1-tasks.css
Last active April 17, 2017 20:04
HabitRPG Stylish styles
body {
/*
background: url(http://subtlepatterns.com/patterns/skulls.png);
background: url(http://subtlepatterns.com/patterns/halftone.png);
background: url(http://i.imgur.com/6Vkqf2z.png); /* wood panel *//*
*/
background: url(http://i.imgur.com/1bBINau.png); /* green cup */
}
// A Node.js example which uses the npm package "request" (https://www.npmjs.com/package/request)
// to send a POST request to convert a ZPL string to a PDF file.
var fs = require('fs');
var request = require('request');
var zpl = "^xa^cfa,50^fo100,100^fdHello World^fs^xz";
var options = {
encoding: null,