Skip to content

Instantly share code, notes, and snippets.

View Alex-Ikanow's full-sized avatar

Alex Alex-Ikanow

View GitHub Profile
@Alex-Ikanow
Alex-Ikanow / gist:2b0966921bc35e6d61fad2ad22d91dfa
Created April 29, 2016 17:04
Titan errors (ignore fact that some of the lines with the same timestamp are in the wrong order, just an artefact of sort)
Fri Apr 29 12:42:45 EDT 2016: M00: GRABBED TRANS 0 toS=standardtitantx[0x772cf46b]
Fri Apr 29 12:42:45 EDT 2016: M00: GRABBING TRANS 0
Fri Apr 29 12:42:45 EDT 2016: M01: GRABBED TRANS 0 toS=standardtitantx[0x02b90cc1]
Fri Apr 29 12:42:45 EDT 2016: M01: GRABBING TRANS 0
Fri Apr 29 12:42:46 EDT 2016: M02: GRABBED TRANS 0 toS=standardtitantx[0x13404f75]
Fri Apr 29 12:42:46 EDT 2016: M02: GRABBING TRANS 0
Fri Apr 29 12:42:46 EDT 2016: M04: GRABBED TRANS 0 toS=standardtitantx[0x6124dda2]
Fri Apr 29 12:42:46 EDT 2016: M04: GRABBING TRANS 0
Fri Apr 29 12:42:47 EDT 2016: M03: GRABBED TRANS 0 toS=standardtitantx[0x45ad3cd8]
Fri Apr 29 12:42:47 EDT 2016: M03: GRABBING TRANS 0
@Alex-Ikanow
Alex-Ikanow / keybase.md
Created November 21, 2015 15:05
Identity proving

Keybase proof

I hereby claim:

  • I am Alex-Ikanow on github.
  • I am alexpiggott (https://keybase.io/alexpiggott) on keybase.
  • I have a public key whose fingerprint is 9651 91FA E52F C87A F24C DE8A 09A8 2855 DA72 13A5

To claim this, I am signing this object:

@Alex-Ikanow
Alex-Ikanow / Mongo.getSplitKeysForChunks
Last active August 29, 2015 13:57
Fixed version of getSplitKeysForChunks
DBCollection.prototype.getSplitKeysForChunks = function ( keyPattern, chunkSize ){
var stats = this.stats()
if( ! stats.sharded ){
print( "Collection " + this + " is not sharded." )
return
}
var config = this.getMongo().getDB("config")
@Alex-Ikanow
Alex-Ikanow / gist:8363741
Created January 10, 2014 22:14
Huginn JSON issue
22:03:36 dj.1 | Agent#7: Exception during check: Did not recognize your adapter specification. -- ["/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:106:in `rescue in load_adapter'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:95:in `load_adapter'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:99:in `load_adapter'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:89:in `use'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:71:in `adapter'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:129:in `current_adapter'", "/usr/local/share/gems1.9/gems/multi_json-1.7.9/lib/multi_json.rb:116:in `load'", "/usr/local/share/gems1.9/gems/jsonpath-0.5.3/lib/jsonpath.rb:78:in `process_object'", "/usr/local/share/gems1.9/gems/jsonpath-0.5.3/lib/jsonpath.rb:64:in `enum_on'", "/usr/local/share/gems1.9/gems/jsonpath-0.5.3/lib/jsonpath.rb:56:in `on'", "/root/huginn-master/lib/utils.rb:55:in `values_at'", "/root
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"<CHANGE-ME>.github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
GHBU_PRUNE_AFTER_N_DAYS=${GHBU_PRUNE_AFTER_N_DAYS-3} # the min age (in days) of backup files to delete
@Alex-Ikanow
Alex-Ikanow / gist:5577084
Created May 14, 2013 15:56
Modified version of brace-fold.js, handles arrays
CodeMirror.braceRangeFinder = function(cm, start) {
var line = start.line, lineText = cm.getLine(line);
var at = lineText.length, startChar, tokenType;
for (; at > 0;) {
var found = lineText.lastIndexOf("{", at);
var startToken = '{';
var endToken = '}';
if (found < start.ch) {
var found = lineText.lastIndexOf("[", at);
if (found < start.ch) break;
@Alex-Ikanow
Alex-Ikanow / Kundera_true_dynamic_class_handling.java
Created April 25, 2013 19:11
A more complicated version that supports multiple dynamic classes (you can only create one class per declared template because once they're loaded they can't be modified)
package com.ikanow.infinit.e.harvest.test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
@Alex-Ikanow
Alex-Ikanow / Kundera_dynamic_class example.java
Last active December 16, 2015 15:28
Sample code showing how to persist a dynamically created (actually modified) class to MongoDB using Kundera (updated to demonstrate JPQL queries, which requires slight hack for classes not discovered by persistence.xml)
// 1] persistence.xml, this can be anywhere in the classpath
//<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="2.0">
//<persistence-unit name="mongoPU">
// <provider>com.impetus.kundera.KunderaPersistence</provider>
// <class>com.ikanow.infinit.e.harvest.test.NoSqlHarvestTest$TemplateClass</class>
// <properties>
// <property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory"/>
// <property name="kundera.port" value="27017" />
// <property name="kundera.dialect" value="mongodb" />
Map kunderaMongoConfig = new HashMap();
kunderaMongoConfig.put("kundera.nodes", "testnode.ikanow.com");
kunderaMongoConfig.put("kundera.port", "27017");
EntityManagerFactory factory = Persistence.createEntityManagerFactory("mongoPU", kunderaMongoConfig);
// (Also tried creating a KunderaPersistence, and also instantiating EntityManagerFactoryImpl directly)
@Alex-Ikanow
Alex-Ikanow / gist:5445445
Last active December 16, 2015 13:59
Kundera / MongoDB issues (Kundera 2.2.1)
/////////////////////////////////////////////
//
// 1] persistence.xml (in classpath - when I move it a get a different set of errors)
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="2.0">
<persistence-unit name="mongoPU">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.client.lookup.class" value="com.impetus.client.mongodb.MongoDBClientFactory"/>
<property name="kundera.nodes" value="localhost" />