Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Om4ar / .gitignore
Created December 5, 2018 14:19 — forked from initlove/.gitignore
How to Readline - an example and the beginnings of the docs
node_modules/
@Om4ar
Om4ar / stars
Created December 12, 2018 20:51 — forked from kensoh/stars
TagUI flow to print the list of your starred repos
// created this flow file to archive my starred repos
// it prints the list of starred repos by github user
// you can get TagUI here (macOS / Windows / Linux)
// https://github.com/kelaberetiv/TagUI#set-up
// usage #1 - copy or download this file, then run
// tagui stars github_userid quiet chrome
// usage #2 - if you want to run this gist directly
@Om4ar
Om4ar / CONCURRENCY.md
Created January 4, 2019 11:57 — forked from montanaflynn/CONCURRENCY.md
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

@Om4ar
Om4ar / jwt-expiration.md
Created January 18, 2019 13:37 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@Om4ar
Om4ar / redis_cheatsheet.bash
Created January 21, 2019 21:28 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@Om4ar
Om4ar / userAvatar.js
Created February 4, 2019 17:04 — forked from SylarRuby/userAvatar.js
NodeJs AWS S3 Upload
/**
* This gist was inspired from https://gist.github.com/homam/8646090 which I wanted to work when uploading an image from
* a base64 string.
* This code is used in my startup, Zired.
* Web: http://zired.io
*/
// You can either "yarn add aws-sdk" or "npm i aws-sdk"
const AWS = require('aws-sdk')
@Om4ar
Om4ar / numberformat.js
Created February 11, 2019 19:30
number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP. It formats a number to a string with grouped thousands, with custom seperator and custom decimal point Demo: https://jsbin.com/yuremoyalu/edit?js,console
/**
* number_format(number, decimals, decPoint, thousandsSep) in JavaScript, known from PHP.
* It formats a number to a string with grouped thousands, with custom seperator and custom decimal point
* @param {number} number - number to format
* @param {number} [decimals=0] - (optional) count of decimals to show
* @param {string} [decPoint=.] - (optional) decimal point
* @param {string} [thousandsSep=,] - (optional) thousands seperator
* @author Felix Leupold <[email protected]>
*/
function number_format(number, decimals, decPoint, thousandsSep) {
@Om4ar
Om4ar / Laravel-Container.md
Created February 16, 2019 21:34
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@Om4ar
Om4ar / axios-vs-superagent.js
Created June 2, 2019 09:49 — forked from natesilva/axios-vs-superagent.js
Compare performance of Axios vs. SuperAgent when running under Node.js
const Benchmark = require('benchmark');
const axios = require('axios');
const superagent = require('superagent');
var suite = new Benchmark.Suite;
const targetUrl = 'http://httpbin.org/ip';
suite
.add('axios', {