Skip to content

Instantly share code, notes, and snippets.

Christian Takle christiantakle

  • Moixa
  • London
View GitHub Profile
View example.bash
sed "/^#/d" "$folders" \
| tee \
>(awk '{print "alias "$1"=\"cd "$2" && ls -a\""}' >> "$shell_shortcuts") \
>(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \
>(awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts") \
| /dev/null
@christiantakle
christiantakle / fizzbuzz.js
Created Nov 8, 2017
Different examples of fizzbuzz in javascript
View fizzbuzz.js
const
whenDivisibleBy = (x, t, f) => n => (n % x == 0 ? t : f),
fizz = whenDivisibleBy(3, 'Fizz', ''),
buzz = whenDivisibleBy(5, 'Buzz', ''),
fizzBuzz = n => fizz(n) + buzz(n) || String(n);
//Array(...Array(100)).map((_,x) => fizzBuzz(x+1))
View Expr.hs
{-# LANGUAGE TupleSections #-}
import Control.Lens
data Expr
= Var String
| App Expr Expr
| Lam String Expr
deriving Show
View postgres_cheat_sheet
Postgres Cheat Sheet
Source: Postgresql Documentation
### shell commands
creatuser <user>
deletesuer <user>
createdb -O <user> -E utf8 -T <template> <db_name>
dropdb <db_name>
@christiantakle
christiantakle / blah.hs
Last active Mar 2, 2017
Haskell refactor, scale functions are made from minMax + period outside
View blah.hs
-- old ----------------------------------------------------------------
mkGraphMeta (start,end) (aggregated,timeSeriesWithColor) =
(aggregated,) $ fromMaybe (Nothing,[]) $ case second unTimeSeries <$> (timeSeriesWithColor :: [(String,TimeSeries)]) of
[] -> Nothing
xss -> do
minMax@(vMin,vMax) <- getMinMax $ snd <$> (xss :: [(String,[(UTCTime,Double)])])
let
tw = end `diffUTCTime` start
fx = fromIntegral pWidth / tw
ph = fromIntegral pHeight
View fix-free-cofree.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
import Prelude hiding (succ)
newtype Fix f = Fix (f (Fix f))
deriving instance (Show (f (Fix f))) => Show (Fix f)
@christiantakle
christiantakle / leaf.hs
Created Mar 22, 2016 — forked from ali-abrar/leaf.hs
Setting up Leaflet.js with Reflex.Dom
View leaf.hs
{-# LANGUAGE ForeignFunctionInterface, JavaScriptFFI #-}
import Reflex.Dom
import Data.Monoid
import GHCJS.Types
import GHCJS.Foreign
import GHCJS.DOM.Element
import GHCJS.DOM.Types
import Control.Monad.IO.Class
newtype LeafletMap = LeafletMap { unLeafletMap :: JSRef LeafletMap }
View Example monoids.js
//-- Sum --------------------------------------------------------------
let
identity = 0,
mappend = (x,y) => x + y, // +
concatSum =
xs => xs.reduce(mappend, identity)
concatSum([1,2,3,4,5]) // => 15
//-- Product ----------------------------------------------------------
View random-refactor.js
// Orignal ------------------------------------------------------------
var isFancy = true;
var fancy = document.querySelector("#commentsbtn");
fancy.addEventListener("click", function(e){
if (isFancy) {
document.body.classList.remove("fancy-comments");
isFancy = false;
}
else {
You can’t perform that action at this time.