Skip to content

Instantly share code, notes, and snippets.

@constfun
constfun / gist:2311083
Created April 5, 2012 13:38
Show Hide MOG Player
on alfred_script(q)
tell application "System Events"
set procName to "MOG"
if not (exists process procName) then
tell application procName to activate
else
not (visible of process procName)
set visible of process procName to the result
not visible of process procName
set frontmost of process procName to the result
@constfun
constfun / gist:2321673
Created April 6, 2012 18:01
Simple script to create a random password
#! /usr/bin/env python
import argparse
import random
import string
import subprocess
arg_parser = argparse.ArgumentParser(description="Generate a random password and save it to the clipboard. OS X only.")
arg_parser.add_argument('length', type=int, default=20, nargs='?', help="Password length. (Default is 20.)")
arg_parser.add_argument('-s', '--simple', action='store_true', help="Letters and numbers only.")
@constfun
constfun / gist:3166334
Created July 23, 2012 21:26
PBKDF2 using openssl
#include <openssl/rand.h>
#include <openssl/evp.h>
#define SECRETS_PBKDF2_ITERATIONS 10000
#define AES_KEY_LEN 32
bstring secrets_encrypt(bstring data, bstring password) {
int res = 0;
unsigned char salt[PKCS5_SALT_LEN] = {0};
@constfun
constfun / tabata.py
Created October 4, 2012 16:11
Tabata timer for mac
#! /usr/bin/env python
from subprocess import call
import sys
import time
def ding():
call(['afplay', '/System/Library/Sounds/Glass.aiff'])
(function (factory) {
// Expose as AMD.
if( typeof define === "function" && define.amd ) {
define(['jquery', 'underscore', 'select'], factory);
}
// Expose as global.
else {
window.scope = factory(jQuery, _, select);
}
import re
from itertools import groupby
# AA[0-9] encodes at most 11 input characters.
MAX_CHUNK_LEN = 11
only_uppercase_letters = re.compile(r'^[A-Z]*$').search
def _compress_chunk(char, count):
object App {
def main(args:Array[String]):Unit = args(0) match {
case "yan" => yan
case "levi" => levi
case "nick" => nick
case "nickbad" => nickbad
}
def yan = {
val r = Iterator.iterate(2L)(_+1) collectFirst {
@constfun
constfun / magic.rb
Created December 17, 2013 16:54
Ruby one liner
# Does it.
doit
import argparse
import smtplib, os
import json
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
# The first line is the heading, the rest are data.
# You can add more colums. Each column must be tab separated.
title password ...
gmail 12345 ...
linkedin 6578 ...
something really long 2134567 ...
# Once you have that in a file, you can import it: