Skip to content

Instantly share code, notes, and snippets.

@jsvnm
jsvnm / gist:3941692
Created October 23, 2012 21:24
automagic reply-to header in macmail
defaults write com.apple.mail UserHeaders {"Reply-To" = "user@host"; }
@jsvnm
jsvnm / getext.coffee
Created November 10, 2012 22:35
get extension from filename
ext = (f) -> (e=/^.+\.([^.]+)$/.exec(f)) and e[1]
@jsvnm
jsvnm / gist:4058444
Created November 12, 2012 09:57
install from (nodejs) msi to path without spaces
msiexec.exe APPLICATIONROOTDIRECTORY=C:\opt\nodejs /i node-v0.8.14-x64.msi
@jsvnm
jsvnm / test.js
Created November 12, 2012 13:07
testing...
var GitHubApi = require("github");
@jsvnm
jsvnm / tmp.js
Created November 12, 2012 13:55
getting a date range strign fr githubsearch
function fm(d){return [d.getFullYear(), d.getMonth()+1, d.getDate()].join('-');}
function rn(a,d){var b=new Date();b.setDate(a.getDate()+d);var ds=[a,b].sort();return " pushed:["+fm(ds[0])+" TO "+fm(ds[1])+"]";}
function se(s,d){window.location="https://github.com/search?type=Repositories&q="+s+rn(new Date(),d);}
@jsvnm
jsvnm / log4netloggersnippet.cs
Created November 13, 2012 17:26
get log4net.Logger for current class
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@jsvnm
jsvnm / HasObservableProperties.cs
Created November 15, 2012 10:26
reactive and inotifyproperties.
using System.ComponentModel;
using System.Linq.Expressions;
using System;
using System.Reactive.Linq;
using System.Reactive;
namespace Foo
{
public abstract class HasObservableProperties: INotifyPropertyChanged
@jsvnm
jsvnm / rgbFromWavelength.rb
Created November 15, 2012 15:42
get rgb value of wavelength
# from http://www.physics.sfasu.edu/astro/color/spectra.html
def rgbFromWavelength(wl, gamma=0.8)
rgb=case wl
when (380..439); [-1.0*(wl-440.0)/(440.0-380.0), 0.0, 1.0]
when (440..489); [0.0, (wl-440.0)/(490.0-440.0), 1.0]
when (490..509); [0.0, 1.0, -1.0*(wl-510.0)/(510.0-490.0)]
when (510..579); [(wl-510.0)/(580.0-510.0), 1.0, 0.0]
when (580..644); [1.0, -1.0*(wl-645.0)/(645-580.0), 0.0]
when (645..780); [1.0, 0.0, 0.0];
@jsvnm
jsvnm / gist:4087131
Created November 16, 2012 12:56
make local branches that track the ones in remote (origin)
for r in `git branch -r | grep -v HEAD`; do b=${r#origin/}; git branch --track $b $r; done
@jsvnm
jsvnm / LinqToVisualTree.cs
Created December 3, 2012 10:42
bit modified linqtovisualtree
// original from http://www.scottlogic.co.uk/blog/colin/2010/03/linq-to-visual-tree/
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace LinqToVisualTree
{