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
InputStream stream = new BufferedInputStream(response.getResponseBodyAsStream()); | |
JsonParser parser = new MappingJsonFactory(Jacksons.JSON_OBJECT_MAPPER).createJsonParser(stream); | |
parser.disableFeature(JsonParser.Feature.AUTO_CLOSE_SOURCE); | |
JacksonIterator<String> iter = JacksonIterator.iterator(parser, String.class, "items"); |
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
require 'cassandra' | |
blog = Cassandra.new('Multiblog') | |
blog.insert(:Blogs, 'david', { UUID.new => 'eventdata' }) | |
blog.insert(:Blogs, 'david', { UUID.new => 'eventdata2' }) | |
... | |
blog.insert(:Blogs, 'david', { UUID.new => 'eventdata9' }) | |
blog.get(:Blogs, "david", :count => 3, :reversed => true).values |
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 java.nio.charset.Charset; | |
import java.text.SimpleDateFormat; | |
import java.util.Arrays; | |
import java.util.Date; | |
import java.util.TimeZone; | |
public class FastDateFormatter | |
{ | |
private static final byte[][] DATES = new byte[24837][]; // days in [1970, 2038) | |
private static final byte[] DIGITS = toUtf8("0123456789"); |
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 <stdio.h> | |
#include <GeoIPCity.h> | |
int main(int argc, char *argv[]) | |
{ | |
GeoIP *geo; | |
char buf[32768]; | |
unsigned long ip; | |
GeoIPRecord *rec; |
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 <stdio.h> | |
#include <GeoIPCity.h> | |
int main(int argc, char *argv[]) | |
{ | |
GeoIP *geo; | |
char buf[32768]; | |
char addr[16]; | |
unsigned int ip1, ip2, ip3, ip4; | |
GeoIPRecord *rec; |
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
public class NewlinePrettyPrinter implements PrettyPrinter | |
{ | |
@Override | |
public void writeRootValueSeparator(JsonGenerator jg) throws IOException | |
{ | |
jg.writeRaw('\n'); | |
} | |
@Override | |
public void writeStartObject(JsonGenerator jg) throws IOException |
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.logging.LogFactory; | |
@SuppressWarnings({"UnusedDeclaration"}) | |
public class Log | |
{ | |
private final org.apache.commons.logging.Log log; | |
private Log(String name) | |
{ | |
log = LogFactory.getLog(name); |
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
#!/bin/sh | |
exec sed -i '' 's/[[:space:]]*$//' "$@" |
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
Hash.new {|h,k| h[k] = [] } |
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
# Take the basename of the upload's original filename. | |
# This handles the full Windows paths given by Internet Explorer | |
# (and perhaps other broken user agents) without affecting | |
# those which give the lone filename. | |
# The Windows regexp is adapted from Perl's File::Basename. | |
def original_filename | |
unless defined? @original_filename | |
@original_filename = | |
unless original_path.blank? | |
if original_path =~ /^(?:.*[:\\\/])?(.*)/m |