Skip to content

Instantly share code, notes, and snippets.

View abargnesi's full-sized avatar

Tony Bargnesi abargnesi

View GitHub Profile
@abargnesi
abargnesi / ig.sh
Last active November 9, 2016 16:19
Induce and log instagram connection issues using curl and jq.
#!/usr/bin/env bash
API_URL="https://api.instagram.com/v1/tags/foodporn/media/recent"
TOKEN="PUT YOUR TOKEN HERE"
request_next_url() {
URL="$1"
#http2 connections seem to be immune to connection issues.
#echo $(curl --http2 --verbose "$URL" 2>> trace-http2.log | jq .pagination.next_url | tr -d '"')
@abargnesi
abargnesi / invalid-extended-tweet.json
Created September 20, 2016 11:45
Extended tweet with invalid display_text_range
{
"created_at": "Mon Sep 19 19:36:50 +0000 2016",
"id": 777954621826342912,
"id_str": "777954621826342912",
"text": "@SobatRizalRamli @rajomalano @republikaonline @antaranews @BeritasatuTV @PKSejahtera @Gerindra @PDemokrat… https://t.co/whQg3y7tGe",
"source": "<a href=\"https://about.twitter.com/products/tweetdeck\" rel=\"nofollow\">TweetDeck</a>",
"truncated": true,
"in_reply_to_status_id": 777953136774225921,
"in_reply_to_status_id_str": "777953136774225921",
"in_reply_to_user_id": 767731724201529347,
@abargnesi
abargnesi / crawl.sh
Last active June 21, 2016 01:08
bash function that crawls for non-web URL paths
function crawl_for_urls() {
if [ $# != 1 ]; then
echo "usage: crawl_for_urls URL" >2
exit 1
fi
wget --spider --force-html -r "$1" 2>&1 | \
grep '^--' | \
awk '{ print \$3 }' | \
grep -v '\.\(css\|js\|png\|gif\|jpg\)$'
@abargnesi
abargnesi / openbel_config_v1_0_0.yml
Created June 8, 2016 09:44
OpenBEL API Config - 1.0.0
# Configuration template for OpenBEL API
# BEL configuration.
bel:
# The BEL version supported by this OpenBEL API instance.
# Allowed values:
# 1.0
# (BEL version 1.0 specification)
# 2.0
# (BEL version 2.0 specification)
@abargnesi
abargnesi / compare_lookup.rb
Created May 18, 2016 15:38
Benchmark (ips) comparison of value lookup.
require 'benchmark/ips'
require 'set'
numbers = (0..10_000_000).to_a
hash = Hash[numbers.map { |n| [n, true] }]
set = Set.new(numbers)
Benchmark.ips do |x|
x.warmup = 5
x.time = 30
@abargnesi
abargnesi / add_failing_partial_identifier_test.patch
Created April 15, 2016 14:57
Patch to add failing partial identifier test.
diff --git a/spec/unit/language/version1/syntax/v1_syntax_spec.rb b/spec/unit/language/version1/syntax/v1_syntax_spec.rb
index 513d716..ad590c1 100644
--- a/spec/unit/language/version1/syntax/v1_syntax_spec.rb
+++ b/spec/unit/language/version1/syntax/v1_syntax_spec.rb
@@ -33,4 +33,18 @@ describe 'parsing' do
end
end
end
+
+ context 'partial' do
@abargnesi
abargnesi / add_keyword_args_to_sexp_shortcuts.patch
Created April 15, 2016 14:56
Patch to add keyword arguments to Sexp shortcuts.
diff --git a/lib/bel_parser/parsers/ast/node.rb b/lib/bel_parser/parsers/ast/node.rb
index 18dfb81..fabd143 100644
--- a/lib/bel_parser/parsers/ast/node.rb
+++ b/lib/bel_parser/parsers/ast/node.rb
@@ -823,83 +823,83 @@ module BELParser
#
# @see https://en.wikipedia.org/wiki/S-expression S-expression
module Sexp
- def nested_statement(*children)
+ def nested_statement(*children, **properties)
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix belv: <http://www.openbel.org/vocabulary/> .
belv:NamespaceConceptScheme rdfs:subClassOf skos:ConceptScheme .
<http://identifiers.org/ncbigene> rdf:type skos:ConceptScheme .
<http://identifiers.org/hgnc> rdf:type skos:ConceptScheme .
@abargnesi
abargnesi / full_abstract1.json
Created March 16, 2016 14:57
JSON Evidence for full_abstract1.json having null and blank citation.id fields.
[
{
"evidence": {
"bel_statement": "a(CHEBI:\"phorbol 13-acetate 12-myristate\") -> kin(p(HGNC:MAPK1))",
"citation": {
"type": "PubMed",
"name": "J Biol Chem. 1997 Jul 4;272(27):16917-23.",
"id": null,
"date": null,
"authors": null,
@abargnesi
abargnesi / replace_line.py
Created February 26, 2016 13:31
Replace matched lines with a replacement line over a file.
#!/usr/bin/env python2
# read program arguments
import sys
program_arguments = sys.argv[1:]
if len(program_arguments) != 3:
sys.stderr.write(
"usage: replace_line.py [FILE] [MATCH] [REPLACE]\n"
)
file_name, match_line, replace_line = program_arguments