Skip to content

Instantly share code, notes, and snippets.

@DoggettCK
DoggettCK / bloomfilter.py
Created February 11, 2013 16:45
A Bloom filter based on Max Burstein's implementation (http://maxburstein.com/blog/creating-a-simple-bloom-filter/)
from bitarray import bitarray
import mmh3
from math import log, pow, ceil
class BloomFilter:
def __init__(self, size, hash_count):
self.size = size
self.hash_count = hash_count
self.bit_array = bitarray(size)
self.bit_array.setall(0)
// ==UserScript==
// @name Hodor
// @namespace gamerswithjobs
// @description Makes everything sound the same
// @exclude /github/
// @author Chris Doggett
// ==/UserScript==
// Special thanks to Jeremy Banks at http://stackoverflow.com/a/6834930/64203
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
@DoggettCK
DoggettCK / sludgehammer.user.js
Created June 13, 2012 16:28
GWJ SludgeHammer
// ==UserScript==
// @name SludgeHammer
// @namespace gamerswithjobs
// @description Replaces marketing speak with English
// @exclude /github/
// @author Chris Doggett
// ==/UserScript==
// Special thanks to Jeremy Banks at http://stackoverflow.com/a/6834930/64203
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
@DoggettCK
DoggettCK / gist:1591307
Created January 10, 2012 21:28
GamersWithJobs.com Ignore Users Chrome User Script
// ==UserScript==
// @name I Didn't Hear Anything
// @namespace gamerswithjobs
// @description Increases the number of potential Tannhauserings
// @include http://www.gamerswithjobs.com/node/*
// @author Chris Doggett
// ==/UserScript==
// Special thanks to Jeremy Banks at http://stackoverflow.com/a/6834930/64203
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
@DoggettCK
DoggettCK / gist:1305566
Created October 22, 2011 03:34
Code from "Enumerations and Strings - Stop the Madness!" (modified and added over time)
using System;
using System.Collections.Generic;
using System.Linq;
namespace Util
{
public static class Enums
{
#region Parse Methods
/// <summary>
@DoggettCK
DoggettCK / Hasher.cs
Last active August 29, 2015 14:17
ASP.NET HMACSHA256 Password hashing
/// <summary>
/// Given a password and salt string, along with an algorithm (MVC4 defaults to HMACSHA256), calculates the password's
/// hash value as stored in the DB.
/// </summary>
/// <param name="password">Plaintext password</param>
/// <param name="salt">Base64 string containing user's salt value</param>
/// <param name="hashingAlgorithm">Known .NET crypto algorithm name. Defaults to MVC4's default of HMACSHA256.</param>
/// <returns>Base64-encoded password hash string</returns>
/// <exception cref="CryptographicException">If hashingAlgorithm is unknown to .NET</exception>
private string HashPassword(string password, string salt, string hashingAlgorithm = "HMACSHA256") {
# Make sure we're installing into user's own Powershell Module path, and not the global one
$PSModuleDir = "$($ENV:PsModulePath)".Split(";") | Select-String "$ENV:UserName" | foreach {$_.Line } | Select-Object -First 1
function ModuleInstalled([parameter(Mandatory=$true)][string] $moduleName) {
return ((Get-Module "$moduleName") -ne $null)
}
function InstallPlugins([parameter(Mandatory=$true)][string[]] $moduleNames) {
if (-NOT (Test-Path "$PSModuleDir\PsGet\PsGet.psm1")) {
New-Item -ItemType Directory -Force -Path "$PSModuleDir\PsGet" | Out-Null
@DoggettCK
DoggettCK / gist:a54f49718d5ac2c74019
Created October 1, 2014 20:39
API self-documentation output
{
RelativePath: "api/products/get?sort_by={sort_by}&sort_order={sort_order}",
Method: "GET",
SupportedResponseFormats: [
"application/json",
"text/json"
],
SupportedEncodings: [
"utf-8",
"utf-16"
@DoggettCK
DoggettCK / gist:e6da2981096968b43e15
Created October 1, 2014 20:38
API self-documentation
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Hosting;
using System.Web.Http;
using System.Web.Http.Description;
using NLog;
namespace Project.Controllers.API {
///