This file contains hidden or 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 <iostream> | |
#include <algorithm> | |
#include <vector> | |
#include "stop_watch.inl" // see https://gist.github.com/2057981 | |
#ifndef COUNT | |
#define COUNT 100000000 | |
#endif | |
int compare_int(const void* p1, const void* p2) |
This file contains hidden or 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 <sys/time.h> // for gettimeofday() | |
class StopWatch { | |
timeval started; | |
std::string msg; | |
public: | |
StopWatch(const std::string& m): msg(m) | |
{ gettimeofday(&started, NULL); } |
This file contains hidden or 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 "curb" | |
class Neography::Rest | |
class Curl::Easy | |
def parsed_response | |
@parsed_response ||= MultiJsonParser.new(body_str, :json).send(:json) | |
end | |
alias :body :body_str | |
alias :code :response_code |
This file contains hidden or 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
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/packages/utils/nano package/nano | |
A package/nano | |
A package/nano/Makefile | |
Exported revision 35148. | |
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ grep DEPENDS package/nano/Makefile | |
DEPENDS:=+libncurses | |
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/trunk/package/ncurses package/ncurses | |
svn: E170000: URL 'svn://svn.openwrt.org/openwrt/trunk/package/ncurses' doesn't exist | |
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/trunk/package/libs/ncurses package/ncurses | |
A package/ncurses |
This file contains hidden or 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
class Nokogiri::HTML::Document | |
def meta_encoding | |
content_type = css("meta[http-equiv=content-type]").each do |meta| | |
break meta.attribute("content").value | |
end | |
return unless content_type | |
content_type.split("; ").each do |part| | |
next unless part =~ /^charset=(.*)/ |
This file contains hidden or 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
class Movie < ActiveRecord::Base | |
end | |
module Crawler | |
extend self | |
def run | |
html = Net::HTTP.get "..." | |
doc = Nokogiri.HTML(html) | |
doc.css(".movies").each do |movie| |
This file contains hidden or 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
func BidirectionalCopy(conn net.Conn, channel net.Conn) { | |
start := time.Now() | |
var done = make(chan int, 1) | |
go copy("to ssh channel", conn, channel, done) | |
go copy("from ssh channel", channel, conn, done) | |
written := <-done | |
conn.Close() | |
channel.Close() |
This file contains hidden or 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
func copy(dest io.Writer, src io.Reader) int64 { | |
// If dest has a ReadFrom method, we use that. This gives us zero copy | |
// when copying between sockets, for example. | |
if reader_from_dest, ok := dest.(io.ReaderFrom); ok { | |
written, _ := reader_from_dest.ReadFrom(src) | |
return written | |
} | |
buf := make([]byte, 1024 * 16) |
This file contains hidden or 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
# encoding: UTF-8 | |
# Chiliproject to Redmine converter | |
# ================================= | |
# | |
# This script takes an existing Chiliproject database and | |
# converts it to be compatible with Redmine (>= v2.3). The | |
# database is converted in such a way that it can be run multiple | |
# times against a production Chiliproject install without | |
# interfering with it's operation. This is done by duplicating |
This file contains hidden or 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
console.log(document.referrer) |