Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / keybase.md
Created September 21, 2014 20:47
Keybase proof

Keybase proof

I hereby claim:

  • I am stefansundin on github.
  • I am stefansundin (https://keybase.io/stefansundin) on keybase.
  • I have a public key whose fingerprint is 7301 7A35 249F 746F F6FF 91D2 7FA5 D4DA 2764

To claim this, I am signing this object:

@stefansundin
stefansundin / bind.c
Last active September 30, 2023 00:51
Bind programs to specific network interface. (Linux)
/*
https://gist.github.com/stefansundin/e4fce00d97f7694c7a27
http://www.ryde.net/code/bind.c.txt
http://daniel-lange.com/archives/53-Binding-applications-to-a-specific-IP.html
*/
/*
Copyright (C) 2000 Daniel Ryde
This library is free software; you can redistribute it and/or
@stefansundin
stefansundin / google-project-hosting-download-counter.user.js
Last active August 29, 2015 14:06
Userscript that helps you count the total downloads for your Project Hosting projects.
// ==UserScript==
// @name Google Project Hosting total download count
// @namespace https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/5ac159d384d3e4b3a036
// @downloadURL https://gist.github.com/stefansundin/5ac159d384d3e4b3a036/raw/google-project-hosting-download-counter.user.js
// @version 0.1
// @author Stefan Sundin
// @description Adds a total download count to the footer.
// @match *://code.google.com/p/*/downloads/list*
// ==/UserScript==
@stefansundin
stefansundin / error-handler.php
Last active August 29, 2015 14:05
Simple PHP error handler mailer.
<?php
# https://gist.github.com/stefansundin/789cc36ccfc75d0ca243
date_default_timezone_set("Europe/Stockholm");
// edit this function to be notified of script errors by email
function mail_error($error) {
return; // comment this line out and edit this function if you want to use this
$error["timestamp"] = strftime("%Y-%m-%d %T %z");
$error["ip"] = $_SERVER["REMOTE_ADDR"];
@stefansundin
stefansundin / sourceforge-bigger-filename-column.user.js
Last active August 29, 2015 14:04
Userscript that makes the filename column bigger on SourceForge, because that shit is not responsive.
// ==UserScript==
// @name SourceForge bigger filename column
// @namespace https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/f1e81a8f5281f6f4cac4
// @downloadURL https://gist.github.com/stefansundin/f1e81a8f5281f6f4cac4/raw/sourceforge-bigger-filename-column.user.js
// @version 0.2
// @author Stefan Sundin
// @description Makes the filename column bigger, saves you from lots of frustration.
// @match *://sourceforge.net/*/files/*
// ==/UserScript==
@stefansundin
stefansundin / ruby-versions.sh
Last active October 29, 2018 01:16
Script that finds out the ruby versions used in subdirectories, to help you reclaim disk space.
#!/bin/bash
# cd src
# wget https://gist.githubusercontent.com/stefansundin/70400e8b6cb22f7ea7e0/raw/ruby-versions.sh
# chmod +x ruby-versions.sh
# ./ruby-versions.sh
for F in *; do
[[ ! -d "$F" ]] && continue
unset V
@stefansundin
stefansundin / install-pre-push.sh
Last active October 12, 2023 10:33
Git pre-push hook to prevent force pushing the master/main branch.
#!/bin/bash
# This script will install a Git pre-push hook that prevents force pushing the master/main branch.
# There are three variants that I have built:
# - pre-push: prevents force-pushing to master/main.
# - pre-push-2: prevents force-pushing to master/main depending on the remote (you need to edit the file!).
# - pre-push-3: prevents any type of pushing to master/main.
# Set the desired version like this before proceeding:
# FILE=pre-push
# Single repo installation:
@stefansundin
stefansundin / git-status-rec
Last active August 29, 2015 14:03
Execute `git status` recursively.
#!/bin/bash
# Executes `git status` in any git subdirectories you may have in your working directory.
# Install in a directory that's in your PATH, e.g. /usr/local/bin
# cd /usr/local/bin
# wget https://gist.githubusercontent.com/stefansundin/4dbd0c4cfb75ff44ff14/raw/git-status-rec
# chmod +x git-status-rec
# Then go to your project directory and type:
# git status-rec
for F in *; do
@stefansundin
stefansundin / git-bundle-hook.md
Last active February 1, 2024 06:42 — forked from 8bitDesigner/1.md
Git post-checkout and post-merge hooks to simplify bundling and other tasks.

Make bundleing and npm installing easy

These git hooks runs bundle or npm install automatically whenever you:

  • git checkout a new branch with a different Gemfile or package.json.
  • git pull a change to Gemfile or package.json.

How to install

  1. cd awesome_git_repo
@stefansundin
stefansundin / make-chrome-app.sh
Last active August 30, 2022 13:06
Create Chrome apps in Mac OS.
#!/bin/sh
# wget https://gist.githubusercontent.com/stefansundin/c89fd15bae5a58831790/raw/make-chrome-app.sh
# chmod +x make-chrome-app.sh
# ./make-chrome-app.sh
echo "Note that the app will run with a separate data dir and thus not have your regular extensions and settings."
echo
echo "What should the app be called?"
read name
echo