Skip to content

Instantly share code, notes, and snippets.

Avatar

mike qin 1mike12

View GitHub Profile
@1mike12
1mike12 / gist:c44eefcf34ce612e169b8dd45985526a
Created May 21, 2021
Entrepreneurial optimism pessimism double think
View gist:c44eefcf34ce612e169b8dd45985526a
How I built this 32:09 canva
Tfs 343 stripe 1:01:43
@1mike12
1mike12 / arcane windows commands.md
Last active Aug 14, 2020
arcane windows commands
View arcane windows commands.md

remove all crap from windows Get-AppXPackage | Remove-AppXPackage

get back windows store Get-AppxPackage -allusers Microsoft.WindowsStore | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

remove all tiles and crap on start menu

#Requires -RunAsAdministrator

$START_MENU_LAYOUT = @"
@1mike12
1mike12 / 1 machine learning WSL2.md
Last active Aug 16, 2020
How to get Windows Subsystem Linux 2 and ML working on windows
View 1 machine learning WSL2.md

1 enable WSL

in admin PS dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

2 Get latest windows developer preview.

You need build 19041 or higher (check version with ver in command prompt), which as of now requires a windows 10 preview build. You have to enable them through your microsoft account.

https://docs.microsoft.com/en-us/windows/wsl/install-win10

3 Enable WSL 2

@1mike12
1mike12 / instructions.md
Last active Feb 11, 2019
Step By Step Node Nginx Postgres
View instructions.md

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

postgres

@1mike12
1mike12 / mocha.js
Last active Feb 14, 2021
Mocha chai expecting exceptions (sync and async)
View mocha.js
//setup async support (doesn't come out of box with chai)
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
//usage
expect(()=> syncFunction()).to.throw(ErrorClass, "error message")
await expect(asyncFunction()).rejectedWith(ErrorClass, "error message")
@1mike12
1mike12 / Fast tethering.md
Last active Aug 9, 2020
fast hotstop tethering
View Fast tethering.md

on android

adb shell

settings put global tether_dun_required 0

with root permsission and running as SU

# makes the build.prop file editable
mount -o rw,remount /

# adds a line in build.props
@1mike12
1mike12 / testing in webstorm.md
Last active Aug 31, 2018
Describes how to get webstorm/intellij tests working
View testing in webstorm.md

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
1mike12 / how to post-receive.md
Last active Apr 13, 2021
node and react git post-receive hook deployment
View how to post-receive.md

server

  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

local

git remote add production user@domain.com:/var/www/project.git

View bookshelf_cheat_sheet.md

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

//Student
let instance = {
  courses : ()=> this.belongsToMany(require("./course"))
}
module.exports = Bookshelf.extend(instance)
@1mike12
1mike12 / webpack.config.dev.js
Created Dec 14, 2017
SCSS/Sass for ejected create react app because webpack must change every fucking week
View webpack.config.dev.js
'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');