Skip to content

Instantly share code, notes, and snippets.

View amberj's full-sized avatar

Amber Jain amberj

View GitHub Profile
@amberj
amberj / fizzbuzz.py
Created April 5, 2012 22:34
FizzBuzz
# fizzbuzz.py
# Python implementation of FizzBuzz (http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/)
#
# Author: Amber Jain (http://amberj.devio.us/)
# Problem description:
# Write a program that prints the numbers from 1 to 100.
# But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
# For numbers which are multiples of both three and five print "FizzBuzz".
# Problem source: http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
@amberj
amberj / rev-youtube-playlist-urls.sh
Created May 7, 2012 23:52
This (bash) script takes a youtube playlist URL as argument and outputs title and URL of each video (in playlist) in reverse order
#!/bin/bash
#
# File: rev-youtube-playlist-urls.sh
# Description: This (bash) script takes a youtube playlist URL as argument and outputs title and URL of each video (in playlist) in reverse order (i.e. starting from last video in playlist)
# Author: Amber Jain
# Check if "only one" argument (playlist_url) passed as input:
if [ "$#" -lt "1" ]
then
echo "Invalid! You must pass playlist_url as argument"
@amberj
amberj / latency.txt
Created June 8, 2012 18:22 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@amberj
amberj / rgb-colored-echo.sh
Last active April 25, 2024 21:45
A bash pretty print script that provides following red/green/blue colored echo functions.
#!/bin/bash
#
## @file rgb-colored-echo.sh
## @author Amber Jain
## @section DESCRIPTION A bash pretty print script which provides red/green/blue colored echo functions
## @section LICENSE ISC
#################
# Documentation #
@amberj
amberj / setup-local-replit.sh
Created March 14, 2013 23:30
A bash script to automate the installation/setup of repl.it on local system.
#!/bin/bash
#
## @file setup-local-replit.sh
## @author Amber Jain
## @section DESCRIPTION A bash script to automate the installation/setup of repl.it on local system
## @section LICENSE ISC
#################
# Documentation #
@amberj
amberj / setup-headless-selenium-xvfb.sh
Created September 25, 2013 05:06
Bash script to install/setup headless Selenium (uses Xvfb and Chrome)
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04)
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)
@amberj
amberj / initial-vps-setup.sh
Last active June 22, 2021 21:36
Initial setup of hosted VPS (which comes with 'root' access by default)
#!/bin/bash
# ABOUT:
#
# Use this set of commands to:
# - Change password of root account
# - Create a new user account, set it's password and grant sudo privileges
# on Ubuntu Linux.
# Change password of currently logged in 'root' account:
{"shop_id":84644,
"vendor_id":62414,
"img_URL":null,
"user_preferred_domain":null,
"shipping_cost":0,
"shop_description":"my test shop",
"domain_identifier":"test59",
"shop_name":"Test",
"shop_logo_URL":null,
"shop_contact_number":"9769110914",
@amberj
amberj / calculate-fd-interest.py
Last active October 19, 2021 10:44
Calculate interest earned and maturity amount for Fixed Deposit (FD) in Python
#!/usr/bin/env python3
principal = 200000
# Annual rate of interest
# e.g. 9.25%
r = 9.25
# number of compounding periods per year
#
@amberj
amberj / calculate-rd-interest.py
Created October 19, 2021 10:46
Calculate interest earned and maturity amount for Recurring Deposit (RD) in Python
#!/usr/bin/env python3
monthly_installment = 30000
# 36 means one installment every month for 3 years
number_of_installments = 36
# Annual rate of interest
# e.g. 9.25%
r = 9.25