Skip to content

Instantly share code, notes, and snippets.

View dannyow's full-sized avatar
👁️‍🗨️

Daniel dannyow

👁️‍🗨️
  • Warsaw
View GitHub Profile
@0xced
0xced / NSString.m
Created April 1, 2012 12:24
Reverse-engineered implementation of -[NSString isEqual:] and -[NSString isEqualToString:]
/*
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations.
* If you know how to create an NSString instance whose class is actually NSString please let me know.
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString.
*/
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3)
@implementation NSObject
- (BOOL) isNSString__
@jspahrsummers
jspahrsummers / macroview.sh
Last active December 10, 2015 07:38
This simple script will preprocess one or more source files, and try to indent them nicely such that expanded macros are made readable. This is useful for debugging the logic of rampant macros.
#!/bin/sh
#
# Example usage:
# ./macroview.sh -IThirdPartyHeadersToInclude file.m
clang -E -nostdinc -nobuiltininc "$@" 2>/dev/null | indent -bl -nce -nei
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@idiomatic
idiomatic / wwdc.sh
Last active April 10, 2022 03:52
Fetch WWDC videos, slides, and sample code.
#!/bin/bash
# usage: get [ RESOLUTION [ YEAR [ IDS... ] ] ]
resolution=${1:-SD}
year=${2:-2015}
shift
shift
ids=$*
RESOLUTION=$(echo $resolution | tr '[:lower:]' '[:upper:]')
@blundgren
blundgren / gist:a68d70f792f138bae23b
Created March 11, 2016 17:56
An NSClipView subclass which performs drag-scrolling.
class DraggableClipView: NSClipView
{
private var clickPoint: NSPoint!
private var originalOrigin: NSPoint!
override func mouseDown(event: NSEvent) {
clickPoint = event.locationInWindow
originalOrigin = bounds.origin
}
@mutewinter
mutewinter / sizing.md
Last active May 18, 2020 11:06
T-Shirt sizes we use for estimation at Postlight

Table

Size What it means
▁ S 💅 I can get this done in one session at the computer with no breaks
▃ M ☕ This will require breaks, less than a day
▅ L 💦 This will require more than one day
▇ XL 😱 Rare! This will require a week or more. Try breaking into multiple smaller issues
@AliSoftware
AliSoftware / Bindings.swift
Last active May 22, 2024 08:45
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI
The only purpose of this code is to implement those wrappers myself
just to understand how they work internally and why they are needed,
⚠️ This is not supposed to be a reference implementation nor cover all
subtleties of the real Binding and State types.
The only purpose of this playground is to show how re-implementing
them myself has helped me understand the whole thing better
@dagronf
dagronf / ShowSystemPreferencePanes.swift
Last active April 29, 2024 17:21
macOS: Open system preferences at a specified pane using Swift (or Objective-C) using x-apple.systempreferences
// Applescript: tell application "System Preferences" to get anchors of current pane
// Result:
// { anchor "Privacy_Reminders" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_SystemServices" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Calendars" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Firewall" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Assistive" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_LinkedIn" of pane id "com.apple.preference.security" of application "System Preferences",
// anchor "Privacy_Accessibility" of pane id "com.apple.preference.security" of application "System Preferences",
@dagronf
dagronf / Files+temporary.swift
Last active May 11, 2020 12:50
Temporary file and folder support for Files (https://github.com/JohnSundell/Files)
public extension Folder {
/// Create a new uniquely-named file within this folder.
/// - Parameter prefix: (optional) prefix to add the temporary file name
/// - Parameter fileExtension: (optional) file extension (without the `.`) to use for the created file
/// - Parameter contents: (optional) the data to write to the file
/// - throws: `WriteError` if a new file couldn't be created.
func createTemporaryFile(prefix: String? = nil, fileExtension: String? = nil, contents: Data? = nil) throws -> File {
var tempFilename = ""
if let prefix = prefix {
tempFilename += prefix + "_"
@IsaacXen
IsaacXen / README.md
Last active June 18, 2024 16:18
(Almost) Every WWDC videos download links for aria2c.