Skip to content

Instantly share code, notes, and snippets.

View mojtabacazi's full-sized avatar

Mojtaba Cazi mojtabacazi

View GitHub Profile
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
TARGET="$INFOPLIST_FILE"
echo $TARGET
if [ ! -f "$TARGET" ]; then
echo "missing file $TARGET"
exit 1;
fi
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$TARGET")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$TARGET"
@mojtabacazi
mojtabacazi / gist:49905ae9e05a24313630
Last active August 29, 2015 14:21
Get all extensions and their respective file count in a directory
find ./ -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq -c | sort -n
@mojtabacazi
mojtabacazi / detectLanguage.m
Last active August 29, 2015 14:22
Detecting language in iOS using NSLinguisticTagger / NSSpellChecker
NSLinguisticTagger *tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:@[NSLinguisticTagSchemeLanguage, nil] options:0];
[tagger setString:@"Das ist ein bisschen deutscher Text. Bitte löschen Sie diesen nicht."];
NSString *result = [tagger tagAtIndex:0 scheme:NSLinguisticTagSchemeLanguage tokenRange:NULL sentenceRange:NULL];
if ([result isEqualToString:@"und"]) {
// language detection failed
} else {
// result will be standard language abbreviations such as “en”, “fr”, “de”, etc.,
// From Apple's doc: Languages are uniformly described by BCP-47 tags , preferably in canonical form;
}
@mojtabacazi
mojtabacazi / CSBuf.c
Last active August 29, 2015 14:22
Circular Buffer in C
/*
Source: http://stackoverflow.com/a/14047028/1017340
*/
#define BUFSIZE 128
char buf[BUFSIZE];
char *pIn, *pOut, *pEnd;
char full;
// init
if [ -z "${PROJECT_DIR}" ]; then
PROJECT_DIR=`pwd`
fi
if [ -z "${PREFIX}" ]; then
PREFIX=""
fi
SVN_DIR="${PROJECT_DIR}/.svn"
GIT_DIR="${PROJECT_DIR}/.git"
@mojtabacazi
mojtabacazi / apns_payload_sample.json
Created August 15, 2015 06:25
Sample payload for Apple APNS
{
"aps": {
"badge": 10,
"alert": "Hello world!",
"sound": "cat.caf"
}
}
@mojtabacazi
mojtabacazi / Steps
Last active September 22, 2015 19:54
Getting Started with Xcode 7 and iOS 9
1. Project Settings | build settings -> Enabele Bitcode => NO
2. Add following to `-info.plist`
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
@mojtabacazi
mojtabacazi / time.h
Last active March 29, 2016 18:55
Execution time in Obj-c
#if DEBUG
# define TICK NSDate *startTime = [NSDate date]
# define TOCK(_TXT_) NSLog(@"%@ Time: %f", _TXT_, -[startTime timeIntervalSinceNow])
#else
# error Debug Only.
#endif