Skip to content

Instantly share code, notes, and snippets.

View amiedes's full-sized avatar
🏠
Working from home

Alberto Miedes Garcés amiedes

🏠
Working from home
View GitHub Profile
@amiedes
amiedes / http.rb
Created May 17, 2016 08:23
Ruby script to make HTTP requests to OrientDB REST API
require 'net/http'
require 'json'
def print_response_body(response)
body = JSON.parse(response.body)
pretty_body = JSON.pretty_unparse(body)
puts pretty_body
end
def make_request(uri, request)
@amiedes
amiedes / datos_trayectos.sql
Created May 17, 2016 08:25
OrientDB queries to create connections between metro stops
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Moncloa' and linea = 3) to (SELECT FROM Parada WHERE nombre = 'Argüelles' and linea = 3) CONTENT { "distancia" : 2 }
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Argüelles' and linea = 3) to (SELECT FROM Parada WHERE nombre = 'Ventura Rodriguez' and linea = 3) CONTENT { "distancia" : 2 }
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Ventura Rodriguez' and linea = 3) to (SELECT FROM Parada WHERE nombre = 'Plaza de España' and linea = 3) CONTENT { "distancia" : 3 }
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Plaza de España' and linea = 3) to (SELECT FROM Parada WHERE nombre = 'Callao' and linea = 3) CONTENT { "distancia" : 2 }
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Callao' and linea = 3) to (SELECT FROM Parada WHERE nombre = 'Sol' and linea = 3) CONTENT { "distancia" : 4 }
CREATE EDGE Trayecto FROM (SELECT FROM Parada WHERE nombre = 'Sol' and linea = 3) to (SELECT FROM Parada
@amiedes
amiedes / datos_paradas.sql
Last active May 17, 2016 10:08
OrientDB queries to create metro stops
CREATE VERTEX Parada CONTENT { "nombre" : 'Alto Del Arenal', "linea" : 1, "latitud" : 40.389768700352434 , "longitud" : -3.6452252835565764 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Alvarado', "linea" : 1, "latitud" : 40.45033105413335 , "longitud" : -3.7033178070796913 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Anton Martin', "linea" : 1, "latitud" : 40.41246302818812 , "longitud" : -3.6993757416732405 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Atocha', "linea" : 1, "latitud" : 40.408846792956474 , "longitud" : -3.692490883566612 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Atocha Renfe', "linea" : 1, "latitud" : 40.406586090726144 , "longitud" : -3.689379993715528 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Bambu', "linea" : 1, "latitud" : 40.47680705593772 , "longitud" : -3.6763772762447107 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Bilbao', "linea" : 1, "latitud" : 40.42904963582931 , "longitud" : -3.702188295886296 }
CREATE VERTEX Parada CONTENT { "nombre" : 'Buenos Aires', "linea
@amiedes
amiedes / index.md
Created February 4, 2017 10:51
Webmapping Gist

Foo

var

@amiedes
amiedes / gobierto-test-output
Created February 18, 2017 17:37
gobierto test output
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.3-compliant syntax, but you are running 2.3.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
== Deleting budgets-forecast-v3 index ==
== Deleting budgets-execution-v3 index ==
== Deleting tbi-collections index ==
== Deleting data index ==
warning: parser/current is loading parser/ruby23, which recognizes
warning: 2.3.3-compliant syntax, but you are running 2.3.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
@amiedes
amiedes / seed-poll-results.rb
Created November 1, 2017 17:59
seed poll results in staging
madrid = Site.find_by(domain: 'madrid.gobify.net')
# Create users
idx = 1
users = []
20.times do
gender = (idx <= 7) ? 'male' : 'female'
@amiedes
amiedes / show_poll.rb
Created February 28, 2018 19:29
refactor method
def next_poll(current_site, current_user, poll_id = nil)
poll = GobiertoParticipation::Poll.by_site(current_site).find(poll_id) if poll_id
answerable_polls = GobiertoParticipation::Poll.by_site(current_site).answerable.order(ends_at: :asc)
answerable_polls_by_user = answerable_polls.detect { |p| p.answerable_by?(current_user) } if current_user
if current_user
if poll && poll.answerable_by?(current_user)
poll
elsif answerable_polls_by_user
answerable_polls_by_user
@amiedes
amiedes / custom_layout_example.html
Created October 15, 2018 12:31
Custom Layout Example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- GENCAT META -->
<!---->
<title>Funció pública. Govern obert</title>
@amiedes
amiedes / index.html
Created October 19, 2018 15:20
Minimal page with Google Translate
<!DOCTYPE html>
<html>
<head>
<script src="http://governobert.gencat.cat/web/resources/fwkResponsive/fpca_capcalera/js/fpca_capcalera.js" type="text/javascript"></script>
<script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</head>
@amiedes
amiedes / dataset_schema.json
Last active November 26, 2018 15:12
ckanext-fluent schema
{
"scheming_version": 1,
"dataset_type": "dataset",
"about": "A reimplementation of the default CKAN dataset schema",
"about_url": "http://github.com/ckan/ckanext-scheming",
"dataset_fields": [
{
"field_name": "title",
"label": "Title Wadus",
"preset": "title",