Skip to content

Instantly share code, notes, and snippets.

View romanr's full-sized avatar
😶

Roman romanr

😶
View GitHub Profile
@romanr
romanr / mpnml
Created July 27, 2012 16:20 — forked from holms/mpnml
Mysql, Php-fpm, Nginx on OSX Mountain Lion
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
@romanr
romanr / gist:3171701
Created July 24, 2012 18:32
Simulate slow network on OSX
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
@romanr
romanr / com.apache.activemq.plist
Created July 11, 2012 09:15
Homebrew activemq launchDaemon script
<?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>
@romanr
romanr / UITableViewCell.m
Created June 27, 2012 10:07 — forked from pier-oliviert/UITableViewCell.m
UITableViewCell subclass to handle indentationLevel
- (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);
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');