Skip to content

Instantly share code, notes, and snippets.

🌴
Apa?

Soheil Rashidi soheilpro

View GitHub Profile
@soheilpro
soheilpro / NSObject+Retry.h
Created May 24, 2013
A simple Objective-C category for retrying a block for n number of times.
View NSObject+Retry.h
@interface NSObject (Retry)
- (void)for:(NSInteger)times timesTryBlock:(void(^)(void(^)(NSError*)))block;
- (void)for:(NSInteger)times timesTryBlock:(void(^)(void(^)(NSError*)))block callback:(void(^)(NSError* error))callback;
@end
@soheilpro
soheilpro / gitchangename.sh
Created Mar 25, 2014
Change Git authors and committers.
View gitchangename.sh
git filter-branch -f --env-filter '
export GIT_COMMITTER_NAME="";
export GIT_AUTHOR_NAME="";
export GIT_COMMITTER_EMAIL="";
export GIT_AUTHOR_EMAIL="";
' --tag-name-filter cat -- --all
@soheilpro
soheilpro / gitreplace.sh
Created Mar 25, 2014
Replace string in all Git history.
View gitreplace.sh
git filter-branch --tree-filter "find . -name '*.*' -exec sed -i '' -e 's/OLDSTRING/NEWSTRING/g' {} \;" -f
View PieView.h
#import <UIKit/UIKit.h>
@interface PieView : UIView
@property (nonatomic) double value;
@end
@soheilpro
soheilpro / main.m
Created Mar 30, 2014
Adds calendar event for Persian birthdays.
View main.m
#import <EventKit/EventKit.h>
#import <Foundation/Foundation.h>
int main(int argc, const char* argv[])
{
@autoreleasepool
{
NSString* name = @"PERSON'S NAME";
NSDateComponents* birthDate = [[NSDateComponents alloc] init];
@soheilpro
soheilpro / csvparser.js
Last active Aug 29, 2015
CSV Parser in JS
View csvparser.js
function ValueToken(value) {
this.value = value;
}
function CommaToken() {
}
function NewLineToken() {
}
@soheilpro
soheilpro / example.sh
Last active Mar 22, 2019
Easy IIS log file format specification for goaccess.
View example.sh
goaccess -f u_ex150629.log --log-format "$(cat u_ex150629.log | ./goiisformat.sh)" --date-format '%Y-%m-%d' --time-format '%H:%M:%S'
@soheilpro
soheilpro / example
Created Jul 12, 2015
Convert JavaScript object to JSON
View example
echo '{name: "soheil", age: 123}' | tojson
# Output:
# {"name":"soheil","age":123}
@soheilpro
soheilpro / ping.sh
Created Jul 29, 2015
Simple web site monitoring script.
View ping.sh
#!/usr/bin/env bash
DATE=$(TZ=Asia/Tehran date +"%Y-%m-%d %H:%M")
TIMESTAMP=$(TZ=Asia/Tehran date +"%Y%m%d%H%M")
# URLs
URLS=(
"google|https://www.google.com"
"wikipedia|https://www.wikipedia.org"
View command.sh
git config --global alias.fu = "!f() { git commit --fixup $1; EDITOR=cat git rebase --interactive --autosquash $1~; }; f"
You can’t perform that action at this time.