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 / 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" />
@Alex-Ikanow
Alex-Ikanow / gist:5008868
Last active December 14, 2015 01:49
Chunk migration errors after adding second shard
--------------------------------
SHARD1 LOGS:
Soon after adding the second shard:
Mon Feb 18 16:10:31 [conn68] moveChunk updating self version to: 2|1||000000000000000000000000 through { index: "000007bdc6f2a4f19f36149b08cac55" } -> { index: "01d8d8f3fcac4efa684888aa46d9008f" } for collection 'feature.association'
---
Mon Feb 18 16:11:18 [conn29881] assertion 13388 [feature.association] shard version not ok in Client::Context: version mismatch detected for feature.association, stored major version 2 does not match received 1 ( ns : feature.association, received : 1|84||000000000000000000000000, wanted : 2|0||000000000000000000000000, send ) ( ns : feature.association, received : 1|84||000000000000000000000000, wanted : 2|0||000000000000000000000000, send ) ns:feature.$cmd query:{ findandmodify: "association", query: { index: "14be3fa342209dacb92cfa69073829e0", communityId: ObjectId('4c927585d591d31d7b37097a')}, fields: { doccount: 1, entity1: 1, entity2: 1, verb: 1, db_sync_time: 1, db_sync_doccount: 1 },
@Alex-Ikanow
Alex-Ikanow / gist:4979375
Created February 18, 2013 18:14
Example document containing "philip morris/company" entity
{
"_id" : ObjectId("4f996119e4b053cd3218c2fd"),
"associations" : [
{
"entity1" : "clay wanta",
"entity1_index" : "clay wanta/person",
"verb" : "current",
"verb_category" : "career",
"entity2" : "police detective",
"entity2_index" : "police detective/position",