Skip to content

Instantly share code, notes, and snippets.

@mgamba
mgamba / t4-sound-display.ino
Last active June 30, 2020 23:52
Example ino file for using MQSL and MOSI/CS at the same time
// This uses the Adafruit ST7735 tft display and teensy 4.0
// audio out -> teensy pin mappings
/*
+ -> 12
- -> GND
*/
// tft -> teensy pin mappings:
/*
@mgamba
mgamba / glowing-triangle.java
Created July 26, 2018 05:38
glowing triangle spinning around circle for Processing P3
//PGraphics pg;
class Triangle {
private float angle = 0;
Triangle() {
}
void rotate() {
this.angle += 1;
@mgamba
mgamba / sinatra_app.rb
Created June 4, 2016 15:49
file uploader because i'm too lazy to figure out how to make my phone talk to my computer
require 'sinatra'
require 'base64'
set :environment, :production
get '/' do
html = '
<form action="run" method="POST" enctype="multipart/form-data">
<input type="file" name="file" accept="image/*" capture="camera">
<input type="submit" value="Upload image">
@mgamba
mgamba / .vimrc
Last active April 18, 2017 02:48
"vim tab mapping for default autocomplete
:function AutoComplete()
: if len(matchstr(getline('.')[col('.')-2], "[^ \t\n]*$")) > 0
: return "\<C-N>"
: else
: return "\<TAB>"
: endif
:endfunction
inoremap <silent> <TAB> <C-R>=AutoComplete()<CR>
@mgamba
mgamba / fizzbuzz.rb
Created July 6, 2015 19:56
fizzbuzz
1.upto(100){|n|print ((n%3==0&&'FIZZ'||'')+(n%5==0&&'BUZZ'||'')).downcase!||n}
@mgamba
mgamba / .git-completion.bash
Created March 21, 2015 16:45
git completion script
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@mgamba
mgamba / .vimrc
Last active August 29, 2015 14:08
execute pathogen#infect()
syntax on
filetype plugin indent on
let g:solarized_termcolors = 256
let g:solarized_termtrans = 1
syntax enable
set background=dark
colorscheme solarized
@mgamba
mgamba / .bash_profile
Created October 16, 2014 21:26
.bash_profile
# bash
PS1="\w: "
alias sadface='echo -e " /^^^^^^^\\ \n/ /. .\\ \\ \n| , |\n| D |\n| ___ |\n \\ / \\ / \n \\_____/ "'
alias reload="source ~/.bashrc && echo reloaded bash"
alias sp="reload"
alias dtree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'"
export HISTFILESIZE=3000
alias now="date +'%Y%m%d%H%M%S'"
alias ts="now | tr '\n' '\000' | pbcopy"
require 'sinatra'
use Rack::CommonLogger
use Rack::Logger
require 'json'
post '/hi/there' do
request.logger.info JSON.pretty_generate(request.env)
"success\n"
end
require 'rack-proxy'
require 'rack'
RemoteHostForName = {
'simple' => "localhost:4567"
}
class ExternalProxy < Rack::Proxy
def rewrite_env(env)
#request = Rack::Request.new(env)