Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
BACKUP_PATH=$1
if [ -z "$BACKUP_PATH" ]; then
echo "Please provide path to Time Machine backup bundle."
exit 1
fi
echo "More info at https://jd-powered.net/notes/fixing-your-time-machine-backup/"
#!/usr/bin/env bash
set -e
PATTERN=$1
COUNT=0
for RULE in $(sudo ufw status numbered | (grep $PATTERN | awk -F"[][]" '{print $2}')); do
sudo ufw --force delete $((RULE-COUNT))
((COUNT=COUNT+1))
done
#!/usr/bin/env bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_obs_testfile}
TEST_FILE_EXISTS=0
if [ -e "$TEST_FILE" ]; then TEST_FILE_EXISTS=1; fi
TEST_FILE_SIZE=134217728
@mxl
mxl / macos_dd_ibs_test.sh
Created June 25, 2019 12:37
dd ibs test for macOS
#!/usr/bin/env bash
# Since we're dealing with dd, abort if any errors occur
set -e
TEST_FILE=${1:-dd_ibs_testfile}
if [ -e "$TEST_FILE" ]; then TEST_FILE_EXISTS=$?; fi
TEST_FILE_SIZE=134217728
# Exit if file exists
@mxl
mxl / log_out.svg
Last active January 12, 2021 18:43
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import UIKit
import XCPlayground
enum UIImageAlignment {
case Center, Left, Top, Right, Bottom, TopLeft, BottomRight, BottomLeft, TopRight
}
enum UIImageScaleMode {
case Fill,
AspectFill,
import Foundation
func testFunction(completion: () -> ()) {
dispatch_async(dispatch_get_main_queue()) {
completion()
}
}
func testSemaphore() {
let semaphore = dispatch_semaphore_create(0)
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "API",
"description": "API"
},
"schemes": [
"http"
],
@mxl
mxl / photoshop-export-layers-android.jsx
Last active January 1, 2016 22:39
Exports first-level layers and layer groups to png images for Android (ldpi, mdpi, hdpi, xhdpi).
#target photoshop
function main(){
if(!documents.length)
return;
// suppress all dialogs
app.displayDialogs = DialogModes.NO;
var mainDoc = app.activeDocument;
var docFullName = mainDoc.fullName;
@mxl
mxl / photoshop-export-layers-iphone.jsx
Last active January 1, 2016 22:39
Exports first-level layers and layer groups to png images for iPhone and iPhone with Retina display.
#target photoshop
function main(){
function scanLayers(el, path, isRetina) {
new Folder(path).create();
// process layer sets (groups)
for(var i = 0; i < el.layerSets.length; i++){
var layer = el.layerSets[i];
if (!layer.visible)