Skip to content

Instantly share code, notes, and snippets.

@dir21
dir21 / mac_os_x_recover_restrictions_pin
Created August 18, 2017 11:12
Recover Restrictions PIN
cd ~/Library/Application\ Support/MobileSync/Backup/
# ls -l then cd into the newest directory
grep --include "*" --binary-files=text -ri restrictionspassword .
# File is probably 398bc9c2aeeab4cb0c12ada0f52eea12cf14f40b
# cat ./39/398bc9c2aeeab4cb0c12ada0f52eea12cf14f40b
# Use http://ios7hash.derson.us/ to process the key and salt
@dir21
dir21 / pages
Last active February 24, 2019 16:17
width width_full height_max height_golden height_golden_full height_e height_e_full
TeX points 318 476 710 197 294 117 175
cm 11.1764 16.7295 24.9536 6.9073 10.3394 4.112 6.1544
inches 4.4001 6.5864 9.8243 2.7194 4.0706 1.6187 2.4230
@dir21
dir21 / Excel_get_local_part_of_email
Created June 9, 2017 14:51
Get the local part of an email address in Excel
=LEFT(A2, FIND("@", A2) -1)
@dir21
dir21 / sed_replace_line
Last active June 1, 2017 09:53
Use sed to replace the fifth line of a file with ` Good morning ' in multiple files
# https://askubuntu.com/questions/434051/
sed -i '5s/.*/ Good Morning /' file{1..4}.txt
# Except on Mac OS X:
# https://stackoverflow.com/questions/19456518/
sed -i '' -e '5s/.*/ Good Morning /' file{1..4}.txt
@dir21
dir21 / OGR_and_SQLite
Created May 28, 2017 12:27
Getting started with SQLite and OGR/GDAL
# http://www.gdal.org/drv_sqlite.html
# https://gis.stackexchange.com/questions/128101/
# http://www.gdal.org/ogr_sql_sqlite.html
# Convert a Shapefile into a new SQLite database (SQLite + FDO database)
ogr2ogr -f "SQLite" mygdb.sqlite a_layer.shp
# FIXME Or, convert a Shapefile into a new SQLite database (SpatiaLite database)
# ogr2ogr -f "SQLite" -dsco spatialite=yes mygdb.sqlite a_layer.shp --config OGR_SQLITE_SYNCHRONOUS OFF  # --config OSM_COMPRESS_NODES YES
# Add another Shapefile to that same SQLite database
ogr2ogr -append mygdb.sqlite b_layer.shp
# List the contents of that same SQLite database
@dir21
dir21 / ImageMagick_extract_pages
Created April 9, 2017 10:56
Multipage TIFF to individual files
convert multipageimage.tif image%03d.png
@dir21
dir21 / pdftk
Created December 8, 2016 09:12
`Normalise' a PDF
pdftk my.pdf output my-fixed.pdf
@dir21
dir21 / wkhtmltopdf
Created November 11, 2016 18:05
Reminder for wkhtmltopdf on Mac OS X
/usr/local/bin/wkhtmltopdf -B 25mm -L 25mm -R 25mm -T 25mm
@dir21
dir21 / arcgis_replace_nulls
Created October 27, 2016 09:43
In ArcGIS replace nulls in a raster with, e.g., zeroes
# From: https://geonet.esri.com/thread/45409
# ArcToolbox > Spatial Analyst > Raster Calculator
Con(IsNull("raster"), 0, "raster")
@dir21
dir21 / arcgis_convert_float_raster_to_integer
Created October 21, 2016 13:45
In ArcGIS convert a floating-point raster to an integer one properly instead of just rounding down
# ArcToolbox > Spatial Analyst > Raster Calculator
Int(myraster + 0.5)