Skip to content

Instantly share code, notes, and snippets.

View eashish93's full-sized avatar

Ashish Rawat eashish93

View GitHub Profile
This file has been truncated, but you can view the full file.
@eashish93
eashish93 / countries.ts
Last active February 3, 2023 07:43
Get countries with their flag.
// From : http://country.io/names.json, http://country.io/prefix.json
// Make sure to update it once in a while
const countries = [
{ name: 'Afghanistan', code: 'AF', prefix: '93' },
{ name: 'Aland Islands', code: 'AX', prefix: '35818' },
{ name: 'Albania', code: 'AL', prefix: '355' },
{ name: 'Algeria', code: 'DZ', prefix: '213' },
{ name: 'American Samoa', code: 'AS', prefix: '1684' },
{ name: 'Andorra', code: 'AD', prefix: '376' },
{ name: 'Angola', code: 'AO', prefix: '244' },
@eashish93
eashish93 / lang.js
Created February 3, 2018 18:27
Language codes
const langCodes = [
{name: 'Africans', code: 'afr'},
{name: 'Arabians', code: 'abr'},
{name: 'Chinese', code: 'chi_sim'},
{name: 'Danish', code: 'dan'},
{name: 'Dutch', code: 'nld'},
{name: 'English', code: 'eng'},
{name: 'Finish', code: 'fin'},
{name: 'French', code: 'fra'},
{name: 'Greek', code: 'ell'},
@eashish93
eashish93 / treeview.js
Created January 25, 2018 07:01
Simplest tree view rendering in react
import React from 'react';
function shortId() {
// Taken from stackoverflow. I Forget the reference.
// I generate the UID from two parts here
// to ensure the random number provide enough bits.
var firstPart = (Math.random() * 46656) | 0;
var secondPart = (Math.random() * 46656) | 0;
firstPart = ("000" + firstPart.toString(36)).slice(-3);
secondPart = ("000" + secondPart.toString(36)).slice(-3);
@eashish93
eashish93 / deploy-node.sh
Last active November 17, 2017 21:02
Deploy Script for My Node.JS app for zero-downtime (single server - no revert - only latest commit)
#!/bin/bash
## SEE: http://pm2.keymetrics.io/docs/tutorials/capistrano-like-deployments
# 0. Folder Structure
# -> /var/www/project_root
# -> source
# -> current -> symlink to latest release
# -> versions
# -> sha-of-commit
# -> logs
@eashish93
eashish93 / material_colors.js
Created September 29, 2017 13:54
Material Colors in JS (For Use in JS based CSS)
// This version is specially built for used in css-in-js solution.
// You can specifically import single colors to take advantage of webpack. For eg: import {red_50} from 'material_colors'
// This one consist of flat naming instead of this json based : https://gist.github.com/kawanet/a880c83f06d6baf742e45ac9ac52af96
module.exports = {
// red
'red_50': '#ffebee',
'red_100': '#ffcdd2',
'red_200': '#ef9a9a',
'red_300': '#e57373',
@eashish93
eashish93 / bash scripting cheatsheet.md
Created August 23, 2017 14:09
Bash Scripting Cheatsheet
@eashish93
eashish93 / express-seed.js
Created April 5, 2017 22:20
Quick Express Seed
const
express = require('express'),
logger = require('morgan'),
path = require('path'),
bodyParser = require('body-parser'),
serveStatic = express.static,
MongoClient = require('mongodb').MongoClient,
io = require('socket.io'),
http = require('http');
@eashish93
eashish93 / googledrive.py
Created February 23, 2017 17:21 — forked from remitamine/googledrive.py
youtube-dl extractor for Google Drive
from .common import InfoExtractor
from ..utils import RegexNotFoundError
class GoogleDriveIE(InfoExtractor):
_VALID_URL = r'(?:https?://)?(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/))(?P<id>.+?)(?:&|/|$)'
_formats = {
'5': {'ext': 'flv'},
'6': {'ext': 'flv'},
'13': {'ext': '3gp'},
'17': {'ext': '3gp'},