Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / google-code-archive.rb
Created Aug 10, 2016
Export data from google-code-archive.
View google-code-archive.rb
#!/usr/bin/env ruby
# https://code.google.com/archive/schema
# https://storage.googleapis.com/google-code-archive/v2/code.google.com/altdrag/project.json
require "httparty"
class CodeParty
include HTTParty
base_uri "https://storage.googleapis.com/google-code-archive/v2/code.google.com"
@stefansundin
stefansundin / Gemfile
Last active Aug 10, 2016
Use rack to host a static website.
View Gemfile
source "https://rubygems.org"
gem "rack"
@stefansundin
stefansundin / manifest.json
Last active Jan 15, 2017
Replace YouPlay videos with YouTube on sweclockers.com
View manifest.json
{
"name": "SweClockers YouTube embed",
"version": "1.1",
"description": "Trött på dålig videospelare?",
"content_scripts": [
{
"matches": ["*://www.sweclockers.com/*"],
"js": ["replace.js"],
"run_at": "document_end"
}
@stefansundin
stefansundin / compile-truecrypt-tails.md
Created May 15, 2016
Compile truecrypt in tails 2.3
View compile-truecrypt-tails.md

compile truecrypt in tails 2.3

sudo apt-get install git build-essential devscripts debhelper pkg-config libgtk2.0-dev libfuse-dev nasm libappindicator-dev bash-completion
sudo apt-get install fakeroot

remove $(LIBS) from Main.make line 108 i.e. result: $(APPNAME): $(OBJS)

@stefansundin
stefansundin / background.js
Created May 2, 2016
WebRequest extension test that changes the response.
View background.js
// The subsequent requests for the videofiles fails, but it was fun to test.
// http://www.oppetarkiv.se/
// https://developer.chrome.com/extensions/webRequest
chrome.webRequest.onBeforeRequest.addListener(
function(info) {
console.log(`Intercepted ${info.url}`);
return {redirectUrl: 'data:application/json,{"inSweden":true}'};
},
{
@stefansundin
stefansundin / github.rb
Last active May 1, 2016
Plot GitHub API rate limit usage with gnuplot.
View github.rb
#!/usr/bin/env ruby
# gem install httparty
require "httparty"
trap "SIGINT" do
STDERR.write "\nBye!"
exit 1
end
while true
@stefansundin
stefansundin / aws_maintenance_window.rb
Created Apr 12, 2016
Convert AWS maintenance window between timezones.
View aws_maintenance_window.rb
#!/usr/bin/env ruby
def offset_maintenance_window(w, offset=-7)
days = %w[mon tue wed thu fri sat sun]
if /(?<day_start>[a-z]{3}):(?<hour_start>\d\d):(?<minute_start>\d\d)-(?<day_end>[a-z]{3}):(?<hour_end>\d\d):(?<minute_end>\d\d)/ =~ w
day_start = days.find_index(day_start)
day_end = days.find_index(day_end)
hour_start = hour_start.to_i + offset
minute_start = minute_start.to_i
hour_end = hour_end.to_i + offset
View Download and merge HTTP Live Streaming .ts files
<?php
/*
Made by Kudusch (blog.kudusch.de, kudusch.de, @Kudusch)
---------
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
View git-open
#!/bin/bash
# https://gist.github.com/stefansundin/2d91d45580763cda29af
# Easily open a repo in a browser, just run `git open`
# Linux users need to change "open" to "xdg-open".
# Example installation instructions:
# curl -fL -o /usr/local/bin/git-open https://gist.githubusercontent.com/stefansundin/2d91d45580763cda29af/raw/git-open
# chmod +x /usr/local/bin/git-open
ORIGIN=`git config --get remote.origin.url | sed -e 's/\.git$//'`
@stefansundin
stefansundin / git-nuke
Created Aug 13, 2015
Git nuke script to remove specified files from all branches and tags.
View git-nuke
#!/bin/bash
set -o errexit
# BE VERY CAREFUL USING THIS SCRIPT. MAKE A BACKUP (OR TWO) FIRST WITH:
# git clone --mirror ...
# Install by putting this file in e.g. /usr/local/bin/git-nuke
# chmod +x /usr/local/bin/git-nuke
if [ $# -eq 0 ]; then