Skip to content

Instantly share code, notes, and snippets.

View umaar's full-sized avatar

Umar Hansa umaar

View GitHub Profile
@umaar
umaar / pygmentize_code.sh
Created February 5, 2023 00:54 — forked from skmetz/pygmentize_code.sh
Script to create syntax highlighted RTF files
#!/bin/bash
# I edited the ruby lexer (line 637 in the following file...
# [skm@skmair2:/Library/Python/2.7/site-packages/pygments/lexers/agile.py
# to remove spacial handling of the word 'name'
# so I could use it as a variable/method name.
# This script come from Katrina, with these instructions:
# I've also attached the presentation.py file which is where the style
# is defined. The colors are normal hex values, so if you know how you
@umaar
umaar / 1-CalendarItem.js
Created August 4, 2022 00:08 — forked from getify/1-CalendarItem.js
an illustration (non-trivial example) of many newer JS class features
// abstract class, not intended to be instantiated directly
class CalendarItem {
static #UNSET = Symbol("unset")
static #isUnset(v) {
return v === this.#UNSET;
}
static {
for (let [idx,msg] of [
"ID is already set.",
"ID is unset.",
@umaar
umaar / scale.js
Created March 31, 2021 23:11 — forked from fpillet/scale.js
Javascript value scaling between two ranges
/* Scale a value from one range to another
* Example of use:
*
* // Convert 33 from a 0-100 range to a 0-65535 range
* var n = scaleValue(33, [0,100], [0,65535]);
*
* // Ranges don't have to be positive
* var n = scaleValue(0, [-50,+50], [0,65535]);
*
* Ranges are defined as arrays of two values, inclusive
@umaar
umaar / setup.sh
Created January 28, 2019 19:04 — forked from bradp/setup.sh
New Mac Setup Script
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
@umaar
umaar / README.md
Created January 25, 2019 12:22 — forked from novemberborn/README.md
AVA throwsAsync transform for jscodeshift

Usage:

$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js

See https://github.com/facebook/jscodeshift#usage-cli for further details.

@umaar
umaar / perceptron.js
Created September 15, 2018 00:14 — forked from primaryobjects/perceptron.js
Perceptron in JavaScript, a simple example. Neural network. See https://jsfiddle.net/qu960cc2/1/
function Perceptron(opts) {
if (!opts) opts = {}
var debug = 'debug' in opts ? opts.debug : false;
var weights = 'weights' in opts
? opts.weights.slice()
: []
var threshold = 'threshold' in opts

convert google takeout archive for location history from kml to gpx and split file into one per day

gpsbabel -i kml -f Location\ History.kml -o gpx -F out.gpx
gpsbabel -t -i gpx -f out.gpx -x track,merge,pack,split,title="ACTIVE LOG # %Y%m%d" -o gpx -F split.gpx
python2 gpxsplitter.py split.gpx
@umaar
umaar / subreddit-face-average.js
Created March 14, 2018 00:09 — forked from vincentriemer/subreddit-face-average.js
Subreddit Face Averaging Script
import * as fs from "fs";
import * as path from "path";
import * as url from "url";
import { exec } from "child_process";
import cuid from "cuid";
import snoowrap from "snoowrap";
import throat from "throat";
import mmm from "mmmagic";
import axios from "axios";
@umaar
umaar / highlight_tweets.js
Created July 12, 2017 17:42 — forked from simevidas/highlight_tweets.js
A JS snippet for highlighting tweets with lots of RTs or hearts
(function(){
'use strict';
let cap = 100; // 100+ RTs or hearts produces max yellow bg color
$('.tweet', '.stream-items').each((i, tweet) => {
let all_nums = $(tweet)
.find('.ProfileTweet-actionList .ProfileTweet-actionCount:visible')
.map((j, elem) => Number(elem.textContent)).toArray();
@umaar
umaar / taxi.sh
Created July 7, 2017 10:45 — forked from e-n-f/taxi.sh
NYC taxi with datamaps
#!/bin/sh
for i in trip_data_*.csv.zip
do
unzip -c $i
done |
tr -d '\015' |
awk -F, '{print $12 "," $11 " 1:0"; print $14 "," $13 " 1:1"}' |
/data2/data/github/datamaps/encode -z19 -m1 -o nyc-taxi-all