Skip to content

Instantly share code, notes, and snippets.

View anujpradhaan's full-sized avatar
🎯
Focusing

anuj kumar anujpradhaan

🎯
Focusing
View GitHub Profile
@anujpradhaan
anujpradhaan / CardType.java
Created September 14, 2017 10:23 — forked from gabrielbauman/CardType.java
A Java enum representing credit card types (Visa, Mastercard etc) that can detect card type from a credit card number.
package com.gabrielbauman.gist;
import java.util.regex.Pattern;
public enum CardType {
UNKNOWN,
VISA("^4[0-9]{12}(?:[0-9]{3})?$"),
MASTERCARD("^5[1-5][0-9]{14}$"),
AMERICAN_EXPRESS("^3[47][0-9]{13}$"),
@anujpradhaan
anujpradhaan / example.sh
Created June 24, 2016 06:15 — forked from tristanbes/example.sh
Install Graphite on Debian Server
# Installing graphite dependencies
apt-get install -y python2.6 python-pip python-cairo python-django python-django-tagging
apt-get install -y libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson
pip install whisper
pip install carbon
pip install graphite-web
# Setup a vhost by grabbing the example the graphite team released on their repo.
# In this file, you'll provide the url used to access to your Graphite dashboard
wget https://raw.github.com/tmm1/graphite/master/examples/example-graphite-vhost.conf -O /etc/apache2/sites-available/graphite
@anujpradhaan
anujpradhaan / pvsl.erl
Created June 17, 2016 07:15 — forked from kidrane/pvsl.erl
benchmark between lists:keyfind and proplists:get_value
-module(pvsl).
-define(LIST_SIZES, [10000, 100000, 1000000]).
-define(RETRIES, 1000).
-compile(export_all).
start() ->
% test for different list sizes
lists:foreach(fun(N) -> test_list(N) end, ?LIST_SIZES).
test_list(ListSize) ->
@anujpradhaan
anujpradhaan / move_to_rds.rb
Created April 26, 2016 09:07 — forked from guenter/move_to_rds.rb
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'