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
# Used in Mac OS X Teminal.app (bash) | |
ping -c 3 255.255.255.255 | grep from | awk '{ print "ping -c 1 -q " $4; }' | sed 's/://' | sort -u | bash > /dev/null ; arp -a | grep ac:ca | sed 's/^.*(//' | sed 's/).*//' |
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
#import <Foundation/Foundation.h> | |
@interface SPInvocationGrabber : NSObject { | |
id _object; | |
NSInvocation *_invocation; | |
int frameCount; | |
char **frameStrings; | |
BOOL backgroundAfterForward; | |
BOOL onMainAfterForward; | |
BOOL waitUntilDone; |
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
NSArray *flattenArray(NSArray *arr) { | |
NSMutableArray *collector = [NSMutableArray array]; | |
for (id obj in arr) { | |
if ([obj isKindOfClass:[NSArray class]]) | |
[collector addObjectsFromArray:flattenArray(obj)]; | |
else | |
[collector addObject:obj]; | |
} | |
return collector; | |
} |
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
# Added to filters.rb | |
def html_truncatewords(input, words = 15, truncate_string = "...") | |
doc = Hpricot.parse(input) | |
(doc/:"text()").to_s.split[0..words].join(' ') + truncate_string | |
end | |
# Used in atom.xml | |
<content type="html">{{ post.content | html_truncatewords:100 | xml_escape }}</content> |
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
#include <iostream> | |
#include <list> | |
#include <map> | |
using namespace std; | |
bool my_pair_compare(pair<string,int> &a, pair<string,int> &b) { | |
return a.second > b.second; | |
} |
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
#import <Foundation/Foundation.h> | |
@interface UIImage (NSCoder) | |
- (void)encodeWithCoder:(NSCoder*)encoder; | |
- (id)initWithCoder:(NSCoder*)decoder; | |
@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
#import <Foundation/Foundation.h> | |
@interface NSObject (AssociatedObject) | |
- (id)associatedObjectForKey:(void*)key; | |
- (void)setAssociatedObject:(id)object forKey:(void*)key; | |
@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
/* setting tint on slider */ | |
UIGraphicsBeginImageContextWithOptions(CGSizeMake(20, 7), NO, 1.0); | |
[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(1, 0, 18, 7) | |
cornerRadius:3.0] addClip]; | |
[[UIColor grayColor] setFill]; | |
[[UIBezierPath bezierPathWithRect:CGRectMake(9, 0, 20, 7)] fill]; | |
[tintColor setFill]; | |
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 5+5, 7)] fill]; | |
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(1, 1, 18, 7) |
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
CGImageRef image = uiimage.CGImage; | |
NSUInteger width = CGImageGetWidth(image); | |
NSUInteger height = CGImageGetHeight(image); | |
// Setup 1x1 pixel context to draw into | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
unsigned char rawData[4]; | |
int bytesPerPixel = 4; | |
int bytesPerRow = bytesPerPixel; | |
NSUInteger bitsPerComponent = 8; |
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
/* | |
* main.cpp | |
* | |
* Created on: 08.12.2012 | |
* Author: sk | |
*/ | |
#include <iostream> | |
#include <windows.h> |
OlderNewer