Skip to content

Instantly share code, notes, and snippets.

View MMcM's full-sized avatar

Mike McMahon MMcM

  • San Francisco, CA
View GitHub Profile
@MMcM
MMcM / 00-README.md
Last active August 29, 2015 14:08
Converting JBoss application to use shared FDB to avoid api_version_already_set

Converting to shared FDB

  • Find the system modules directory, which is something like $JBOSS_HOME/modules or .../jboss-eap/modules/system/layers/base/.

  • Add a new directory com/foundationdb/main there. (There should already be com and org or you probably don't have the right starting directory.)

  • Put the module.xml file into that new directory.

@MMcM
MMcM / Gemfile.patch
Created October 10, 2014 21:39
disapora* on FoundationDB SQL layer
diff --git a/Gemfile b/Gemfile
index 678a5d2..d5748b4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -56,6 +56,7 @@ ENV['DB'] ||= 'mysql'
gem 'mysql2', '0.3.16' if ENV['DB'] == 'all' || ENV['DB'] == 'mysql'
gem 'pg', '0.17.1' if ENV['DB'] == 'all' || ENV['DB'] == 'postgres'
+gem 'activerecord-fdbsql-adapter', github: 'FoundationDB/sql-layer-adapter-activerecord' if ENV['DB'] == 'all' || ENV['DB'] == 'fdbsql'
@MMcM
MMcM / FDBRoutines.java
Last active August 29, 2015 14:05
Stored procedures to access key-value store from SQL layer transaction
package com.foundationdb.example;
import com.foundationdb.Transaction;
import com.foundationdb.directory.DirectoryLayer;
import com.foundationdb.server.store.FDBTransactionService.TransactionState;
import com.foundationdb.server.store.FDBTransactionService;
import com.foundationdb.sql.server.ServerCallContextStack;
import com.foundationdb.sql.server.ServerQueryContext;
import java.util.Arrays;
@MMcM
MMcM / TestJavaBasic.java
Last active October 29, 2018 03:46
FoundationDB SQL Layer Java Routine Example
package com.foundationdb.example;
public class TestJavaBasic
{
public static void addSub(int x, int y, int[] sum, int[] diff) {
sum[0] = x + y;
diff[0] = x - y;
}
}
@MMcM
MMcM / 00-README.md
Created July 2, 2014 14:17
Problem with closed sockets in CC3000 library

Problem sequence:

  • Server completes request and sends close.
  • Client interrupt handler sets closed_sockets.
  • Application closes socket before reading all input and so without calling connected when empty.
  • Closed flag is still set on unused connection.
  • New connection (CC3000 does not cycle socket numbers -- so almost always 0 again).
  • Server is slow to respond so no input available.
  • connected has closed and none available, so not connected.
  • Connection failed.
@MMcM
MMcM / extendedcommand
Created May 27, 2014 13:50
CM10 on MK802
run_program("/sbin/cp", "-R", "/cache/recovery", "/tmp/recovery");
ui_print("ROM Manager Version 5.0.2.0");
ui_print("Septiembre 12, 2012");
ui_print("Preparing to install ROM...");
run_program("/sbin/mount", "/sdcard");
format("/system");
format("/data");
format("/cache");
assert(install_zip("/sdcard/cm10_a10_20121011.zip"));
assert(install_zip("/sdcard/gapps-jb-20121011-signed.zip"));
@MMcM
MMcM / 00-HOWTO.md
Last active August 29, 2015 13:57
Using DD-WRT to build a demo cluster firewall

Demo Firewall

Features

  • WiFi AP & NAT firewall. (192.168.10.x)
  • Radio initially off; front button (Cisco logo) turns on.
  • Isolated VLAN on Port 4. (192.168.11.x)
  • HAProxy load balancer. (192.168.10.2)
  • PXE on vlan2 netboots Ubuntu 12.04 LTS installer.
  • Linksys WRT54GS!
@MMcM
MMcM / ReadRows.java
Last active August 29, 2015 13:56
Reading and writing Tuple format rows directly
package test;
import com.foundationdb.Database;
import com.foundationdb.FDB;
import com.foundationdb.KeyValue;
import com.foundationdb.Transaction;
import com.foundationdb.directory.DirectoryLayer;
import com.foundationdb.directory.DirectorySubspace;
import com.foundationdb.async.AsyncIterable;
import com.foundationdb.async.AsyncUtil;
@MMcM
MMcM / check_pdo.php
Last active January 3, 2016 11:49
Check PHP PDO connectivity.
<?php
$dbh = new PDO("pgsql:host=localhost port=15432 dbname=system");
$stmt = $dbh->prepare('SELECT version()');
$stmt->execute();
$row = $stmt->fetch();
echo $row[0] . "\n";
?>
@MMcM
MMcM / fdb_sql_protobuf.py
Last active December 27, 2015 06:29
Using FDB SQL STORAGE_FORMAT to allow read access from Python
from google.protobuf import descriptor
from google.protobuf import descriptor_pb2
from google.protobuf import descriptor_pool
from google.protobuf import message
from google.protobuf import reflection
import fdb
from directory import directory