This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ "net/http/pprof" | |
// If the app is not running an http server, one needs to start one: | |
go func() { | |
log.Println(http.ListenAndServe("localhost:8000", nil)) | |
}() | |
// Or else/then its just point the browser to: | |
// http://ip:port/debug/pprof/</code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Person struct { | |
Name string | |
age int // not Exported | |
} | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package payment | |
import ( | |
"fmt" | |
"appengine" | |
"appengine/urlfetch" | |
"github.com/stripe/stripe-go" | |
"github.com/stripe/stripe-go/currency" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# I deliberately didn't DRY /usr/local references into a variable as this | |
# script will not "just work" if you change the destination directory. However | |
# please feel free to fork it and make that possible. | |
# | |
# If you do fork ensure you add a comment here that explains what the changes | |
# are intended to do and how well you tested them. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
require 'dm-postgres-adapter' | |
require 'adapter.rb' # local; patched | |
require 'comparison.rb' # local; patched | |
require 'symbol.rb' | |
#require 'dm-migrations' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'postgres://user:password@localhost/database') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DataMapper | |
module Model | |
# update_or_create method: finds and updates, or creates; | |
# merger is a boolean that determines if the conditions are merged with the attributes upon create; | |
# merge = true => merges conditions to attributes and passes the merge to the create method | |
# merge = false => only attributes are passed into the create method | |
def update_or_create(conditions = {}, attributes = {}, merger = true) | |
(first(conditions) && first(conditions).update(attributes)) || create(merger ? (conditions.merge(attributes)) : attributes ) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
## | |
# == remember: | |
# * insert your login and password at Line 100, and save this file. | |
# * of couse, be very carefull if you send this to a friend... REMOVE your credentials first! | |
# * if you are using Google Hosted for your Domain (Google Apps), your_login is something like: me@mydomain.com | |
# * example: go = GoGmail.new($*[0], 'imap.gmail.com', 993, $*[1], 'tree@forest.org', 'littlebird', $*[2]) | |
# | |
# == usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DataMapper | |
module Model | |
# update_or_create method: finds and updates, or creates; | |
# -upon create, returns the object | |
# -upon update, returns the object (by default, returned True) | |
# @param[Hash] Conditions hash for the search query. | |
# @param[Hash] Attributes hash with the property value for the update or creation of a new row. | |
# @param[Boolean] Merger is a boolean that determines if the conditions are merged with the attributes upon create. | |
# If true, merges conditions to attributes and passes the merge to the create method; | |
# If false, only attributes are passed into the create method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# PS1 magic | |
# | |
# Mostly copied from YUVAL KOGMAN version, added my own __git_ps1 stuff | |
# Original: http://gist.github.com/621452 | |
# | |
# See video demo of this at http://vimeo.com/15789794 | |
# | |
# To enable save as .bash_prompt in $HOME and add to .bashrc: |
OlderNewer