Skip to content

Instantly share code, notes, and snippets.

View abargnesi's full-sized avatar

Tony Bargnesi abargnesi

View GitHub Profile
@abargnesi
abargnesi / error_cherrypy.py
Created October 1, 2012 13:08
Custom response bodies for HTTP errors
#!/usr/bin/env python
import cherrypy
import simplejson
def not_found():
resp = cherrypy.response
resp.headers['Content-Type'] = 'application/json'
resp.status = 404
body = {'success': False, 'code': 404}
@abargnesi
abargnesi / infinite_loop
Created January 22, 2013 17:01
BEL script that causes an infinite loop while parsing.
##################################################################################
# Document Properties Section
SET DOCUMENT Name = "InfiniteLoop"
SET DOCUMENT Description = "InfiniteLoop"
SET DOCUMENT Version = "1.0"
##################################################################################
# Definitions Section
@abargnesi
abargnesi / gist:6628656
Created September 19, 2013 19:30
Groovy snippet that causes type error on groovy 2.1.7 (invokedynamic version).
interface ServiceA {}
interface ServiceB {}
interface ServiceC {}
interface ServiceD {}
interface ServiceE {}
interface ServiceF {}
interface ServiceG {}
static Expando getRefs(Integer i, Class<?>... ifaces) {
Expando e = new Expando()
@abargnesi
abargnesi / free_invalid_pointer_test.rb
Created April 25, 2014 13:16
invalid pointer tests in redlander
#!/usr/bin/env ruby
require 'redlander'
include Redlander
class Node
def self.finalize_node(rdf_node_ptr)
proc {
# XXX Uncommenting the following line seems to invalidate the "rdf_node_ptr". Then the librdf_free_node call always succeeds without error.
#Redland.librdf_node_get_type(rdf_node_ptr)
Redland.librdf_free_node(rdf_node_ptr)
@abargnesi
abargnesi / 0_Gemfile_only_git
Created July 18, 2014 03:08
'bundler package --all' fails to find git-sourced gem if Bundler.setup is called twice. Fails in '3_terminal_multiple.md' as well as with the '4_example.rb'.
source 'https://rubygems.org'
gem 'bel', :git => 'https://github.com/OpenBEL/bel.rb.git'
@abargnesi
abargnesi / 0_directories
Created July 18, 2014 15:15
Using local directories for gem dependency paths.
.
├── directories
├── Gemfile
├── Gemfile.dev
├── Gemfile.dev.lock
├── Gemfile.lock
├── libraries
│   └── gemx
│   ├── gemx.gemspec
│   └── lib
@abargnesi
abargnesi / redland.rb
Created July 30, 2014 19:55
Streaming statements, with configurable return values, using the ruby redland-bindings
require_relative '../api.rb'
require 'rdf/redland'
require_relative './triple_iterator.rb'
module OpenBEL
class Storage
include OpenBEL::StorageAPI
DEFAULTS = {
storage: 'sqlite',
@abargnesi
abargnesi / gem-fetch-dependencies
Last active August 29, 2015 14:04 — forked from Milly/gem-fetch-dependencies
Works with rubygems on ruby 2.1.2
#!/usr/bin/env ruby
require 'rubygems'
require 'rubygems/commands/fetch_command'
class Gem::Commands::FetchCommand
def add_version_option_with_fetch_depends
add_version_option_without_fetch_depends
add_option('-y', '--[no-]dependencies', "Fetch dependent gems") do |value, options|
options[:dependencies] = value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f4a7c7c7e10, pid=19173, tid=139957912000256
#
# JRE version: Java(TM) SE Runtime Environment (7.0_65-b17) (build 1.7.0_65-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libzmq.so.3+0x26e10] zmq::socket_base_t::process_term(int)+0x80
#
@abargnesi
abargnesi / gist:72be7fcb7009adb82e14
Created August 6, 2014 18:26
Fail to migrate using sqlite database...SQL compliant ALTER syntax?
[tony@starship openbel-webtools (master * u=)]$ rm db/development.sqlite3
[tony@starship openbel-webtools (master * u=)]$ rm db/test.sqlite3
[tony@starship openbel-webtools (master * u=)]$ rake db:setup
-- create_table("belfiles", {:force=>true})
-> 0.0494s
-- initialize_schema_migrations_table()
-> 0.1396s
You have 3 pending migrations:
20140806032021 CreateGraphs
20140806032038 CreateNodes