Skip to content

Instantly share code, notes, and snippets.

View drew2a's full-sized avatar
:octocat:
Looking for a job: https://www.linkedin.com/in/drew2a

Andrei Andreev drew2a

:octocat:
Looking for a job: https://www.linkedin.com/in/drew2a
View GitHub Profile
@sbrugman
sbrugman / testable_tread.py
Last active September 7, 2021 08:44
Wrapper around Python's thread that propages exceptions (pytest).
import threading
class TestableThread(threading.Thread):
"""Wrapper around `threading.Thread` that propagates exceptions."""
def __init__(self, target, args):
super().__init__(self, target=target, args=args)
self.exc = None
@Anachron
Anachron / wg_install.sh
Created June 24, 2019 07:15 — forked from sethenoka/wg_install.sh
A script to spin up a Wireguard VPN server with Unbound recursive DNS in a hurry
#!/bin/bash
# This file is designed to spin up a Wireguard VPN quickly and easily,
# including configuring a recursive local DNS server using Unbound
#
# Make sure to change the public/private keys before running the script
# Also change the IPs, IP ranges, and listening port if desired
# iptables-persistent currently requires user input
# add wireguard repo
sudo add-apt-repository ppa:wireguard/wireguard -y
@jackcarter
jackcarter / slack_delete.py
Last active November 29, 2023 07:03
Delete Slack files older than 30 days. Rewrite of https://gist.github.com/jamescmartinez/909401b19c0f779fc9c1
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 30 * 24 * 60 * 60
def list_files():
@jamescmartinez
jamescmartinez / slack_delete.rb
Last active January 4, 2021 21:28
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@adam-p
adam-p / Local PR test and merge.md
Last active February 5, 2024 19:39
Testing a pull request, then merging locally; and avoiding TOCTOU

It's not immediately obvious how to pull down the code for a PR and test it locally. But it's pretty easy. (This assumes you have a remote for the main repo named upstream.)

Getting the PR code

  1. Make note of the PR number. For example, Rod's latest is PR #37: Psiphon-Labs/psiphon-tunnel-core#37

  2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it pr37:

$ git fetch upstream pull/37/head:pr37
@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active April 16, 2024 16:36
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@jordelver
jordelver / gist:3073101
Created July 8, 2012 22:06
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port