Skip to content

Instantly share code, notes, and snippets.

View codingjester's full-sized avatar
🙊
Focusing

codingjester

🙊
Focusing
View GitHub Profile
@codingjester
codingjester / hello.py
Created December 19, 2014 21:55
oh spit.
print "Hello World."
@codingjester
codingjester / delete_merged_branches.sh
Last active August 29, 2015 14:09
Deleting merged branches
git branch --merged | grep -v "master" | xargs git branch -d
@codingjester
codingjester / app.go
Created September 1, 2014 01:15
Well, Now we're getting complicated. Hardcoded values for a database are kinda useless right? Lets load some JSON configs.
var config *Configuration // A global we'll reuse for the application
// Defining the structure of the JSON as we'll expect it
type Configuration struct {
Port int // Port the app is served on
Db_Type string
Db_Username string
Db_Password string
Db_Host string
DB string
@codingjester
codingjester / app.go
Created September 1, 2014 00:59
Building on Hello World. Lets add a Database connection to MySQL
package main
import (
"database/sql" // Needs the mysql driver so we can connect to the DB.
"net/http"
"log"
_ "github.com/go-sql-driver/mysql" // Importing mysql driver for its side-effects, no implicit use
"github.com/gorilla/mux"
)
@codingjester
codingjester / app.go
Created September 1, 2014 00:48
Simple Hello World Golang Web Application
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
@codingjester
codingjester / awesome.sh
Created August 22, 2014 14:22
Awk one-liner for grabbing haproxy requests (using httplog) longer than 1 second.
# You can change 1000 to whatever you want
awk '{n=split($8, b,"/"); if(b[n] >= 1000) print}' your_haproxy_log.log
.johnny .cant .touch .this {
align: left;
}
@codingjester
codingjester / globby.rb
Created April 2, 2014 15:42
Example File globbing for the path you want
def job_files(path=".")
Dir.glob("#{path}/**/*").select { |path| File.file?(path) }
end
puts job_files("ok")
@codingjester
codingjester / etrade.rb
Created August 28, 2013 13:55
Scraping the totalMarketValue of your E*Trade account. Probably could be better. You pass in your username/password as arguments to the script.
require 'mechanize'
a = Mechanize.new
a.get('https://us.etrade.com/home') do |page|
mypage = page.form_with(:action => '/login.fcc') do |f|
f.USER = ARGV[0]
f.PASSWORD = ARGV[1]
end.click_button
jQuery.getJSON(
'http://api.tumblr.com/v2/blog/codingjester.tumblr.com/posts?api_key=<api_key>&jsonp=?',
function(d) {
console.log(d);
});