Skip to content

Instantly share code, notes, and snippets.

@ddm
ddm / gist:e837207cb673024c245c
Created May 8, 2014 15:35
Python profiling
The Python 2.7 documentation recommends the use of cProfile to profile Python code with reasonnably low overhead: https://docs.python.org/release/2.7/library/profile.html
If you use virtualenv, dont forget to activate it:
$ . bin/activate
How do you launch your script with cProfile enabled ?
$ python -m cProfile -o run.profile myscript.py
The output file (run.profile) will be generated when the execution terminates (including CTRL-C).
@ddm
ddm / 16step.coffee
Created March 8, 2012 15:09 — forked from peterc/16step.coffee
Simple 16 step drum machine using CoffeeScript and Node
# Simple 16 step drum machine experiment with Node and CoffeeScript
# by Peter Cooper - @peterc
#
# Inspired by Giles Bowkett's screencast at
# http://gilesbowkett.blogspot.com/2012/02/making-music-with-javascript-is-easy.html
#
# Screencast demo of this code at http://www.youtube.com/watch?v=qWKkEaKL6DQ
#
# Required:
# node, npm and coffee-script installed
@ddm
ddm / css_transition_callback.js
Created October 16, 2013 09:17
CSS transition callback
$el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function callback () {
// Executed after CSS transition
});
DIR=`dirname $0`
gcc -g \
`pkg-config --cflags --libs gtk+-3.0` \
-I$DIR \
-lMPSSE \
-lftd2xx \
-L$DIR \
-o spixio \
spixio-gtk.c spixio-gui.c spixio.c
@ddm
ddm / nrf51.openocd.cfg
Created December 12, 2016 11:13
NRF51 openocd SWD config
source programmer.cfg
transport select swd
set WORKAREASIZE 0
set CHIPNAME nrf51822
source [find target/nrf51.cfg]
reset_config srst_only srst_nogate
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
@ddm
ddm / Dockerfile
Last active December 22, 2016 16:54
CM13 bacon
FROM debian:jessie
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y python git-core gnupg flex bison gperf libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev libncurses5-dev gcc-multilib g++-multilib parted kpartx debootstrap pixz qemu-user-static abootimg cgpt vboot-kernel-utils vboot-utils bc lzma lzop automake autoconf m4 dosfstools rsync u-boot-tools schedtool git e2fsprogs device-tree-compiler ccache dos2unix debootstrap
RUN git clone --depth 1 https://github.com/offensive-security/kali-nethunter.git /nethunter
WORKDIR /nethunter/nethunter-fs/
RUN ./build.sh -f
@ddm
ddm / apk.sh
Created February 8, 2017 08:22
Unpack or pack an apk
#!/usr/bin/env bash
DIR=`dirname $0`
TARGET_APK="target.apk"
TARGET_DIR="target"
if [[ ! "$1" =~ ^(unpack|pack)$ ]]; then
echo "Choose 'unpack' or 'pack'"
exit 1
fi

From this paper: http://fpgacpu.ca/fpga/hdl/Tumbush%20DVCon%2005.pdf

  1. If any operand in an operation is unsigned the entire operation is unsigned.
  2. Investigate fully all "signed to unsigned conversion occurs" synthesis warnings. These point to incorrect functionality.
  3. All signed operands will be sign-extended to match the size of the largest signed operand.
  4. Type casting using $unsigned will make the operation unsigned. The operand will be extended with 0’s if necessary.
  5. Type casting using $signed makes the operand signed. The operand will be sign-extended with 1's if necessary. Pad the operand with a single 0 bit before the cast if this is not desired.
  6. Expression type depends only on the operands or operation; it does not depend on the LHS of the expression.

Additional points based on feedback from Owen Shepherd:

// A round-robin priority arbiter for valid/ready signaling using carry chain logic.
module arbiter#(parameter N = 2)
(
input wire clk,
input wire [N-1:0] s_valid,
output wire [N-1:0] s_ready,
output wire m_valid,
input wire m_ready
);
@ddm
ddm / cm13-bacon.sh
Last active April 5, 2017 07:25
CM13 bacon
#!/usr/bin/env bash
sudo apt-get update && sudo apt-get install -y bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop maven openjdk-8-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-dev lib32z1-dev android-sdk
if `hash adb &>/dev/null`; then
echo "Android tools found..."
else
echo "Installing android tools..."
echo "y" | android update sdk -u -a --filter tools
echo "y" | android update sdk -u -a --filter platform-tools