Skip to content

Instantly share code, notes, and snippets.

View tralston's full-sized avatar

Taylor Ralston tralston

  • Sacramento, CA
  • 04:41 (UTC -07:00)
View GitHub Profile
@tralston
tralston / rsync.sh
Created April 10, 2018 08:08
[Rsync over SSH with Paths with Spaces]
# the -s argument protects what's inside the quotation marks. This is crucial when there are spaces in the path
rsync -avP -s --rsync-path=/bin/rsync ~e/Videos/Videos/2013/h265/* "superman@homenas:/volume1/PlexMedia/Home Videos/"
@tralston
tralston / install_net3.bat
Created April 10, 2018 03:56
[Install .NET 3/3.5 Framework on Windows 8, 8.1 and 10] Check status of and install .NET 3.5 Framework on later versions of Windows that have removed it.
rem Check if it is installed to begin with.
DISM /Online /Get-Features /Format:Table | findstr -i netfx3
rem Install .NET 3(.5)
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:D:\sources\sxs
@tralston
tralston / 7zip.sh
Last active April 24, 2018 20:49
[7zip CLI] Ultra high compression for 7zip on commandline #bash
# This will compress the entire pwd, dot files included. Archive placed in pwd
sudo 7z a -t7z [FILENAME.7z] -m0=lzma2 -mx=9 -aoa .
# No compression, just copy. Also, splits into 900MB parts for easier transfer over internet
7z a -t7z -mx=0 -v900m [FILENAME.7z] [files...]
# Same as previous, but encrypt headers (file names, and password protected
7z a -t7z -mx=0 -mhe=on -p -v900m [FILENAME.7z] [files...]
@tralston
tralston / clean_time_machine.sh
Last active January 2, 2018 18:57
[Time Machine Clean Up]
# Prerequisites
# - the `hln` command, which on mac can be installed via `brew install hardlink-osx`
# - various time machine cleaning scripts: tmdejunk, tmdeempty, tmdeduphl, tmdeduphldir
# In the time machine volume, under Backups.backupdb/<Machine Name>
# Note: this only prunes the hardlinks in the /Users/ folder of each backup snapshot.
# The following code will find the /Users folder within each snapshot, and then run the tmdejunk command, followed by tmclean command. It will prune empty folders, prune hardlink folders, then delete hardlink files, then prune empty folders again. This process can take several hours depending on how many snapshots you have backed up
@tralston
tralston / reload-config-postgresql.md
Created August 21, 2017 08:18
[Reload PostgreSQL config] After updating pg_hba.conf or postgresql.conf, the server needs the config needs to be reloaded. #postgres

After updating pg_hba.conf or postgresql.conf, the server needs the config needs to be reloaded. The easiest way to do this is by restarting the postgres service:

service postgresql restart

When the service command is not available (no upstart on Synology NAS, for example), there are some more creative ways to reload the config. Note this first one needs to be done under the user that runs postgres (usually the user=postgres).

user#  sudo su postgres
postgres#  pg_ctl reload
@tralston
tralston / format-json-vim.md
Created August 20, 2017 23:42
[Clean up JSON from vim] #JSON #vim

Usage

:%!python -m json.tool

Requires python to be installed. This command can also be stored in a macro in .vimrc:

function! FormatJSON()
:%!python -m json.tool
endfunction
@tralston
tralston / curl-ttfb.sh
Created October 28, 2016 22:22 — forked from acdha/curl-ttfb.sh
Use curl to measure and report HTTP response times (pre-, start- and total transfer)
#!/bin/bash
#
# Report time to first byte for the provided URL using a cache buster to ensure
# that we're measuring full cold-cache performance
while (($#)); do
echo $1
curl -so /dev/null -H "Pragma: no-cache" -H "Cache-Control: no-cache" \
-w "%{http_code}\tPre-Transfer: %{time_pretransfer}\tStart Transfer: %{time_starttransfer}\tTotal: %{time_total}\tSize: %{size_download}\n" \
"$1?`date +%s`"
@tralston
tralston / nginx.conf
Created March 21, 2015 17:24
Fix Wordpress permalinks on nginx
#Put this in the nginx.conf file. You may need to add "index index.php" under the server block.
location / {
try_files $uri $uri/ /index.php?$args;
}
@tralston
tralston / color.gradle
Created March 21, 2015 17:22
Add color to Gradle script
import org.gradle.logging.StyledTextOutput;
import org.gradle.logging.StyledTextOutputFactory;
import static org.gradle.logging.StyledTextOutput.Style;
StyledTextOutput o = services.get(StyledTextOutputFactory).create("test string")
task taskname << {
o.withStyle(Style.Description).append("Hello world!")
// Style.?? Can be normal, header, userinput, identifier, description, progressstatus, failure, info, or error
}
@tralston
tralston / loadscript.js
Created March 21, 2015 13:44
Load external script with a callback to wait for it
$.getScript("http://url/to/javascript.js", function () {
// Do something here. This will be safe to call after asynchronous script load
});