Skip to content

Instantly share code, notes, and snippets.

@cfg
cfg / slack_leave_bd_channels.py
Created July 15, 2022 17:39 — forked from krets/slack_leave_bd_channels.py
Quick script to leave a bunch of slack channels with the "bd-" prefix.
#!/usr/bin/env python
import argparse
import requests
import logging
LOG = logging.getLogger("slack_leaver")
class JSONRest(object):
def __init__(self, base_url):
@cfg
cfg / billboard.js
Last active July 10, 2021 20:19
Anti-Adblock Removal Scripts
javascript:(function(){
document.querySelector('.article__body.article__overlay') && document.querySelector('.article__body.article__overlay').classList.remove('article__overlay');
document.getElementById('checkout-container') && document.getElementById('checkout-container').remove();
document.querySelector('div.piano-article-overlay') && document.querySelector('div.piano-article-overlay').remove();
})();
#!/usr/bin/env bash
# Take a snapshot of user and system application icons before the Big Sur aesthetic is applied
function sync() {
FROM="$1"
TO="$2"
mkdir -p "$TO"
@cfg
cfg / dns_lookup.py
Created May 30, 2019 19:37
Use python for quick dns lookups when other tools (dig, host, nslookup) aren't available
import socket
list( map( lambda x: x[4][0], socket.getaddrinfo('example.com.', 80, 0, socket.SOCK_STREAM) ))
function parse_str(str, array) {
// discuss at: http://phpjs.org/functions/parse_str/
// original by: Cagri Ekin
// improved by: Michael White (http://getsprink.com)
// improved by: Jack
// improved by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: Onno Marsman
// bugfixed by: Brett Zamir (http://brett-zamir.me)
// bugfixed by: stag019
// bugfixed by: Brett Zamir (http://brett-zamir.me)
@cfg
cfg / slack_emoji.js
Last active May 23, 2019 16:56
Crudely extract custom emoji from a Slack web instance. Load the web interface for the Slack instance and paste this into the developer console.
jQuery('#main_emo_menu').click();
jQuery('button[aria-label=Custom]').click();
jQuery('.p-emoji_picker__list').css('min-height', '900px');
jQuery('.p-emoji_picker__list_container').parents('.ReactModal__Content.ReactModal__Content--after-open.popover').css('top', '0px');
jQuery('.p-emoji_picker__list_container').css('max-height', '100%');
jQuery('.p-emoji_picker__content .p-emoji_picker__input_container').hide();
var emoji = [];
@cfg
cfg / .bashrc
Created May 6, 2019 14:44
Storing sensitive environment variables the keychain, selectively setting them on a per-application basis.
source ~/bash.includes/keychain-environment-variables.sh
function aws-vault() {
/usr/local/bin/aws-vault-wrapper "$@"
}
# example wrapper
## function cloudns-api() {
## (
## export CLOUDNS_API_ID=$(keychain-environment-variable CLOUDNS_API_ID)
@cfg
cfg / comments.php
Created December 3, 2015 16:51
Fix expensive comment queries
<?php
if ( defined( 'WPCOM_IS_VIP_ENV' ) && true === WPCOM_IS_VIP_ENV ) {
wpcom_vip_load_plugin( 'disable-comments-query' );
// Kill wp_count_comments lookups because they happen too frequently and are super slow.
if ( is_admin() ) {
add_filter( 'wp_count_comments', function( $counts, $post_id ) {
if ( $post_id )
return $counts;
@cfg
cfg / bash_script_source_dir.sh
Created May 21, 2012 13:14
Get the directory the current bash script is located in.
# From discussion at http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Is a useful one-liner which will give you the full directory name of the script no matter where it is being
# called from
# Or, to get the dereferenced path (all directory symlinks resolved), do this:
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# These will work as long as the last component of the path used to find the
@cfg
cfg / compile_futurerestore.sh
Created January 1, 2017 19:39
Compile futurerestore from @tihmstar on OS X
brew install openssl
git clone --recursive git@github.com:tihmstar/futurerestore.git
cd futurerestore/
export PKG_CONFIG_PATH=/usr/local/share/pkgconfig:/usr/local/lib/pkgconfig:$(brew --prefix openssl)/lib/pkgconfig
./autogen.sh
make
./futurerestore/futurerestore