Nicholas Cottrell niccottrell
- Normandy, France
- Sign in to view email
- http://www.niccottrell.com
View db-compare.js
// 1. Configure settings below | |
// 2. Run with "mongo db-spotchecks.js" | |
uriOld = "mongodb://user:pass@hosname:27017/admin?replicaSet=MySet&ssl=true" | |
uriNew = "mongodb://localhost" | |
dbName = "MyDB"; | |
excludeCollections= ["CronLog", "HitLog", "Freq", "SystemLog", "Message"] // Exclude any non-critical collections | |
sample = { | |
min: 10, | |
max: 2000 |
View tuned-mongod-virtual-guest.conf
# | |
# tuned configuration optimized for MongoDB on AWS (or other cloud services) | |
# based on the 'virtual-guest' tuned profile | |
# tested on RHEL7 | |
# | |
[main] | |
summary=Optimize for MongoDB wiredTiger Performance | |
include=virtual-guest |
View shard-key-compound.js
/** | |
* | |
* This script is to experiment with a compound shard key. | |
* | |
* Goals: | |
* 1. the hash (h) to always be the same for the same date (down to the day level) | |
* 2. documents with the same exact date (dMy) go on the same shard but different day to different shards | |
* 3. will work well with 100m+ documents | |
* 4. small overhead related to a simple (non-compound) date shard key | |
* 5. still support targeted queries (as long as "h" field is included in the query by the application) |
View YelpApi.java
import com.github.scribejava.core.builder.ServiceBuilder; | |
import com.github.scribejava.core.builder.api.DefaultApi20; | |
import com.github.scribejava.core.model.*; | |
import com.github.scribejava.core.oauth.OAuth20Service; | |
import org.jetbrains.annotations.Nullable; | |
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
import org.json.simple.parser.JSONParser; | |
import org.json.simple.parser.ParseException; |
View inline-labels.js
// Inline Labels | |
// -------------------------------------------------- // | |
$('input, textarea').each(function() { | |
// load the corresponding label | |
var $self = $(this); | |
var $label = $("label[for='" + $self.attr("id") + "']"). | |
if ($label.text(); { |
View mongodb-arbiter.conf
systemLog: | |
destination: file | |
path: "/var/log/mongo/mongo-arb.log" | |
logAppend: true | |
storage: | |
dbPath: "/var/lib/mongo-arb" | |
processManagement: | |
fork: true | |
pidFilePath: "/var/run/mongo/mongod-arb.pid" | |
net: |
View etckeeper.sh
# After etckeeper installation | |
/etc/etckeeper/etckeeper.conf VCS="git" | |
etckeeper init && etckeeper commit | |
# ------ | |
git config --global user.name "My Machine" | |
git config --global user.email "etckeeper@my.machine" |
View functions.js
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm | |
function map() { | |
emit(1, // Or put a GROUP BY key here | |
{sum: this.value, // the field you want stats for | |
min: this.value, | |
max: this.value, | |
count:1, | |
diff: 0, // M2,n: sum((val-mean)^2) | |
}); |