Skip to content

Instantly share code, notes, and snippets.

# vim: set ft=zsh:
# Settings
MAX_LOOKUP_LEVEL=3
# If a virtualenv is not found in current and parent directories in up to MAX_LOOKUP_LEVEL levels,
# then use $HOME's virtualenv as default.
ALWAYS_DEFAULT_TO_HOME_VIRTUALENV=1
function chpwd() {
detect_virtualenv
detect_hsenv
@ofan
ofan / Actor.hs
Last active December 17, 2015 12:08
module Actor where
import System.IO
import Control.Concurrent.STM.TChan
import Control.Concurrent
import Control.Monad.STM
import Control.Monad
type Mailbox a = TChan a
data Behaviour a = Behaviour {
module Actor where
import System.IO
import Control.Concurrent.STM.TChan
import Control.Concurrent
import Control.Monad.STM
import Control.Monad
type Mailbox a = TChan a
data Behaviour a = Behaviour {
import Control.Concurrent.STM.TChan
import Control.Concurrent
import Control.Monad.STM
import Control.Monad
type Mailbox a = TChan a
data Behaviour a = Behaviour {
runBehaviour :: Actor a -> a -> IO (Maybe (Behaviour a))
}
data Actor a = Actor { mbox :: Mailbox a, beh :: Behaviour a }
#!/usr/bin/env python
# This script takes two parameters, the first is the filename needs to be matched,
# the second is the file contains glob patterns.One pattern per line.
import fnmatch
import sys
def check_match(f, fn):
with open(f) as fpattern:
#!/bin/sh
SALT=`git config --get encrypt.salt`
PASS=`git config --get encrypt.pass`
PATTERN_FILE=`git config --get encrypt.patternFile`
NAME_MATCHED=0
getSaltPass(){
if [ -z "$SALT" -o -z "$PASS" ];then
SALT=`getpwd git_crypt_salt`
#include <iostream>
#include <functional>
template <typename Lambda, typename Curried>
Curried Ycombinator(Lambda f) {
return std::bind(f, std::bind(&Ycombinator<Lambda, Curried>,f) , std::placeholders::_1);
}
int main() {
typedef std::function<int(int)> L;
@ofan
ofan / buffer.cpp
Created October 29, 2012 02:05
buffer
#include <iostream>
#include <thread>
#include <condition_variable>
#include <mutex>
#include <chrono>
#include <random>
using namespace std;
const int BUFSIZE = 10;
@ofan
ofan / gist:3447877
Created August 24, 2012 09:08
Final report
Hi,
Sorry for being so late to give the final report. I've pushed all code
to my cloned repo on git.kde.org last week.
Here's the instructions to compile Spotify collection and the resolver.
1) To compile Amarok with Spotify collection:
$ git clone git://anongit.kde.org:clones/amarok/zhengliangfeng/amarok-spotify.git
$ cd amarok-spotify && git checkout gsoc-spotify
$ cd ../ && mkdir amarok-spotify-build
/****************************************************************************************
* Copyright (c) 2010 Andrew Coder <andrew.coder@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *