Skip to content

Instantly share code, notes, and snippets.

@xfire
xfire / Test.java
Created June 6, 2013 06:58
Joint union in type parameter variance.
class Test {
interface Foo {
int doFoo();
}
interface Bar {
int doBar();
}
// here we use the union type parameter: Foo & Bar
printf '\33]50;%s%d\007' "xft:Terminus:pixelsize=" 20
- python properties -----------------------------------------------------------------------
>>> props.py >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| def python_properties():
| with open("/home/fire/python.txt", "r") as f:
| print(f.read())
|
@xfire
xfire / xmonad-gnome.session
Created August 30, 2012 12:38
gnome 3 session file for xmonad
[GNOME Session]
Name=xmonad-gnome session
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;notifications;
DefaultProvider-windowmanager=xmonad
DefaultProvider-notifications=notification-daemon
@xfire
xfire / LensesRecursive.hs
Created February 5, 2012 20:31
haskell lenses on recursive data structures
{-# LANGUAGE TemplateHaskell, FlexibleContexts #-}
import Data.Lenses
import Data.Lenses.Template
-- data structures to work on
-- for fields ending with an underscore, special lens accessor functions
-- can be created with "deriveLenses"
data TD = TD { name_ :: String
, td_ :: TD
@xfire
xfire / Lenses.hs
Created February 5, 2012 20:06
play with haskell lenses
{-# LANGUAGE TemplateHaskell, FlexibleContexts #-}
import Data.Lenses
import Data.Lenses.Template
-- data structures to work on
-- for fields ending with an underscore, special lens accessor functions
-- can be created with "deriveLenses"
data Address = Address { street_ :: String
, houseNumber_ :: Int
@xfire
xfire / WriterMonad.cs
Created February 2, 2012 20:05
first attempt of the writer monad for c#/linq
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace WriterMonadExample
{
public interface Monoid<T>
{
T Mempty { get; }
@xfire
xfire / KnightMove.cs
Created February 1, 2012 20:50
knight move for c# from LYAHFGG inclusive the composing of monadic functions
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace KnightsMove
{
public static class KnightsMoveMain
{
static string Show<T>(this IEnumerable<T> xs) { return "[" + string.Join(", ", xs) + "]"; }
@xfire
xfire / jobinterviewquestions.txt
Created January 31, 2012 16:52 — forked from Skyr/jobinterviewquestions.txt
Job Interview Questions you Should Ask
Software development
- Which platforms (Linux, Windows, Mac, Embedded) will I develop for?
- What programming languages are you using for which kind of projects / applications?
- What Development Environment are you using?
- Are you using any coding style guidelines? If yes, can I take a look at the document?
- Are you actively supporting / allowing time for keeping your code base maintainable and up to date?
- How do you handle documentation? Is there time reserved specifically for documenting projects?
@xfire
xfire / gist:1200346
Created September 7, 2011 11:38
clojure dynamic binding
user=> (defn slow-double [n] (Thread/sleep 100) (* n 2))
#'user/slow-double
user=> (defn calls-slow-double [] (map slow-double [1 2 1 2 1 2]))
#'user/calls-slow-double
user=> (calls-slow-double )
(2 4 2 4 2 4)
user=> (time (dorun (calls-slow-double)))
"Elapsed time: 601.008572 msecs"
nil
user=> (defn demo-memoize []
@xfire
xfire / liftToErrorT.hs
Created July 27, 2011 11:39
lifting Either to ErrorT
import Control.Monad.Error
execAna :: Int -> Either String (Int, Int)
execAna 0 = Left "ERROR"
execAna n = Right (n - 1, n + 1)
report :: Either String () -> IO ()
report (Left err) = putStrLn $ "failed: " ++ err
report _ = putStrLn "complete"