Skip to content

Instantly share code, notes, and snippets.

@vikage
vikage / backupDSYM.sh
Last active October 7, 2016 08:26
Backup DSYM file to Desktop after build **Include to xcode run script - Build pharses**
DSYM_UDID="$(xcrun dwarfdump --uuid ${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH} | cut -c 7-42)"
DSYM_LOCATE=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
DSYM_BACKUP_FOLDER="$HOME/Desktop/DSYM/${TARGET_NAME}"
mkdir -p $DSYM_BACKUP_FOLDER
DSYM_BACKUP_LOCATE="$DSYM_BACKUP_FOLDER/$DSYM_UDID.DSYM"
if [ ! -e "$DSYM_BACKUP_LOCATE" ]; then
echo "DSYM Backup File not found!... Copying"
cp -r "$DSYM_LOCATE" "$DSYM_BACKUP_LOCATE"
fi
@vikage
vikage / gist:c2019c600da4aafa3b49946a68e9ae8c
Created November 16, 2016 08:04 — forked from XueshiQiao/gist:5918651
Disable warning "PerformSelector may cause a leak because its selector is unknown"
//disable warning:"PerformSelector may cause a leak because its selector is unknown"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.delegate performSelector:self.selector];
#pragma clang diagnostic pop
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
for (UIView *v in viewController.view.subviews)
{
NSLog(@"%@",[v class]);
if ([v isKindOfClass:[NSClassFromString(@"CMKBottomBar") class]])
{
SEL se = NSSelectorFromString(@"cancelButton");
// method
@vikage
vikage / xxx.m
Last active February 27, 2017 06:25
Fix UIImagePickerController allowEditing bug
@implementation UpdateAvatarViewController
{
UIScrollView *cropImageScrollView;
}
-(void) chooseCameraPicture
{
cropImageScrollView = nil;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
@vikage
vikage / xbuild
Created May 15, 2017 14:48
xbuild script to build project iOS. Put it to /usr/bin and call from current project command line. xbuild -h for more.
#!/bin/bash
BUILD_CONFIG="Release"
SCHEME=""
FILENAME="xxx"
while getopts m:s:f:h aflag; do
case $aflag in
m) BUILD_CONFIG=$OPTARG;;
s) SCHEME=$OPTARG;;
f) FILENAME=$OPTARG;;
@vikage
vikage / .bash_profile
Created May 17, 2017 02:28 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@vikage
vikage / clean_code.md
Created June 10, 2017 15:49 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:@{
UIFontDescriptorNameAttribute: @"SourceSansPro-Regular",
UIFontDescriptorCascadeListAttribute:
@[
[UIFontDescriptor fontDescriptorWithFontAttributes:@{ UIFontDescriptorNameAttribute: @"Hiragino Sans GB W3" }]
]
}];
});
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:pointSize];
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
int main() {
// extra_rc must be the MSB-most field (so it matches carry/overflow flags)
// indexed must be the LSB (fixme or get rid of it)
void * -[HelloService getValue](void * self, void * _cmd) {
var_18 = [@"Hello thanhvu.dev" retain];
var_28 = [var_18 retain];
objc_storeStrong(var_18, 0x0);
rax = [var_28 autorelease];
return rax;
}