Skip to content

Instantly share code, notes, and snippets.

@pharpend
pharpend / ghci.conf
Last active January 1, 2020 15:01
ghci.conf january 2020
import Data.Complex
import Text.Printf
import Test.QuickCheck
import Text.RE.PCRE
:set -XFlexibleContexts
:set -XOverloadedStrings
:set -XQuasiQuotes
:set -XScopedTypeVariables
let f2c dc = (dc - 32) * (5 / 9)
let c2f df = ((9 / 5) * df) + 32
@pharpend
pharpend / sample.hs
Created December 24, 2019 04:22
hindent demo
myFunction :: [String] -> IO ()
myFunction args=
do
let val=fmap (+3)$fmap length args
blah<-readFile "foo.txt"
let myNewList=[blah,
mconcat(fmap show val ) ,"hello"]
print myNewList
-- Formatted to
@pharpend
pharpend / group.py
Created December 19, 2019 05:59
Group implementation
def group(ls):
'''group([1,1,2,2,3,3]) = [[1, 1], [2, 2], [3, 3]]'''
if len(ls) <= 1:
return [ls]
else:
current_head = ls[0]
current_group = [current_head]
rest_of_list = ls[1:]
ls_idx = 0
for item in rest_of_list:
@pharpend
pharpend / www.txt
Created December 17, 2019 22:04
Wild Wild West lyrics
Wild Wild West
Wild Wild West, Jim West, desperado, rough rider
No you don't want nada
None of this, gun in this, brotha runnin this,
Buffalo soldier, look it's like I told ya
Any damsel that's in distress
Be out of that dress when she meet Jim West
Rough neck so go check the law and abide
Watch your step with flex and get a hole in your side
Swallow your pride, don't let your lip react,
@pharpend
pharpend / Combinators.hs
Last active October 6, 2019 02:53
Regex checker
module Combinators where
import Control.Monad (forM_)
import Test.Hspec
import Test.QuickCheck
import Text.RE.PCRE
alphabetical :: Gen Char
alphabetical = elements $ ['A'..'Z'] ++ ['a'..'z']
@pharpend
pharpend / repl.hs
Created September 17, 2019 00:48
Stack repl script
#!/usr/bin/env stack
{- stack script
--resolver lts-14.6
--package aeson
--package bytestring
-}
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
@pharpend
pharpend / graphs.sage
Last active September 16, 2019 20:23
Sage graphs
#!/usr/bin/env sage
# -*- mode: Python -*-
'''To run this, run the terminal command "sage graphs.sage". Or simply run the
command sage and type the lines of code into the prompt
To get help, from the sage prompt run help(plot), or see
http://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html
'''
#!/usr/bin/env python
from __future__ import division
import numpy as np
f = open('clean1.data', 'r')
f_nums = [map(float, x.strip().split(',')[2:]) for x in f.readlines()]
d = np.array(f_nums)
d_cols = d.transpose()
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
\documentclass[12pt]{article}
\usepackage[letterpaper,margin=0.2in,landscape,layoutvoffset=0in]{geometry}
\usepackage{tabu}
\usepackage{tikz}
\pagenumbering{gobble}
\begin{document}