Skip to content

Instantly share code, notes, and snippets.

View mojtabacazi's full-sized avatar

Mojtaba Cazi mojtabacazi

View GitHub Profile
@mojtabacazi
mojtabacazi / MacOS.ahk
Created March 29, 2018 15:45
OSX like keyboard. Left Keys: Win/Alt/Ctrl. Right: Ctrl/ Alt
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
RAlt::RCtrl
LAlt::LCtrl
LCtrl::LWin
RCtrl::RAlt
@mojtabacazi
mojtabacazi / main.m
Last active June 28, 2017 07:07
Find Unused Headers
//
// main.m
// Unsused Import Finder
//
// Created by Mojtaba Cazi on 6/27/17.
// Copyright © 2017 CaziSoft, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@mojtabacazi
mojtabacazi / git-insert-init.txt
Created November 29, 2016 21:09
Inserting a commit before git initial commit.
# first you need a new empty branch; let's call it `newroot`
git checkout --orphan newroot
git rm -rf .
# then you apply the same steps
git commit --allow-empty -m 'root commit'
git rebase --onto newroot --root master
git branch -d newroot
@mojtabacazi
mojtabacazi / UIViewController.m
Last active June 30, 2016 19:18
Boilerplate code for NSFetchedResultsController and UITableView
@interface ViewController () <UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate>
@property (nonatomic, weak) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSFetchedResultsController *fetchController;
@end
@implementation ViewController
@mojtabacazi
mojtabacazi / UIScrollView+ContentOffset.m
Created March 31, 2016 17:32
Changing UIScrollView contentOffset without triggering scrollViewDidScroll:
CGPoint desiredContentOffset = <#content offset#>;
CGRect scrollBounds = scrollView.bounds;
scrollBounds.origin = desiredContentOffset;
scrollView.bounds = scrollBounds;
@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
@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 / apns_payload_sample.json
Created August 15, 2015 06:25
Sample payload for Apple APNS
{
"aps": {
"badge": 10,
"alert": "Hello world!",
"sound": "cat.caf"
}
}
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 / 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