Skip to content

Instantly share code, notes, and snippets.

@bricef
bricef / party.dot
Last active February 13, 2018 15:30
Abduction: Bat out of hell party - attitude graph
//➤ neato party.dot -Gsep="+200" -Goverlap=scalexy -Tpng -o party.png && open party.png
digraph party {
Ad [label="Adric"];
Az [label="Azrael"];
P [label="Peridot"];
Li [label="Liberace"];
Pe [label="Pete"];
K [label="Koros"];
Lu [label="Luth"];
F [label="Fletcher"];
<html>
<body>bucket served file ok</body>
</html>
@bricef
bricef / Hash.cs
Last active October 3, 2016 00:41
Salting and Hashing passwords correctly in .NET
/**
* From http://lockmedown.com/hash-right-implementing-pbkdf2-net/
*/
public class Hash
{
private const int SaltByteLength = 32;
private const int DerivedKeyLength = 32;
private const int IterationCount = 48000;
private const char separator = '|';
@bricef
bricef / PaddingOracle.py
Created September 8, 2016 20:56
Padding Oracle attack example in python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import sys
from Crypto.Cipher import AES
BLOCK_SIZE = 16 # bytes
INIT_VEC = 'This is an IV456' # hardcoding this is a terrible idea
@bricef
bricef / monkey.py
Last active January 29, 2021 19:54
Monkey patching of builtins in Python3
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import MappingProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@bricef
bricef / SMSSpamCollection.txt
Created April 5, 2016 17:19
Very Naive Bayesian Spam Filtering
ham Go until jurong point, crazy.. Available only in bugis n great world la e buffet... Cine there got amore wat...
ham Ok lar... Joking wif u oni...
spam Free entry in 2 a wkly comp to win FA Cup final tkts 21st May 2005. Text FA to 87121 to receive entry question(std txt rate)T&C's apply 08452810075over18's
ham U dun say so early hor... U c already then say...
ham Nah I don't think he goes to usf, he lives around here though
spam FreeMsg Hey there darling it's been 3 week's now and no word back! I'd like some fun you up for it still? Tb ok! XxX std chgs to send, £1.50 to rcv
ham Even my brother is not like to speak with me. They treat me like aids patent.
ham As per your request 'Melle Melle (Oru Minnaminunginte Nurungu Vettam)' has been set as your callertune for all Callers. Press *9 to copy your friends Callertune
spam WINNER!! As a valued network customer you have been selected to receivea £900 prize reward! To claim call 09061701461. Claim code KL341. Valid 12 hours only.
spam Had your mobile 11 months
@bricef
bricef / foo.js
Created March 16, 2016 16:32
Example lecture desc
export default {
uid:"uid-00-begin-fsharp",
title: "First steps with F#",
level:0,
description:"Let's build stuff with F#...",
url_img:"https://placehold.it/250x250?text=First+Steps",
available:"available",
access:true,
content: [
{
@bricef
bricef / bayes.fs
Created February 16, 2016 14:48
A bayesian spam classifier
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open Argu
type Label = Spam | Ham
type Corpus = {
spamFreqs:Map<string, int>;
hamFreqs:Map<string, int>;
@bricef
bricef / bayes.fs
Created January 25, 2016 09:27
Start to Bayes filtering in F#
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open System.IO
open System
// 01 - Defining the problem
type Label = Ham | Spam
let classify msg : Label =
Spam
@bricef
bricef / NaiveBayesClassifier.fs
Created January 20, 2016 16:05
Spam Filtering in F# - without probability combinations
open System.IO
open System
type Label = Ham | Spam
let classify msg : Label = Spam
type Corpus = Map<Label, Map<string, float>>
type LabeledData = seq<Label*string>