Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
gcmurphy / edit.py
Created July 11, 2014 02:21
Pops up your $EDITOR and returns the content entered. Similar to 'git commit -a'
def edit_dialog(**kwargs):
EDITOR = os.environ.get("EDITOR", "vim")
with tempfile.NamedTemporaryFile(suffix=".tmp") as tmp:
if 'prefill' in kwargs:
tmp.write(kwargs.get('prefill'))
tmp.flush()
subprocess.call([EDITOR, tmp.name])
output = ""
with open(tmp.name) as message:
@gcmurphy
gcmurphy / mutt.py
Created July 11, 2014 03:16
draft an email using mutt..
def draft_email(**kwargs):
cmd = ["mutt"]
if 'to' in kwargs:
cmd.append(",".join(kwargs.get('to')))
if 'subject' in kwargs:
cmd.append("-s")
cmd.append(kwargs.get('subject'))
@gcmurphy
gcmurphy / keybase.md
Created August 20, 2014 10:24
keybase.md

Keybase proof

I hereby claim:

  • I am gcmurphy on github.
  • I am gmurphy (https://keybase.io/gmurphy) on keybase.
  • I have a public key whose fingerprint is 634C 0EB3 217B 3080 5C9A 0ACB 8362 ECFD 8F22 453B

To claim this, I am signing this object:

@gcmurphy
gcmurphy / tw.sh
Created August 29, 2014 03:14
simple pingdom replacement
#!/bin/bash
# Check if your site is still up and send you a direct tweet if it isn't
#
# [dependencies]
# libwww-perl
# ruby-gem -> t
#
# [setup]
# mkdir ~/twitter_alerts
# t authorize
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
bool constant_time_compare(const char *lhs, size_t lhs_sz, const char *rhs, size_t rhs_sz)
{
size_t i;
@gcmurphy
gcmurphy / HW01.1.hs
Last active August 29, 2015 14:06
CS194 Homework 1 - Credit card verification
-- http://www.seas.upenn.edu/~cis194/hw/01-intro.pdf
module Main where
-- | Return the last digit of an integer
--
-- >>> lastDigit 123
-- 3
--
-- >>> lastDigit 0
-- 0
@gcmurphy
gcmurphy / HW01.2.hs
Created September 22, 2014 00:38
CS194 Homework 2 - Towers of Hanoi
module Main where
type Peg = String
type Move = (Peg, Peg)
{-
| Towers of hanoi solution
>>> hanoi 2 "a" "b" "c"
[("a","c"),("a","b"),("c","b")]
move n-1 disc from a to c using b as temporary storage
@gcmurphy
gcmurphy / HW02.hs
Last active August 29, 2015 14:07
CS194 Homework week 2 (most of it)
module HW02 where
import Words
import Data.List
-- Though a Scrabble hand is the same Haskell type as a Scrabble word, they
-- have different properties. Specifically, a hand is unordered whereas a word
-- is ordered. We denote this distinction by using a type synonym to talk
-- about hands, even though we could just say `String`.
@gcmurphy
gcmurphy / poodle.c
Created October 15, 2014 02:51
Unnecessary C program to test if SSLv3 is enabled..
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
char SSLv3_ClientHello[] = {
@gcmurphy
gcmurphy / ghost.go
Last active August 29, 2015 14:14
detect ghost vulnerability in statically linked binaries..
package main
import (
"bytes"
"debug/elf"
"fmt"
"os"
)
func staticallyLinked(file *elf.File) bool {