Skip to content

Instantly share code, notes, and snippets.

View vector-man's full-sized avatar

Michael Corbett vector-man

View GitHub Profile
@canadaduane
canadaduane / jquery.textselect.js
Created February 12, 2011 05:29
jQuery Text Selection method and events
/* jQuery plugin textselect
* version: 1.0
* tested on jQuery 1.3.2, 1.5
* author: josef.moravec@gmail.com, duane.johnson@gmail.com
*
* usage:
* $(function() {
* $(document).bind('textselect', function(e) {
* Do stuff with e.text
* });
@natritmeyer
natritmeyer / Program.cs
Created May 11, 2011 18:10
A tiny c# app that operates the Open File dialog using White. Useful if you're testing a WPF app with bewildr (http://www.bewildr.info) but the app you're testing uses the old Win32 dialog boxes. The compiled exe takes one arg; the value you want typed in
/*
Create a console app, add references to the various white libraries and use the following as a template for operating the Open Dialog window
Get the white binaries from here: http://white.codeplex.com/
*/
using System.Collections.Generic;
using System.Linq;
using System.Windows.Automation;
using White.Core;
using White.Core.UIItems;
@jmangelo
jmangelo / CallerInfo.cs
Created June 9, 2012 14:51
Extended Logging Sample with .NET 4.5 Caller Info Attributes and NLog
using System;
using System.IO;
using System.Runtime.CompilerServices;
using NLog;
public sealed class CallerInfo
{
private CallerInfo(string filePath, string memberName, int lineNumber)
{
this.FilePath = filePath;
@automatonic
automatonic / MurMurHash3.cs
Created September 14, 2012 22:46
MurMurHash3 .Net (C#) implementation
/*
This code is public domain.
The MurmurHash3 algorithm was created by Austin Appleby and put into the public domain. See http://code.google.com/p/smhasher/
This C# variant was authored by
Elliott B. Edwards and was placed into the public domain as a gist
Status...Working on verification (Test Suite)
Set up to run as a LinqPad (linqpad.net) script (thus the ".Dump()" call)
*/
@Larry57
Larry57 / ini.cs
Last active February 21, 2024 05:05
A single class to read and write INI files.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
public class Ini
{
Dictionary<string, Dictionary<string, string>> ini = new Dictionary<string, Dictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
string file;
@chilts
chilts / alexa.js
Created October 30, 2013 09:27
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
anonymous
anonymous / contains-v4-schema.json
Created November 7, 2013 17:59
{
"description": "\"contains\" hack for v4 JSON Schema. The array must contain at least one \"A\", specified by saying that if all the entries are *not* \"A\", then it fails.",
"type": "array",
"not": {
"items": {
"not": {
"enum": ["A"]
}
}
}
var tv4 = require('tv4');
var schema = {
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema",
"id": "#",
"required": ["events"],
"properties": {
"events": {
"type": "array",
@richardkundl
richardkundl / BloomFilter.cs
Created January 7, 2014 14:29
Bloom filter implementation in c#.
namespace BloomFilter
{
using System;
using System.Collections;
/// <summary>
/// Bloom filter.
/// </summary>
/// <typeparam name="T">Item type </typeparam>
public class Filter<T>
@JulienBlancher
JulienBlancher / filter.d_nginx-auth.conf
Last active July 14, 2024 19:32
Fail2ban Config with Nginx and SSH
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =