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
query = "param1=1¶m2=2&offset=3" | |
unless query.empty? | |
# build an Hash based on the query string | |
# we want to build {"param1"=>"1", "param2"=>"2", "offset"=>"3"} | |
temp_params = {} | |
query.split("&").each {|v| temp_params.merge!(Hash[*v.split("=")]) unless (v.split("=").count < 2)} | |
# remove the offset parameter | |
temp_params.delete("offset") | |
# convert the Hash back to a String |
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
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
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
Gem::Specification.new do |s| | |
s.name = 'bang' | |
s.version = '0.1.0' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Jeff Kreeftmeijer' | |
s.email = 'jeff@kreeftmeijer.nl' | |
s.summary = 'Bang!' | |
s.description = 'Bangs existing model methods' | |
s.files = ['bang.rb'] |
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
$("#element").click(function (ev) { | |
if(typeof ev.offsetX === "undefined" || typeof ev.offsetY === "undefined") { | |
var targetOffset = $(ev.target).offset(); | |
ev.offsetX = ev.pageX - targetOffset.left; | |
ev.offsetY = ev.pageY - targetOffset.top; | |
} | |
// now ev.offsetX and ev.offsetY can be used | |
// ... |
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
def query(sql) | |
sql += ';' unless sql.end_with?(';') | |
# api call | |
res = @bq_client.execute( | |
:api_method => @bg_api.jobs.query, | |
:body_object => { "query" => sql }, | |
:timeoutMs => BQ_TIMEOUT, | |
:parameters => { "projectId" => BQ_EPF_PROJECT_ID } | |
) | |
# return result |
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
type SStore struct { | |
Name string | |
Descr string | |
Data map[string]string | |
} |
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
/* load configs. defaults to dev environment. */ | |
func load_environment(e string) bool { | |
var err error | |
if e == "" { | |
e = "dev" | |
} | |
configs, err = sstore.ReadFile("./configs/config_"+e+".sstore") | |
if err != nil { | |
return false | |
} |
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
configs.Data["smtp_host"] |
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" | |
// fibonacci is a function that returns | |
// a function that returns an int. | |
func fibonacci() func() int { | |
n_1, n := -1, 1 | |
return func() int { | |
tmp := n |
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
http://commandcenter.blogspot.pt/2012/06/less-is-exponentially-more.html | |
"In the end of course it came out quite different from either C or C++. More different even | |
than many realize. I made a list of significant simplifications in Go over C and C++: | |
regular syntax (don't need a symbol table to parse) | |
garbage collection (only) | |
no header files | |
explicit dependencies | |
no circular dependencies |