Skip to content

Instantly share code, notes, and snippets.

@lmatteis
lmatteis / gist:1322511
Created October 28, 2011 15:16
This is a PHP snippet on how to get all the triats of an ontology given its name:
<?php
class traits {
var $url = 'http://www.cropontology-curationtool.org';
function get_children($parent_id) {
$children = json_decode(file_get_contents($this->url. '/get-children/' . $parent_id));
foreach($children as $child) {
if($child->has_children > 0) {
$child->children = $this->get_children($child->id);
}
@lmatteis
lmatteis / gist:1354589
Created November 10, 2011 10:48
I can actually still write PHP code!
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("singer_dec_21") or die(mysql_error());
$origcodes = array(
'AFG',
'DZA',
'BHR',
@lmatteis
lmatteis / gist:1433554
Created December 5, 2011 13:13
Luca's TODO for Ontology Proposal 2012

Luca's TODO

Activity 1.1

a) Make sure the three main features for uploading traits are working properly. These being the OBO upload, the online web interface for creating Ontologies and finally the Trait Template excel upload functionality. Provide assistance and fix bugs in case users are unable to use the upload functionality.

Activity 1.2

a) Closely work with the ICIS developers to provide assistance with the synchronization of the data using the Crop Ontology API. In case more features are needed to programmatically retrieve this data, implement them.

@lmatteis
lmatteis / gist:1434458
Created December 5, 2011 17:24
web server in bash
#!/bin/bash
read request # this will read the first line of input
#while /bin/true; do
# read header
# [ "$header" == $'\r' ] && break;
#done
#
@lmatteis
lmatteis / gist:1865476
Created February 19, 2012 20:02
WorryDream
* { margin:0; padding:0; }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* generic */
body {
background: #ffffff;
font: 13px "Optima", "Helvetica", "Arial", sans-serif;
font-weight: normal;
@lmatteis
lmatteis / gist:2421227
Created April 19, 2012 14:15
Some fucked up php code
<?php
require_once('../csv_parser.php');
function do_post_request($url, $fields)
{
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
@lmatteis
lmatteis / gist:2507155
Created April 27, 2012 07:52
JSON.parse() not working correctly in Rhino?

Here's the JSON I'm trying to parse:

`{"Name of submitting scientist":" Eva Weltzien","Institution":"ICRISAT Bamako","Language of submission (only in ISO 2 letter codes)":{"english":"En","french":"Fr"},"Date of submission":"11/23/2011","Crop":"Sorghum","Name of Trait":{"english":"Grain covering","french":"Couverture du Grain"},"Abbreviated name ":{"english":"GRNCOV","french":"CvGr"},"Trait ID for modification, Blank for New":{"english":"CO_324:0000043","french":""},"Description of Trait":{"english":"Amount of grain covered by glumes","french":"Observation Visuelle du degr\u00e9 de couverture du grain par les glumes \u00e0 la maturit\u00e9"},"How is this trait routinely used?":{"english":"Nursery","french":"P\u00e9pini\u00e8re"},"Trait Class":"Morphological","Name of method":{"english":"Grain Covering","french":"Ouverture des glumes"},"Describe how measured (method)":{"english":"Visual observation of the recovery level of grain by the glumes at maturity to give a score","french":"Observation visuelle du niv

@lmatteis
lmatteis / httpWordFinder.php
Created July 3, 2012 08:41
Write a simple PHP script that accepts a single word and URL that then returns the number of instances the word is found at the destination URL.
<?php
/**
* This returns the amount of times
* a $word is found in a string ($str)
*/
function wordsInString($word, $str) {
// \b is for a word boundary,
// the i modifier is for case-insensitive matching
// g is for global
$regex = "/\b$word\b/i";
@lmatteis
lmatteis / gist:3193524
Created July 28, 2012 13:59
HN tumblr theme
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1,user-scalable=no">
<title>{block:SearchPage}{lang:Search results for SearchQuery} - {/block:SearchPage}{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}</title>
<link rel="alternate" type="application/rss+xml" href="{RSS}">
<link rel="shortcut icon" href="{Favicon}" />
{block:Description}<meta name="description" content="{MetaDescription}" />{/block:Description}
@lmatteis
lmatteis / gist:3739581
Created September 17, 2012 20:28
Nat.org tumblr theme
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1,user-scalable=no">
<title>{block:SearchPage}{lang:Search results for SearchQuery} - {/block:SearchPage}{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}</title>
<link rel="alternate" type="application/rss+xml" href="{RSS}">
<link rel="shortcut icon" href="{Favicon}" />
{block:Description}<meta name="description" content="{MetaDescription}" />{/block:Description}