Skip to content

Instantly share code, notes, and snippets.

View lmorillas's full-sized avatar

Luis Miguel Morillas lmorillas

View GitHub Profile
@lmorillas
lmorillas / data-ex-fixed-order
Created February 8, 2015 09:23
Simile - Exhibit Fixed Order on Facet: data-ex-fixed-order
<div data-ex-role="exhibit-facet" data-ex-expression=".month"
data-ex-facet-label="Month" data-ex-show-missing="false"
data-ex-scroll="true" data-ex-collapsible="true"
data-ex-fixed-order="January;February;March;April;May;June;July;August;September;October;November;December"
data-ex-collapsible="true">
</div>
@lmorillas
lmorillas / Simile - yearOf
Last active August 29, 2015 14:17
yearOf() Extract the year from an ISO date. Function for Simile - Exhibit
<script>
$(document).bind("scriptsLoaded.exhibit", function() {
Exhibit.FunctionUtilities.registerSimpleMappingFunction("yearOf",
function(d) {
return d.split('-')[0];
},
"number");
});
</script>
@lmorillas
lmorillas / show_hide.html
Last active August 29, 2015 14:18
Show / hide a block at an exhibit view
<script>
$(document).bind("onAfterViewPanelSwitch.exhibit", function(event, i) {
$("#st").hide(); // divs you want to hide: summary timeline
$("#sm").hide(); // id for summary map
switch (i) {
case 1:
$("#st").show(); // id of the second view
break;
case 2:
$("#sm").show(); // id of the third view
@lmorillas
lmorillas / gist:e5bf618beccd4b297ae2
Created June 27, 2015 21:39
cuadro de mapa exhibit redondeado
$(document).bind("dataload.exhibit", function() {
$('div.exhibit-mapView-map').addClass('img-rounded')
});
@lmorillas
lmorillas / gist:dcfe37914c2f4253f58b
Created June 27, 2015 21:44
Move the exhibit legend
$(document).bind("dataload.exhibit", function() {
$('div#leyenda').append($('div.exhibit-legendWidget'));
$('div#leyenda').show();
});
<link href="#indata" type="application/json" rel="exhibit-data"/>
<script type="application/json" id="indata">
{
"types": {
"Nobelist" : {
"pluralLabel": "Nobelists"
}
},
"properties": {
@lmorillas
lmorillas / csv_a_json.py
Created October 7, 2015 11:55
Tabla a json con python
# convierto la tabla a csv con phpmyadmin
from csv import DictReader
import json
f = open('materiales.csv')
reader = DictReader(f, delimiter=';')
result = [line for line in reader]
@lmorillas
lmorillas / table_to_csv.py
Last active October 8, 2015 10:16
convert a mysql table to csv
'''
table_to_csv converts a table
db_to_csv converts all the tables
'''
import MySQLdb
import csv
# configure
DB_HOST = 'localhost'
@lmorillas
lmorillas / add_traduccion.py
Last active October 28, 2015 13:05
Introduce una traducción nueva a una tabla para arasaac
import csv
import MySQLdb
conn = ...
cur = conn.cursor()
reader = csv.reader(open('arasaac_croata.csv'))
lineas = [l for l in reader]
insert = '''INSERT INTO `traducciones_16` (`id_traduccion`, `id_palabra`, `traduccion`) VALUES (%s, %s, %s)'''
@lmorillas
lmorillas / mw.sh
Last active February 9, 2016 08:52
Resize mediawiki image with api call
$ curl {SERVER}/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url&iiurlheight=200&titles=File:xxx