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 org.apache.commons.lang.StringUtils; | |
private String computeMD5(String string) throws NoSuchAlgorithmException { | |
byte[] stringBytes = string.getBytes(); | |
MessageDigest messageDigest = MessageDigest.getInstance("MD5"); | |
messageDigest.update(stringBytes, 0, stringBytes.length); | |
String md5 = new BigInteger(1, messageDigest.digest()).toString(16); | |
md5 = StringUtils.leftPad(md5, 32, '0'); |
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
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
float indentPoints = self.indentationLevel * self.indentationWidth; | |
if (indentPoints > 0) { | |
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
UIView *view = (UIView *)obj; | |
CGFloat width = CGRectGetWidth(view.frame); | |
if (width > indentPoints * 2) | |
width -= indentPoints; | |
CGFloat x = CGRectGetMinX(view.frame); |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>KeepAlive</key> | |
<true/> | |
<key>Label</key> | |
<string>com.apache.activemq</string> | |
<key>WorkingDirectory</key> | |
<string>/usr/local/Cellar/activemq/5.5.1/libexec</string> |
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
Configure a pipe that has the appropriate bandwidth limit and delay. | |
sudo ipfw pipe 1 config bw 16Kbit/s delay 350ms | |
Attach it to all traffic going to or from port 80. | |
sudo ipfw add 1 pipe 1 src-port 80 | |
sudo ipfw add 2 pipe 1 dst-port 80 | |
Now traffic coming from or going to port 80 anywhere is limited by the pipe that you specified. Do your testing and once you get frustrated with slow access to the web remove the rules like so: | |
sudo ipfw delete 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
sudo port -v install mysql5-server | |
sudo -u _mysql mysql_install_db5 | |
# if above command produce this error: ERROR: 1004 Can't create file '/var/tmp/#sqle967_1_0.frm' (errno: 9) | |
# do this: | |
# sudo chown -R mysql:mysql /opt/local/var/db/mysql5 | |
# sudo chmod u+rwx,go= /opt/local/var/db/mysql5 | |
# sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql | |
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
sudo port -v install mysql5-server | |
sudo -u _mysql mysql_install_db5 | |
# if above command produce this error: ERROR: 1004 Can't create file '/var/tmp/#sqle967_1_0.frm' (errno: 9) | |
# do this: | |
# sudo chown -R mysql:mysql /opt/local/var/db/mysql5 | |
# sudo chmod u+rwx,go= /opt/local/var/db/mysql5 | |
# sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql | |
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
Warning: Your developer_dir setting in macports.conf points to a non-existing directory. Since this is known to cause problems, please correct the setting or comment it and let macports auto-discover the correct path. | |
xcode-select --print-path | |
sudo nano /opt/local/etc/macports/macports.conf |
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
// Google Analytics Macro | |
#define GA_INIT_TRACKER(ACCOUNT, PERIOD, DELEGATE) \ | |
[[GANTracker sharedTracker] startTrackerWithAccountID:ACCOUNT \ | |
dispatchPeriod:PERIOD \ | |
delegate:DELEGATE]; | |
#define GA_STOP_TRACKER \ | |
[[GANTracker sharedTracker] stopTracker]; | |
#define GA_TRACK_PAGE(PAGE) {\ |
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
//Create store and moc: | |
NSURL *baseURL = [NSURL URLWithString:myUrl]; | |
RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:baseURL]; | |
//not sure what this does but it's in example project | |
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]; | |
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; | |
objectManager.managedObjectStore = managedObjectStore; | |
NSString *modelPath = nil; |
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 setFrameX(_a_, _x_) { CGRect tempframe = _a_.frame; tempframe.origin.x = _x_; _a_.frame = tempframe; } | |
#define setFrameY(_a_, _y_) { CGRect tempframe = _a_.frame; tempframe.origin.y = _y_; _a_.frame = tempframe; } | |
#define setFrameWidth(_a_, _w_) { CGRect tempframe = _a_.frame; tempframe.size.width = _w_; _a_.frame = tempframe; } | |
#define setFrameHeight(_a_, _h_) { CGRect tempframe = _a_.frame; tempframe.size.height = _h_; _a_.frame = tempframe; } | |
#define printDimensions(__X__) TVLog(@"%s : Origin:(%f, %f) Size:(%f, %f)", #__X__, __X__.frame.origin.x, __X__.frame.origin.y, __X__.frame.size.width, __X__.frame.size.height) | |
#define printSize(a) TVLog(@"%s : (%f, %f)", #a, a.width, a.height) | |
#define radiansForOrientation(_a_) (_a_ == UIInterfaceOrientationPortrait? 0 : _a_ == UIInterfaceOrientationLandscapeLeft? M_PI/2.f : _a_ == UIInterfaceOrientationLandscapeRight? -M_PI/2.f : _a_ == UIInterfaceOrientationPortraitUpsideDown? -M_PI : 0) |
OlderNewer