Skip to content

Instantly share code, notes, and snippets.

View mtso's full-sized avatar
shipping

Matthew mtso

shipping
View GitHub Profile
@mtso
mtso / goto_project_root.sh
Last active March 17, 2018 03:00
Recursively finds the project directory root from within a subdirectory.
#!/bin/bash
# Set FLAG_FILE to the project metadata file.
# Ex: package.json, Gemfile, requirements.txt, etc.
FLAG_FILE=${FLAG_FILE:-package.json}
NOTFOUND_MESSAGE="Reached system root / and couldn't find package.json"
goto_project_root() {
if [ -f $FLAG_FILE ]; then
# do something
@mtso
mtso / echo.py
Created March 8, 2018 01:45
gunicorn simple JSON echo server.
"""
Usage:
$ pip install gunicorn
$ gunicorn --workers 4 echo:app
Notes:
gunicorn spawns new processes for each worker,
which means the count incrementer variable is
unique for each worker. Use 1 worker to watch
the count increment linearly.
new Promise((resolve, reject) => {
if (ok) {
resolve('Some success message');
} else {
reject('Error message');
}
})
.then(console.log)
.catch(console.error);
[
{
"year": 1753,
"month": 1,
"variance": -1.366
},
{
"year": 1753,
"month": 2,
"variance": -2.223
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
[
{
"year": 1753,
"month": 1,
"variance": -1.366
},
{
"year": 1753,
"month": 2,
"variance": -2.223
import { Component } from 'react';
// CleanComponent wraps Component to provide a middleman
// that passes only the specified PropTypes to the parent.
// This makes it easier to just pass all props down to
// children and not worry about overriding props.
// E.x.:
//
// render() {
// const { props } = this;
Promise.allKeys = function(table) {
const keys = Object.keys(table);
const promises = keys.map((k) => table[k]);
return Promise.all(promises).then((array) => {
return keys.reduce((results, k, i) => {
results[k] = array[i];
return results;
}, {});
});
var imgs = document.getElementsByTagName('img'); for (let i = 0; i < imgs.length; i++) { console.log(imgs[i].getAttribute('src')); }
@mtso
mtso / hotkeys.md
Last active January 23, 2018 22:10

gdb:

Crtl + x, Crtl + 2 to cycle through windows

Crtl + x, Crtl + 1 to go back

Crtl + a to open tui mode

Crtl + l to repaint the curses screen.

---
apiVersion: v1
kind: Namespace
metadata:
name: emojivoto
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: emoji-svc