Skip to content

Instantly share code, notes, and snippets.

@elwinar
elwinar / nilscan.go
Last active August 29, 2015 14:01
Proof of Concept: scan to pointer in go
package sqlx
import (
"bytes"
"database/sql"
"fmt"
"reflect"
"strconv"
"strings"
)
@elwinar
elwinar / translit.sql
Created September 16, 2014 08:43
MySQL Utils
DROP FUNCTION IF EXISTS `translit`;
DELIMITER //
CREATE FUNCTION `translit`(`str` TEXT)
RETURNS text
LANGUAGE SQL
DETERMINISTIC
NO SQL
SQL SECURITY INVOKER
COMMENT ''
BEGIN
@elwinar
elwinar / gitconfig
Last active August 29, 2015 14:11
Elwinar's git configuration
[alias]
lo = log --graph --pretty=format:'%C(red)%h%C(reset) -%C(yellow)%d%C(reset) %s %C(green)(%an) %C(blue)<%cr>%C(reset)'
st = status
co = checkout
up = pull
ci = commit
br = branch
hunt = log --diff-filter=A --
[color]
ui = true
@elwinar
elwinar / gist:c8658987699e62ee201b
Created March 17, 2015 08:16
DEB Packaging Script
#! /bin/bash
echo "DEB Packaging Tool"
# Create a temp directory
root=`mktemp -d /tmp/pkg.XXXXX`
echo "Creating temporary directory $root"
# Reproduce the tree in the temp directory
for dir in `find deb/ -type d -print`
[[ $- != *i* ]] && return
PS1="\[$(tput bold)\]\[$(tput setaf 3)\]\t \[$(tput setaf 2)\]\w\[$(tput setaf 4)\] \\$ \[$(tput sgr0)\]"
source ~/.bin/git-completion
source ~/.bin/sagent
{ sshagent_init; ssh-add; } &> /dev/null
alias ls="ls --color=auto"

Keybase proof

I hereby claim:

  • I am elwinar on github.
  • I am elwinar (https://keybase.io/elwinar) on keybase.
  • I have a public key ASB_Jbc3PNKxo7cWC4bIoxSY8iUikx9VjBS_ARLxMu-uGwo

To claim this, I am signing this object:

@elwinar
elwinar / snake.go
Created November 18, 2014 11:30
ToSnake function for golang, convention-compliant
package main
import (
"unicode"
)
// ToSnake convert the given string to snake case following the Golang format:
// acronyms are converted to lower-case and preceded by an underscore.
func ToSnake(in string) string {
runes := []rune(in)
@elwinar
elwinar / clip
Created February 13, 2015 09:03
Shortcut to pipe from and to clipboard using xclip
#!/bin/bash
# Linux version
# Use this script to pipe in/out of the clipboard
#
# Usage: someapp | clip # Pipe someapp's output into clipboard
# clip | someapp # Pipe clipboard's content into someapp
#
if command -v xclip 1>/dev/null; then
if [[ -p /dev/stdin ]] ; then