Skip to content

Instantly share code, notes, and snippets.

View weekwood's full-sized avatar
🎯
Focusing

Di Wu weekwood

🎯
Focusing
View GitHub Profile
defaults write com.omnigroup.OmniFocus RelativeDateFormatterShowTime YES
@weekwood
weekwood / gist:4129679
Created November 22, 2012 06:27
objective-c Shaking
static BOOL AccelerationIsShaking(UIAcceleration* last, UIAcceleration* current, double threshold) {
double
deltaX = fabs(last.x - current.x),
deltaY = fabs(last.y - current.y),
deltaZ = fabs(last.z - current.z);
return
(deltaX > threshold && deltaY > threshold) ||
(deltaX > threshold && deltaZ > threshold) ||
(deltaY > threshold && deltaZ > threshold)
@weekwood
weekwood / scriptsort.sh
Created November 28, 2012 18:53 — forked from jprante/scriptsort.sh
Scripted sorting
curl -XDELETE 'localhost:9200/scriptsort'
curl -XPOST 'localhost:9200/scriptsort' -d '
{
"mappings": {
"test": {
"_id": {
"index" : "not_analyzed",
"stored": "yes"
}
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
- (NSString *) platform;
@weekwood
weekwood / JailBreakCheck.mm
Created December 12, 2012 21:15
Check if iPhone jailbreak or not
+(BOOL) jailBreakCheck{
NSArray *jailbrokenPath = [NSArray arrayWithObjects:
@"/Applications/Cydia.app",
@"/Applications/RockApp.app",
@"/Applications/Icy.app",
@"/usr/sbin/sshd",
@"/usr/bin/sshd",
@"/usr/libexec/sftp-server",
@"/Applications/WinterBoard.app",
@"/Applications/SBSettings.app",
@weekwood
weekwood / RegexCatchMention
Created December 24, 2012 01:16
Regex to catch @mention #hashtag and link http(s)://
NSRegularExpression *regex = [NSRegularExpressionregularExpressionWithPattern:@"((@|#)([A-Z0-9a-z(é|ë|ê|è|à|â|ä|á|ù|ü|û|ú|ì|ï|î|í)\u4e00-\u9fa5_]+))|(http(s)?://([A-Z0-9a-z._-]*(/)?)*)" options:NSRegularExpressionCaseInsensitive error:&error];
@weekwood
weekwood / pauseLayer.m
Created January 8, 2013 02:19
pause and resume Layer
- (void)pauseLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
}
- (void)resumeLayer:(CALayer*)layer
{
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
@weekwood
weekwood / ShadowRadius.mm
Last active December 10, 2015 20:59
UINavigationBar rounded corners
CALayer *capa = [self.navigationController navigationBar].layer;
[capa setShadowColor: [[UIColor blackColor] CGColor]];
[capa setShadowOpacity:0.85f];
[capa setShadowOffset: CGSizeMake(0.0f, 1.5f)];
[capa setShadowRadius:2.0f];
[capa setShouldRasterize:YES];
//Round
CGRect bounds = capa.bounds;
@interface NSFileManager (DoNotBackup)
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@end
server {
listen 80;
server_name www.mysite.com;
root /path/to/main_site;
# ...
location / {
proxy_set_header X-Real-IP $remote_addr;
# ...