Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / youtube-global-shortcuts.user.js
Last active May 5, 2022 17:27
Makes the YouTube shortcuts work even if the player is not focused. Install Greasemonkey/Tampermonkey first, then click [Raw] to install.
// ==UserScript==
// @name YouTube global shortcuts
// @namespace https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/65e3d6db697636d8e7f1
// @downloadURL https://gist.github.com/stefansundin/65e3d6db697636d8e7f1/raw/youtube-global-shortcuts.user.js
// @version 1.1
// @author Stefan Sundin
// @description Makes the YouTube shortcuts work even if the player is not focused.
// @icon https://www.youtube.com/favicon.ico
// @match https://www.youtube.com/*
@stefansundin
stefansundin / filetime.c
Last active August 29, 2015 14:12
Retrieve and edit file timestamps in Windows.
#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 06:32
Ruby stringified hash.
# 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 / git-nuke
Created August 13, 2015 00:17
Git nuke script to remove specified files from all branches and tags.
#!/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
#!/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$//'`
<?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>
@stefansundin
stefansundin / aws_maintenance_window.rb
Created April 12, 2016 01:15
Convert AWS maintenance window between timezones.
#!/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
@stefansundin
stefansundin / github.rb
Last active May 1, 2016 00:30
Plot GitHub API rate limit usage with gnuplot.
#!/usr/bin/env ruby
# gem install httparty
require "httparty"
trap "SIGINT" do
STDERR.write "\nBye!"
exit 1
end
while true
@stefansundin
stefansundin / background.js
Created May 2, 2016 03:18
WebRequest extension test that changes the response.
// 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 / compile-truecrypt-tails.md
Created May 15, 2016 23:01
Compile truecrypt in tails 2.3

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)