This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Foo: Codable { | |
internal struct CodingKey: Swift.CodingKey { | |
internal let stringValue: String | |
internal let intValue: Int? | |
internal init?(stringValue: String) { | |
self.stringValue = stringValue | |
self.intValue = Int(stringValue) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure to have a valid config.php ready before running this script!!! | |
# Check parameters | |
if [[ $# -ne 1 ]]; then | |
echo " Usage: $0 <app path>" | |
exit 1 | |
fi | |
app_path=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
struct ViewStyle<T> { | |
let style: (T) -> Void | |
} | |
let filled = ViewStyle<UIButton> { | |
$0.setTitleColor(.white, for: .normal) | |
$0.backgroundColor = .red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Convert tabs to spaces (https://stackoverflow.com/a/11094620/981846) | |
find . \( -name '*.m' -o -name '*.h' -o -name '*.swift' -o -name '*.pch' \) ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; | |
# Trim trailing whitespace (https://stackoverflow.com/a/10711226/981846) | |
find . \( -name '*.m' -o -name '*.h' -o -name '*.swift' -o -name '*.pch' \) ! -type d -exec bash -c 'sed "s/[[:space:]]\{1,\}$//" "$0" > /tmp/e && mv /tmp/e "$0"' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Generate a new RSA key pair (public and private key) with a 4096 bit long modulus. | |
# You can optionally pass e.g. '-aes256' to encrypt the key pair with a passphrase. The key | |
# pair will be saved as 'private.pem' ('pem' is just a container file format, | |
# see https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file). | |
openssl genrsa -out private.pem 4096 | |
# 2. Extract the public key from the RSA key pair ('private.pem'). | |
# The result is again saved in a 'pem' file, this time named 'public.pem'. | |
openssl rsa -in private.pem -outform PEM -pubout -out public.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Check for any local time machine snapshots | |
tmutil listlocalsnapshots / | |
# 2. Ask time machine to free 100 GBs of local snapshots. Third parameter '4' probably means high priority (https://apple.stackexchange.com/a/398356) | |
tmutil thinlocalsnapshots / $((100 * 1024 * 1204 * 1024)) 4 | |
# 3. Make sure that only a `(dataless)` snapshot exists | |
tmutil listlocalsnapshots / | |
# 4. List all mounted volumes and find the one mounted on '/' (probably '/dev/disk1s1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load NVM | |
export NVM_DIR="$HOME/.nvm" | |
. "/usr/local/opt/nvm/nvm.sh" | |
# ls coloring etc. | |
alias ls='ls -Ga' | |
# Fix Perl locale | |
export LC_CTYPE=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$referencingTableName = 's_plugin_viison_address_label_dispatch_configuration'; | |
$referencingColumnName = 'dispatchId'; | |
$prefix = 'fk'; | |
$maxSize = 30; | |
$hash = implode('', array_map(function ($column) { | |
return dechex(crc32($column)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check parameters | |
if [[ $# -ne 2 ]]; then | |
echo " Usage: $0 <dev|prod> <plugin_path>" | |
exit 1 | |
fi | |
mode=$1 | |
plugin_path=$(cd $2 && pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func rz_smoothlyDeselectRows(tableView tableView: UITableView?) { | |
let selectedIndexPaths = tableView?.indexPathsForSelectedRows ?? [] | |
if let coordinator = transitionCoordinator() { | |
coordinator.animateAlongsideTransitionInView(parentViewController?.view, animation: { context in | |
selectedIndexPaths.forEach { | |
tableView?.deselectRowAtIndexPath($0, animated: context.isAnimated()) | |
} |
NewerOlder