Skip to content

Instantly share code, notes, and snippets.

View lokeb's full-sized avatar

Loknath Bharti lokeb

View GitHub Profile
@lokeb
lokeb / Currency.csv
Last active April 15, 2024 09:40
Currency of 109 countries with symbols in unicode
Country and Currency Currency Code Unicode: Hex
Albania Lek ALL \u004c\u0065\u006b
Afghanistan Afghani AFN \u060b
Argentina Peso ARS \u0024
Aruba Guilder AWG \u0192
Australia Dollar AUD \u0024
Azerbaijan Manat AZN \u20bc
Bahamas Dollar BSD \u0024
Barbados Dollar BBD \u0024
Belarus Ruble BYN \u0042\u0072
@lokeb
lokeb / String.js
Created August 23, 2018 19:31
Prototype methods to convert Currency.csv Unicode values
String.prototype.hexDecode = function () {
var j;
var hexes = this.split("\\u").slice(1);
var back = "";
for (j = 0; j < hexes.length; j++) {
back += String.fromCharCode(parseInt(hexes[j], 16));
}
return back;
}
@lokeb
lokeb / parser.js
Created August 23, 2018 20:20
Parse currency symbols from https://www.xe.com/symbols.php into a csv string
var tdr = $('table')[0].children[0].children;
var out = '';
$.each(tdr, (c, el) => {
const els = el.children;
var curr = '';
var ucs = els[6].textContent.trim();
if(ucs.length) {
ucs = ucs.split(",");
for(var i = 0; i < ucs.length; i++) {
curr += (c > 0 ? '\\u' : '') + ucs[i].trim().padStart("4", "0");
@lokeb
lokeb / Currency.js
Created August 23, 2018 20:32
109 Currency symbols in an Array in Unicode
const Symbols = [
["Country and Currency", "Currency Code", "Unicode: Hex"],
["Albania Lek", "ALL", "\u004c\u0065\u006b"],
["Afghanistan Afghani", "AFN", "\u060b"],
["Argentina Peso", "ARS", "\u0024"],
["Aruba Guilder", "AWG", "\u0192"],
["Australia Dollar", "AUD", "\u0024"],
["Azerbaijan Manat", "AZN", "\u20bc"],
["Bahamas Dollar", "BSD", "\u0024"],
["Barbados Dollar", "BBD", "\u0024"],
@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>
))
@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 / 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 / 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 / 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 / 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;