Skip to content

Instantly share code, notes, and snippets.

View mohitmun's full-sized avatar
💭
yak shaving

Mohit Munjani mohitmun

💭
yak shaving
View GitHub Profile
@mohitmun
mohitmun / .aliases.zsh
Last active March 11, 2024 09:47
Art of command line, all things related to command line and dotfiles
# GistID:963f95aaf61d50e512511ac4eb097e50
function add_alias() {
if [[ -z $1 || -z $2 || $# -gt 2 ]]; then
echo usage:
echo "\t\$$0 ll 'ls -l'"
else
echo "alias $1='$2'" >> $ALIASFILE
echo "alias ADDED to $ALIASFILE"
alias $1="$2"
fi
require 'json'
require 'csv'
def run_command(command)
puts "Running command #{command}"
res = `#{command}`
return res
end
args = {}
ARGV.each do |arg|

stderr in red 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done)

@mohitmun
mohitmun / find_by_json_store
Last active February 4, 2018 16:34
find_by equivaltent for json datatype
def self.find_byjs(hash)
User.where("(json_store ->> '#{hash.keys.first}') = ?", hash.values.first).last
end
@mohitmun
mohitmun / uber_vs_publictransport.rb
Last active January 23, 2018 07:39
Script I used to compare my travel time when using uber vs publictransport (bus, train) Note: This code doesnt include using bus/train data. Used google location history to track public transport timings
require 'json'
token = YOUR_TOKEN
cmd = "curl -H 'Authorization: Bearer #{token}' -H 'Accept-Language: en_US' -H 'Content-Type: application/json' 'https://api.uber.com/v1.2/history?limit=50'"
res = `#{cmd}`
b = JSON.parse(res)
require 'csv'
data = [["Request time", "Start time", "End time", "Distance", "Wait time", "Travel time", "Total time"]]
b["history"].each do |item|
rt = Time.at(item["request_time"])
rts = rt.strftime("%m/%d/%Y %I:%M%p")
This is too good http://www.brynosaurus.com/pub/net/p2pnat/
Problem: I love AskHN, but they show top 60 posts so chances on losing good questions are high;
Solution: Found hnrss.org, use IFTTT to push updated to telegram. solved
@mohitmun
mohitmun / brew_21_12_2017
Created December 21, 2017 07:37
Brew packages
adns
gettext
lame
matlab2tikz
sane-backends
adwaita-icon-theme
gflags
leptonica
maven
scapy