Skip to content

Instantly share code, notes, and snippets.

stefansundin /
Last active Oct 16, 2020
Reusable class for Python requests library.
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 /
Last active Oct 6, 2020
Create Chrome apps in Mac OS.
# wget
# chmod +x
# ./
echo "Note that the app will run with a separate data dir and thus not have your regular extensions and settings."
echo "What should the app be called?"
read name
View moved.txt
Moved to
stefansundin /
Last active Sep 18, 2020
Download all of your Team's custom Slack emojis.
#!/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.
stefansundin / ffmpeg.rb
Last active Sep 11, 2020
Download Twitch video that has muted sound.
View ffmpeg.rb
#!/usr/bin/env ruby
files = Dir["*.ts"].sort_by { |fn| fn.split(".")[0].to_i }
puts "ffmpeg -i 'concat:#{files.join("|")}' -codec copy output.mkv"
puts "run this first:"
puts "ulimit -n 4096"
stefansundin /
Last active Sep 10, 2020
Git pre-commit check to stop accidental commits to master and develop branches. There is also a variant with a core.whitespace check.
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are four variants that I have built:
# - pre-commit: stops commits to "master" and "develop" branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set desired version like this before installing:
stefansundin /
Last active Aug 8, 2020 — forked from 8bitDesigner/
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 /
Last active Jul 22, 2020
Git pre-push hook to prevent force pushing the master branch.
# This script will install a Git pre-push hook that prevents force pushing the master branch.
# Global installation instructions:
# mkdir $HOME/.githooks
# git config --global core.hooksPath $HOME/.githooks
# curl -fL -o $HOME/.githooks/pre-push
# chmod +x $HOME/.githooks/pre-push
# Uninstall:
# rm $HOME/.githooks/pre-push
View twitch-extension.lua
--[[ extension v0.0.2 by Stefan Sundin
The only thing that this extension does is to act as a helper to seek to the
correct time when you open a url that contains a timestamp.
You must have the playlist parser installed as well!
1. Install the playlist parser:
You can’t perform that action at this time.