Skip to content

Instantly share code, notes, and snippets.

@maugre
maugre / watcher.sh
Last active December 11, 2017 16:11
Rebuild a Go project when a code change is detected.
#!/usr/bin/env bash
P=`pwd`
BUILDNAME=/tmp/${P##*/}-build
function goRun() {
echo "-- Building..."
## Build new binary
go build -i -o $BUILDNAME ./cmd/frontend/*.go
@maugre
maugre / log.go
Created May 30, 2016 12:26 — forked from Tantas/log.go
Apache access logs for golang.
import (
"fmt"
"io"
"net/http"
"strings"
"time"
)
// https://httpd.apache.org/docs/2.2/logs.html#combined + execution time.
const apacheFormatPattern = "%s - - [%s] \"%s %s %s\" %d %d \"%s\" \"%s\" %.4f\n"
@maugre
maugre / sassc-watcher.xml
Created June 25, 2015 11:05
SassC watcher for PhpStorm
<?xml version="1.0" encoding="UTF-8"?>
<TaskOptions>
<TaskOptions>
<option name="arguments" value="-I ~/Software/compass-mixins-master/lib/ scss/$FileName$ css/$FileNameWithoutExtension$.css" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" value="Compiles .scss files into .css files using SassC" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="scss" />
<option name="immediateSync" value="false" />
<option name="name" value="sassc compass" />
## Get the size of the image file using Lua.
## Cf. http://wiki.nginx.org/HttpLuaModule#set_by_lua.
location ~* \.(?:gif|jpe?g|png)$ {
set_by_lua $img_file_size '
function fsize (file)
local current = file:seek() -- get current position
local size = file:seek("end") -- get file size
file:seek("set", current) -- restore position
return size
end
@maugre
maugre / 0_reuse_code.js
Created April 26, 2014 17:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console