Skip to content

Instantly share code, notes, and snippets.

View srdjan's full-sized avatar

⊣˚∆˚⊢ srdjan

View GitHub Profile
@pksunkara
pksunkara / config
Last active November 15, 2024 16:02
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
@srdjan
srdjan / observer.coffee
Created November 1, 2011 19:49 — forked from sdiehl/observer.coffee
Observer Pattern in Coffeescript
class Observer
bind : (event, fn) ->
this._events ||= {}
this._events[event] ||= []
this._events[event].push(fn)
unbind: (event, fn) ->
@_events ||= {}
@ovatsus
ovatsus / Setup.fsx
Created March 17, 2012 17:07
Script to setup F# Interactive session, loading everything in the current solution
#r "System.Xml.Linq"
open System
open System.IO
open System.Xml.Linq
let script = seq {
//TODO: this currently loads fsproj's in alphabeticall order, we should instead
//build the dependencies graph of the fsproj's and load them in topological sort order
@trey
trey / happy_git_on_osx.md
Last active September 19, 2024 16:23
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "[email protected]"

@derek-watson
derek-watson / simple-throttle.js
Created August 14, 2012 14:44
Simple javascript function throttling
var isThrottled = false,
throttleDuration = 24; // ms
function thingToThrottle() {
if (isThrottled) { return; }
isThrottled = true;
setTimeout(function () { isThrottled = false; }, throttleDuration);
// do your work here
}

The Scope class regulates lexical scoping within CoffeeScript. As you generate code, you create a tree of scopes in the same shape as the nested function bodies. Each scope knows about the variables declared within it, and has a reference to its parent enclosing scope. In this way, we know which variables are new and need to be declared with var, and which are shared with the outside.

Import the helpers we plan to use.

{extend, last} = require './helpers'

@MikeBild
MikeBild / LRUObservableCollection.cs
Created November 13, 2012 15:18
Tiny LRU cache implementation
public class LRUObservableCollection<T> : ObservableCollection<T>
{
private readonly int _length;
public LRUObservableCollection(int length)
{
_length = length;
}
protected override void InsertItem(int index, T item)
anonymous
anonymous / gist:4297250
Created December 15, 2012 17:08
using Simple.Data from F# for fun
open Simple.Data
open Xunit
open Swensen.Unquote
open ImpromptuInterface.FSharp
let adapter = new InMemoryAdapter()
adapter.SetKeyColumn("Test", "Id");
adapter.SetKeyColumn("Test", "Name");
Database.UseMockAdapter(adapter);
@joeriks
joeriks / RoslynDynamicCompilation.cs
Created December 28, 2012 07:44
Add a piece of dynamically compiled code in memory with the help of Roslyn. (After this the Greeter class will be available and can be run from example from the immediate window in visual studio).
public static void AddGreeter()
{
AddInmemory("Greeter", @"using System;
class Greeter
{
public string Greet()
{
return ""Hello World"";
}
@kijanawoodard
kijanawoodard / LastInWinsReplicationConflictResolver.cs
Created April 4, 2013 01:54
Last One Wins Raven Resolver - Updated for 2.x
using System;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Abstractions.Logging;
using Raven.Bundles.Replication.Plugins;
using Raven.Json.Linq;
namespace RavenConflictResolverPlugin
{
public class LastInWinsReplicationConflictResolver