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
var dbs = db.getMongo().getDBNames(); | |
for(var i = 0; i < dbs.length; i++){ | |
print("dropping " + dbs[i]); | |
db = db.getSiblingDB(dbs[i]); | |
db.dropDatabase(); | |
} | |
// see also: http://stackoverflow.com/questions/4727127/mongodb-shell-scripting | |
// see also: http://stackoverflow.com/a/3010848/156060 |
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/bash | |
# shrinkpdf - Reduce PDF filesize. | |
# Copyright (C) 2012 Adam Monsen <[email protected]> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# |
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
#!/usr/bin/env python | |
# Python script to make Skype co-operate with GNOME3 notifications. | |
# | |
# | |
# Copyright (c) 2011, John Stowers | |
# | |
# Adapted from skype-notify.py | |
# Copyright (c) 2009, Lightbreeze | |
# | |
# |
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
<?php | |
namespace Foo\BarBundle\Facebook; | |
use FOS\FacebookBundle\Facebook\FacebookSessionPersistence as BaseFacebookSessionPersistence; | |
use Symfony\Component\HttpFoundation\Session\Session; | |
/** | |
* Quick (and dirty) fix for running tests using FosFacebookBundle. | |
* It may have unwanted consequences (not tested)! |
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
<?php | |
// Demonstrate Papertrail API issue. This stopped working 2012-11-05. | |
// workaround: create a new curl handle before every request | |
$ch = curl_init(); | |
// First request. Output ignored. | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Papertrail-Token: ' . $argv[1])); |
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
<?php | |
// app/config/assets_version.php | |
$container->loadFromExtension('framework', array( | |
'templating' => array( | |
'engines' => array('twig'), | |
'assets_version' => exec('git rev-parse --short HEAD'), | |
), | |
)); |
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
// I wanted to know the top five largest collections in my MongoDB database in | |
// terms of document count. This MongoDB-specific JavaScript gets the job done. | |
// | |
// Edit variables in the config section, then execute like so: | |
// | |
// mongo --quiet topCollections.js | |
// config | |
var dbname = 'FIXME'; |
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
#!/usr/bin/python | |
# coding: utf-8 | |
import re, unittest | |
def octalReplace(x): | |
c = int(x.group(1), 8) | |
if c > 0x20 and c < 0x2e or c > 0x2e and c < 0x7f: | |
return chr(c) | |
else: |
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
# I was surprised today by Python's class semantics. tl;dr is that | |
# "pre-declaration" (like you might do in Java or PHP) is unnecessary, and can | |
# lead to some unexpected results. | |
# | |
# See: https://twitter.com/meonkeys/status/289454306707521536 | |
# and: http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables | |
# and: http://stackoverflow.com/questions/664294/just-declaring-a-variable-in-python | |
# and: http://stackoverflow.com/questions/68645/static-class-variables-in-python | |
# and: http://stackoverflow.com/questions/207000/python-difference-between-class-and-instance-attributes |
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
$ svn checkout https://svn.apache.org/repos/asf/incubator/mesos/trunk mesos-trunk | |
$ cd mesos-trunk | |
$ ./bootstrap | |
... | |
$ ./configure && make | |
... | |
make[2]: Entering directory `/tmp/mesos/mesos-trunk/src' | |
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DPACKAGE_NAME=\"mesos\" -DPACKAGE_TARNAME=\"mesos\" -DPACKAGE_VERSION=\"0.12.0\" -DPACKAGE_STRING=\"mesos\ 0.12.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesos\" -DVERSION=\"0.12.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_PTHREAD=1 -DMESOS_HAS_JAVA=1 -DMESOS_HAS_PYTHON=1 -DHAVE_LIBZ=1 -DHAVE_LIBCRYPTO=1 -DHAVE_LIBSSL=1 -DHAVE_LIBCURL=1 -I. -Wall -Werror -DMESOS_WEBUI_DIR=\"/usr/local/share/mesos/webui\" -DMESOS_LIBEXECDIR=\"/usr/local/libexec/mesos\" -I../include -I../third_party/libprocess/include -I../include -I../third_party/boost-1.51.0 -I../thi |