This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// suggested shell cmd line to run this: | |
// | |
// mongo --shell example2.js | |
// | |
// Note: the { out : … } parameter is for mongodb 1.8+ | |
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } ); | |
db.things.insert( { _id : 2, tags : ['cat'] } ); | |
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } ); | |
db.things.insert( { _id : 4, tags : [] } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## GrabSnap -- An automated screenshot and osx iSight imaging tool | |
## Requires isightcapture in the path | |
## grabsnap.sh [name] [interval in seconds] [number of monitors] | |
## [2011.04.11] | |
INTERVAL=60 | |
PICTURE_DIR="$HOME/Pictures/grabsnap" | |
MONITORS=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default). | |
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic. | |
# Required variables: | |
RSS_URI="/rss" | |
MAIL_TO="[email protected]" | |
LOG_FILE="/var/log/httpd/access_log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'thread' | |
$o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten; | |
$n_found = 0 | |
$mutex = Mutex.new | |
def generate | |
generated = (0...4).map{ $o[rand($o.length)] }.join; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize | |
{ | |
//UIGraphicsBeginImageContext(newSize); | |
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0); | |
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSString*) sha1:(NSString*)input | |
{ | |
const char *cstr = [input cStringUsingEncoding:NSUTF8StringEncoding]; | |
NSData *data = [NSData dataWithBytes:cstr length:input.length]; | |
uint8_t digest[CC_SHA1_DIGEST_LENGTH]; | |
CC_SHA1(data.bytes, data.length, digest); | |
NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSURLRequest *)requestForFetchRequest:(NSFetchRequest *)fetchRequest | |
withContext:(NSManagedObjectContext *)context { | |
// init the query string dictionary | |
NSMutableDictionary *queryString = nil; | |
// if we're given a predicate, convert it to a dictionary | |
if (fetchRequest.predicate) { | |
if ([fetchRequest.predicate isKindOfClass:[NSCompoundPredicate class]]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install class-dump | |
brew install class-dump | |
# dump the frameworks you're interested in | |
class-dump -H -o UIKit /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework | |
class-dump -H -o SpringBoardUI /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/PrivateFrameworks/SpringBoardUI.framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ms_invoke_block_if_not_nil(BLOCK, ...) if ((BLOCK)) {(BLOCK)(__VA_ARGS__);} | |
// Usage: | |
void (^block)(id, id, id) = void(^)(id parameter1, id parameter2, id parameter3) { | |
// ... | |
}; | |
ms_invoke_block_if_not_nil(block, parameter1, parameter2, parameter3); | |
// As opposed to: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pod::Spec.new do |s| | |
s.name = "Nimble" | |
s.version = "0.0.1" | |
s.summary = "Core Data and iCloud made nimble and fast." | |
s.homepage = "http://github.com/MarcoSero/Nimble" | |
s.license = 'MIT' | |
s.author = { "Marco Sero" => "[email protected]" } | |
s.source = { :git => "https://github.com/MarcoSero/Nimble.git", :tag => "0.0.1" } | |
s.platform = :ios, '5.0' | |
s.source_files = 'Nimble/*.{h,m}', 'Nimble/**/*.{h,m}' |
OlderNewer