Skip to content

Instantly share code, notes, and snippets.

View markjlorenz's full-sized avatar

Mark Lorenz markjlorenz

View GitHub Profile
@markjlorenz
markjlorenz / .bash_profile
Created June 25, 2013 20:29
Colored BASH prompt, tells you how long it's been since your last commit and the current branch
function minutes_since_last_commit {
Color_Off="\033[0m"
Red="\033[0;31m"
Green="\033[0;32m"
Yellow="\033[0;33m"
git branch &>/dev/null
if [ $? -eq 0 ]; then
now=`date +%s`
last_commit=`git log --pretty=format:'%at' -1`
@markjlorenz
markjlorenz / vim_hints.vim
Last active December 20, 2015 07:39
Vim Mappings
" Run app.js and put the output in a new buffer below the current one
:bel new | r !node app.js
" And map it to ",r"
:map ,r :bel new \| r !node app.js <cr>
" And stop warning me about unsaved data
:map ,r :bel new \| setlocal buftype=nofile \| r !node app.js <cr>
@markjlorenz
markjlorenz / how-to.markdown
Last active March 24, 2022 06:42
Reverse Proxy Tunneling with an amazon EC2. Poor-mans gotomypc, teamviewer, etc.

Reverse Port Tunneling with EC2

Reverse port tunneling is used to give a user outside of a networks firewall accesst to a computer inside the firewall where direct SSH connections aren't allowed. It works by the in-firewall computer SSH'ing to a middleman computer that then forwards incomming SSH connections on a given port to the firewalled computer.

Setup the middleman

  • Get an ubuntu EC2 instance
  • Download it's security keys (both in-firewall and out-firewall computers will need the private key)
  • Setup the security group to allow connections on port 10002
  • SSH into the middleman and add: GatewayPorts yes to /etc/ssh/sshd_config
@markjlorenz
markjlorenz / app.coffee
Created August 19, 2013 04:38
OpenCV in node.js without temp files
# Use the mac's built in webcame to snap a pic, and circle the faces.
# requires (imagesnap)[https://github.com/rharder/imagesnap] be in `/vendor/imagesnap`
# and that you have openCV installed:
# `brew update`
# `brew tap homebrew/science`
# `brew install opencv`
# Ye 'olde requires.
cv = require('opencv')
spawn = require('child_process').spawn
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@markjlorenz
markjlorenz / .vimrc
Created October 5, 2013 15:34
a vimrc
colorscheme vividchalk
set nocompatible
set nobackup
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set indentexpr=
set number
set autoindent
@markjlorenz
markjlorenz / .screenrc
Created October 6, 2013 15:43
screenrc
bind c stuff "screen -X chdir \$PWD; screen^M"
defscrollback 90000 # Use a 30000-line scrollback buffer
escape ^@a # Instead of Control-a, make the escape/command character be Control-space
term screen-256color
CMRotationMatrix rotationMatrixFromGravity(float x, float y, float z)
{
// The Z axis of our rotated frame is opposite gravity
vec3f_t zAxis = vec3f_normalize(vec3f_init(-x, -y, -z));
// The Y axis of our rotated frame is an arbitrary vector perpendicular to gravity
// Note that this convention will have problems as zAxis.x approaches +/-1 since the magnitude of
// [0, zAxis.z, -zAxis.y] will approach 0
vec3f_t yAxis = vec3f_normalize(vec3f_init(0, zAxis.z, -zAxis.y));
@markjlorenz
markjlorenz / fitting.gplot
Last active January 2, 2016 23:49
gnuplot examples
#!/usr/bin/env gnuplot
set datafile separator ","
file="`echo $plot_file`" # make sure to set the $plot_file environment varible first
f(x) = m * x**b # fit to trend matching mx^b
m = 5 # start the 'm' search at 5
b = 2 # start the 'b' search at 2
fit f(x) file via m,b