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 / debug.clj
Last active August 29, 2015 14:18 — forked from vsmart/gist:8deecda2be8fb3e6afa0
Debug clojure cool
;; This is a useful macro for clojure debugging
(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))
;; Use it anywhere in your expression like so:
(defn factorial[n] (if (= n 0) 1 (* n (dbg (factorial (dec n))))))
;; Taken from [stackoverflow](http://stackoverflow.com/a/2352280/789070)
@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,

Keybase proof

I hereby claim:

  • I am dschneider on github.
  • I am dschneider (https://keybase.io/dschneider) on keybase.
  • I have a public key whose fingerprint is FED7 7C45 B87E 8ABA D362 F678 4AE9 9923 616C 4C6E

To claim this, I am signing this object:

@dschneider
dschneider / GenerateSSLCertificate.sh
Created May 16, 2014 09:56
Generate an SSL certificate locally
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days XXX
@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 / CameraMovement.cs
Created March 14, 2014 17:00
Unity 2D Camera movement
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour {
public float dampTime = 0.15f;
private Vector3 velocity = Vector3.zero;
private Transform target;
// Use this for initialization
#!/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