Skip to content

Instantly share code, notes, and snippets.

package main
import (
"github.com/codegangsta/martini"
"github.com/codegangsta/martini-contrib/binding"
"github.com/codegangsta/martini-contrib/render"
"labix.org/v2/mgo"
)
type Wish struct {
@alehano
alehano / gist:11144804
Last active August 29, 2015 14:00
Random string in Go
import (
"crypto/rand"
)
func randString(n int) string {
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var bytes = make([]byte, n)
rand.Read(bytes)
for i, b := range bytes {
@alehano
alehano / gist:11302364
Last active August 29, 2015 14:00
Responsive CSS
/*
Depend of screen size it adds to all element with class "scr", additional class (e.g. "scr-sm").
In a css file you can define representation of elements for different devices.
CSS e.g.
element.scr-xs {
... style for mobile phones
}
*/
function viewport() {
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/iconsets/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<link rel="import" href="../core-menu/core-submenu.html">
@alehano
alehano / Bootstrap align responsive
Last active August 29, 2015 14:17
Bootstrap align responsive
/*
* Responsive text aligning
* http://ohryan.ca/2014/08/14/set-responsive-text-alignment-bootstrap-3/
*/
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
@alehano
alehano / gist:3729edd107c752935237
Last active August 29, 2015 14:18
Sublime text move cursor with CTRL+JLIKUO
[
{ "keys": ["ctrl+l"], "command": "move_to", "args": {"to": "hardeol", "extend": false} },
{ "keys": ["ctrl+j"], "command": "move_to", "args": {"to": "hardbol", "extend": false} },
{ "keys": ["ctrl+i"], "command": "line_jumper", "args": { "number_of_lines": 10, "cmd": "up" } },
{ "keys": ["ctrl+shift+i"], "command": "line_jumper", "args": { "number_of_lines": 10, "cmd": "up_select" } },
{ "keys": ["ctrl+k"], "command": "line_jumper", "args": { "number_of_lines": 10, "cmd": "down" } },
{ "keys": ["ctrl+shift+k"], "command": "line_jumper", "args": { "number_of_lines": 10, "cmd": "down_select" } },
@alehano
alehano / gist:fe96934a7f7d421f3e76
Created January 12, 2016 07:40
Stop / remove all Docker containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@alehano
alehano / gist:db216ee27b421e4a11b4
Created July 31, 2014 06:45
Http Handler auth decorator
package main
import (
"fmt"
"net/http"
)
const (
//user_is_authenticated = false
user_is_authenticated = true
@alehano
alehano / gist:11167317
Last active February 22, 2018 08:34
Golang observer pattern
package main
import (
"container/list"
"fmt"
)
type Observer interface {
Update()
}
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")