Skip to content

Instantly share code, notes, and snippets.

Stefan Sundin stefansundin

Block or report user

Report or block stefansundin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stefansundin
stefansundin / git-status-rec
Last active Aug 29, 2015
Execute `git status` recursively.
View git-status-rec
#!/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 / sourceforge-bigger-filename-column.user.js
Last active Aug 29, 2015
Userscript that makes the filename column bigger on SourceForge, because that shit is not responsive.
View sourceforge-bigger-filename-column.user.js
// ==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 / error-handler.php
Last active Aug 29, 2015
Simple PHP error handler mailer.
View error-handler.php
<?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 / google-project-hosting-download-counter.user.js
Last active Aug 29, 2015
Userscript that helps you count the total downloads for your Project Hosting projects.
View google-project-hosting-download-counter.user.js
// ==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==
View keybase.md

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 / indabamusic-download.rb
Last active Aug 29, 2015
Download all remixes from an indabamusic campaign.
View indabamusic-download.rb
# https://gist.github.com/stefansundin/22259d6309f34084cb8e
require 'net/http'
require 'json'
require 'time'
require 'iso_country_codes'
slug = 'infected-mushroom-kipod-remix-contest'
dest = "indabamusic-#{slug}"
@stefansundin
stefansundin / disqus-gadget.xml
Last active Aug 29, 2015
Disqus google gadget embed (note: haven't used this in a long while)
View disqus-gadget.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Disqus embed" author="Stefan Sundin" width="640" height="390"></ModulePrefs>
<UserPref name="shortname" datatype="string" default_value="" />
<UserPref name="id" datatype="string" default_value="" />
<UserPref name="url" datatype="string" default_value="" />
<UserPref name="title" datatype="string" default_value="" />
<UserPref name="width" datatype="string" default_value="" />
<UserPref name="height" datatype="string" default_value="" />
<UserPref name="args" datatype="string" default_value="" />
@stefansundin
stefansundin / filetime.c
Last active Aug 29, 2015
Retrieve and edit file timestamps in Windows.
View filetime.c
#include <stdio.h>
#include <windows.h>
// FILETIME is always UTC. Note that Windows itself will display timestamps in your local timezone, e.g. in the file properties dialog.
// Error codes: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx
// i686-w64-mingw32-gcc -o filetime filetime.c
int main(int argc, char *argv[]) {
if (argc < 2) {
fprintf(stderr, "Usage: filetime <file> [new mtime] ...\n");
@stefansundin
stefansundin / string_hash.rb
Created May 25, 2015
Ruby stringified hash.
View string_hash.rb
# I have been annoyed that hash[:key] != hash["key"], which has caused problems more than once when converting things to Sidekiq jobs, etc.
# This is a major hack, and it is probably not really useful unless you can monkey patch the Hash class, which I didn't succeed with.
# I will have to look into how Rack does the params magic...
class StringHash < Hash
def []=(key, val)
super(key.to_s, val)
end
def [](key)
@stefansundin
stefansundin / svnsync.php
Last active Dec 15, 2015
This is a PHP script that can process PostCommitWebHooks from Google Code Project Hosting.
View svnsync.php
<?php
/*
https://gist.github.com/stefansundin/5224325
https://code.google.com/p/support/wiki/PostCommitWebHooks
To use PHP to verify the authentication hash, you can do this. It supports multiple projects and can also run svnsync. However, this requires you to make your web server user (often 'www-data') to be able to launch svnsync without sudo having to ask for a password:
$ sudo visudo
Then add this to the bottom (it's important that it is in the bottom!):
www-data ALL=(ALL) NOPASSWD:/usr/bin/svnsync
You can’t perform that action at this time.