Skip to content

Instantly share code, notes, and snippets.

View dweinstein's full-sized avatar

David Weinstein dweinstein

View GitHub Profile
@dyoo
dyoo / ordered-to-bst.rkt
Created November 2, 2012 20:49
ordered list to binary tree
#lang racket
;; The code of SICP Exercise 2.64, but rewritten to use define-values instead of let.
;; http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#%_thm_2.64
(struct tree (entry left right) #:transparent)
(define EMPTY-TREE '())
;; list->tree: (listof X) -> tree
;; Given an ordered list of elements, constructs the balanced binary tree.
@greghendershott
greghendershott / termsheet.rkt
Created November 9, 2012 23:54
A "term sheet" is a light-weight, more casual version of a contract. :)
#lang racket
;; A term sheet is a light-weight, casual version of a contract. :)
;;
;; Seriously, `define/termsheet' takes the same form as
;; `define/contract', but uses the contract predicates as simple
;; checks. As a result, this runs much faster -- e.g. ~200x faster --
;; than a normal, chaperoned wrapped procedure.
;;
;; In other words it gives the declarative convenience of
@heapwolf
heapwolf / npm-qos-heuristic.md
Last active December 11, 2015 10:38
general heuristics for ranking package quality

Health

Has CI

Tests pass

Total number of breaking commits

Number of dependencies

Average age of issue

Frequency of issues fixed

Average response time of issues fixed to bugs filed

Last commit

@lmullen
lmullen / .slate
Created February 8, 2013 04:19
My configuration file for the Slate window manager
# GLOBAL CONFIGURATIONS
# -------------------------------------------------------------------
# See https://github.com/jigish/slate/wiki/Global-Configs
config defaultToCurrentScreen true
config secondsBeforeRepeat 0.4
config secondsBetweenRepeat 0.1
config keyboardLayout "qwerty"
config nudgePercentOf screenSize
config resizePercentOf screenSize
@mbrevoort
mbrevoort / LogstashUDP.js
Created June 24, 2013 06:55
A simple Logstash UDP logger for Winston.
// Really simple Winston Logstash UDP Logger
var dgram = require('dgram'),
util = require('util'),
os = require('os'),
winston = require('winston');
var LogstashUDP = module.exports = function (options) {
winston.Transport.call(this, options);
options = options || {};
@fi01
fi01 / How to use msm_acdb explot
Created July 28, 2013 04:42
Stack-based buffer overflow in acdb audio driver (CVE-2013-2597)
To use msm_acdb explot we need to work 4 steps.
1. Find how to run command with root or system previlege
2. Get offset for registers to setup
3. Choose proper code in kernel image
4. Setup parameters in acdb.c
1. Find how to run command with root or system previlege
Do it your self. :-P
@ursachec
ursachec / build-libevent-ios.sh
Last active June 30, 2023 07:22
libevent build script for iOS
#!/bin/bash
set -u
# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("armv7" "armv7s" "i386")
SDKS=("iphoneos" "iphoneos" "macosx")
LIB_NAME="libevent-2.0.21-stable"
TEMP_DIR="$(pwd)/tmp"
TEMP_LIB_PATH="$(pwd)/tmp/${LIB_NAME}"
@commonsguy
commonsguy / SimpleAsyncTask.java
Created October 9, 2013 12:46
AsyncTask subclass with simplified API, to ease use by newcomers to Java, by avoiding generics and varargs. Simply subclass SimpleAsyncTask and override doInBackground() (no parameters, no return value) and onPostExecute() (also no parameters, no return value). Call execute() with no parameters to execute it in a thread pool. Data can be "passed…
/***
Copyright (c) 2013 CommonsWare, LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
package org.jf.InstrumentationTest;
import com.google.common.collect.Lists;
import org.jf.dexlib2.DexFileFactory;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.builder.MutableMethodImplementation;
import org.jf.dexlib2.builder.instruction.BuilderInstruction11x;
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c;
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c;
import org.jf.dexlib2.iface.ClassDef;
@jduck
jduck / adis.py
Last active February 2, 2017 15:28
Sample utility to disassemble a raw ARM bytecode file using Capstone.
#!/usr/bin/env python
#
# Simple utility to disassemble a raw bytecode file using Capstone.
#
# -jduck
#
import argparse
import capstone
import struct