Skip to content

Instantly share code, notes, and snippets.

@dmjio
dmjio / gist:330f02e2279446f4b4bf
Last active Aug 28, 2015 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
View gist:330f02e2279446f4b4bf
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@dmjio
dmjio / gist:4050405
Created Nov 10, 2012
Sublime Text 2 - Useful Shortcuts
View gist:4050405

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
View SwaggerExample.hs
{-# LANGUAGE DeriveGeneric, FlexibleInstances, ScopedTypeVariables, FlexibleContexts, DataKinds, TypeFamilies #-}
module SwaggerExample where
import Data.Proxy
import qualified GHC.Generics as G
import Generics.SOP
data Todo = Todo {
created :: Int
, description :: String
@dmjio
dmjio / docker-push.sh
Created Nov 10, 2015 — forked from fizruk/docker-push.sh
Push to Docker from Circle CI
View docker-push.sh
#!/bin/sh
set -x
CIRCLE_TAG=`git name-rev --tags --name-only $(git rev-parse HEAD)`
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
if [ "$CIRCLE_TAG" -ne "undefined" ]; then
docker tag user/repo user/repo:$CIRCLE_TAG
View setup_flask_and_friends.sh
#!/bin/bash
#
# Shell script to automatically configure a new Flask, nginx and uWSGI based blog
# on an Amazon EC2 instance.
#
# See http://bit.ly/MeGwjD for more information!
#
# If you are forking this for your own custom configuration script, see the following other gists:
# https://gist.github.com/3071737
# https://gist.github.com/3071739
@dmjio
dmjio / Nub.hs
Created Feb 7, 2016 — forked from roelvandijk/Nub.hs
Incredibly slow type-level Nub
View Nub.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Nub where
import Data.Proxy
import Data.Type.Bool
@dmjio
dmjio / Constraints.org
Created Aug 20, 2016 — forked from Icelandjack/Constraints.org
Type Classes and Constraints
View Constraints.org

Type classes are a language of their own, this is an attempt to document some features.

Work in progress.

Accept values with varying number of arguments

Common technique used in EDSLs (embedded domain-specific languages) to accept functions with varying number of arguments.

(Hackage) QuickCheck

quickCheck :: Testable prop => prop -> IO ()
View cabal-from-source.nix
{ runCommand, fetchzip, cabal2nix }:
let
package-src = runCommand "package-src" {
src = fetchzip {
url = "...zip";
sha256 = "...";
};
buildInputs = [ cabal2nix ];
}
''
@dmjio
dmjio / 0_reuse_code.js
Created Mar 19, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View gist:db6c1ce67ee84a320aa0971242be3971
{ pkgs ? import <nixpkgs> {}}:
let
texpkgs = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-small latexmk;
};
in
pkgs.stdenv.mkDerivation {
name = "mbd";