Skip to content

Instantly share code, notes, and snippets.

View mlaflamm's full-sized avatar

Manuel Laflamme mlaflamm

View GitHub Profile
@mlaflamm
mlaflamm / nvm_fix.md
Last active January 4, 2021 14:12 — forked from itsmepetrov/nvm_fix.sh
Fix NVM to use from root (or sudo)

StackOverflow: http://stackoverflow.com/questions/21215059/cant-use-nvm-from-root-or-sudo

Source: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps

The below command seems to fix the problem

n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local

The above command is a bit complicated, but all it's doing is copying whatever version of node you have active via nvm into the /usr/local/ directory (where user installed global files should

@mlaflamm
mlaflamm / README.md
Last active September 12, 2023 20:22
Custom types wrapper for go-jet generator

We love go-jet! We are now using it or migrating it to, in all our projects. This is simply the best go SQL builder we have tried so far. It is type safe thanks to the code generation and the query result mapping is very powerful. As far as we know, this is the only solution that fully supports mapping of LEFT OUTER JOIN out of the box.

We have used straight sql package, sqlx, squirrel with and without sqlx, and more recently sqlboiler. The latter is an ORM rather than an SQL builder but we love the type safety with code generation. Also their null types package is a breeze to work with. But over time, sqlboiler being an ORM, showed its limitations in terms of performance and flexibility.

@mlaflamm
mlaflamm / gist:5fc398ec5f595f1acb455b7b04f25a41
Created December 1, 2016 21:46
Changing Docker's IP Address (Ubuntu 14.04)
sudo vim /etc/default/docker
#Change #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" to DOCKER_OPTS="--bip="192.168.200.1/24"
sudo stop docker
#sudo apt-get install bridge-utils
sudo ip link set dev docker0 down
@mlaflamm
mlaflamm / GetHostname.java
Last active September 1, 2016 20:54
Safe and ugly way to get the hostname in java
public String getFirstHostname() throws Exception {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface nic = networkInterfaces.nextElement();
if (!nic.isLoopback() && nic.isUp()) {
Enumeration<InetAddress> addresses = nic.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement();
if (address instanceof Inet4Address) {
return address.getHostName();