This file contains hidden or 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
startup_message off | |
hardstatus on | |
hardstatus alwayslastline | |
hardstatus string "%{.bW}%-w%{..G}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a" |
This file contains hidden or 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
// This is a helper function to make Go work with https://github.com/marmelab/admin-on-rest parameters | |
// a little bit easier. | |
func QueryBuilder(tableName string, cols string, query url.Values) (string, error) { | |
// only match string like `name`, `users.name` | |
var columnRegexp = regexp.MustCompile("^[a-zA-Z\\d]+(\\.[a-zA-Z\\d]+)*$") | |
baseQuery := fmt.Sprintf("SELECT %s FROM %s", cols, tableName) | |
colsMap := make(map[string]bool) |
This file contains hidden or 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
// A slower insert that is faster to type. | |
func (db *DB) ReflectInsert(tablename string, obj interface{}) error { | |
base := "INSERT INTO %s(%s) VALUES (%s)" | |
count := 1 | |
var columns []string | |
var placeholders []string | |
var vals []interface{} | |
v := reflect.ValueOf(obj).Elem() | |
t := v.Type() |
This file contains hidden or 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 AppResponse struct { | |
Error error `json:"-"` | |
Code int `json:"code,omitempty"` | |
Message string `json:"message,omitempty"` | |
Data interface{} `json:"data,omitempty"` | |
} | |
type apiHandler func(w http.ResponseWriter, r *http.Request) AppResponse | |
func (handler apiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
This file contains hidden or 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
hugo@hp ~/play/ktor-ktor-0.3.3/ktor-samples/ktor-samples-hello $ mvn exec:java -Pexec-netty | |
[INFO] Scanning for projects... | |
[WARNING] | |
[WARNING] Some problems were encountered while building the effective model for org.jetbrains.ktor:ktor-samples-hello:jar:0.3.3 | |
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. @ org.jetbrains.ktor:ktor-samples:[unknown-version], /home/hugo/play/ktor-ktor-0.3.3/ktor-samples/pom.xml, line 65, column 21 | |
[WARNING] | |
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. | |
[WARNING] | |
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. | |
[WARNING] |
This file contains hidden or 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
# Precisei disto no Linux Mint 18.1 Serena | |
# (http://www.andersonlfeitosa.com/2014/10/cedilha-no-linux-mint-17-com-teclado-americano.html) | |
sudo bash | |
sed -i "s/az:ca:co:fr:gv:oc:pt:sq:tr:wa/az:ca:co:fr:gv:oc:pt:sq:tr:wa:en/" /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache | |
sed -i "s/az:ca:co:fr:gv:oc:pt:sq:tr:wa/az:ca:co:fr:gv:oc:pt:sq:tr:wa:en/" /usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules.cache | |
sed -i "s/ć/ç/g" /usr/share/X11/locale/en_US.UTF-8/Compose | |
sed -i "s/Ć/Ç/g" /usr/share/X11/locale/en_US.UTF-8/Compose | |
echo "GTK_IM_MODULE=cedilla" >> /etc/environment | |
echo "QT_IM_MODULE=cedilla" >> /etc/environment |
This file contains hidden or 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
/* from http://number-none.com/product/Packing%20Integers/index.html */ | |
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
static uint32_t m_accumulator = 0; | |
static char m_buffer[17]; | |
char* to_bitstring(uint32_t val, char buffer[], int size) { |
This file contains hidden or 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
Originally: https://gist.github.com/vurtun/8da6c0ec7820ec002044579f84547a2e | |
LIBRARY WRITING REFERENCE LIST | |
=============================== | |
1.) Designing and Evaluating Reusable Components (Casey Muratori: http://mollyrocket.com/casey/stream_0028.html) | |
---------------------------------------------------------------------------------------------------------------- | |
_THE_ reference on API design up to this day on the internet. Nobody should write a library without having seen this. | |
I come back to this talk every N number of weeks it is that good. | |
2.) stb_howto (Sean Barrett: https://github.com/nothings/stb/blob/master/docs/stb_howto.txt) |
This file contains hidden or 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
// [[a b] [c d]] -> [[a c] [a d] [b c] [b d]] | |
func combinations(path []int, sets [][]int, acc *[][]int) { | |
if len(sets) == 0 { | |
*acc = append(*acc, path) | |
} else { | |
for _, el := range sets[0] { | |
path := append(path, el) | |
np := make([]int, len(path)) | |
copy(np, path) | |
combinations(np, sets[1:], acc) |
This file contains hidden or 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 ( | |
"os/exec" | |
"strings" | |
"log" | |
"time" | |
"fmt" | |
) |