Skip to content

Instantly share code, notes, and snippets.

oneToTen.reduce(function(acc, a) {
return acc + a;
}, 0)
@homam
homam / .block
Created August 29, 2018 12:41 — forked from micahstubbs/.block
world map 07 Jenks natural breaks
height: 510
border: no
license CC0-1.0
WITH R AS (
SELECT (case when strpos(R.msisdn, '372') = 1 then substr(R.msisdn, 4) else R.msisdn end) as redshift_msisdn, R.msisdn as full_msisdn,
R."timestamp" as redshift_timestamp
FROM (
SELECT *
FROM dblink('redshift_server',$REDSHIFT$
SELECT u.msisdn, u.timestamp from user_sessions u
WHERE u.timestamp >= '2018-06-10Z'
AND u.offer_id = 853
AND u.country_code = 'EE'
@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
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) {
@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