Skip to content

Instantly share code, notes, and snippets.

<?php
// inserts 1,000,000 docs in 14 seconds on a MacBook Pro running Ubuntu 9.04
class Timer
{
var $start;
var $pause_time;
/* start the timer */
<?php
function getReplicationInfo($m) {
$db = $m->local;
$result = array();
$ol = $db->system->namespaces->findOne(array("name" => 'local.oplog.$main'));
if ($ol && array_key_exists('options', $ol)) {
$result['logSizeMB'] = $ol['options']['size'] / 1000 / 1000;
@kchodorow
kchodorow / other.h
Created April 20, 2011 19:59
tester.cpp
#include <stdio.h>
#include "other.h"
#include "tester.h"
namespace other {
void other_type::some_method() {
printf("here\n");
}
}
@kchodorow
kchodorow / gist:3626251
Created September 4, 2012 20:44 — forked from anonymous/gist:3610610
Informadiko Sample Schema
#!/usr/bin/mongo informadiko
// ┏━┓┏━╸┏━╸┏━┓╻ ╻┏┓╻╺┳╸┏━┓
// ┣━┫┃ ┃ ┃ ┃┃ ┃┃┗┫ ┃ ┗━┓
// ╹ ╹┗━╸┗━╸┗━┛┗━┛╹ ╹ ╹ ┗━┛
db.dropDatabase() // BE CAREFUL
//db.createCollection("system.profile", {capped:true, size:1024000000}) // 1024 Megs
db.setProfilingLevel(2);
@kchodorow
kchodorow / spritescale9.js
Last active December 21, 2015 09:49
This is a SpriteScale9 class for use with LimeJS. It can be used to create resizable shapes with rounded corners, e.g., speech bubbles and progress bars.
// Copyright (C) 2013 Kristina Chodorow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@kchodorow
kchodorow / limejs.md
Last active December 20, 2017 11:04
LimeJs Notes

Adding a CSS Class

In JavaScript:

whatever.domClassName = 'foo';

In HTML:

@kchodorow
kchodorow / branch.sh
Created September 23, 2014 15:11
See all git branches with descriptions and last commit date
#!/bin/bash
# Shows branches with descriptions
branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
for branch in $branches; do
last_used=$(git show --pretty=format:"%Cgreen%cr%Creset" $branch | head -1)
desc=$(git config branch.$branch.description)
if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
branch="*\t$last_used\t\033[0;32m$branch\033[0m"
else
@kchodorow
kchodorow / Spider.java
Last active August 29, 2015 14:14
Extra credit stub for Monday, February 9th
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.NoSuchElementException;
@kchodorow
kchodorow / Restaurant.java
Created March 10, 2015 15:33
OOP practice
public class Restaurant {
public static void main(String args[]) throws InterruptedException {
Kitchen kitchen = new Kitchen();
while (true) {
Order meal = kitchen.checkForFinished();
System.out.println("Finished: " + meal);
// Maybe send a new order to the kitchen.
double rand = Math.random();
if (rand < .1) {
@kchodorow
kchodorow / SubwayLine.java
Created March 31, 2015 20:46
Train skeleton
public class SubwayLine {
public static void main(String[] args) {
Train local = new Train("C", 1, 16);
Train express = new Train("A", 3, 0);
for (int i = 0; i < 10; ++i) {
System.out.println("local: " + local.nextStop());
System.out.println("express: " + express.nextStop());