Skip to content

Instantly share code, notes, and snippets.

🙊
Focusing

John Bunting codingjester

  • twitter
View GitHub Profile
View hello.py
print "Hello World."
@codingjester
codingjester / delete_merged_branches.sh
Last active Aug 29, 2015
Deleting merged branches
View delete_merged_branches.sh
git branch --merged | grep -v "master" | xargs git branch -d
@codingjester
codingjester / app.go
Created Sep 1, 2014
Well, Now we're getting complicated. Hardcoded values for a database are kinda useless right? Lets load some JSON configs.
View app.go
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 Sep 1, 2014
Building on Hello World. Lets add a Database connection to MySQL
View app.go
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 Sep 1, 2014
Simple Hello World Golang Web Application
View app.go
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
@codingjester
codingjester / awesome.sh
Created Aug 22, 2014
Awk one-liner for grabbing haproxy requests (using httplog) longer than 1 second.
View awesome.sh
# You can change 1000 to whatever you want
awk '{n=split($8, b,"/"); if(b[n] >= 1000) print}' your_haproxy_log.log
@codingjester
codingjester / globby.rb
Created Apr 2, 2014
Example File globbing for the path you want
View globby.rb
def job_files(path=".")
Dir.glob("#{path}/**/*").select { |path| File.file?(path) }
end
puts job_files("ok")
@codingjester
codingjester / etrade.rb
Created Aug 28, 2013
Scraping the totalMarketValue of your E*Trade account. Probably could be better. You pass in your username/password as arguments to the script.
View etrade.rb
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
View tumblrjsonp.js
jQuery.getJSON(
'http://api.tumblr.com/v2/blog/codingjester.tumblr.com/posts?api_key=<api_key>&jsonp=?',
function(d) {
console.log(d);
});
You can’t perform that action at this time.