Skip to content

Instantly share code, notes, and snippets.

View trojanfoe's full-sized avatar

Andy Duplain trojanfoe

  • Wickham, Hampshire, UK.
View GitHub Profile
@echo off
REM Change this to where you want the files backed-up to...
REM (Always put a backslash at the end so xcopy knows you want to create a directory)
set dst="%USERPROFILE%\Backups\Minecraft Dungeons\"
set srcdir="%LOCALAPPDATA%\Packages\Microsoft.Lovika_8wekyb3d8bbwe\LocalCache\Local\Dungeons"
if exist %srcdir% goto find_subdir
set srcdir="%LOCALAPPDATA%\Dungeons"
if exist %srcdir% goto find_subdir
$ cat locktest.m
#import <Foundation/Foundation.h>
@interface Locker : NSObject {
NSRecursiveLock *_lock;
}
- (void)setLock:(NSRecursiveLock *)lock;
@end
@implementation Locker
#!/usr/bin/python
#
# Bump build number if source files have changed, writing the version and build
# number to source files as well as updating one or more info.plist files.
#
# usage: bump_build_number.py version-file version-impl-file version-header-file plist-file [ ... plist-file ]
#
import sys, os, subprocess, re
2014-01-21 14:57:39.317 getifaddrs[31705:707] name=lo0, family=30, address=fe80::1
2014-01-21 14:57:39.319 getifaddrs[31705:707] name=lo0, family=2, address=127.0.0.1
2014-01-21 14:57:39.319 getifaddrs[31705:707] name=lo0, family=30, address=::1
2014-01-21 14:57:39.320 getifaddrs[31705:707] name=en1, family=30, address=fe80::fa1a:67ff:fe0e:30eb
2014-01-21 14:57:39.320 getifaddrs[31705:707] name=en1, family=2, address=192.168.1.100
#import <Foundation/Foundation.h>
@interface ClassA : NSObject
@property NSMutableString *string;
- (void)changeString;
- (void)printString;
@end
@trojanfoe
trojanfoe / dateiter.m
Last active January 3, 2016 11:09
Objective-C NSDate example of checking how many times a day-of-the-month appears between two dates. See: http://stackoverflow.com/questions/21161125/how-many-times-a-specific-day-has-passed-between-two-dates Compile with: clang -g -o dateiter dateiter.m -fobjc-arc -framework Foundation
#import <Foundation/Foundation.h>
static void nextMonth(NSDateComponents *comps) {
NSInteger month = [comps month];
if (month == 12) {
[comps setYear:[comps year] + 1];
[comps setMonth:1];
} else {
[comps setMonth:month + 1];
}
@trojanfoe
trojanfoe / NSArray unrecognized selector exception
Last active December 22, 2015 03:29
NSMutableArray from NSArray copy
#import <Foundation/Foundation.h>
int main(int argc, const char **argv) {
@autoreleasepool {
NSMutableArray *mutableArray;
NSString *str = @"one two three";
mutableArray = [[str componentsSeparatedByString:@" "] copy];
[mutableArray addObject:@"four"];
for (NSString *s in mutableArray) {
NSLog(@"%@", s);
@trojanfoe
trojanfoe / PrefabPool.m
Created May 6, 2015 10:10
Prefab Pool implementation
#import "PrefabPool.h"
#pragma mark - Private Interface
@interface PrefabPool ()
{
NSUInteger _nextIndex;
NSMutableArray *_pool;
}
@trojanfoe
trojanfoe / build-png.sh
Created September 4, 2014 20:24
Script to build libpng for iOS
#!/bin/sh
dobuild=1
docopy=1
doclean=1
version=1.6.9
srcdir=libpng-${version}
srcfile=${srcdir}.tar.gz
srctarball=http://sourceforge.net/projects/libpng/files/libpng16/${version}/${srcfile}/download
outdir=$(cd ../external-deps/png; pwd)
@trojanfoe
trojanfoe / Test results
Last active August 29, 2015 14:05
Demonstrate changing the directory to the executable's path using C++
--- Source/cpptinkering ‹master*➔ ?› » make
clang++ -DDEBUG=1 -g -Wall -std=c++11 -stdlib=libc++ -o setcwd setcwd.cpp -lstdc++
--- Source/cpptinkering ‹master*➔ ?› » ./setcwd
Changing to directory '.'
This is a one.
This is line two.
This is line three.
--- Source/cpptinkering ‹master*➔ ?› » cd /
--- / » /Users/andy/Source/cpptinkering/setcwd
Changing to directory '/Users/andy/Source/cpptinkering'