Skip to content

Instantly share code, notes, and snippets.

#include <unistd.h>
#include <sys/epoll.h>
#include "lib.h"
#define DEPTH 6
#define FANOUT 1000
void add_many(int parent, int child) {
int i;
[nelhage@aeronautique:~]$ pry
[1] pry(main)> require 'mongo'
=> true
[2] pry(main)> Mongo::Connection.new['nelhage']['things'].insert({'type' => 'string', :type => 'string'})
=> BSON::ObjectId('52794ae096bae530ad000001')
[3] pry(main)>
[nelhage@aeronautique:~]$ mongo nelhage
MongoDB shell version: 2.4.6
connecting to: nelhage
- def self.julian_date
+ def self.julian_date(t=Time.now)
# consistent for duration of process
- @julian_date ||= utc_to_submission(Time.now).strftime('%y%j')
+ @julian_date ||= utc_to_submission(t).strftime('%y%j')
end
mongo = db.getMongo();
dbs = mongo.getDB('admin').runCommand({listDatabases: 1});
dbs.databases.forEach(function (d) {
if (/^_test/.test(d.name)) {
printjsononeline({dropping: d.name});
mongo.getDB(d.name).dropDatabase()
}
});
function framesLinks() {
$('.framelink').toggle(function() {
$(this).text('links with frames');
$(this).parents('h2').nextAll('.libraries').first().find('li a').each(function() {
$(this).attr('href', $(this).attr('href').replace(/\/frames$/, ''));
});
}, function() {
$(this).text('links without frames');
$(this).parents('h2').nextAll('.libraries').first().find('li a').each(function() {
$(this).attr('href', $(this).attr('href') + '/frames');
from lxml import etree
import os.path
import os
import sys
import re
import urllib2
import urlparse
import logging
class Chapter(object):
/**
1728 * Code shared by String and StringBuffer to do searches. The
1729 * source is the character array being searched, and the target
1730 * is the string being searched for.
1731 *
1732 * @param source the characters being searched.
1733 * @param sourceOffset offset of the source string.
1734 * @param sourceCount count of the source string.
1735 * @param target the characters being searched for.
1736 * @param targetOffset offset of the target string.
module Golem::Mongo
# Golem::Mongo::ReplSet is an abstraction around a mongo replica set
# that provides methods for performing administrative functions. It
# implements equivalents to a number of the rs.* helpers in the
# mongo shell, as well as higher-level functions for operations such
# as managing failovers
class ReplSet
@nelhage
nelhage / keybase.md
Last active January 25, 2018 04:55
keybase.md

Keybase proof

I hereby claim:

  • I am nelhage on github.
  • I am nelhage (https://keybase.io/nelhage) on keybase.
  • I have a public key whose fingerprint is C808 7020 87F6 8CD8 C818 F239 DFC1 CF0D A816 9ACF

To claim this, I am signing this object:

@nelhage
nelhage / is_in_epoll.rb
Created March 28, 2014 06:12
Is this pid (using epoll, on amd64, on EM 1.0.0) currently blocked in the EM mainloop?
def is_in_eventmachine(pid)
begin
syscall = File.read("/proc/#{pid}/syscall")
rescue Errno::ENOENT
return false
end
words = syscall.split(" ")
if words.length != 9
# Running, or in an fault handler