Skip to content

Instantly share code, notes, and snippets.

View dbonates's full-sized avatar
🏠
Working from home

Daniel Bonates dbonates

🏠
Working from home
View GitHub Profile
@dbonates
dbonates / SMBDIS.ASM
Created April 19, 2023 19:20 — forked from 1wErt3r/SMBDIS.ASM
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@dbonates
dbonates / remove_swift_headers.sh
Created November 17, 2022 15:19 — forked from fe9lix/remove_swift_headers.sh
Xcode: Remove header comments in Swift files
find . -type f -name "*.swift" -not -path "./Pods/*" -exec sed -i '' -e '1,/^import/{/^\/\/.*/d;}' -e '/./,$!d' {} \;
@dbonates
dbonates / Alamofire-JSON-Serialization.md
Created August 23, 2016 22:42 — forked from jpotts18/Alamofire-JSON-Serialization.md
Alamofire JSON Serialization of Objects, Collections, Nesting

Alamofire JSON Serialization of Objects and Collections

Alamofire is a great Swift library developed by the creator of AFNetworking @mattt. The purpose of this gist is to explain how to use the built-in power of Alamofire to serialize your JSON. In this example we will be serializing a simple blog API. First we will start with serializing a single JSON object and add complexity as we go along.

Warning: This was written before Swift 1.2

A Single JSON Serialization

This is the first JSON object that we will be serializing.

@dbonates
dbonates / iOS_learning_resources.md
Last active March 25, 2017 21:00 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos

@dbonates
dbonates / cachedThreadLocalObjectWithKey.swift
Created June 20, 2016 20:22 — forked from kristopherjohnson/cachedThreadLocalObjectWithKey.swift
Swift utility function to create and reuse a thread-local object
import Foundation
/// Return a thread-local object, creating it if it has not already been created
///
/// :param: create closure that will be invoked to create the object
/// :returns: object of type T
public func cachedThreadLocalObjectWithKey<T: AnyObject>(key: String, create: () -> T) -> T {
if let threadDictionary = NSThread.currentThread().threadDictionary {
if let cachedObject = threadDictionary[key] as T? {
return cachedObject
@dbonates
dbonates / git_branch.sh
Created January 28, 2016 15:51 — forked from dciccale/git_branch.sh
Bash script to get the current git branch and last commit
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@dbonates
dbonates / test.swift
Created January 26, 2016 03:50 — forked from jepers/test.swift
Example of something that takes a long time to type check.
// This little program takes ~ 6 seconds to compile on my MacBook Pro Late 2013.
// It compiles and works as expected. But the type checker spends a lot of time
// on the function at the end.
// In my actual project, I have much more code like this, and it results in very
// long compile times. So I'd like to know if there is something I can do to
// speed that up.
protocol DefaultInitializable { init() }
extension Float : DefaultInitializable {}
@dbonates
dbonates / xcode_ramdisk.sh
Created September 26, 2015 13:36 — forked from derjohng/xcode_ramdisk.sh
Create a RAM disk for using with XCode, with Umount disks method
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"