Skip to content

Instantly share code, notes, and snippets.

@phausler
phausler / gist:6058774
Last active December 20, 2015 02:49
NEVER EVER DO THIS!
struct BlockObject {
Class isa;
int retainCount;
struct BlockObject *(^alloc)();
struct BlockObject *(^init)();
struct BlockObject *(^retain)();
void (^release)();
struct BlockObject *(^autorelease)();
void (^dealloc)();
} BlockObject = {
#!/bin/bash
echo -n "GitHub User: "
read USER
echo -n "GitHub Password: "
read -s PASS
echo ""
echo -n "GitHub Repo (e.g. foo/bar): "
@ZevEisenberg
ZevEisenberg / resetAllSimulators.sh
Last active November 30, 2022 09:27
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all
@stevenharman
stevenharman / expanding_raid_5_array.sh
Created March 31, 2015 00:03
Improving RAID Expansion speed (and wall clock time) on my Synology DS1515+.
# log the default values:
echo "speed_limit_max: `cat /proc/sys/dev/raid/speed_limit_max`" #=> 200000
echo "speed_limit_min: `cat /proc/sys/dev/raid/speed_limit_min`" #=> 10000
echo "stripe_cache_size: `/sys/block/md2/md/stripe_cache_size`" #=> 256
# update to use more RAM (Stripe Cache Size) and higher lower bound (speed_limit_min)
echo 100000 > /proc/sys/dev/raid/speed_limit_min
# This will result in more memory usage. bumping to 32768 resulted in ~512MB RAM increase.
echo 32768 > /sys/block/md2/md/stripe_cache_size
@fritz-c
fritz-c / git-recentco
Last active April 8, 2024 02:54 — forked from jordan-brough/git-recent
Git: Check out a branch from a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/fritz-c/c1e528b09bc1c0827a3c
# Original: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# Download this script as "git-recentco" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recentco` from inside any git repo.
# Example:
#
@zacwest
zacwest / ios-font-sizes.swift
Last active May 17, 2024 10:24
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
# Carthage has no built-in way of testing if built products are already up-to-date
# Lets use a stampfile ourselves, so we don't have to rebuild each time if nothing changed
Carthage: Carthage/Build/build.stamp
Carthage/Build/build.stamp: Cartfile.resolved
-$(RM) -r Carthage/Build
$(CARTHAGE) bootstrap --platform iOS,watchOS
@touch '$@'
@genegoykhman
genegoykhman / Blitz Talk.scpt
Created June 24, 2016 01:29
Auto-advance a Deckset presentation 15-seconds per slide
tell application "Deckset"
set doc to first document
set ind to 0
set slideIndex of doc to ind
set delaySeconds to 15
--set question to display dialog "Start presentation?" buttons {"OK", "Cancel"} default button 1
--set answer to button returned of question
--if answer is equal to "OK" then
@adriencanterot
adriencanterot / AppDelegate.swift
Last active September 1, 2017 19:37
create a simple sqlite database for Fluent
func configureDatabase() {
let manager = FileManager.default
let applicationDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let databasePath = applicationDirectory.first! + "/development.sqlite"
if !manager.fileExists(atPath: databasePath) {
manager.createFile(atPath: databasePath, contents: nil, attributes: nil)
}
let driver = try! SQLiteDriver(path: databasePath)
self.database = Fluent.Database(driver)
}
import Foundation
final class SafeSyncQueue {
struct QueueIdentity {
let label: String
}
let queue: DispatchQueue