Writing a simple Cassandra CRUD class in PHP with ThriftInterface
Oct 13th
NOSQL – so hot right now. As part of my own learning curve, I’m building a simple abstract and schema-less Factory Patterned CRUD class for Cassandra, and shoe-horning it in with Apache Thrift. There’s a very thorough blog by Evan Weaver to help dealing with the RDBMS to Cassandra conceptual jump. If you haven’t dealt with Cassandra before, it may be a good place to start. For a very decent cluster setup example, check here, and for Thrift just grab the source and follow the instructions I guess, but if you’re using debian/ubuntu I’ve written a quick install guide.
Dubbed Pandra, it will be maintained via github. Requires PHP 5.2, Cassandra 0.4, and latest Thrift Interface.
for fun, Euler Solution 11 (PHP)
Oct 1st
A bit bored so knocked up a solution to this Project Euler problem :
11: What is the greatest product of four numbers on the same straight line in the 20 by 20 grid?
More >
Finding the first and last instance of a date sorted pkey
Oct 1st
Came across a bit of a strange problem with an ad-hoc query. Basically I have a log of categorisation actions against a realm dataset for which I needed to find a list of realms in the last month where the last action on a pkey group (realm + userid, realms can multiple userid’s) different from the first action, and the first action was ‘A’. Luckily there’s an indexed ‘logdate’ field, otherwise I would have no idea how to find this data in a single query – so I’m extremely keen for feedback from anyone who could do it with elegance! Ne’er a dirtier subselect has ye seen ![]()
More >
Installing Thrift Interface on Debian
Sep 30th
So I’m getting Cassandra/Thrift up and running and came across a few dependencies with the install. Here’s the fix if you encounter either the ` PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)’ or missing yac configure and make errors.
If you’re compiling and seeing the MONO errors prior to having installed pkg-configure, just run ./cleanup.sh before running through the instructions below.
- Before compiling the Thrift source, make sure you at least have these packages installed
$ sudo apt-get install automake libtool pkg-config libboost-dev byacc mono-2.0-service flex
- This should also mostly apply to Ubuntu, though I noticed libboost1.35-dev was required (at the time of writing)
- From the directory you’ve unpacked Thrift into, just this will do, though check the configure for options
$ ./bootstrap.sh $ ./configure $ sudo make $ sudo make install
- No errors?
$ thrift -version Thrift version 20080411-exported
SEXY!
Debian (lenny) SFTP Jailing
Sep 6th
- First add a new sftp users group, I’ve named mine ‘sftponly’.
groupadd sftponly
Open /etc/ssh/sshd_config for editing. The line you will be looking for as it appears in lenny will be :
Subsystem sftp /usr/lib/openssh/sftp-server
Change this to
Subsystem sftp internal-sftp
At the bottom of the file, you’ll need this acl
Match Group sftpusers
ChrootDirectory /home/%u
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no‘Match Group’s are terminated either by a new Match Group directive, or simply the end of file, so save and restart sshd.
/etc/init.d/sshd restart
- Make sure you can still login normally through another console
- Now adduser, assign them to the new group and strip their shell. Mine will be called feyfey
adduser feyfey usermod -g sftponly feyfey usermod -s /bin/false feyfey
- Next, set the user home directory ownership to root.root, and only user writable, then jump into the users directory and create a ‘public’ directory the sftp only user can write to.
chown root.root /home/feyfey chmod 775 /home/feyfey cd /home/feyfey mkdir public; chown feyfey.sftpuser public
If there are any errors during your permissions testing thereafter, check /var/log/auth.log.
and you’re done
Some say suggestive, I also say suggestive (but also, AWESOME!!)
Sep 5th
No, I’m not on a homoerotic tip, but Cho Aniki fascinates me. Been, gone, (will play on a Japanese PS2 which shouldn’t be too hard to get), whoever owns a copy will have themselves a rather strange collectible.
How does this exist!? 愛日本 ^_^


Recent Comments