Skip to content

Instantly share code, notes, and snippets.

@sabha
sabha / counter.elm
Last active March 16, 2017 17:17
Elm Multiple Counter sample using List Type & Array
-- Try the sample using this URL
-- http://elm-lang.org/try
import Html exposing (beginnerProgram, div, button, text, p, Html, span)
import Html.Events exposing (onClick)
import Array
main =
beginnerProgram { model = [0,7], view = view, update = update }
@sabha
sabha / client.elm
Last active October 24, 2021 08:29
Elm Client, Node Server , Mongo DB, Mongoose ODM - Get Users and Post User
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Http
import Json.Decode as Decode
import Json.Encode as Encode
main =
@sabha
sabha / index.js
Last active August 14, 2017 22:39
Node http File system and JSON exp
const http = require('http')
const url = require("url");
const fs = require('fs');
const port = 3000
const requestHandler = (request, response) => {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received. "+(pathname === '/persons'));
var json = JSON.parse(fs.readFileSync('./persons.json', 'utf8'));
@sabha
sabha / index.html
Created September 21, 2017 22:23
Fractal Tree
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="900" height="300" style="border:1px solid #000000; background: #F4F6F6">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
function Vector(x,y) {
this.x = x;
@sabha
sabha / circle.html
Created September 22, 2017 20:40
Circle - Velocity - Acceleration
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="400" height="600">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
function Vector(x,y) {
this.x = x;
@sabha
sabha / reactChild.js
Created November 10, 2017 22:48
Recursion React Children
var childrens = [{name: 'ql-0', childrens : [ { name: 'ql-0-0' }] },{name: 'ql-1'}, {name: 'ql-2', childrens : [ { name: 'ql-2-0' }, { name: 'ql-2-1' }] }]
function recursive(children, i){
return children.map((child, index) => {
if(child.childrens) return Object.assign({},child,{index: `${i}-${index}`, childrens: recursive(child.childrens, `${i}-${index}`)});
else return Object.assign({},child,{index: `${i}-${index}`});
})
}
var a = recursive(childrens,'ql');
@sabha
sabha / Jitter.html
Created February 11, 2018 17:33
Jitter
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
@sabha
sabha / vector.html
Last active February 18, 2018 04:31
Vector
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var mouseX = 0;
var mouseY = 0;
@sabha
sabha / index.html
Created February 21, 2018 22:08
Circle
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="640" height="640" style="border:1px solid #d3d3d3; background: black;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCanvas");
@sabha
sabha / index.html
Created March 12, 2018 21:04
Unit CIrcle
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(() => {
$("#grid").click(() => {
});
});