Skip to content

Instantly share code, notes, and snippets.

View lokeb's full-sized avatar

Loknath Bharti lokeb

View GitHub Profile
@lokeb
lokeb / parse-options.sh
Created April 24, 2021 00:46 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CGPDeviceCategory</key>
<string>GamePad</string>
<key>CGPDeviceType</key>
<string>PS3</string>
<key>CGPDisplayNameOvr</key>
<string>DualShock3 Analogue Triggers</string>
@lokeb
lokeb / jack.rb
Last active November 21, 2020 03:19 — forked from jaygooby/jack.rb
#does not work Homebrew formula to install JackOSX binary package.
require 'formula'
class Jack2 <Formula
homepage 'http://jackaudio.org'
version '1.9.16'
url 'https://github.com/jackaudio/jack2-releases/releases/download/v1.9.16/jack2-macOS-v1.9.16.tar.gz'
def install
system "xar -xf jack2-osx-1.9.16.pkg"
@lokeb
lokeb / colors.csv
Last active March 31, 2019 04:40
Color names with Hex Code obtained from https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F
Name Hex Code
Absolute Zero #0048BA
Acid #B0BF1A
Acid green #B0BF1A
Aero #7CB9E8
Aero blue #C9FFE5
Air superiority blue #72A0C1
Alabama crimson #AF002A
Alabaster #EDEAE0
Alice blue #F0F8FF
@lokeb
lokeb / fixed-topbar-scroll-offset.html
Last active October 31, 2018 21:34
Fix vertical offset to compensate for a fixed topbar when using "Space", "Shift+Space", "Page Up", "Page Down" keyboard shortcuts to scroll
<html>
<head>
<title>Fixing Scrolling Controlled by Space, Page Up, Page Down with a fixed top navbar</title>
<style>
html {
font: 14px Arial;
}
* {
margin: 0;
padding: 0;
@lokeb
lokeb / ISODate.go
Created September 9, 2018 19:00
Custom Date type with format YYYY-MM-DD and JSON decoder (Parser) and encoder (Unmarshal and Marshal methods)
//ISODate struct
type ISODate struct {
Format string
time.Time
}
//UnmarshalJSON ISODate method
func (Date *ISODate) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
@lokeb
lokeb / autosuggest.js
Last active September 7, 2018 23:22
Ready to use React Material-UI component to render autocomplete input field. Accepts standard input properties
import React from 'react';
import deburr from 'lodash/deburr'
import Autosuggest from 'react-autosuggest';
import match from 'autosuggest-highlight/match'
import parse from 'autosuggest-highlight/parse'
import TextField from '@material-ui/core/TextField'
import Paper from '@material-ui/core/Paper'
import MenuItem from '@material-ui/core/MenuItem'
import { withStyles } from '@material-ui/core/styles'
@lokeb
lokeb / autosuggest.js
Created September 7, 2018 23:20
Ready to use React Material-UI component to render autocomplete input field
import React from 'react';
import deburr from 'lodash/deburr'
import Autosuggest from 'react-autosuggest';
import match from 'autosuggest-highlight/match'
import parse from 'autosuggest-highlight/parse'
import TextField from '@material-ui/core/TextField'
import Paper from '@material-ui/core/Paper'
import MenuItem from '@material-ui/core/MenuItem'
import { withStyles } from '@material-ui/core/styles'
@lokeb
lokeb / countries.js
Created September 6, 2018 23:20
List of 241 countries in Javascript array
const countries = [
"Afghanistan",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",
"Antigua And Barbuda",
@lokeb
lokeb / react-object.js
Created August 30, 2018 18:22
React recurse through and render an object
const renderObj = (obj) => Object.entries(obj).map((el) => (
<div>
<div>el[0]</div>
<div>el[1]</div>
</div>
))