Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / test.js
Created November 12, 2012 13:07
testing...
var GitHubApi = require("github");
@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 / getext.coffee
Created November 10, 2012 22:35
get extension from filename
ext = (f) -> (e=/^.+\.([^.]+)$/.exec(f)) and e[1]
@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 / gist:3544998
Created August 30, 2012 23:30
wanted "most recent before current"-window. get-mru-window gives current. instead of simplest, i did the most complex thing that could work. almost.
(defun windows-in-use-time-order (&optional old-to-new windows)
"Windows sorted by their `window-use-time'.
Without arguments windows on current frame ordered from most to least recent.
Optional argument OLD-TO-NEW with non-nil value reverses the order.
Optional argument WINDOWS specifies which windows to sort by use time:
- a list is assumed to contain windows and sorted
@jsvnm
jsvnm / ymd.rb
Created March 18, 2012 08:24
monkeypatch to Date to get difference to other date asstring with any or all of years,months,weeks,days. started out as codegolf...
class Date
# prev_week and next_week, add/remove 7 days * optarg
['prev_','next_'].each{|n|define_method(n+'week'){|w=1|send n+'day',7*w}}
# other is Date to compare to
# wants tells what to include in timediff. default is years,months,weeks,days
# by default returns <timediff> from <earlier> to <later>
# if abs=true returns <self> is <timediff> later|earlier than <other>
def diff_str other, want="ymwd",abs=false
return "Both dates are #{self}" if self==other
@jsvnm
jsvnm / generation.cs
Created February 29, 2012 16:53
funcs that generate funcs that generate values. and things yield returning as enumerables
static public class FunFactory
{
static public Func<TResult> Make<TResult>(TResult a, Func<TResult, TResult> step)
{
TResult next=a;
return ()=>{ TResult cur=next; next=step(cur); return cur; };
}
static public Func<TResult> Cycle<TResult>(IEnumerable<TResult> values)
{