Skip to content

Instantly share code, notes, and snippets.

View ga2arch's full-sized avatar
🐢

Gabriele Carrettoni ga2arch

🐢
View GitHub Profile
@ga2arch
ga2arch / progbar.hs
Last active August 29, 2015 14:01 — forked from adinapoli/progbar.hs
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
module Main where
import Data.ByteString (ByteString)
import System.IO.Streams (InputStream, OutputStream)
import Network.Http.Client
import Text.Printf (printf)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C8
@ga2arch
ga2arch / TState.hs
Created April 9, 2014 21:22
State monad transformer that keep track of the state updates and allows to move back and forward between states as well as tagging them
import Control.Monad.Trans
import qualified Data.Map as M
import qualified Data.Vector as V
data StateHolder s t = StateHolder {
holderStates :: V.Vector s
, holderTags :: M.Map t Int
, holderPos :: Int
}

I like LYAH as a reference and cheat-sheet but I found it a little slow for learning Haskell.

Here's my recommended order for just learning Haskell:

http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 80% completion here is fine if you feel your attention waning, the next thing will address hammering in things like functors and monads via typeclasses.

https://github.com/NICTA/course/ this will hammer in the lessons in a very direct form by forcing you to confront the challenges and lessons learned by the creators and community of Haskell itself. Doing the exercises here is critical for being fluent.

Real World Haskell is available online. (Thanks bos!)

13:15 < xQuasar> HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF FUCKIN
PUSSIES
13:15 < xQuasar> JAVASCRIPT FOR LIFE FAGS
13:16 < luite> hello
13:16 < ChongLi> somebody has a mental illness!
13:16 < merijn> Wow...I suddenly see the error of my ways and feel compelled to
write Node.js!
13:16 < genisage> hi
13:16 < luite> you might be pleased to learn that you can compile haskell to
javascript now
@ga2arch
ga2arch / gist:8698178
Created January 29, 2014 22:09
youtube radio
while true; do cat -n playlist | sort -R | cut -f2- | head -1 | xargs youtube-dl -g | xargs -I url ffmpeg -i url -vn -acodec libvorbis -f ogg pipe: | oggfwd localhost 8000 password /onlybombz.ogg; done
set("log.file.path","/tmp/basic-radio.log")
set("server.telnet",true)
set("server.telnet.bind_addr","162.243.94.219")
set("server.telnet.port",9000)
def input.mplayer(~id="input.mplayer",
~restart=true,~restart_on_error=false,
~buffer=0.2,~max=10.,s) =
input.external(id=id,restart=restart,
restart_on_error=restart_on_error,
@ga2arch
ga2arch / gist:8547483
Created January 21, 2014 20:13
Create Dummy ALSA Devices (en mass)
Create Dummy ALSA Devices (en mass)
Written by Mike C. Fletcher on April 16, 2012 in Tuxedo.
Since this was a bit of a pain to track down, here's the process, on an Ubuntu Server 12.04 machine, to create many ALSA dummy devices:
$ cat /etc/modprobe.d/alsa-dummy.conf
options snd-dummy enable=1,1,1,1,1,1,1,1,1,1,1,1 pcm_devs=4,4,4,4,4,4,4,4,4,4,4,4 fake_buffer=0,0,0,0,0,0,0,0,0,0,0,0
$ modprobe snd-dummy
That sample creates 48 dummy devices (on 12 cards), though that's likely more than you'll ever need. The fake_buffer array means they should all have a real internal buffer. The "enable" array is specifying how many cards to create. The pcm_devs array specifies how many pcm devices to have on each card.
@ga2arch
ga2arch / getmusic.clj
Last active January 3, 2016 15:39
Get all youtube urls from a facebook page's feed
(def base-url "https://www.facebook.com/feeds/page.php?id=")
(def tech-minimal "117466024943987")
(def url (let [[_ u] *command-line-args*]
(if (empty? u) tech-minimal u)))
(->> (slurp (str base-url url "&format=json"))
(re-seq #"watch\?v=(.[^<,\"]*?)&")
(map #(str "http://www.youtube.com/watch?v=" (second %)))
(into #{})
(map println)
parsed_uri(Text, Z) :-
do(
[
S <-- scheme,
char(':'),
A <-- authority,
try $ do(
[
char('/'),
Pa <-- try $ path,
% Vecchia versione
parse_ip_(Text, Acc, Z) :-
digits(Text, (P, [46|Rs])),
not(is_empty(P)),
append(Acc, [P, 46], W),
digits(Rs, (P1, [46|Rs1])),
not(is_empty(P1)),