Skip to content

Instantly share code, notes, and snippets.

@homam
homam / TimerRecursion.hs
Created July 25, 2015 13:31
Timer, setInterval in Haskell
import Control.Concurrent
import Control.Exception
setInterval :: Int -> a -> (a -> IO a) -> IO ()
setInterval microsecs a action = do
mvar <- newEmptyMVar
_ <- setInterval' microsecs a mvar action
takeMVar mvar
import Html exposing (div, button, text, Attribute)
import Html.Events exposing (onClick)
import Html.Attributes exposing (style)
import StartApp.Simple as StartApp
{-| Read more about StartApp and how this works at:
https://github.com/evancz/start-app
The rough idea is that we just specify a model, a way to view it,
@homam
homam / stress-test-rx.ls
Last active September 21, 2015 09:26
stress test pipe rxjs
{Observable, AsyncSubject} = require \Rx
request = require \request
{sum} = require \prelude-ls
log-source = (source) ->
source.subscribe do
(x) ->
console.log \x, x
(err) ->
console.log \err, err
@homam
homam / so
Created September 21, 2015 22:54
select TagId, Count (*) as Count from PostTags
where PostId > 31938184
group by TagId
select top 1 * from Posts
where CreationDate > '2015-01-02'
order by Id
select top 1 * from Posts
lsof -n -i4TCP:4081 | tail -n1 | cut -d' ' -f5 | xargs kill
Rx.Observable.prototype.bufferWithTimeHasty = function(interval, refresh){
var source;
source = this;
return Rx.Observable.create(function(observer){
var bundle, refereshInterval;
bundle = [];
refereshInterval = setInterval(function(){
var now, expiration, j, i;
now = Date.now();
expiration = now - interval;
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx-full
nginx -V 2>&1 | grep -o with-http_stub_status_module
@homam
homam / commit-msg
Created October 31, 2015 15:41
git commit spell checker
#!/bin/zsh
# brew install aspell
# nano .git/hooks/commit-msg
# chmod +x .git/hooks/commit-msg
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "Aspell not installed - unable to check spelling" >&2
exit
else
WORDS=$($ASPELL list < "$1")
@homam
homam / DefaultKeyBinding.dict
Created November 18, 2015 16:16
OSX DefaultKeyBinding.dict
{
"~a" = ("insertText:", "α");
"~b" = ("insertText:", "β");
"~g" = ("insertText:", "γ");
"~i" = ("insertText:", "ι");
"~k" = ("insertText:", "κ");
"~@k" = ("insertText:", "κ");
"~^d" = ("insertText:", "∂");
"~d" = ("insertText:", "δ");
"~$D" = ("insertText:", "Δ");
import SetInterval
import SetIntervalT
import Control.Concurrent
import Control.Exception
import Control.Monad.State
sprint :: (Show b) => MVar () -> b -> IO ()
sprint mvar b = do
putMVar mvar ()
print b