Skip to content

Instantly share code, notes, and snippets.

View srdjan's full-sized avatar

⊣˚∆˚⊢ srdjan

View GitHub Profile
var If = React.createClass({
render: function() {
return this.props.value && this.props.children;
}
});
// usage
<If value={this.state.whatever}>
Stuff
</If>
namespace FSharp.Data
open Microsoft.FSharp.Core.CompilerServices
open ProviderImplementation.ProvidedTypes
open System.Reflection
module internal HexParser =
open System.Text.RegularExpressions
let private getHexVal (hex: char) =
require ('./globals')(global); // Mixed in Ramda to global here
var Task = require ('data.future'),
M = require ('control.monads'),
State = require ('fantasy-states'),
Reader = require ('fantasy-readers'),
Tuple2 = require ('fantasy-tuples').Tuple2,
Maybe = require ('data.maybe'),
ST = State.StateT (Task),
App = Reader.ReaderT (ST);
//scala
vertx.createHttpServer().requestHandler({ req: HttpServerRequest =>
req.response()
.putHeader("Content-Type", "text/html")
.end("<html><body><h1>Hello from Vert.x!" +
"</h1></body></html>")
}).listen(8080)
//groovy
vertx.createHttpServer().requestHandler({ req ->
@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 ||= {}

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);
@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
@creationix
creationix / sample.js
Last active December 18, 2015 12:39
Low Level JS API for local git repos
var gitRepo = require('../.');
var fs = require('min-fs');
var run = require('gen-run');
var consume = require('../stream-to-string.js');
run(function* main() {
// Configure the repo API to work from a local clone.
var repo = gitRepo({ fs: fs("./my-repo") });