Skip to content

Instantly share code, notes, and snippets.

View harish2704's full-sized avatar

Harish Karumuthil harish2704

View GitHub Profile
@harish2704
harish2704 / grub.cfg
Last active June 6, 2019 13:41
grub.cfg for live boot of custom usb drive
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry "Try openSUSE Tumbleweed GNOME Live ISO" {
set gfxpayload=keep
set iso_path=/openSUSE-Tumbleweed-GNOME-Live-x86_64-Snapshot20180220-Media.iso
loopback loop0 ${iso_path}
echo Loading kernel...
@harish2704
harish2704 / shutdown-dialog.sh
Created October 1, 2016 05:45
A simple commandline tool to show system Shutdown/suspend/hibernate/restart dialog. in a Linux desktop environment
#!/usr/bin/env bash
# A simple commandline tool to show system Shutdown/suspend/hibernate/restart dialog.
# this tool can be used in any modern linux desktop environemtnt provided the following packages are instaleld
# * systemd - The new system service manager
# * yad - A powerfull alternative to zenity or 'dialog' command
yad \
--on-top \
--center \
@harish2704
harish2704 / lodash.get.js
Last active June 3, 2023 23:41
Simple lodash.get function in javascript
/* Implementation of lodash.get function */
function getProp( object, keys, defaultVal ){
keys = Array.isArray( keys )? keys : keys.split('.');
object = object[keys[0]];
if( object && keys.length>1 ){
return getProp( object, keys.slice(1) );
}
return object === undefined? defaultVal : object;
}
@harish2704
harish2704 / cookie-store.js
Created December 7, 2016 06:44
cookie as storage location
@harish2704
harish2704 / flattern-object.js
Created January 18, 2017 05:59
Flatten a nested json into a plain json
var handlers = {
Object: flattenObject,
Array: flattenArray,
};
function router(val, store, prefix, i ) {
var kind, handler, key = prefix? prefix + '.'+ i : i; ;
if( val === undefined || val === null ){
return store[ key ] = val;
}
@harish2704
harish2704 / grub.cfg
Created May 1, 2017 05:41
Boot ubuntu iso file
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
# File name of ISO file
set ubu_path=/ubuntu-16.04-desktop-amd64.iso
menuentry "Try Ubuntu without installing Failsafe" {
# Search for iso file in all paritions and set the partition as root
@harish2704
harish2704 / generate-certificate-openssl.sh
Created June 16, 2017 09:40
Generate Root CA and self-singed certificate using openssl
#!/usr/bin/env bash
DomainName="yourdomain.example.com";
echo "Generating Root CA key"
[[ -f rootCA.key ]] || openssl genrsa -des3 -out rootCA.key 2048
echo "Generating Root CA certificate"
[[ -f rootCA.pem ]] || openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
@harish2704
harish2704 / example.my.cnf
Last active February 16, 2024 07:26
local mysql server for testing
[mysqld]
innodb_buffer_pool_size=10G
query_cache_size=64M
skip-name-resolve
max_heap_table_size=64M
tmp_table_size=64M
max_connections = 200
innodb_read_io_threads = 64
innodb_write_io_threads = 64
@harish2704
harish2704 / multiline-to-js.js
Last active June 20, 2017 06:08
multiline-to-js.js
const getStdin = require('get-stdin');
/* Usage */
/*
>> cat file.html | node multiline-to-js.js
*/
/* Input */
/*
<div class="tab-pane active" >
<div class="card-box">
@harish2704
harish2704 / catch-if.js
Created June 22, 2017 06:52
catchIf syntax sugar for ES6 Promise. can be applied to any Promise library
/*
Adds a catchIf method to Promise.
Usage
Promise.reject( new TypeError() )
.catchIf( TypeError, function handler(err){ console.log('TypeError handled')} )
.catchIf( RangeError, function handler(err){ console.log('RangeError handled')} )
*/
function addCatchIf ( promiseClass ){
promiseClass.prototype.catchIf = function(){