Skip to content

Instantly share code, notes, and snippets.

View yogonza524's full-sized avatar
:octocat:
Coding..

Gonza yogonza524

:octocat:
Coding..
View GitHub Profile
// ==UserScript==
// @name UTN FRRe: SysAcad - Extra Info Exámenes
// @namespace http://sysacadweb.frre.utn.edu.ar
// @author Sebastián J. Seba
// @version 1.2.8
// @description Muestra información ampliada sobre los exámenes tales como promedios generales, aplazos, cantAusentes y más.
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @include http://sysacadweb.frre.utn.edu.ar/examenes.asp
// @include http://sysacadweb.frre.utn.edu.ar/examenes.asp?id=*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
/*
* @Owner Gonzalo H. Mendoza
* @Version 1.0.0
*/
import java.util.List;
import org.blh.habilitacion.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@yogonza524
yogonza524 / CentrosController
Created July 6, 2015 15:38
Implementation of AbstractController like must to be
package org.blh.habilitacion.controllers;
import java.util.ArrayList;
import java.util.Iterator;
import org.blh.habilitacion.entities.Centros;
import org.blh.habilitacion.util.HibernateUtil;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
SELECT current_date - (timestamp '2015-11-29')::date;
CREATE OR REPLACE FUNCTION betweenDays(fecha date)
RETURNS integer AS $$
DECLARE
output integer;
BEGIN
IF fecha IS NOT NULL THEN
SELECT current_date - fecha INTO output;
ELSE
-- Table: public.config
-- DROP TABLE public.config;
CREATE TABLE public.config
(
id character varying(255) NOT NULL,
dia_emision integer NOT NULL,
dia_vencimiento integer NOT NULL,
fecha_creacion timestamp with time zone,
-- Function: public.update_config()
-- DROP FUNCTION public.update_config();
CREATE OR REPLACE FUNCTION public.update_config()
RETURNS trigger AS
$BODY$
DECLARE
output integer;
BEGIN
CREATE OR REPLACE FUNCTION date_arg_format(fecha date)
RETURNS CHARACTER VARYING AS $$
DECLARE
mes double precision;
mes_salida character varying(20);
BEGIN
IF (fecha IS NOT NULL) THEN
mes = date_part('month',fecha);
CASE mes
WHEN 1 THEN mes_salida = 'Enero';
@yogonza524
yogonza524 / PostgreSQL - Funcion para validar email
Last active April 11, 2020 14:39
La función se encarga de comprobar que el parametro tenga el formato conocido para los emails. Devuelve TRUE o FALSE
CREATE OR REPLACE FUNCTION validateEmail(email character varying)
RETURNS BOOLEAN AS $$
BEGIN
IF (email !~ '^[A-Za-z0-9._%-]+@[A-Za-z0-9-]+[.][A-Za-z]+$') THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END IF;
END
$$
@yogonza524
yogonza524 / gist:9eccf1ebfffcd2042106
Last active December 2, 2015 01:37
Método para invocar un procedimiento amacenado via Hibernate
public List callProcedure(String query, Map<String,Object> params){
SessionFactory sf = HibernateUtil.getSessionFactory();
Session s = sf.openSession();
Query consulta = s.createSQLQuery(query);
Iterator it = params.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
consulta.setParameter(pair.getKey(), pair.getValue());
}
List result = consulta.list();