Skip to content

Instantly share code, notes, and snippets.

View amitlzkpa's full-sized avatar

Amit Nambiar amitlzkpa

View GitHub Profile
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@amitlzkpa
amitlzkpa / Encode coordinates as ints
Created August 4, 2018 13:19
Used for an ethereum smart-contract project to store coordinates as int256 in Solidity.
function pad(n, len=6) {
n = n.toString();
n.trim();
let q = n.length;
for(let i=q; i<len; i++) {
n = "0"+n;
}
return n;
}
@amitlzkpa
amitlzkpa / Deploy a smart-contract using Web3.js from client side.
Last active August 4, 2018 13:48
Deploys an instance for a smart-contract compiled in Solidity to an Ethereum network
// Assumes you have a MetaMask wallet running on Chrome
/*
Put this on the html page
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
*/
// Assumes you have a MetaMask wallet running on Chrome
/*
Put this on the html page
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
*/
// You can get the ABI json for your contract here.
// Assumes you have a MetaMask wallet running on Chrome
/*
Put this on the html page
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
*/
// You can get the ABI json for your contract here.
@amitlzkpa
amitlzkpa / Sublime Settings
Last active February 21, 2019 16:03
Sublime settings with shortcuts for shifting group focus, javascript log and reindent
[
{ "keys": ["ctrl+alt+left"], "command": "focus_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+alt+right"], "command": "focus_neighboring_group" },
{ "keys": ["ctrl+p"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true }
@amitlzkpa
amitlzkpa / ImportGTFSData.sh
Created April 13, 2019 06:37 — forked from dsamojlenko/ImportGTFSData.sh
Import GTFS data to MongoDB
mongoimport --db <dbname> --collection agencies --type csv --headerline --file agency.txt
mongoimport --db <dbname> --collection calendardates --type csv --headerline --file calendar_dates.txt
mongoimport --db <dbname> --collection calendars --type csv --headerline --file calendar.txt
mongoimport --db <dbname> --collection routes --type csv --headerline --file routes.txt
mongoimport --db <dbname> --collection stoptimes --type csv --headerline --file stop_times.txt
mongoimport --db <dbname> --collection stops --type csv --headerline --file stops.txt
mongoimport --db <dbname> --collection trips --type csv --headerline --file trips.txt
@amitlzkpa
amitlzkpa / revit-addin-locations.txt
Created May 15, 2019 21:18 — forked from teocomi/revit-addin-locations.txt
Revit Addin folder location
Autodesk Revit addins are generally loaded from the following locations.
User Addins:
%appdata%\Autodesk\Revit\Addins\
Machine Addins (for all users of the machine):
C:\ProgramData\Autodesk\Revit\Addins\
Addins packaged for the Autodesk Exchange store:
C:\ProgramData\Autodesk\ApplicationPlugins\
@amitlzkpa
amitlzkpa / index.html
Last active April 19, 2020 08:32
Trying out jsbin - ThreeJS// source https://jsbin.com/zigujew
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>ThreeJS</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/110/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
</head>
<body>
@amitlzkpa
amitlzkpa / Fuzzy formatted dates
Created April 30, 2020 21:16
show pretty dates
// ref: https://stackoverflow.com/questions/7641791/javascript-library-for-human-friendly-relative-date-formatting
function fuzzyTime(date) {
var delta = Math.round((+new Date - date) / 1000);
var minute = 60,
hour = minute * 60,
day = hour * 24,
week = day * 7;