Skip to content

Instantly share code, notes, and snippets.

View AshikNesin's full-sized avatar

Ashik Nesin AshikNesin

View GitHub Profile
@AshikNesin
AshikNesin / export.js
Created April 20, 2022 19:19 — forked from katoen/export.js
Export Wallet by BudgetBakers records to JSON
// Source for Jake Archibald's idb https://github.com/jakearchibald/idb/blob/v3.0.2/build/idb.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.idb = {}));
}(this, function (exports) { 'use strict';
function toArray(arr) {
return Array.prototype.slice.call(arr);
}
@AshikNesin
AshikNesin / letsencrypt_2017.md
Created April 8, 2018 09:46 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@AshikNesin
AshikNesin / validateEmail.js
Created May 27, 2017 06:38 — forked from oscarmorrison/validateEmail.js
ES6 email validation
// regex from http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;
const validateEmail = email => {
return email
&& email.length < 255
&& EMAIL_REGEX.test(email);
};
export default validateEmail;

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@AshikNesin
AshikNesin / airtable-proxy.js
Created December 25, 2016 11:45 — forked from benoror/airtable-proxy.js
Node.js Airtable API Proxy
var express = require('express');
var proxy = require('http-proxy-middleware');
var options = {
logLevel: 'debug',
target: 'https://api.airtable.com/v0/' + process.env.APP_ID,
changeOrigin: true,
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + process.env.API_KEY
},
@AshikNesin
AshikNesin / statuses.md
Created December 4, 2016 11:26 — forked from vkostyukov/statuses.md
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@AshikNesin
AshikNesin / unhandled-exceptions.js
Created November 6, 2016 18:59 — forked from ericelliott/unhandled-exceptions.js
Capturing Unhandled Exceptions
window.onerror = function(message, file, line, column, error) {
error = error || {};
$.ajax({
method: 'POST',
url: 'https://yourapp.com/path/to/error/log',
data: JSON.stringify({
message: message,
file: file,
line: line,
column: column,

This let's me git clone a template repo, cd into and fire up a new template in my editor of choice:

$ clone starter # clones https://github.com/addyosmani/starter (a personal boilerplate)

$ clone h5bp html5-boilerplate # get me HTML5 Boilerplate

$ clone angular angular-seed # same for AngularJS seed

$ clone polymerlabs seed-element # same for a new Polymer element
@AshikNesin
AshikNesin / $.3.js
Created August 6, 2016 13:38 — forked from ofca/$.3.js
// based on https://gist.github.com/Potfur/5576225 & https://github.com/james2doyle/saltjs
// more info: https://plus.google.com/109231487156400680487/posts/63eZzzrBSb6
window.$ = function(s) {
var c = {
'#': 'ById',
'.': 'sByClassName',
'@': 'sByName',
'=': 'sByTagName'}[s[0]];
return document[c?'getElement'+c:'querySelectorAll'](s.slice(1))
};
@AshikNesin
AshikNesin / multiple-3rd-party-widgets.js
Created July 16, 2016 10:53 — forked from zenorocha/multiple-3rd-party-widgets.js
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);