Skip to content

Instantly share code, notes, and snippets.

View ashokhein's full-sized avatar

Ashok Subramanian ashokhein

  • London
View GitHub Profile
@ashokhein
ashokhein / hello.js
Created March 9, 2017 12:32 — forked from planetoftheweb/hello.js
Simple Node.js Hello World
var http = require('http'); //add the http module
//Create a server
var myServer = http.createServer(function (request, response) {
// Return something from server
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello Node\n");
}); //create a server
Bind server to a port
@ashokhein
ashokhein / docker.txt
Created July 3, 2017 23:10
docker crt
Delete all containers: docker rm $(docker ps -a -q)
Delete all images: docker rmi $(docker image ls -q)
@ashokhein
ashokhein / play-nine-game.js
Created July 4, 2017 09:59
Exercising the Play Nine Game Using React JS [To compile and run https://jscomplete.com/repl]
var possibleCombinationSum = function(arr, n) {
if (arr.indexOf(n) >= 0) { return true; }
if (arr[0] > n) { return false; }
if (arr[arr.length - 1] > n) {
arr.pop();
return possibleCombinationSum(arr, n);
}
var listSize = arr.length, combinationsCount = (1 << listSize)
for (var i = 1; i < combinationsCount ; i++ ) {
var combinationSum = 0;
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: sudo $0 /dev/sdh1"
exit 1;
fi
dd if=$1 of=/dev/null & pid=$!
while true; do
ps -p$pid --no-heading || break;
echo "-- $(date) ------------------";
@ashokhein
ashokhein / babel.js
Last active July 6, 2017 20:55
Babel Example
ES5/6 : 
//ES6
const numbers= [1,2,3,4,5];
const add = (a,b) => a+b;
const sub = (a,b) => a-b;
@ashokhein
ashokhein / blogEditor.tsx
Last active November 20, 2020 11:23
RichText Editor in MaterialUI/React/Typescript/DraftJS (mui-rte)
import React, { useRef, useState, FunctionComponent, useEffect } from 'react'
import MUIRichTextEditor from 'mui-rte'
import Grid from '@material-ui/core/Grid'
import { createMuiTheme, makeStyles, MuiThemeProvider } from '@material-ui/core/styles'
import Popover from '@material-ui/core/Popover'
import TextField from '@material-ui/core/TextField'
import IconButton from '@material-ui/core/IconButton'
import Button from '@material-ui/core/Button'
import BackupIcon from '@material-ui/icons/Backup'
import DoneIcon from '@material-ui/icons/Done'