Skip to content

Instantly share code, notes, and snippets.

View harish2704's full-sized avatar

Harish Karumuthil harish2704

View GitHub Profile
@harish2704
harish2704 / nginx-maintenance-server
Last active February 9, 2016 08:33
Nginx maintenance site
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
server_name localhost;
# 503.html: https://gist.github.com/pitch-gist/2999707
error_page 503 /503.html;
@harish2704
harish2704 / json-formatter.html
Created February 29, 2016 10:18
Simple json formatter
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Json formatter</title>
<style type="text/css" media="all">
#container > div {
width: 50%;
display: block;
@harish2704
harish2704 / SimpleEventEmiiter.js
Last active March 10, 2016 03:45
Simple stupid Event Emitter class implementation in Javascript
function EventEmitter(){
this.listers = {};
}
EventEmitter.prototype = {
on: function( name, handler ){
var evnt = this.listers[ name ];
if( !evnt ){
this.listers[ name ] = [ handler ];
var HOME = process.env.HOME;
var CONFIG_DIR = `${HOME}/.config/chromium/`;
var fs = require('fs');
function listProfileDirs( ){
return fs.readdirSync( CONFIG_DIR ).filter( ( dirName) => {
return dirName.match( 'Profile ' );
})
}
@harish2704
harish2704 / setup-ssh-agent.sh
Created May 13, 2016 07:24
Setup ssh-agent
# To start agent
# echo $(ssh-agent) > ~/.ssh_agent_env
cat<<EOF >> ~/.profile
# For setting up ssh-agent
if [ -f "$HOME/.ssh_agent_env" ]; then
. "$HOME/.ssh_agent_env"
fi
@harish2704
harish2704 / index.js
Created May 22, 2016 15:24
Simple react-native-redux-router
import React, { Component } from 'react';
import {
Text,
View,
LayoutAnimation,
UIManager
} from 'react-native';
#!/usr/bin/env bash
codeName='xenial'
component='main'
arch='amd64'
dirname="dists/$codeName/$component/binary-$arch"
mkdir -p $dirname
cat<<EOF > $dirname/Release
@harish2704
harish2704 / generate_icons.sh
Created August 5, 2016 10:00
automatically resize icons for Linux desktop configuration file in 256 128 96 and 48 pixel resolution
for i in 256 128 96 48; do dname="${i}x${i}"; mkdir $dname; convert INFILE.png -resize $dname "$dname/OUTFILE.png"; done
@harish2704
harish2704 / repack-initrd.sh
Created August 7, 2016 14:52
Repack/create a initrd image from a existing initrd directory tree
# Run from root of the initrd tree
find ./ | cpio -H newc -o | lzma -9 - > ../initrd.lz
# Extract initrd file.
# create a empty dir and cd to it
# lzma -d < ../initrd.lz | cpio --extract
@harish2704
harish2704 / mount_vdi.sh
Created August 7, 2016 14:58
Mount / Unmount a Virtualbox vdi image in linux
# Mount command
sleep 1; modprobe nbd
sleep 1; qemu-nbd -c /dev/nbd0 /path/to/image.vdi
sleep 1; mount /dev/nbd0p1 ~/u
# Below command to compress the entire mounted dir tree into a squafs filesystem
# mksquashfs u/ /path/to/image.squashfs -no-recovery -wildcards -e 'var/cache/apt/archives/*.deb' -e "home/user/Downloads/*" -e home/user/.cache -e home/user/.config/chromium
# Unmount command
# sleep 1; umount ~/u