Skip to content

Instantly share code, notes, and snippets.

View kkleidal's full-sized avatar

Ken Leidal kkleidal

  • Genesis Therapeutics
  • Boston, MA
View GitHub Profile
'use-strict';
(function() {
function copyTextArea($selTextArea) {
$selTextArea.select();
var successful = false;
try {
successful = document.execCommand('copy');
} catch (err) {
successful = false;
@kkleidal
kkleidal / Makefile
Created October 1, 2015 16:24
Tex Makefile
SRC_FILES=*.tex
pdf:
pdflatex $(SRC_FILES)
clean:
rm *.aux *.log *.pdf
all: pdf
### Keybase proof
I hereby claim:
* I am kkleidal on github.
* I am kkleidal (https://keybase.io/kkleidal) on keybase.
* I have a public key ASCMLGKNvE2sMm4iKxH2xGNwsLTQInAiVe0ffuQPZwgwgwo
To claim this, I am signing this object:
@kkleidal
kkleidal / .gitignore
Created March 27, 2016 16:43
Latex Helper Files
*.pdf
*.log
*.aux
*.out
@kkleidal
kkleidal / image_metadata.swift
Last active August 18, 2016 12:00
Strip location/date metadata from photo library photo asset imported with FDTake
private var xifDateFormatter: NSDateFormatter = { () -> NSDateFormatter in
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy:MM:dd' 'HH:mm:ss"
dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC")
return dateFormatter
}()
// ...
@kkleidal
kkleidal / install-hook.sh
Created July 24, 2016 19:35
Express.js linting and beautifying pre-commit hook
#!/bin/sh
ln -s $(pwd)/pre-commit.bash .git/hooks/pre-commit
@kkleidal
kkleidal / mailer.js
Created July 25, 2016 20:47
Send Mail via SMTP with Node
/* jshint node: true */
"use strict";
var nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport({
host: "smtp.zoho.com",
// port: 587,
secure: true,
@kkleidal
kkleidal / example.py
Last active November 25, 2016 04:01
For executing long-running ML jobs
import gensim
from job import Job
import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
# Load Google's pre-trained Word2Vec model.
# model = gensim.models.Word2Vec.load_word2vec_format('./data/GoogleNews-vectors-negative300.bin', binary=True)
def pca_plot(points, training_points=None):
import subprocess
import base64
def keyscan(host):
p = subprocess.Popen(['/bin/sh', '-c', '(ssh-keyscan %s | grep ssh-rsa) 2>/dev/null' % host], stdout=subprocess.PIPE)
config = p.stdout.read().decode('ascii').split(' ')
p.wait()
if p.returncode != 0:
raise Exception("Could not scan %s for SSH key." % host)
config[2] = paramiko.RSAKey(data=base64.b64decode(config[2]))
package main
import (
"log"
"strings"
"time"
)
type threadPoolWorker struct {
free chan *threadPoolWorker