Skip to content

Instantly share code, notes, and snippets.

View dyokomizo's full-sized avatar

Daniel Yokomizo dyokomizo

View GitHub Profile
@ToJans
ToJans / CQRS.cs
Created May 5, 2011 08:49
Simple concept code to show how CQRS works
//---><8--------------------------- UI loads viewmodels and generates commands ----
UI.Viewmodel = ViewModelStore.Query(UI.SomeParameters);
UI.HandleInput = GeneratedCommand => CommandStore.Add(GeneratedCommand);
//---><8--------------------------- Commands to events -----------------------------------------
// This uses an iterator because a command should only be handled once
while(CommandStore.HasCommands)
@sjoerdvisscher
sjoerdvisscher / EffectExamples.hs
Created August 10, 2011 00:09
Computational effects: eff EDSL in Haskell
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleContexts #-}
module Main where
import Effects
import Prelude hiding (catch)
import Control.Monad.Trans.Class (lift)
import qualified Data.Set as Set
import Data.Monoid
@arwagner
arwagner / gist:1323952
Created October 29, 2011 01:13
Combinatorial explosion and testing
I found http://groups.google.com/group/growing-object-oriented-software/browse_thread/thread/47695af2c6b5adda fascinating, so I decided to make it a little more concrete. It's also in ruby using rspec, sorry about that. Here's the code under test:
class EligibleForDiscountPolicy
def initialize transaction, user
@transaction = transaction
@user = user
end
def decide
return true if @user.is_gold_member?
@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@ajsutton
ajsutton / basic.js
Created November 13, 2011 19:56
Long Poll JS Patterns
(function($) {
var longPollUrl = '/longpoll';
var lastReceivedSequence;
function poll() {
$.ajax(longPollUrl, {
data: { 'lastSequence': lastReceivedSequence },
dataType: 'json',
timeout: 15000,
@soveran
soveran / elements.md
Created November 18, 2011 17:38
Excerpts from The Elements of Programming Style. The source of this compilation is unknown.

The Elements of Programming Style

The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."

@sjoerdvisscher
sjoerdvisscher / 10553.txt
Created November 19, 2011 20:55
10553, church encoded as ((4*((3*(((5^3)*7)+4))+1))+1)
λs.λz.(λs.λz.s(s(s(s z))))(λz.(λs.λz.s(s(s z)))(λz.(λs.λz.s(s(s z)))(λs.λz.s(s(s(s(s z)))))(λz.s(s(s(s(s(s(s z)))))))(s(s(s(s z)))))(s z))(s z)
@mbbx6spp
mbbx6spp / README.md
Created December 4, 2011 04:24
Best UNIX shell-based tools I can't live without with example usages

Best UNIX Shell tools

These are a list of usages of shell commands I can't live without on UNIX-based systems.

Install

Mac OS X

Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages:

@mbbx6spp
mbbx6spp / README.md
Created December 6, 2011 01:11
Idea for getting GitHub URLs for various needs

GitHub (Bash) Shell URLs

Local Shell setup

This is an environment file to source upon shell startup (via .bashrc/.bash_profile or your shell's corresponding file). If your shell isn't Bash you will likely need to port the functions to your shell's syntax.

Setup your local clone of a GitHub repo

When inside your local Git clone of a Github repo you need to do the following (only once per repo):

@dpiponi
dpiponi / example.cu
Created December 19, 2011 22:42
Minimal CUDA example
#include <stdio.h>
#define N 1000
__global__
void add(int *a, int *b) {
int i = blockIdx.x;
if (i<N) {
b[i] = 2*a[i];
}