Skip to content

Instantly share code, notes, and snippets.

View sayanriju's full-sized avatar

Sayan "Riju" Chakrabarti sayanriju

View GitHub Profile
@sayanriju
sayanriju / curry.js
Last active March 5, 2017 14:13 — forked from kevincennis/curry.js
curry.js
function curry( fn, arity ) {
//var arity = fn.length;
return (function resolver() {
let mem = Array.prototype.slice.call( arguments );
return function() {
let args = mem.slice();
Array.prototype.push.apply( args, arguments );
return ( args.length >= arity ? fn : resolver ).apply( null, args );
};
@sayanriju
sayanriju / sayanrju.zsh-theme
Last active February 28, 2021 08:37
My ZSH Theme
local ret_status="%(?:%{$fg_bold[green]%}λ:%{$fg_bold[red]%}λ%s)"
PROMPT='${ret_status}%{$fg_bold[cyan]%}%p %{$fg[cyan]%}%c » %{$fg[green]%}%{$reset_color%}'
RPROMPT='$(git_prompt_info)%{$fg_bold[white]%}%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%} "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[yellow]%}%{$fg[red]%} 🗴 %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[yellow]%}%{$fg[green]%} 🗹 %{$reset_color%}"
{
"env": {
"es6": true,
"node": true,
"mocha": true
},
"extends": "airbnb-base",
"rules": {
"func-names": ["error", "never"],
"comma-dangle": ["error", "only-multiline"],
#!/usr/bin/env python
import sys
import json
import jinja2
templateLoader = jinja2.FileSystemLoader( searchpath="./" )
templateEnv = jinja2.Environment( loader=templateLoader )
template_file = sys.argv[1]
@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

@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 / 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 <[email protected]>
#
# 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 / 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 / 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;
/**
* 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(".")