Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / altdrag-toggle.ahk
Created Jun 8, 2017
Press Ctrl+Alt+A to toggle AltDrag. Compile with AutoHotKey: https://www.autohotkey.com/
View altdrag-toggle.ahk
; Press Ctrl+Alt+A to toggle AltDrag
; 0x111 = WM_COMMAND
; 0x8000+1 = SWM_TOGGLE https://github.com/stefansundin/altdrag/blob/8547fc8ea13829af712586558851b9ed50ae23e8/altdrag.c#L27
DetectHiddenWindows, on
^!a::
SendMessage, 0x111, 0x8000+1, 0,, ahk_class AltDrag
return
@stefansundin
stefansundin / download-slack-emoji.sh
Last active Sep 18, 2020
Download all of your Team's custom Slack emojis.
View download-slack-emoji.sh
#!/bin/bash -eo pipefail
# Log in to Slack in a web browser and open the network tools to inspect the traffic.
# Filter the requests with "/api/" and pick one to inspect. Click on the Headers tab and scroll down to see the request details.
# You need the xoxc token from the request body, and a copy of the cookies. It is the "d" cookie that is important, but you can copy all of them.
# Paste the values below.
# You need to have curl and jq installed.
SLACK_TOKEN="xoxc-...."
COOKIES="d=...."
@stefansundin
stefansundin / .gitignore
Last active Mar 17, 2019
Gnuplot Heroku runtime metrics
View .gitignore
*.tsv
*.gz
*.dat
*.png
*.json
@stefansundin
stefansundin / heroku-replay.sh
Last active Aug 30, 2018
Replay production Heroku requests to your local dev environment.
View heroku-replay.sh
#!/bin/bash -e
app=rssbox
dev=http://rssbox.dev
heroku logs -t -s heroku -d router -a $app | {
while IFS= read -r line
do
path=$(echo $line | grep -oE 'path="([^"]+)"' | cut -d'"' -f2)
code=$(curl -s -o /dev/null -w "%{http_code}" "$dev$path")
@stefansundin
stefansundin / openssh-7.3.sh
Last active Mar 24, 2020
Install OpenSSH 7.3 in Ubuntu 16.04
View openssh-7.3.sh
# WARNING: Use this at your own risk. It will probably break your other packages and cause other havoc.
# These days you should just upgrade to Ubuntu 18.04.
$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
wget https://launchpadlibrarian.net/277739251/openssh-client_7.3p1-1_amd64.deb
wget https://launchpadlibrarian.net/298453050/libgssapi-krb5-2_1.14.3+dfsg-2ubuntu1_amd64.deb
wget https://launchpadlibrarian.net/298453058/libkrb5-3_1.14.3+dfsg-2ubuntu1_amd64.deb
wget https://launchpadlibrarian.net/298453060/libkrb5support0_1.14.3+dfsg-2ubuntu1_amd64.deb
@stefansundin
stefansundin / manifest.json
Last active Apr 25, 2017
Speed up the Wistia player automatically.
View manifest.json
{
"name": "Wistia auto-speed",
"version": "1.0",
"description": "Automatically speed up Wistia embeds to 1.5x, and select the best quality.",
"content_scripts": [
{
"matches": [
"*://*.wistia.com/medias/*",
"*://fast.wistia.net/embed/iframe/*"
],
@stefansundin
stefansundin / manifest.json
Created Mar 3, 2017
Replace the TED player with the equivalent YouTube video.
View manifest.json
{
"name": "TED YouTube embed",
"version": "1.0",
"description": "Replace the TED player with the equivalent YouTube video.",
"content_scripts": [
{
"matches": ["*://www.ted.com/talks/*"],
"js": ["replace.js"],
"run_at": "document_end"
}
View twitch-extension.lua
--[[
Twitch.tv extension v0.0.2 by Stefan Sundin
https://gist.github.com/stefansundin/c200324149bb00001fef5a252a120fc2
The only thing that this extension does is to act as a helper to seek to the
correct time when you open a twitch.tv url that contains a timestamp.
You must have the playlist parser installed as well!
Usage:
1. Install the playlist parser: https://addons.videolan.org/p/1167220/
@stefansundin
stefansundin / requests_api.py
Last active Oct 16, 2020
Reusable class for Python requests library.
View requests_api.py
# http://docs.python-requests.org/en/master/api/
import requests
class RequestsApi:
def __init__(self, base_url, **kwargs):
self.base_url = base_url
self.session = requests.Session()
for arg in kwargs:
if isinstance(kwargs[arg], dict):
kwargs[arg] = self.__deep_merge(getattr(self.session, arg), kwargs[arg])
@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"
You can’t perform that action at this time.