Skip to content

Instantly share code, notes, and snippets.

// Newbie programmer
int factorial_newbie(int n) {
if (n == 0) {
return 1
} else {
return n * factorial_newbie(n - 1)
}
}
println factorial_newbie(6)
var sys = require('./rx_sys');
var http = require('./rx_http');
var fs = require('./rx_fs');
var url = require('url');
var path = require('./rx_path');
var serverData = http.createServer();
var requests = serverData.Select(function(details) {
details.url = url.parse(details.request.url);
@hayashih
hayashih / CloudFrontObjectInvalidation.cs
Created November 30, 2010 10:18
Control CloudFront Object Invalidation. Require AWS SDK for .NET http://aws.amazon.com/sdkfornet/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Amazon.CloudFront;
using Amazon.CloudFront.Model;
using System.Collections.Specialized;
using System.Configuration;
// Require AWS SDK for .NET http://aws.amazon.com/sdkfornet/
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@JeremySkinner
JeremySkinner / 01_Demo.cs
Created January 23, 2011 21:21
A little strongly-typed wrapper around WebMatrix.Data - this is now its own project at https://github.com/JeremySkinner/WebMatrix.Data.StronglyTyped
// WebMatrix.Data's Query method returns an IEnumerable<dynamic>
// While this is great for simple scenarios, if you want to add behaviour to your DB objects
// then it can be a pain. Here's a simple wrapper that adds a strongly-typed Query method
// This is a simple implementation and could be improved.
// Represents a table in the database
public class User {
public int Id { get; set; }
public string Name { get; set; }
}
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@joliver
joliver / gist:875528
Created March 18, 2011 02:35
EventStore Fluent Builder API
return EventStore.Wireup.Init()
.UsingSqlPersistence("EventStore")
.InitializeDatabaseSchema()
.UsingCustomSerializer(new JsonSerializer())
.Compress()
.EncryptWith(EncryptionKey)
.UsingAsynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(DispatchCommit))
.HandleExceptionsWith(DispatchErrorHandler)
.Build();
@thecodejunkie
thecodejunkie / gist:881542
Created March 22, 2011 16:44
Spike of Nancy test harness
public class BrowserFixture
{
private readonly Browser browser;
public BrowserFixture()
{
var bootstrapper =
new FakeDefaultNancyBootstrapper();
this.browser = new Browser(bootstrapper);
@joeriks
joeriks / NancyStart.cs
Created April 6, 2011 09:47
First try with NancyFx and SisoDb - form insert and list product names
using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using SisoDb;
/// <summary>
/// Requires the NuGet packages Nancy.Hosting.Aspnet and SisoDb
/// and a local Database in .\Sqlexpress called sisodemo
/// </summary>