Skip to content

Instantly share code, notes, and snippets.

View hugows's full-sized avatar
🏠
Working from home

Hugo Schmitt hugows

🏠
Working from home
View GitHub Profile
davesecretarystillatwork posted this on July 19th, 2007 @ 11:41:59 am
KYLE AND I HAVE A DUMB INSIDE JOKE THAT HAS BEEN WITH US FOR NEARLY FIFTEEN YEARS NOW.
WHENEVER WE WALK BY A LARGE AMOUNT OF YELLOW SNOW ONE OF US HAS TO SAY "I
DON'T KNOW, MAYBE A SQUIRREL PEED THERE".
ALRIGHT SO ONE COLD WINTERY AFTERNOON WHEN I WAS 9 OR 10 KYLE AND I DECIDE TO
ENTERTAIN OURSELF BY GETTING OUR OTHER NEIGHBOR, EVAN, TO DRINK PEE. WE HAVE A
BRILLIANT AND TOTALLY ORIGINAL PLAN WHICH LARGELY INVOLVES TELLING EVAN IT'S
"APPLE JUICE". TO MAKE THINGS SEEM EVEN MORE NATURAL, WE DECIDE TO INVITE HIM
package main
import (
"os/exec"
"strings"
"log"
"time"
"fmt"
)
// [[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)
@hugows
hugows / gist:4997167
Created February 20, 2013 17:11
Trying to use pgfplotstable
\usepackage{pgfplotstable}
\usepackage{booktabs}
% global settings
\pgfplotstableset{
after row={\hline},
every head row/.style={
before row={
\rowcolor{lightgray}
@hugows
hugows / pack_unpack.c
Last active September 12, 2016 13:21
/* 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) {
# 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
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]
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) {
// 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 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)