GithubHelp home page GithubHelp logo

jnaudon / indultometro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from psicobyte/indultometro

0.0 2.0 0.0 9.4 MB

El indultómetro

License: GNU Affero General Public License v3.0

Ruby 2.76% Shell 0.01% HTML 62.17% JavaScript 13.53% CSS 21.53%

indultometro's Introduction

El indultometro

TODO: Documentar esto mucho mejor :/

Instalación del front-end

  • Instalar Jekyll and its dependencies:

     $ cd web
     $ bundle install
    
  • Arrancar Jekyll:

     $ cd web
     $ jekyll serve --watch
    

Instalación del back-end

  • bundle install

  • Crear base de datos Postgres, 'indultometro': createdb indultometro

  • Cargar datos:

     $ rake crime_categories:load
     $ rake pardon_crime_categories:load
     $ rake pardons:load
    
  • Arrancar el servidor: ./server

Configuración de la búsqueda en PostgreSQL

Para poder hacer búsquedas sin tener en cuenta los acentos, vía la consola de PostgreSQL (psql o heroku pg:psql):

 $ CREATE EXTENSION unaccent;
 
 $ CREATE TEXT SEARCH CONFIGURATION unaccent_spa ( COPY = pg_catalog.spanish );

 $ ALTER TEXT SEARCH CONFIGURATION unaccent_spa
    ALTER MAPPING FOR hword, hword_part, word
    WITH unaccent, spanish_stem;

via esto y esto

Configuración para el uso de percentiles en PostgreSQL

Para calcular los percentiles, vía la consola de PostgreSQL (psql o heroku pg:psql):

 $ CREATE OR REPLACE FUNCTION array_sort (ANYARRAY)
 RETURNS ANYARRAY LANGUAGE SQL
 AS $$
 SELECT ARRAY(
     SELECT $1[s.i] AS "foo"
     FROM
         generate_series(array_lower($1,1), array_upper($1,1)) AS s(i)
     ORDER BY foo
 );
 $$;
 
 $ CREATE OR REPLACE FUNCTION my_percentile_cont(myarray real[], percentile real)
 RETURNS real AS
 $$
 DECLARE
   ary_cnt INTEGER;
   row_num real;
   crn real;
   frn real;
   calc_result real;
   new_array real[];
 BEGIN
   ary_cnt = array_length(myarray,1);
   row_num = 1 + ( percentile * ( ary_cnt - 1 ));
   new_array = array_sort(myarray);
   crn = ceiling(row_num);
   frn = floor(row_num);
   if crn = frn and frn = row_num then
     calc_result = new_array[row_num];
   else
     calc_result = (crn - row_num) * new_array[frn] 
             + (row_num - frn) * new_array[crn];
   end if;
   RETURN calc_result;
 END;
 $$
 LANGUAGE 'plpgsql' IMMUTABLE;

via esto

indultometro's People

Contributors

dcabo avatar jjelosua avatar psicobyte avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.