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
@interface NSString (Formatting) | |
- (NSString*)stringWithOnlyLetters; | |
- (NSString*)stringWithOnlyNumbers; | |
@end |
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
//Brandon Levasseur | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGSTOP, 0, queue); | |
if (source) { | |
dispatch_source_set_event_handler(source, ^{ | |
NSLog(@"Hi, I am: %@", weakSelf); | |
}); | |
dispatch_resume(source); |
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
dir=$(pwd) | |
find "$dir" -name "*@2x.png" | while read image; do | |
outfile=$(dirname "$image")/$(basename "$image" @2x.png).png | |
if [ "$image" -nt "$outfile" ]; then | |
basename "$outfile" | |
width=$(sips -g "pixelWidth" "$image" | awk 'FNR>1 {print $2}') | |
height=$(sips -g "pixelHeight" "$image" | awk 'FNR>1 {print $2}') |
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
float x = 5.0f; | |
float y = 5.0f; | |
float destX = 25.0f; | |
float destY = 30.0f; | |
float diffX = abs(destX - x); | |
float diffY = abs(destY - y); | |
float scale = 0.0f; |
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
# Source: https://gist.github.com/izackp/967c059abe102745f61d | |
# Thumbnails | |
._* | |
# Files that might appear on external disk | |
.Spotlight-V100 | |
.Trashes | |
# Directories potentially created on remote AFP share |
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
using FullSerializer; | |
using System.Collections.Generic; | |
[fsObject(Converter = typeof(DictionaryConverter))] | |
public class Dictionary<TValue> : Dictionary<string, TValue> { | |
} |
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
public class CollisionUpdater | |
{ | |
List<IPhysics> components; | |
public CollisionUpdater () | |
{ | |
components = new List<IPhysics> (); | |
} | |
public void AddComponent (IPhysics newComp) | |
{ |
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
using System; | |
using System.Security.Cryptography; | |
namespace Security | |
{ | |
public static class PBKDF2 | |
{ | |
const int cSaltByteLength = 24; | |
const int cDerivedKeyLength = 24; | |
const int cIterationCount = 2; |
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
using UnityEngine; | |
public class ConfigCamera : MonoBehaviour { | |
public float Zoom = 1.0f; | |
float _pixelsPerUnit = 1.0f; //Set this to whatever you set for your texture | |
public float ScreenWidth; //For Debugging | |
public float ScreenHeight; //For Debugging | |
Rect _bounds; |
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
h = sqrt(a² + b²); | |
//All these assume 0 ≤ a ≤ b. | |
h = ((sqrt(2) - 1) * a) + b; //Max Error: 8.24% over true value, b must the be larger number | |
h = 0.414213562 * a + b; //Same as above. Either works compiler will optimize. | |
h = 4142 * a / 10000 + b; //Same as above. We just only use ints | |
h = (a >> 1) + b; //Max Error: a/2 //Simplified version of above to be faster and less accurate | |
h = b + 0.337 * a // max error ≈ 5.5 % |