Skip to content

Instantly share code, notes, and snippets.

mike qin 1mike12

  • United States
Block or report user

Report or block 1mike12

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
1mike12 /
Last active Feb 11, 2019
Step By Step Node Nginx Postgres

Ubuntu shit

add larger swapfile

  1. fallocate -l 1G /swapfile
  2. chmod 600 /swapfile
  3. mkswap /swapfile
  4. swapon /swapfile
  5. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  • make swapfile persist through restarts


1mike12 / example.js
Created Feb 4, 2019
Mocha chai expecting exceptions (sync and async)
View example.js
//setup async support (doesn't come out of box with chai)
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
expect(syncFunction()).to.throw(ErrorClass, "error message")
await expect(asyncFunction()).rejectedWith(ErrorClass, "error message")
1mike12 / Fast
Last active Feb 13, 2019
fast hotstop tethering
View Fast

on android

adb shell

settings put global tether_dun_required 0

restart device

Changing TTL


My OS on high sierra didn't have the file needed so create it first. Otherwise just add the line

1mike12 / testing in
Last active Aug 31, 2018
Describes how to get webstorm/intellij tests working
View testing in

Why the HELL do my tests run as node instead of a test?

Webstorm only runs tests from the right click menu depending on what it finds in package.json

ie. if it finds mocha as a dependency, then it will assume mocha when you attempt to run.

not visually a test

Webstorm looks for the pattern test("...") or describe("...") in the file somewhere, before it will mark a file as a test file

setting up Jest

1mike12 / how to
Last active Feb 10, 2019
node and react git post-receive hook deployment
View how to


  1. make a project/ directory and project.git/ directory
  2. cd project.git && git init --bare
  3. cd project.git/hooks && touch post-receive
  4. copy paste post-receive script
  5. make executable chmod +x post-receive


git remote add production


Saving with relationship

Way to save new model in relation to a pre-existing one. Will automatically handle setting correct foreign keys. many to many

let instance = {
  courses : ()=> this.belongsToMany(require("./course"))
module.exports = Bookshelf.extend(instance)
1mike12 /
Created Dec 14, 2017
SCSS/Sass for ejected create react app because webpack must change every fucking week
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
1mike12 / timestamps.js
Last active Oct 19, 2016
add a mechanisms to automatically add timestamp to google sheets, edit the "update" column with any value, and corresponding timestamp column will insert itself
View timestamps.js
function onEdit(){
var sheet = SpreadsheetApp.getActiveSheet();
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
var activeCell = sheet.getActiveCell();
var activeRow = activeCell.getRow();
var activeColumn = activeCell.getColumn();
var updateColumnName = "update";
var updateColumn = headers.indexOf(updateColumnName) + 1; //bec activeColumns are 1 indexed
You can’t perform that action at this time.