Skip to content

Instantly share code, notes, and snippets.

Will C. wichopy

Block or report user

Report or block wichopy

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
View keybase.md

Keybase proof

I hereby claim:

  • I am wichopy on github.
  • I am wichopy (https://keybase.io/wichopy) on keybase.
  • I have a public key whose fingerprint is 7658 0331 4DB7 C2E0 833A 44FD 5BAC 3985 7ECF C68B

To claim this, I am signing this object:

@wichopy
wichopy / gist:315c76626dd405340de3cd3aefb66310
Created Jul 31, 2019
brew installing my trace route (MTR) and manually sym linking
View gist:315c76626dd405340de3cd3aefb66310
# Brew cannot sym link this app on its own due to permissions, this is how to do it manually:
brew install mtr
# brew link mtr // will return error
# sudo brew link mtr // will return warning about how its dangerous to run brew in sudo
# Manually sym link the path to your mtr install to your local bin folder.
# Check the version by going to /usr/local/Cellar/mtr
View google-login.js
var provider = new firebase.auth.GoogleAuthProvider();
function onSigninClick () {
firebase.auth().signInWithPopup(provider).then(function (result) {
console.log('Auth resposne from firebase:', result)
})
}
function onSignoutClick () {
firebase.auth().signOut().then(function() {
@wichopy
wichopy / higher_order_single_click.js
Last active Aug 16, 2018
higher order single click function
View higher_order_single_click.js
//Wrap an onclick handler
const once = fn => {
let done = false;
return (...args) => {
if (!done) {
done = true;
fn(...args);
}
}
}
@wichopy
wichopy / cors-notes.md
Last active Jul 23, 2018
CORS requests
View cors-notes.md

resource: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_request_headers

  • web applications makes a CORs request when it requests a resource that has a different origin (domain, protocol, port) then its own origin.
  • CORS is for security reasons, browsers restrict cross-origin HTTP requests initiated within scripts
  • HTTP Header that allows servers to describe the set of origins that are permitted to read that information using a web browser.
  • HTTP requests that can cause side-effects on server's data, browser must pre-flight the request (HTTP OPTIONS method), After approval, the server will send the actual request back to the browser.
  • Allowed Methods:
    • GET
    • HEAD
    • POST
@wichopy
wichopy / webpack-docker-package-conf.json
Created Jul 12, 2018
Connecting webpack dev server to an api hosted locally in a docker container
View webpack-docker-package-conf.json
"proxy": {
"/server": {
"target": "http://0.0.0.0:8080",
"changeOrigin": true
}
}
@wichopy
wichopy / pm2_with_env.sh
Created Jul 1, 2018
PM2 start npm script with environment variables injected.
View pm2_with_env.sh
pm2 start npm --name [process name] -- run [npm script name] ENV_VAR=some_env_var_value
@wichopy
wichopy / redeploy.sh
Created May 1, 2018
Redeploy server war and restart postgres docker container locally.
View redeploy.sh
#!/bin/bash
echo "Stop tomcat";
/Library/Tomcat/bin/shutdown.sh;
echo "Restart postgres container";
#Assuming you have docker, with a postgres container running called local-postgres. The postgres container can be renamed in the docker run command.
docker stop local-postgres;
docker rm local-postgres;
docker run --name local-postgres -e POSTGRES_USER=user -e POSTGRES_DB=db -d -p 5432:5432 postgres;
@wichopy
wichopy / filterString.js
Created Feb 3, 2018
Filter out text strings using regex of a URL.
View filterString.js
// assuming env var
// BASE_URL=www.mydomain.com
removebaseURL = (fullURL) => { // pass in (www.mydomain.com/kittens)
// Allow api calls to handle just the end point (/kittens) or the full URL (www.mydomain.com/kittens)
// by filtering out the base URL if the route contains it.
const reg = new RegExp(process.env.BASE_URL, 'gi');
const match = fullURL.match(r eg)
let endpoint
if (match) {
endpoint = fullURL.split(reg)[1]
@wichopy
wichopy / isolateKeys.js
Last active Jan 9, 2018
Immutable removal of keys from a javascript object using ES6 deconstructing.
View isolateKeys.js
//Avoid annoying immutability bugs by using this nice ES6 deconstructing trick to keep your object immutable.
// example obj
const someObj = {
want: 'this',
need: 'that',
dont: 'wantthis',
forget: 'this'
};
You can’t perform that action at this time.