Skip to content

Instantly share code, notes, and snippets.

View meain's full-sized avatar

Abin Simon meain

View GitHub Profile
let rects = [];
function visualize(analyser) {
analyser.fftSize = 2048;
var bufferLength = analyser.fftSize;
var dataArray = new Uint8Array(bufferLength);
function run() {
analyser.fftSize = 2048;
var bufferLengthAlt = analyser.frequencyBinCount;
function hexToHSL(H, off) {
// Convert hex to RGB first
let r = 0,
g = 0,
b = 0;
if (H.length == 4) {
r = "0x" + H[1] + H[1];
g = "0x" + H[2] + H[2];
b = "0x" + H[3] + H[3];
} else if (H.length == 7) {
@meain
meain / bunny.js
Created April 14, 2020 15:52 — forked from luruke/bunny.js
draw bunny on terminal
const drawille = require('drawille')
const bunny = require('bunny')
const glmatrix = require('gl-matrix')
const width = 200
const height = 200
const canvas = new drawille(width, height)
const mat4 = glmatrix.mat4
const vec3 = glmatrix.vec3
let points = []
@meain
meain / server-cors.py
Created April 6, 2020 11:36 — forked from mkows/server-cors.py
Allow CORS with python Simple HTTP Server – for Python 3
'''
Based on https://gist.github.com/enjalot/2904124 (in Python 2) -> quick-migrated to Python 3
Usage: python server-cors
'''
import http.server as httpserver
class CORSHTTPRequestHandler(httpserver.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
#!/bin/sh
# Automatically turn off a system if no ssh connection is found in last 1hr
set -e
if last | grep "still logged in";then
exit 0
fi
#!/bin/sh
test "" = "$(cat "$1" | head -n 1 | grep -v '^\[.*\]\ .*')" || {
FOLDER=$(git diff --name-only --cached | sed 's|/.*||' | uniq -c | sort | awk '{print $2}' | sed 1q)
echo "[$FOLDER] $(cat "$1")"
echo "[$FOLDER] $(cat "$1")" > "$1"
}
from colour import Color
def to_hex_string(color: list) -> str:
c = Color(hsl=tuple(color))
return c.hex
def to_hsl(color: str):
color = Color(color)
@meain
meain / commit-msg
Last active April 7, 2018 06:40
Make commit message have the format `[for] commit message`
#!/bin/bash
test "" = "$(cat "$1" | head -n 1 | grep -v '^\[.*\]\ .*')" || {
echo >&2 "Commit message format is: [git] added new commit message hook"
exit 1
}
@meain
meain / .eslintrc.js
Last active February 18, 2018 14:43
React + flow eslint config
module.exports = {
parser: 'babel-eslint',
env: {
browser: true,
es6: true,
},
extends: ['eslint:recommended', 'plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
@meain
meain / .eslintrc.js
Created February 17, 2018 09:58
React sample eslintrc
module.exports = {
env: {
browser: true,
es6: true,
},
extends: ['eslint:recommended', 'plugin:react/recommended'],
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,