Skip to content

Instantly share code, notes, and snippets.

@uraimo
uraimo / sp-bootstrap2.css
Created November 13, 2014 15:06
Bootstrap 2 theme for bgrins/spectrum color picker button
.sp-boot2.sp-replacer {
margin:0;
overflow:hidden;
cursor:pointer;
padding: 4px;
display:inline-block;
*zoom: 1;
*display: inline;
border: solid 1px #dddddd;
background: #eee;
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
@uraimo
uraimo / jekyll3.diff
Created November 19, 2015 10:58
Diff of some required modifications for my site from jekyll 2.5.x to 3.x
diff --git a/Gemfile b/Gemfile
index f25308a..4b32b39 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ source "http://rubygems.org"
gem 'rake'
gem 'jekyll'
+gem 'jekyll-paginate'
gem 'rdiscount'
@uraimo
uraimo / maps.go
Created June 2, 2013 09:46
A Tour of Go: Maps Exercise solution w/o strings.Fields
package main
import (
"code.google.com/p/go-tour/wc"
)
func WordCount(s string) map[string]int {
res := make(map[string]int);
str := make([]rune,0,10)
for _, r := range(s){
@uraimo
uraimo / fibonacci_closure.go
Created June 2, 2013 09:38
A Tour of Go: Fibonacci closure solution
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a,b := 0,1
return func() int{
res := a
@uraimo
uraimo / slices.go
Last active December 17, 2015 23:59
A Tour of Go: Slices exercise answer , added a factorial for a better picture
package main
import "code.google.com/p/go-tour/pic"
func Fact(x uint8) uint8 {
if x>1 {
return x * (x-1)
}
return x+1
}
@uraimo
uraimo / images.go
Created June 6, 2013 12:15
A Tour of Go #59: Images Exercise
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
func Sqrt(f int) int {
var z int = 1
@uraimo
uraimo / rot13_reader.go
Last active December 18, 2015 03:58
A Tour of Go: Rot13 Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@uraimo
uraimo / binary_tree_equal.go
Created June 7, 2013 14:26
A Tour Of Go: Equivalent Binary Trees
package main
import (
"fmt"
"code.google.com/p/go-tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int){
@uraimo
uraimo / notreallya_crawler.go
Last active December 18, 2015 07:58
A Tour Of Go: Web Crawler
package main
import (
"fmt"
"sync"
)
type StringArray []string
var urlmap StringArray= make([]string,1)