Skip to content

Instantly share code, notes, and snippets.

if !has('ruby')
finish
endif
" Vim syntax functions
" Language: wordpress_vim
" Maintainer: pedro mg <pedro.mota [at] gmail.com>
" Version: 1.1
" Last Change: 2008 Apr 04
" Remark: Simple functions for vim blogging bundle in ruby.

Keybase proof

I hereby claim:

  • I am pedromg on github.
  • I am pedromg (https://keybase.io/pedromg) on keybase.
  • I have a public key ASAHu8RbaxCP59ycfkQTB4j1U0k8KcF7A2fmQXciodG-two

To claim this, I am signing this object:

@pedromg
pedromg / gist:3045216
Created July 4, 2012 04:10
Rob Pike list of simplifications in Go over C++
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
@pedromg
pedromg / fibonacci_closure.go
Created June 21, 2017 22:44
Fibonacci closure in Golang
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
@pedromg
pedromg / gist:8668430
Created January 28, 2014 14:15
acessing sstore values
configs.Data["smtp_host"]
@pedromg
pedromg / gist:8668335
Last active January 4, 2016 19:39
load environment values
/* 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
}
@pedromg
pedromg / gist:8668302
Last active January 4, 2016 19:38
SStore struct
type SStore struct {
Name string
Descr string
Data map[string]string
}
@pedromg
pedromg / gist:7035908
Created October 18, 2013 03:08
Google API Ruby client, when used for Google BigQuery returns unnamed columns. This new_row_format method solves that, rebuilding the array of hashes with named keys.
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
@pedromg
pedromg / gist:2898946
Created June 9, 2012 01:11
Use of mouse event offsetX and offsetY in Firefox. With jQuery 1.7.2
$("#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
// ...
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']