Skip to content

Instantly share code, notes, and snippets.

View dklassen's full-sized avatar

Dana Klassen dklassen

View GitHub Profile
@dklassen
dklassen / celery.sh
Last active March 25, 2017 17:58 — forked from amatellanes/celery.sh
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
import android.content.Context;
import android.os.Debug;
import java.io.File;
public class OomExceptionHandler implements Thread.UncaughtExceptionHandler {
private static final String FILENAME = "out-of-memory.hprof";
public static void install(Context context) {
Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
#!/bin/bash
usage()
{
cat << EO
Usage: format_data_disks [options]
Find and format data disks on nodes
EO
@dklassen
dklassen / gist:385585425a45e5d41ba7ba918aa9f533
Created June 25, 2016 23:38 — forked from shacker/gist:87908e13c9ee6655ce90
Using the Workday API with Python and the suds client library
import sys
from suds import client
from suds.wsse import Security, UsernameToken
from suds.sax.text import Raw
from suds.sudsobject import asdict
from suds import WebFault
'''
Given a Workday Employee_ID, returns the last name of that employee.
openssl genrsa 1024 > ~/pk.pem
yes "" | openssl req \
-new \
-x509 \
-nodes \
-sha1 \
-days 3650 \
-key ~/pk.pem \
-outform PEM > ~/cert.pem
@dklassen
dklassen / post_request_lever.md
Created July 22, 2016 14:46
Golang Lever API

When making a POST request to lever API via golang you need to be able to send an array in somecases. For example, when updating tags ["test1", "test2"]. In python using the requests lib didn't have this issue but perhaps can save some time because it wasn't obvious right away:

data := url.Values{"tags[]": []string{"test", "test1"}}

req, err := http.NewRequest("POST", "https://api.lever.co/v1/candidates/132412-12312-1241/addTags?perform_as=1341-1243124", strings.NewReader(data.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") // <- Don't forget the header!
http_client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
@dklassen
dklassen / mockDate.ts
Last active November 21, 2018 19:11
Mocking global date
// source: https://github.com/facebook/jest/issues/2234
let timeNow;
const realDate = Date;
describe("Stubbed Date", () => {
beforeAll(() => {
timeNow = Date.now();
const _GLOBAL: any = global;
_GLOBAL.Date = class {
@dklassen
dklassen / groupBy.ts
Last active November 27, 2018 18:41
Vanillia GroupBy in Typescript
const groupBy = (data, key) => {
return data.reduce(
(acc, cur) => {
const value = acc[cur[key]] ? acc[cur[key]] : []
value.push(cur);
acc[cur[key]] = value;
return acc;
}, {});
};