Skip to content

Instantly share code, notes, and snippets.

from lxml import etree
import os.path
import os
import sys
import re
import urllib2
import urlparse
import logging
class Chapter(object):
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');
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()
}
});
- 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
[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
#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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% datatypes.sty %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Commands Provided:
%%
%% \DECLARETYPE{Foo}
%% \DECLARESUBTYPE{Foobar}{Foo}
%%
%% \PRESETS{Foobar}{STUFF}
@nelhage
nelhage / char.tex
Last active December 25, 2015 01:19
char.tex
\PRESETS{Char}{
\FD\MYdesc {} %% badge description
\FD\MYstats {} %% use \newstat to add stats
% \newstat\MYcr {Combat Rating}{CR}{2} %% for DarkWater-style combat
\newstat\MYpsi {$\psi$}{$\psi$}{$7,9,11,13$}
\newstat\MYdrunk {$\iota$}{$\iota$}{0}
\newstat\MYdelta {$\delta$}{$\delta$}{}
\newstat\MYtau {$\tau$}{$\tau$}{10}
package main
import "log"
func main() {
var a [128]byte
log.Printf("len(a) = %d", len(a))
log.Printf("cap(a) = %d", cap(a))
log.Printf("len(a[:10]) = %d", len(a[:10]))
log.Printf("cap(a[:10]) = %d", cap(a[:10]))
/* Excerpted from https://github.com/mongodb/mongo/blob/ea83ad3103fef1664e9385d48537c4163344ce8a/src/mongo/util/debug_util.h#L37 */
// The following declare one unique counter per enclosing function.
// NOTE The implementation double-increments on a match, but we don't really care.
#define MONGO_SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; )
#define SOMETIMES MONGO_SOMETIMES
#define MONGO_OCCASIONALLY SOMETIMES( occasionally, 16 )
#define OCCASIONALLY MONGO_OCCASIONALLY