Skip to content

Instantly share code, notes, and snippets.

@paulsmith
paulsmith / echo.go
Created January 12, 2011 06:09
A simple echo server testing a few interesting Go language features, goroutines and channels.
// $ 6g echo.go && 6l -o echo echo.6
// $ ./echo
//
// ~ in another terminal ~
//
// $ nc localhost 3540
package main
import (
@gregwebs
gregwebs / External.hs
Created November 5, 2011 17:09
addDependentFile
module External where
import Language.Haskell.TH.Syntax
import Language.Haskell.TH.Lib
loadStringFromFile :: Q Exp
loadStringFromFile = do
let externalDependency = "external.txt"
qAddDependentFile externalDependency
s <- qRunIO $ readFile externalDependency
@raimohanska
raimohanska / AesonTest.hs
Created December 2, 2011 20:53
Data.Aeson.Generic examples with Strings
{-# LANGUAGE OverloadedStrings, DeriveDataTypeable, NoMonomorphismRestriction #-}
module AesonTest where
import qualified Data.Aeson.Generic as A
import qualified Data.ByteString.Lazy as L8
import Data.Data
import Data.Typeable
import Codec.Binary.UTF8.String as U8
import Data.Maybe
@yosemitebandit
yosemitebandit / key-fingerprint
Created March 7, 2012 18:27
view your ssh public key's fingerprint; compare this to what Github has listed in the ssh key audit
$ ssh-keygen -l -f /path/to/keys/id_rsa.pub
2048 aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99 id_rsa.pub (RSA)
@egonSchiele
egonSchiele / reader.hs
Created June 10, 2013 20:51
Reader monad example
import Control.Monad.Reader
hello :: Reader String String
hello = do
name <- ask
return ("hello, " ++ name ++ "!")
bye :: Reader String String
bye = do
name <- ask
@chreekat
chreekat / gist:5965830
Last active December 19, 2015 13:59
QuickCheck'ing values in Template Haskell's Q monad.
{-# LANGUAGE TemplateHaskell #-}
-- An example of testing TH-generated thingadoohickies.
--
-- Using the standard QuickCheck module, there is no direct way to test
-- values generated with Template Haskell functions, most of which end up
-- in the Q monad. This little writeup describes how to test those values
-- using the module Test.QuickCheck.Monadic.
--
-- For this example, you can ignore the doohickies being generated. I just
@dysinger
dysinger / idris-ubuntu-12.04.md
Last active August 29, 2015 13:56
Install Idris (latest) on Ubuntu 12.04

Install GHC & Cabal-Install

apt-get update
apt-get install -y zlib1g-dev libncurses5-dev ghc cabal-install happy alex

Update Cabal-Install

cabal update
cabal install cabal-install

export PATH=$HOME/.cabal/bin:./.cabal-sandbox/bin:$PATH

@mziwisky
mziwisky / Oauth2.md
Last active February 15, 2024 23:31
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.

@lpf23
lpf23 / CNTLM Proxy - Centos
Last active May 11, 2022 08:29
Configure CNTLM Proxy on Centos/Ubuntu
1) Download cntlm rpm package from http://sourceforge.net/projects/cntlm/files/cntlm/
2) Login as root
3) Run command:
$ rpm -ivh cntlm-*.rpm
4a) Obtain password hash for the configuration file in step 4b (do not put plaintext password in configuration)
$ cntlm -H -d <domain> -u <username>
@jpetitcolas
jpetitcolas / parsing-binary-file.go
Last active July 27, 2020 12:40
How to parse a binary file in Go? Snippet based on MoPaQ SC2 replay parsing. Related blog post: http://www.jonathan-petitcolas.com/2014/09/25/parsing-binary-files-in-go.html
package main
import (
"bytes"
"encoding/binary"
"fmt"
"log"
"os"
)