Skip to content

Instantly share code, notes, and snippets.

@f0ster
f0ster / Guardfile.rb
Last active July 2, 2018 18:39
guard
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
module MethodLogger
def self.included(base)
methods = base.instance_methods(false) + base.private_instance_methods(false)
base.class_eval do
methods.each do |method_name|
original_method = instance_method(method_name)
Rails.logger.info "creating override method for #{method_name} #{base}"
define_method(method_name) do |*args, &block|
Rails.logger.info "-> #{base}##{method_name}(#{args.inspect})"
Rails.logger.info "-- #{block}"
{
"env":
{
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules":
{
"linebreak-style": ["error", "unix"],
@f0ster
f0ster / docker_WSL_volume_hack.sh
Created August 17, 2017 23:19
Using docker volumes in windows linux subsystem
# Docker for Windows/Docker Machine is mounting C:\Users\ of your Windows to //c on the Docker host.
sudo touch /usr/local/bin/docker
sudo chmod +x /usr/local/bin/docker
cat EOF > /usr/local/bin/docker
#!/bin/bash
ARGS=`echo -n "$@" | sed -E 's/\/mnt\/([a-z])\//\/\/\1\//g'`
eval /usr/bin/docker $ARGS
EOF
## great success
@f0ster
f0ster / serverless.invoke.test.js
Created August 9, 2017 00:24
Wrapper to call serverless invokes with mock data, with execution wrapped with promises and tested with mocha
// wire up exec for serverless invokes with mock test data event inputs
require('dotenv').load();
const exec = require('child_process').exec
, assert = require('assert')
const stream = require('stream');
const expect = require('chai').expect;
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
@f0ster
f0ster / history.sh
Created June 11, 2017 21:36
handy bash history command
function h() {
if [ -z "$1" ]
then
history
else
history | grep "$@"
fi
}
@f0ster
f0ster / auth0.go
Last active April 26, 2017 04:18
auth0 jwt go middleware example
func getUserFromRequest(r *http.Request) *model.User {
//Authorization: bearer {token}
//auth0 user is in user
jwtContext := context.Get(r, "user")
auth0Id := ((jwtContext.(*jwt.Token)).Claims).(jwt.MapClaims)["sub"]
user := model.GetUserFromAuthId(auth0Id.(string))
return user
}
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
@f0ster
f0ster / gist:8411998
Created January 14, 2014 02:26
tmux config that allows scrolling up with mouse wheel/pad in osx
set -g mode-mouse on
set-window-option -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf