Skip to content

Instantly share code, notes, and snippets.

@GM3D
GM3D / simplefuzzer3.py
Created November 14, 2013 08:09
A simple fuzzer based on Charlie Miller's "Babysitting an Army of Monkeys". Adjusted for Udacity CS258 PS4 homework.
#!/usr/bin/python
file_list = ["2010820135318.xls",
"tax__down_kyuyoido_rei.xls",
"toku-kirikae.xls",
"44hp.xls",
"tool_1_3.xls"]
apps = ["/usr/bin/gnumeric"]
@GM3D
GM3D / gist:7e838695f4f8f09978e5
Created July 19, 2014 06:42
Test run result of ex-3.15
n = 0
n = 1
1 initial orders were sortable within 0 ops.
n = 2
1 initial orders were sortable within 0 ops.
2 initial orders were sortable within 1 ops.
n = 3
1 initial orders were sortable within 0 ops.
4 initial orders were sortable within 1 ops.
6 initial orders were sortable within 2 ops.
import copy
import math
import random
def random_x():
return 2*random.randint(0, 1) - 1
def modify(x):
i = random.randint(0, 2)
xr = copy.copy(x)
@GM3D
GM3D / theano_scan_example2.py
Last active December 7, 2015 15:21
Theano simple implementation of exmaple 1 in the MCMC book
#!/usr/bin/python3
'''Theano simple implementation of exmaple 1 in the MCMC book,
the same progrm with
example1.py (https://gist.github.com/GM3D/51965c9e6de5456971b5).
without shared variable.'''
from __future__ import print_function
import numpy as np
import theano
from theano.ifelse import ifelse
#!/usr/bin/python3
import numpy as np
from numpy import random
N = 10
size = [N, N]
theta = 0.42
n_steps = 1000000
x = 2 * random.random_integers(0, 1, size=size) - 1
@GM3D
GM3D / pdf-to-png.sh
Last active December 8, 2016 11:52
shell script to convert a multi-page pdf to separate png images.
#!/bin/bash
fbody="$(basename "$1" .pdf)"
outfile="$(echo $fbody | sed -s s/-$//)"-p.png
convert -type Grayscale -density 600 -resample 100 -antialias "${fbody}.pdf" "$outfile"
from sympy import sqrt
N = 15
a = [[]]*N
for n in range(N):
a[n] = [0]*(n+1)
if n == 0:
a[0][0] = 1
else:
for l in range(n + 1):
@GM3D
GM3D / exercise-I-2-2.py
Last active October 2, 2017 07:59
Coursera Modular forms 2017 exercise I-2-2
#!/usr/bin/python3
from math import sqrt, factorial
from operator import mul
def binomial(n, k):
return factorial(n)/(factorial(n-k) * factorial(k))
def dot_prod(a, b):
return sum(map(mul, a, b))
@GM3D
GM3D / nielsen-chuang-exercise-5.17.py
Last active December 14, 2021 15:27
A code to describe the algorithm in Nielsen-Chuang exercise 5.17.
import math as m
def pure_power(N):
"""checks if N is a pure power, i. e. N = a^b for some integers
a >=1, b >= 2.
returns (a, b) if a and b are found.
returns (N, 1) if N is not a pure power.
See ref.1.: https://en.wikipedia.org/wiki/
Computational_complexity_of_mathematical_operations#Elementary_functions
for the computational complexities for each element.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.