Skip to content

Instantly share code, notes, and snippets.

View mammadori's full-sized avatar

Marco Amadori mammadori

  • Rovereto (TN) -- Italy
View GitHub Profile
Verifying that +mammadori is my openname (Bitcoin username). https://onename.io/mammadori

[wafflepool][1] monitor It just quick and dirty code.

Requirements

  • python-rrdtool
  • requests

Install

Just clone this, and add minutely cronjob

@mammadori
mammadori / ckanclient_fix.py
Created February 13, 2013 16:27
How to use CkanClient with CKAN 1.8 for file upload using ckan_client.upload_file(). The fixed issue was about handling HTTP Redirects, the original version returns an "obscure" «('', 'Found')» "warning" instead. The problem was first reported here: http://lists.okfn.org/pipermail/ckan-dev/2012-August/002816.html
def _post_multipart(self, selector, fields, files):
'''Post fields and files to an http host as multipart/form-data.
:param fields: a sequence of (name, value) tuples for regular form
fields
:param files: a sequence of (name, filename, value) tuples for data to
be uploaded as files
:returns: the server's response page
@mammadori
mammadori / source.py
Created October 15, 2012 09:17
Python: "source" a shell script and read variables
from subprocess import Popen, PIPE
from os import environ
def source(script, update=True, clean=True):
"""
Source variables from a shell script
import them in the environment (if update==True)
and report only the script variables (if clean==True)
"""
@mammadori
mammadori / description gr patch
Created May 18, 2012 16:37
This fails on virtuoso 6.1.5 develop/6
--- a/binsrc/dbpedia/vsp/description.vsp
+++ b/binsrc/dbpedia/vsp/description.vsp
@@ -102,9 +103,8 @@
-- setup rdf alternative links
rdf_link := 'http://'|| http_request_header (http_request_header (), 'Host')
- ||'/sparql?default-graph-uri=http%3A%2F%2F'||replace(registry_get('dbp_graph'),'http://','')||'&query=DESCRIBE+<' ||
- replace (page_resource_uri, '%', '%25') || '>';
- gen_rdf_link := rdf_link;
+ ||'/sparql?default-graph-uri=http%3A%2F%2F'||registry_get('dbp_graph_abr')||'&query=DESCRIBE+<' ||
@mammadori
mammadori / gist:2700758
Created May 15, 2012 10:45
lxc iptables
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@mammadori
mammadori / runinenv.sh
Created April 26, 2012 15:19 — forked from parente/runinenv.sh
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@mammadori
mammadori / gist:2377734
Created April 13, 2012 15:32
Added support for italian in Homepage extractor.
diff --git a/core/src/main/scala/org/dbpedia/extraction/config/mappings/HomepageExtractorConfig.scala b/core/src/main/scala/org/dbpedia/extraction/config/mappings/HomepageExtractorConfig.scala
index 504dcc7..29a2b5d 100644
--- a/core/src/main/scala/org/dbpedia/extraction/config/mappings/HomepageExtractorConfig.scala
+++ b/core/src/main/scala/org/dbpedia/extraction/config/mappings/HomepageExtractorConfig.scala
@@ -13,7 +13,6 @@ object HomepageExtractorConfig
"en" -> Set("website", "homepage", "web", "site"),
"es" -> Set("website", "homepage", "web", "site", "siteweb", "site web", "página", "sitio", "pagina"),/*cleanup*/
"eu" -> Set("webgunea"),
- "it" -> Set("homepage", "sito", "sito web"),
"fr" -> Set("website", "homepage", "web", "site", "siteweb", "site web"),/*cleanup*/