This script got promoted to a real repo! See it here: https://github.com/grafted-in/nixops-manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This literate Haskell program implements a type safe interpreter for a | |
simple functional language. Such an interpreter is the "hello world" | |
example for dependently typed languages and this program mimics it in | |
Haskell. Generalized algebraic data types and type families are | |
sufficient. | |
> {-# LANGUAGE GADTs #-} | |
> {-# LANGUAGE TypeFamilies #-} | |
> {-# LANGUAGE TypeOperators #-} | |
> {-# LANGUAGE MultiParamTypeClasses #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, TypeFamilies, FlexibleInstances, RankNTypes #-} | |
import Data.Reify | |
import Control.Applicative | |
import Data.Map | |
data Ast e where | |
IntLit :: Int -> Ast Int | |
Add :: Ast Int -> Ast Int -> Ast Int | |
BoolLit :: Bool -> Ast Bool | |
IfThenElse :: Ast Bool -> Ast e -> Ast e -> Ast e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This is free and unencumbered software released into the public domain. | |
# | |
# Requires bc, dc, openssl, xxd | |
# | |
# by grondilu from https://bitcointalk.org/index.php?topic=10970.msg156708#msg156708 | |
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z}) | |
bitcoinregex="^[$(printf "%s" "${base58[@]}")]{34}$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MagicHash, TupleSections, TemplateHaskell #-} | |
module Data.Vector.Storable.Bake(bake, unsafeFromAddrLen) where | |
import Data.Typeable | |
import qualified Data.Vector.Storable as VS | |
import Foreign | |
import GHC.Prim | |
import GHC.Ptr | |
import Language.Haskell.TH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Add leaflet css --> | |
<link | |
rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" | |
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" | |
crossorigin="" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set -eux | |
# This a simple script that builds static versions of Python and LibPython using musl-libc | |
# Find the associated article at: http://general-purpose.io/2015/12/06/compiling-python-and-libpython-statically-using-musl-libc/ | |
WORKING_DIR="/code/static-python" | |
MUSL_PREFIX="/code/static-python/musl" | |
PY_PREFIX="/code/static-python/python" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
-- | For when you have a record that doesn't have lenses derived for | |
-- it and you need a lens, just use @$(lens 'thefield)@ and away you go. | |
module Control.Lens.FieldTH where | |
import Language.Haskell.TH | |
lens :: Name -> Q Exp | |
lens name = do | |
[|\f r -> | |
fmap | |
$(lamE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
import re | |
import urllib2 | |
import os | |
import argparse | |
import sys | |
import json | |
# adapted from http://stackoverflow.com/questions/20716842/python-download-images-from-google-image-search |
OlderNewer