Skip to content

Instantly share code, notes, and snippets.

@missett
missett / password-checker.py
Created January 19, 2019 22:52
Checks a list of passwords against Have I Been Pwned to find which passwords you should change
#! /usr/bin/env python
import hashlib
import httplib
with open("passwords.txt", "r") as file:
for password in file:
password = password.strip()
sha = hashlib.sha1(password).hexdigest().upper()
head = sha[:5]
@missett
missett / Jive
Last active August 29, 2015 14:08
function Scope(parent, symbols) {
this.parent = parent;
this.symbols = symbols;
}
Scope.prototype.contains = function(key) {
if(this.symbols.hasOwnProperty(key)) {
return true;
} else if(this.parent !== null) {
return this.parent.contains(key);
function parse(input) {
var i = 0;
function descend(input) {
var escape = false,
atom = '',
atomSet = [];
for(i; i<input.length; i++) {
function pop(input) {
var i = input.indexOf('(') + 1, // Start of out outermost s-expression
j = -1, // Will be set to the index of the matching ) to close the outsermost s-expression
l = 1, // Nesting 'stack counter' to make sure we get the outermost expression only
k = 0; // Loop index
if(i < 0)
return input;
for(k=i; k<input.length; k++) {
@missett
missett / Haskell Sieve of Eratosthenes
Created December 21, 2013 15:13
Haskell implementation of the Sieve of Eratosthenes algorithm for finding prime numbers.
sieve :: [Integer] -> [Integer]
sieve [] = []
sieve (x:xs)
| x < 2 = sieve xs
| otherwise = x : sieve (filter (\n -> n `mod` x /= 0) xs)
@missett
missett / Haskell Quicksort
Created December 21, 2013 13:34
Haskell implementation of the quicksort algorithm
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) = let lesser = filter (< x) xs
greaterThanOrEqual = filter (>= x) xs
in quicksort lesser ++ [x] ++ quicksort greaterThanOrEqual
@missett
missett / JS Sieve of Eratosthenes
Last active April 6, 2021 20:36
Recursive implementation of the Sieve of Eratosthenes algorithm for filtering a set of numbers for prime numbers.
var sieve = function(xs) {
var head = xs[0],
tail = xs.slice(1);
if(head === undefined) return [];
if(head < 2) return sieve(tail);
tail = tail.filter(function(x) {
return x % head > 0 ? true : false;
@missett
missett / JS Flatten
Created December 10, 2013 10:26
Recursive implementation to flatten a nested array structure.
var flatten = function(nested) {
var head = nested.slice(0, 1),
tail = nested.slice(1),
type = Object.prototype.toString.call(head[0]);
if(nested.length === 0) return [];
if(type === '[object Array]') return flatten(head[0]).concat(tail);
return head.concat(flatten(tail));
@missett
missett / JS Quicksort
Created October 24, 2013 11:47
Recursive Quicksort implementation in JS
function quicksort(input) {
if(input.length === 0) return input;
var head = input[0],
tail = input.slice(1);
var less = tail.filter(function(i) {
return i < head ? true : false;
});
@missett
missett / gist:5960723
Created July 9, 2013 19:58
Example of a custom event in ExtJS
Ext.create('Ext.grid.Panel', {
columns: [
{
xtype: 'actioncolumn',
isDisabled: function(value) {
return true;
},
handler: function() {
this.fireEvent('customevent', arg1, arg2, ...);
}