Skip to content

Instantly share code, notes, and snippets.

View nicktelford's full-sized avatar

Nick Telford nicktelford

View GitHub Profile
@nicktelford
nicktelford / gist:988485
Created May 24, 2011 10:25
goto loop in libmemcached - criminal!
test_connect:
if (connect(ptr->fd,
(struct sockaddr *)&servAddr,
sizeof(servAddr)) < 0)
{
switch (errno)
{
case EINPROGRESS:
case EALREADY:
case EINTR:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /usr/lib/hadoop-0.20/logs (Is a directory)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:216)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133)
@nicktelford
nicktelford / gist:919227
Created April 14, 2011 10:18
How to determine available system memory
$ free -m
total used free shared buffers cached
Mem: 3017 2953 64 0 381 671
-/+ buffers/cache: 1899 1118
^
Available memory (in MB) -------------|
The Linux kernel will allocate as much free memory as possible to buffers and caches (e.g. the fs cache)
to improve performance. When an application allocates more memory than is "free", the kernel will allocate
memory from it's caches.
@nicktelford
nicktelford / gist:872445
Created March 16, 2011 12:55
Abuse of 'self' to manipulate type-hinting
<?php
interface Comparable
{
public function compare(self $obj);
}
class A implements Comparable
{
public function compare(self $obj) {
return $this == $obj;