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 / install-pre-commit.sh
Last active Dec 3, 2019
Git pre-commit check to stop accidental commits to master and develop branches. There is also a variant with a core.whitespace check.
View install-pre-commit.sh
#!/bin/sh
# 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:
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 / download-slack-emoji.sh
Last active Nov 15, 2019
Download all of your Team's custom Slack emojis.
View download-slack-emoji.sh
#!/bin/bash
# get a token from https://api.slack.com/custom-integrations/legacy-tokens
# or if you don't have permissions to create one, you can inspect the Slack web client and you can get the one it is using
SLACK_TOKEN=
curl -q -s "https://slack.com/api/emoji.list?token=$SLACK_TOKEN" | jq -Mr '.emoji | to_entries | .[] | select(.value | startswith("http")) | "\(.key) \(.value)"' | sort | while read name url; do
fn="$name.${url##*.}"
echo "$fn"
curl -q -s -o "$fn" "$url"
done
@stefansundin
stefansundin / extract-attachments.py
Last active Oct 30, 2019
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. Please use Python >= 3.4.
View extract-attachments.py
#!/usr/bin/env python3
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: https://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Instructions:
# Go to your emails, click the arrow button in the top right, "Show original", then "Download Original".
# Move the files to the same directory as this program, then run it.
import email
@stefansundin
stefansundin / youtube-global-shortcuts.user.js
Last active Oct 28, 2019
Makes the YouTube shortcuts work even if the player is not focused. Install Greasemonkey/Tampermonkey first, then click [Raw] to install.
View youtube-global-shortcuts.user.js
// ==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/*
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>
@stefansundin
stefansundin / make-chrome-app.sh
Last active Oct 24, 2019
Create Chrome apps in Mac OS.
View make-chrome-app.sh
#!/bin/sh
# wget https://gist.githubusercontent.com/stefansundin/c89fd15bae5a58831790/raw/make-chrome-app.sh
# chmod +x make-chrome-app.sh
# ./make-chrome-app.sh
echo "Note that the app will run with a separate data dir and thus not have your regular extensions and settings."
echo
echo "What should the app be called?"
read name
echo
@stefansundin
stefansundin / git-bundle-hook.md
Last active Oct 15, 2019 — forked from 8bitDesigner/1.md
Git post-checkout and post-merge hooks to simplify bundling and other tasks.
View git-bundle-hook.md

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
stefansundin / clop.c
Last active Oct 14, 2019
(Windows) clop.exe: like Mac's pbpaste.
View clop.c
// https://gist.github.com/stefansundin/9d95826a712096b24ae2
// https://devblogs.microsoft.com/oldnewthing/?p=3023
// gcc -s -o clop clop.c
// Usage:
// clop | gpg -v
// clop /u = output is printed in Unicode
// clop /a = output is printed in ANSI
// otherwise, output is printed in OEM codepage
@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.