Skip to content

Instantly share code, notes, and snippets.

Сергей Галездинов Sega-Zero

  • Nizhnekamsk
Block or report user

Report or block Sega-Zero

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Sega-Zero
Sega-Zero / TestSample.swift
Last active May 1, 2016
Example structures for stress-testing a Cereal library
View TestSample.swift
enum SerializationError: ErrorType {
case IncorrectData
case FileNotExists
}
extension Array where Element: CerealType {
func serialize(to filePath: String) throws {
var encoder = CerealEncoder(capacity: self.count)
try encoder.encode(self, forKey: "array")
let data = encoder.toData()
@Sega-Zero
Sega-Zero / copy_ffmpeg.sh
Created Jan 8, 2016
Script copies ffmpeg binaries that are built with brew into a specified folder and makes those binaries to be able to run from the app bundle. More info on http://sega-zero.tumblr.com/post/136899723544/ffmpeg-dylibs
View copy_ffmpeg.sh
#install ffmpeg if it is not installed
(brew list -1 | grep "ffmpeg" >/dev/null) || brew install ffmpeg
#update your ffmpeg distribution to the latest version
brew outdated ffmpeg || brew upgrade ffmpeg
#cleanup the destination folder
for file in `ls ffmpeg/*`; do rm -f $file; done;
#determine the last local ffmpeg version
@Sega-Zero
Sega-Zero / export_xliff.command
Created Jan 6, 2016
An alternative for run_genstrings script. Uses xliff export and import. Replace {YourProjectNameHere} with your project file name. Script expects to be located in the project's root directory.
View export_xliff.command
cd "`dirname "$0"`"
#this will export ru.xliff file into LocalizedFiles subfolder
xcodebuild -exportLocalizations -project ./{YourProjectNameHere}.xcodeproj -localizationPath LocalizedFiles -exportLanguage ru
#I prefer to edit xml files in TextWrangler, replace it with TextEdit, or any other text editor you like
echo `open -a 'TextWrangler' ./LocalizedFiles/ru.xliff`
@Sega-Zero
Sega-Zero / run_genstrings.command
Last active Jan 6, 2016
A useful bash script to gather all localizable strings of your Objective-C project into Localizable.strings file with UTF8 encoding. The script should be placed to the root of your project. Replace {ProjectFolderName} with your project's folder path and you're done!
View run_genstrings.command
cd "`dirname "$0"`/{ProjectFolderName}"
find . -name "*.m" -print0 | xargs -0 genstrings -o Base.lproj
cd ./Base.lproj
#this is to encode Localizable.strings in UTF8 encoding
iconv -f UTF-16 -t UTF-8 Localizable.strings > Localizable.strings1
rm -f Localizable.strings
mv Localizable.strings1 Localizable.strings
@Sega-Zero
Sega-Zero / addDependency.m
Last active Aug 29, 2015
an example of NSOperation addDependency for this SO question: http://stackoverflow.com/q/30851799/1254172
View addDependency.m
//assume NSOperationQueue *operationQueue is created somewhere
//assume dispatch_semaphore_t semaphore is created somewhere
NSOperation *firstOperation = [NSBlockOperation blockOperationWithBlock:^{
[self doTask1];
}];
NSOperation *secondOperation = [NSBlockOperation blockOperationWithBlock:^{
[self doTask2];
}];
NSOperation *notificationOperation = [NSBlockOperation blockOperationWithBlock:^{
You can’t perform that action at this time.