Skip to content

Instantly share code, notes, and snippets.

@dschneider
dschneider / gist:294256e447cd52c7855ad374b9cef0fa
Created April 14, 2023 09:46 — forked from rentzsch/gist:1047967
Close a Chrome Tab using AppleScript
tell application "Google Chrome"
set windowList to every tab of every window whose URL starts with "https://mail.google.com"
repeat with tabList in windowList
set tabList to tabList as any
repeat with tabItr in tabList
set tabItr to tabItr as any
delete tabItr
end repeat
end repeat
end tell
@dschneider
dschneider / gist:2941985
Created June 16, 2012 17:15
RSpec - Stub Remote IP Request
ActionDispatch::Request.any_instance.stub(:remote_ip).and_return("192.168.0.1")
@dschneider
dschneider / stream_file.sh
Last active November 13, 2020 23:07
Stream file over network with netcat and pigz
# pigz is "A parallel implementation of gzip for modern multi-processor, multi-core machines"
# See http://zlib.net/pigz/
# On the receiving machine run this:
nc -w 10 SENDING_MACHINE_IP 7878 | pigz -d | tar x
# On the sending machine run this:
tar c FILENAME_HERE | pigz | nc -l 7878
# You can compare the md5 checksum from both files after the transfer,
@dschneider
dschneider / convert_utf8_to_utf8mb4
Created May 7, 2014 14:44
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)
@dschneider
dschneider / nginx_with_lua.sh
Created October 23, 2013 15:20
Install Nginx with Lua module
#!/usr/bin/bash
#
# (Original gist from https://gist.github.com/jmervine/5407622/raw/nginx_w_lua.bash)
set -x
cd /tmp
if ! test -d /usr/local/include/luajit-2.0; then
echo "Installing LuaJIT-2.0.1."
wget "http://luajit.org/download/LuaJIT-2.0.1.tar.gz"
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@dschneider
dschneider / open_modified_in_vim.sh
Created November 5, 2013 15:37
GIT: Open modified files in VIM
gst | grep modified | awk '{print $3}' | xargs vim
credentials_hash = {
aws_secret_access_key: "KEY",
aws_access_key_id: "ID"
}
route53 = Fog::DNS::AWS.new(credentials_hash)
resource_record_sets = route53.list_resource_record_sets("ZONE_ID")
data = resource_record_sets.data[:body]["ResourceRecordSets"]
redis_resource_record = data.detect { |record_set| record_set["Name"] == "record_name_with_a_dot_at_the_end." }
former_cname_entry = redis_resource_record["ResourceRecords"].first
@dschneider
dschneider / kill_process_by_name.sh
Created October 26, 2013 16:08
Kill process by name with shell
ps aux | grep PROCESS_NAME | grep -v grep | awk '{print $2}' | xargs kill -9
@dschneider
dschneider / vim_clipboard_instructions
Last active December 26, 2015 12:59
VIM - User system clipboard on Mac OS X
1.) Run in terminal: 'vim --version | grep clipboard'
2.) Make sure the output says +clipboard (-clipboard means it is not installed)
3.) Put the following in your vimrc:
" Enabling clipboard
set clipboard=unnamed
4.) Install vim through homebrew: 'brew install vim'
5.) Put an alias on vim in your bashrc/zshrc: alias vim="/usr/local/Cellar/vim/7.4.052/bin/vim"
6.) Check vim --version for clipboard value again