Skip to content

Instantly share code, notes, and snippets.

View JesseBuesking's full-sized avatar

Jesse Buesking JesseBuesking

View GitHub Profile
@JesseBuesking
JesseBuesking / Log4NetPlugin.cs
Created January 14, 2012 20:12
Log4Net Glimpse plugin interfacing with MySql through Dapper and MiniProfiler's ProfiledDbConnection
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using Dapper;
using Glimpse.Core.Extensibility;
using MySite.WebGUI.Areas.Admin.Controllers;
using MvcMiniProfiler.Data;
using MySql.Data.MySqlClient;
@JesseBuesking
JesseBuesking / SqlServerStorage.cs
Created May 30, 2012 00:29
MiniProfiler Client Timing Persistent Storage
// SqlServerStorage.cs
// ...
if (t.HasChildren) // line 187 of the original file
{
foreach (var child in t.Children)
{
SaveTiming(conn, profiler, child);
}
" automatic installation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" Colorschemes
@JesseBuesking
JesseBuesking / invert_colors_bookmark.js
Last active December 15, 2015 12:29
Inverts browser colors. I've in-lined a stripped-down version of rgbcolor.js and minified the entire script. For reference, checkout http://stackoverflow.com/a/4766232/435460
javascript:var c=[{r:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,p:function(b){return[parseInt(b[1]),parseInt(b[2]),parseInt(b[3])]}},{r:/^(\w{2})(\w{2})(\w{2})$/,p:function(b){return[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16)]}},{r:/^(\w{1})(\w{1})(\w{1})$/,p:function(b){return[parseInt(b[1]+b[1],16),parseInt(b[2]+b[2],16),parseInt(b[3]+b[3],16)]}}];function w(b){this.ok=!1;"#"==b.charAt(0)&&(b=b.substr(1,6));b=b.replace(/ /g,"").toLowerCase();for(a=0;a<c.length;a++){var d=c[a].r.exec(b);d&&(z=c[a].p(d),this.r=z[0],this.g=z[1],this.b=z[2],this.ok=!0)}this.r=0>this.r||isNaN(this.r)?0:255<this.r?255:this.r;this.g=0>this.g||isNaN(this.g)?0:255<this.g?255:this.g;this.b=0>this.b||isNaN(this.b)?0:255<this.b?255:this.b}function y(){var b=["color","background-color"];$($("*").get().reverse()).each(function(){var d=null,e;for(e in b)e=b[e],$(this).css(e)&&(d=new w($(this).css(e)),d.ok&&$(this).css(e,"rgb("+(255-d.r)+","+(255-d.g)+","+(255-d.b)+")"))})}function z(b,d){var e=document.createElement("script
@JesseBuesking
JesseBuesking / gist:5600328
Created May 17, 2013 16:39
git tfs clone project
git tfs quick-clone -d http://tfs-server-name:tfs-server-port/tfs/name $/project/info C:/where/to/put/it
http://stackoverflow.com/a/7532131/435460
@JesseBuesking
JesseBuesking / ClassWithListView.java
Last active December 18, 2015 04:19
Template-ish code for returning a user to the correct position within a ListView in an Android application.
public class ClassWithListView {
/**
* The last index in the list that the user was at.
*/
private int lastIndex = -1;
/**
* Used with lastIndex to match the exact offset.
*/
private int lastIndexOffset = 0;
public class Singleton
{
private static readonly Lazy<Singleton> _lazy = new Lazy<Singleton>(
() => new Singleton(), LazyThreadSafetyMode.ExecutionAndPublication);
public static Singleton Instance
{
get
{
return Singleton._lazy.Value;
public struct Id
{
private long _id;
public Id(long id)
{
this._id = id;
}
public static implicit operator Id(long value)
@JesseBuesking
JesseBuesking / create-package.bat
Last active January 3, 2016 04:09
Creating a virtualenv and updating so that the compiler is set to mingw32 (so that things like cython can be installed via pip).
virtualenv --distribute --no-site-packages %1
python update-mingw-compiler.py %1
@JesseBuesking
JesseBuesking / pprint_defaulttict.py
Created March 17, 2014 17:51
Pretty prints a default dict in IPython
def pprint_defaultdict():
from collections import defaultdict
import IPython
ip = get_ipython()
tf = ip.display_formatter.formatters['text/plain']
def _print_default_dict(arg, p, cycle):
""" Pretty print a defaultdict. """
def rec(obj, indent=0, level=0):
if isinstance(obj, defaultdict) or isinstance(obj, dict):
p.text('{\n')