Skip to content

Instantly share code, notes, and snippets.

@homam
homam / Main.purs
Created May 5, 2018 11:09
PureScript Transformers
module Main where
import Prelude
import Control.Monad.Eff
import Control.Monad.Eff.Console
import Control.Monad.Free
import Control.Monad.Eff.Class (class MonadEff, liftEff)
import Control.Monad.Eff.Ref (REF, Ref, newRef, modifyRef, readRef)
import Control.Monad.Trans.Class (class MonadTrans, lift)
import Control.Monad.Reader (class MonadAsk, ReaderT, ask, runReaderT)
module Counter where
import Prelude
import Control.Monad.Eff.Class (class MonadEff, liftEff)
import Control.Monad.Eff.Console (logShow)
import Control.Monad.RWS.Trans (class MonadTrans)
import Control.Monad.State (StateT, get, put, runStateT)
import Control.Monad.Trans.Class (lift)
import Data.Tuple (Tuple)
This file has been truncated, but you can view the full file.

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
},{}],2:[function(_dereq_,module,exports){
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narw
@homam
homam / index.html
Created September 16, 2016 14:31
service workers offline page
<!doctype html>
<html lang=en-GB>
<head>
<meta charset='utf-8'>
<title>The Air Horner</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>
<iframe style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; width:100%; height: 100%"
src="http://tv-app-web-map.herokuapp.com/"
TextTable = function (rows_, opts) {
if (!opts) opts = {};
var hsep = opts.hsep === undefined ? ' ' : opts.hsep;
var align = opts.align || [];
var stringLength = opts.stringLength
|| function (s) { return String(s).length; }
;
var dotsizes = reduce(rows_, function (acc, row) {
forEach(row, function (c, ix) {
@homam
homam / ping_internet.sh
Created April 29, 2017 11:54
Check if internet connection is alive every second
while true
do
echo -e "GET http://google.com HTTP/1.0\n\n" | nc -w2 google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo $(date +"%T") " Online"
else
echo $(date +"%T")" Offline"
say "offline"
fi
TextTable = function (rows_, opts) {
if (!opts) opts = {};
var hsep = opts.hsep === undefined ? ' ' : opts.hsep;
var align = opts.align || [];
var stringLength = opts.stringLength
|| function (s) { return String(s).length; }
;
var dotsizes = reduce(rows_, function (acc, row) {
forEach(row, function (c, ix) {
class Callback {
constructor(f) {
// this.run = f
this.run = callback => {
try {
f(callback)
} catch (ex) {
callback(ex, null)
}
@homam
homam / fast-json-csv.ls
Last active October 19, 2016 13:15
CLI tool for fast and hassle-free JSON to CSV conversion
#!/usr/local/bin/lsc -d
{foldl, Str, Obj, map} = require \prelude-ls
json-to-csv = (obj) ->
cols = obj.0 |> Obj.keys
(cols |> (Str.join \,)) + "\n" + do ->
obj
|> foldl do
(acc, a) ->
acc.push <| cols |> (map (c) -> a[c]) |> Str.join \,
@homam
homam / imagemagick-round.sh
Created October 4, 2016 12:06
ImageMagick Round a Image - Mask
mkdir -p thumbs
for f in *.jpg; do
size=$(identify -format "%[fx:w]" $f)
sizeh=$(expr $size / 2)
convert -size "$size"x"$size" xc:none -fill $f -draw "fill white circle $sizeh,$sizeh $sizeh,1" thumbs/$f.png
; done