Skip to content

Instantly share code, notes, and snippets.

View markjlorenz's full-sized avatar

Mark Lorenz markjlorenz

View GitHub Profile
@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
@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 / 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 / .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 / widget.coffee
Created June 14, 2013 18:01
jQuery widget template
jQuery ($)->
$.widget 'yourNamespace.yourPluginName',
options:
_create: ->
$ele = $(@element)
@markjlorenz
markjlorenz / 10-April-2013_PhoneCall.markdown
Created April 11, 2013 13:10
10-April-2013 Meeting Notes
  • On landing page both the email and text should do the same action.

  • Contest page, maybe replace landing page.

  • Focus webpage on contest

    • Author first name, last name
    • Previously publish in including issue
  • Try to implement a story upload on the contest site.

  • Send a story based on some ones' mood "I'm pissed"

  • Themed contest by season, so content is pre-sorted.

@markjlorenz
markjlorenz / vimrc
Last active December 15, 2015 11:39
Let's cargo cult a .vimrc
syntax on
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set indentexpr=
set number
set ai
"for snippets plugin
@markjlorenz
markjlorenz / TattleTale.js
Created December 17, 2012 21:36
Report client side JS errors back to the application
// If you pash an object of the same format as `testCases` it will be merged into test cases
// requires jQuery
var objectSupport = function(additionalObjects){
additionalObjects = typeof additionalObjects !== 'undefined' ? additionalObjects : {};
if(!jQuery){throw new Error("clientJSError requires jQuery");}
//takes an object path, returns true of it's available. For Example:
// >objectSupported("Array.prototype.forEach")
// >false //false in IE7
//
@markjlorenz
markjlorenz / RecursiveAsyncFileRead.coffee
Created October 12, 2012 18:53
Uses Node.js's asynchronous file functions to recrusivly read a directory structure.
app.get "/ls", (req, res)->
path = "."
directoryCount = 0
edges = {} #key only for internal purpose {key:[], key2:[]}
nodes = {} #stores data for nodes
recursiveCalls = 0
nodeId = (path)->
"#{path}"
recursionComplete = ()->
console.log "-- Directory Count: ", directoryCount
@markjlorenz
markjlorenz / AssociativeObject.rb
Created September 20, 2012 12:56
A Ruby Object that Works Like Javascript's Objects. The idea is to make creating/validating non-model based forms easier.
class AssociativeObject
def eigenclass; class << self; self; end; end
#form_for requires these methods
attr_accessor :id
attr_accessor :errors
def new_record?; return true; end
def to_param; return nil; end #for AR object to_param returns nil for new objects
def to_key; id ? [id] : nil end #borrowed from rails source for dummy object
def self.model_name; ActiveModel::Name.new(self); end #how AR determines the name for the params hash. TODO: allow dynamic assignment