Skip to content

Instantly share code, notes, and snippets.

View saiashirwad's full-sized avatar
🏠
Working from home

texoport saiashirwad

🏠
Working from home
View GitHub Profile
@sderosiaux
sderosiaux / balance.scala
Created February 20, 2018 23:52
Parenthesis balancing using Monoid
// From haskell "Monoidal Parsing—Edward Kmett"
import cats.implicits._
final case class Balance(l: Int, r: Int)
object Balance {
val EMPTY = Balance(0, 0)
val LEFT = Balance(0, 1)
val RIGHT = Balance(1, 0)
}
@suriyadeepan
suriyadeepan / grid.js
Created January 4, 2017 03:04
"All work and no play makes Jack a dull boy" - Cellular Automata in p5.js
function Grid(cells, generation, cell_scale){
this.text = " all work and no play makes jack a dull boy ";
// cells
this.cells = cells;
this.generation = generation;
// scale
this.cell_scale = cell_scale;
// create next generation
this.next_gen = function(ruleset){
@gtors
gtors / underscore_to_camel_case
Created August 20, 2015 11:38
Postgresql function which converts json underscored keys to camel case keys.
CREATE FUNCTION key_underscore_to_camel_case(s text)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT to_json(substring(s, 1, 1) || substring(replace(initcap(replace(s, '_', ' ')), ' ', ''), 2));
$$;
-- TODO: add recursive processing
CREATE FUNCTION json_underscore_to_camel_case(data json)