Skip to content

Instantly share code, notes, and snippets.

View kukiron's full-sized avatar
🚀
I do stuff...

Kafil Uddin Kiron kukiron

🚀
I do stuff...
View GitHub Profile
@kukiron
kukiron / multiple_ssh_setting.md
Created February 2, 2022 10:26 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@kukiron
kukiron / mime.csv
Created April 9, 2020 23:18 — forked from jimschubert/mime.csv
List of more common mime types from MDN, in CSV and TSV
Name MIMEType Extension Description
aac audio/aac .aac AAC audio file
abw application/x-abiword .abw AbiWord document
arc application/octet-stream .arc Archive document (multiple files embedded)
avi video/x-msvideo .avi AVI: Audio Video Interleave
azw application/vnd.amazon.ebook .azw Amazon Kindle eBook format
bin application/octet-stream .bin Any kind of binary data
bz application/x-bzip .bz BZip archive
bz2 application/x-bzip2 .bz2 BZip2 archive
csh application/x-csh .csh C-Shell script
@kukiron
kukiron / AttachmentPicker.ts
Created March 5, 2020 14:56 — forked from Aliath/AttachmentPicker.ts
Wrapper for the react-native-image-picker and react-native-document-picker. Allow to pick media from gallery on iOS.
import { Platform, ActionSheetIOS } from 'react-native';
import DocumentPicker from 'react-native-document-picker';
import ImagePicker from 'react-native-image-picker';
import RNFS from 'react-native-fs';
type Captions = {
image: string,
document: string,
cancel: string,
title: string,
@kukiron
kukiron / after_res_hooks.js
Created March 2, 2018 13:06 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@kukiron
kukiron / es7-async-await.js
Created February 24, 2018 18:47 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@kukiron
kukiron / promises.md
Created February 24, 2018 12:58 — forked from domenic/promises.md
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@kukiron
kukiron / app.js
Created February 3, 2018 21:12 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@kukiron
kukiron / passport_node_acl_example.js
Created February 3, 2018 07:26 — forked from danwit/passport_node_acl_example.js
Authentication and authorization with passportjs + node_acl + mongo + express
/**
* Simple authentication and authorization example with passport, node_acl,
* MongoDB and expressjs
*
* The example shown here uses local userdata and sessions to remember a
* logged in user. Roles are persistent all the way and applied to user
* after logging in.
*
* Usage:
* 1. Start this as server
@kukiron
kukiron / gist:1a9c7ec9d57acf018633611101372d5f
Created January 18, 2018 15:04 — forked from rmwxiong/gist:ad6e922dcc739a599640
Fix for color components with single digit values
// get the average color of two hex colors.
function avgcolor(color1,color2){
var avg = function(a,b){ return (a+b)/2; },
t16 = function(c){ return parseInt((''+c).replace('#',''),16) },
hex = function(c){ var t = (c>>0).toString(16);
return t.length == 2 ? t : '0' + t },
hex1 = t16(color1),
hex2 = t16(color2),
r = function(hex){ return hex >> 16 & 0xFF},
g = function(hex){ return hex >> 8 & 0xFF},
@kukiron
kukiron / UPGRADE-7.0.md
Created January 13, 2018 20:51 — forked from xtuc/UPGRADE-7.0.md
Upgrade guide for Babel 7