Skip to content

Instantly share code, notes, and snippets.

View mtso's full-sized avatar
shipping

Matthew mtso

shipping
View GitHub Profile
@mtso
mtso / simple-promise.rb
Last active July 13, 2018 15:31
Quick and dirty promise. Must call .then and .catch to wait for the async thread to join and finish.
class Promise
def initialize(&cb)
@thread = Thread.new {
cb.call(
lambda {|result| resolve(result)},
lambda {|error| reject(error)}
)
}
end
@mtso
mtso / effective-rust-types.md
Created June 6, 2018 05:11
Basic Rust types to know for more effective, idiomatic Rust programming.
@mtso
mtso / install-minikube.md
Created May 31, 2018 02:43
Install minikube, hyperkit driver, kubectl
curl -LO https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-hyperkit \
&& chmod +x docker-machine-driver-hyperkit \
&& sudo mv docker-machine-driver-hyperkit /usr/local/bin/ \
&& sudo chown root:wheel /usr/local/bin/docker-machine-driver-hyperkit \
&& sudo chmod u+s /usr/local/bin/docker-machine-driver-hyperkit
brew install kubectl minikube
- proxy for links
- human-memorable gist (like cp.glitch.me)
- tallybox in rust
-

For SSH: (need SSH public key copied into ~/git-server/keys folder)

jkarlos/git-server-docker

For HTTP:

cirocosta/gitserver-http

@mtso
mtso / yarn-fill-cache.sh
Last active April 21, 2018 05:22
Fill yarn's cache for offline working.
#!/bin/bash
yarn add \
express koa body-parser express-session dotenv multer ejs \
winston morgan helmet \
react react-dom react-router-dom history redux react-redux mobx mobx-react redux-thunk \
redux-devtools redux-logger \
react-swipeable \
webpack webpack-dev-server \
babel-core babel-loader babel-jest babel-plugin-syntax-jsx babel-preset-env @babel/core \
@mtso
mtso / api-docs.css
Last active April 10, 2018 07:59
CSS inspired by glitch.com's boilerplate style.
/* styles */
/* called by your view template */
/* You might want to try something fancier: */
/* less: http://lesscss.org/ */
* {
box-sizing: border-box;
}
@mtso
mtso / promisify.js
Created March 28, 2018 06:32
Implement promisify from first-principles.
const promisify = (fn) => function() {
const args = Array.prototype.slice.call(arguments);
return new Promise((resolve, reject) => {
// Access resolve/reject.
function callback() {
const results = Array.prototype.slice.call(arguments);
if (results[0]) {
reject(results[0]);
@mtso
mtso / Hello.jsx
Last active March 26, 2018 01:47
Inject props with a higher-order component by defining propTypes.
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import inject from './injector';
class Hello extends PureComponent {
render() {
const name = this.props.nameService.getName();
return (
<div>Hello, { name }</div>
);
#!/usr/bin/env ruby
# Generates bcrypt password
# USAGE
#
# $ ./genpass.sh
# Password:
#
# or (also sets password for user in .credentials.json)
#