Skip to content

Instantly share code, notes, and snippets.

View truthadjustr's full-sized avatar
☠️
rebirth

truthadjustr

☠️
rebirth
  • Cebu, Philippines
View GitHub Profile
@truthadjustr
truthadjustr / webapp.py
Created February 5, 2018 04:16
python flask serving angular5 dist/
from flask import Flask
from flask import send_from_directory
from werkzeug.routing import BaseConverter
app = Flask(__name__, static_url_path="", static_folder="ng5-material/dist/")
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
super(RegexConverter, self).__init__(url_map)
@truthadjustr
truthadjustr / a.hs
Last active August 3, 2018 20:42
modification
mapx f g xxs =
case xxs of
[] -> 0
(x:xs) -> f x+mapx g f xs
@truthadjustr
truthadjustr / constructs.hs
Last active August 4, 2018 07:34
fp Sat Aug 4 15:21:38 +08 2018
import Data.List
import Data.List.Split
-- a :: Num a => [a]
a = [1..10]
-------------------------------------------------------------------------------
myreverse xxs =
case xxs of
[] -> []
(x:xs) -> myreverse xs ++ [x]
-------------------------------------------------------------------------------
secsToWeeks secs =
let perMinute = 60
perHour = 60 * perMinute
perDay = 24 * perHour
perWeek = 7 * perDay
in secs / perWeek
@truthadjustr
truthadjustr / spl.hs
Created August 4, 2018 13:41
insert to list
# insert 69 into list a
a = [1..10]
a' = let (x1,x2) = splitAt 2 a in x1 ++ [69] ++ x2
classify age = case age of 0 -> "newborn"
1 -> "infant"
2 -> "toddler"
_ -> "senior citizen"
@truthadjustr
truthadjustr / who.hs
Created August 4, 2018 15:02
who are you?
module Main where
import qualified Data.Map as M
errorsPerLine = M.fromList
[ ("Chris", 472), ("Don", 100), ("Simon", -5) ]
main = do putStrLn "Who are you?"
name <- getLine
case M.lookup name errorsPerLine of
@truthadjustr
truthadjustr / let.hs
Created August 5, 2018 09:16
understanding let
x = 5
q =
let
x = 2
y = 3
in x + y
r = let x = 2; y = 3; in x + y
@truthadjustr
truthadjustr / maybe.hs
Created August 5, 2018 10:17
understanding Maybe
mapMaybe (\x -> if x == 1 then Just True else if x == 0 then Just False else Nothing) [1,0,0,1,4,1,1,1,1,5,5,0,0,0]
@truthadjustr
truthadjustr / curl.md
Created August 7, 2018 01:23 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.