Skip to content

Instantly share code, notes, and snippets.

View jveillet's full-sized avatar

Jérémie Veillet jveillet

View GitHub Profile
@candlerb
candlerb / go-project-layout.md
Last active April 24, 2024 19:22
Suggestions for go project layout

If someone asked me the question "what layout should I use for my Go code repository?", I'd start by asking back "what are you building: an executable, or a library?"

Single executable

Stage 1: single source file

Create a directory named however you want your final executable to be called (e.g. "mycommand"), change into that directory, and create the following files:

@ireade
ireade / sw.js
Last active May 28, 2024 19:17
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@Karreg
Karreg / docker-cleanup.sh
Last active October 28, 2020 07:08
Script to cleanup Docker leftovers, related to https://github.com/moby/moby/issues/22207
#!/bin/bash
echo "WARN: This will remove everything from docker: volumes, containers and images. Will you dare? [y/N] "
read choice
if [ \( "$choice" == "y" \) -o \( "$choice" == "Y" \) ]
then
sudo echo "> sudo rights [OK]"
sizea=`sudo du -sh /var/lib/docker/aufs`
@maxrimue
maxrimue / semver.sh
Created July 24, 2015 15:36
Compare semantic versions in pure bash
#!/bin/bash
# Assume we have two semantic versions that we want to compare:
version1=0.12.0
version2=1.15.5
# First, we replace the dots by blank spaces, like this:
version1=${version1//./ }
@jonathanhle
jonathanhle / gist:1fea2935737451721ae1
Created April 25, 2015 23:49
Rebase babun after installing packages, when you get memory conflicts
1) Exit babun.
2) cmd /c %SYSTEMDRIVE%\Users\%USERNAME%\.babun\cygwin\bin\dash.exe -c '/usr/bin/rebaseall -v'
@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: