Skip to content

Instantly share code, notes, and snippets.

View joom's full-sized avatar

Joomy Korkut joom

View GitHub Profile
@joom
joom / kuler-scraper
Created March 28, 2014 19:46
Gives the hex values of colors in a swatch page in Adobe Kuler. Run in JS console.
$('.themeBox').children().map(function(){return $(this).attr('title');});
@joom
joom / permEqual.ml
Created April 4, 2014 03:52
List equality checker (regardless of element order)
(* Checks if the two given int lists are the same, regardless of their order *)
(* val permEqual : int list -> int list -> bool = <fun>
# permEqual [] [];;
- : bool = true
# permEqual [1] [2];;
- : bool = false
# permEqual [1;2;3;4] [2;3;1;4];;
- : bool = true
# permEqual [1;2;3;4] [2;2;3;4];;
- : bool = false
@joom
joom / Timeclock.js
Created April 4, 2014 20:50
Wesleyan University Timeclock Total Hours Calculator
/*
//Human readable version:
var frame = document.querySelectorAll('frame')[1].contentWindow.document;
var list = Array.prototype.slice.call(frame.querySelectorAll('center tr'));
list = list.slice(1);
list.map(function(tr) {
return parseFloat(tr.querySelectorAll('td:nth-child(4)')[0].innerText);
}).reduce(function(pre, cur){
return pre + cur;
@joom
joom / permEqual.sml
Created April 7, 2014 18:15
List equality checker (regardless of element order)
(* Checks if the two given int lists are the same, regardless of their order *)
(*val permEqual = fn : int list * int list -> bool
- permEqual([1,2,3,4,5], [1,2,3,4,5]);
val it = true : bool
- permEqual([1,5,4,2,3], [1,2,3,4,5]);
val it = true : bool
- permEqual([1,2,3,4],[5,3,6,2]);
val it = false : bool
- permEqual([], []);
val it = true : bool
@joom
joom / 100doors.hs
Created April 27, 2014 19:44
My 100 doors problem solution
data DoorState = Open | Closed deriving (Show, Eq)
switch Open = Closed
switch Closed = Open
initial = map (\n -> (n, Closed)) [1..100]
visitMult xs n = map change xs
where mult x y = x `mod` y == 0
change (x, st) = (x, if x `mult` n then switch st else st)
List.app (fn x => print(
if (x mod 15) = 0 then "FizzBuzz\n" else
if (x mod 3) = 0 then "Fizz\n" else
if (x mod 5) = 0 then "Buzz\n" else
(Int.toString x) ^ "\n")) (tl (List.tabulate(100, (fn x=>x))))
@joom
joom / longestAlph.hs
Last active August 29, 2015 14:03
Find longest word with letters in alphabetical order in Turkish language
import Data.List
import Data.List.Split
import Data.Maybe
import Data.Function (on)
up = ['A','B','C','Ç','D','E','F','G','Ğ','H','I','İ','J','K','L','M','N','O','Ö','P','R','S','Ş','T','U','Ü','V','Y','Z']
low = ['a','b','c','ç','d','e','f','g','ğ','h','ı','i','j','k','l','m','n','o','ö','p','r','s','ş','t','u','ü','v','y','z']
lower xs = map single xs
where single x = case (x `elemIndex` up) of
-- ghc --make -O2 -threaded setInterval.hs
import Control.Concurrent (forkIO, putMVar, takeMVar,
newEmptyMVar, threadDelay)
import Control.Exception (finally)
setInterval :: IO a -> Int -> IO ()
setInterval action microsecs = do
mvar <- newEmptyMVar
_ <- forkIO $ loop `finally` putMVar mvar ()
takeMVar mvar
@joom
joom / syllablize.hs
Last active August 29, 2015 14:04
Turkish NLP: Split a word to its syllables
import Data.Maybe (isNothing, fromJust)
import Data.Char (isAlpha, toLower)
import Data.List (findIndex)
-- charAt xs i = Just x, where x character at index i
-- Nothing, is i is out of bounds
charAt :: String -> Int -> Maybe Char
charAt xs i = if length xs > i then Just (xs !! i) else Nothing
-- isVowel x = True if x is a vowel,
@joom
joom / .emacs
Last active August 29, 2015 14:07
My Emacs config
;; My packages installed: evil, evil-leader, undo-tree, evil-surround (not in MELPA), color-theme-wombat, haskell-mode.
;; packages
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")))
(add-to-list 'load-path "~/.emacs.d")
(package-initialize)
(evil-mode 1)