Skip to content

Instantly share code, notes, and snippets.

View sayanriju's full-sized avatar

Sayan "Riju" Chakrabarti sayanriju

View GitHub Profile
@sayanriju
sayanriju / keypress.py
Created February 7, 2019 12:01
A tiny, nifty script for playing random musical notes on each keypress
#!/usr/bin/env python
## A tiny, nifty script for playing random musical notes on each keypress.
##
## Copyright Sayan "Riju" Chakrabarti <s26c.sayan@gmail.com> 2009-2019
## Released under WTFPL Version 2
## (DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE)
## Copy of license text can be found online at
## http://sam.zoy.org/wtfpl/COPYING
##
## External/System Dependencies:
@sayanriju
sayanriju / .htaccess
Created December 4, 2018 18:26
Redirect http to https for SPA
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
@sayanriju
sayanriju / daysSpentOnGitProject.sh
Last active June 9, 2018 10:57
Oneliner to count the total number of days spent on a git project
GIT_USER="${1-`git config user.name`}"
GIT_BRANCH=${2-master}
OFFSET=${3-0}
DAYS=`git log --pretty=format:"%cd %an" $GIT_BRANCH 2> /dev/null | grep -i "$GIT_USER" | awk '{print $1,$2,$3}' | uniq | wc -l`
echo "$GIT_USER spent `expr $DAYS - $OFFSET` days (tops!) on this git project ($GIT_BRANCH branch)"
/**
* Formats a number to a string in the lakh/crore (Indian) format.
* Also, add/truncate to two decimal places, as expected for a currency
* @param num The number to format
*/
function desiCurrency(num) {
let ret = num.toFixed(2)
ret = `${ret}` || ""
// works for integer and floating as well
let n1 = ret.split(".")
@sayanriju
sayanriju / Minimal_VirtualHost_Config.md
Last active March 17, 2023 13:24
Web Server Configs

Minimal VirtualHost Config

Nginx

server {
       listen 80;
       listen [::]:80;

       server_name example.com www.example.com;
@sayanriju
sayanriju / setup_node_mongo_digital_ocean.md
Last active July 8, 2020 11:36
Set up Digital Ocean Droplet for Node & MongoDB (optionally Redis)

Set up Digital Ocean Droplet for Node & MongoDB (optionally Redis)

Locale Setup

Append the following to the file /etc/environment:

LANG="en_US.UTF-8"  
LC_ALL="en_US.UTF-8"  
LANGUAGE="en_US.UTF-8" 
@sayanriju
sayanriju / fontconverter.py
Created August 24, 2017 17:18
Python Scripts to convert non-unicode Bangla fonts to Unicode
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# fontconverter.py
#
# Copyright 2014-17 Sayan "Riju" Chakrabarti <s26c.sayan@gmail.com>
#
# License: MIT
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@sayanriju
sayanriju / README.md
Last active July 2, 2022 19:07 — forked from RobK/serial.js
Generate Random Serial Keys

Synopsis

This is a simple package to generate (pseudo) random strings of specified length separated into "blocks" of specified blockLengths by specified separator characters. This makes this package suitable for generating license or product or serial keys.

The similar looking characters (and numbers) I, 1, 0 and O are always left out of the generated strings to avoid confusion.

Note that the generated keys are just random strings and there's no provision to check their validity cryptographically.

Installation

From npm registry:

@sayanriju
sayanriju / README.md
Created May 18, 2017 18:32 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

#!/usr/bin/env python
import sys
import json
import jinja2
templateLoader = jinja2.FileSystemLoader( searchpath="./" )
templateEnv = jinja2.Environment( loader=templateLoader )
template_file = sys.argv[1]