Skip to content

Instantly share code, notes, and snippets.

@Jviejo
Jviejo / asyncawait.ts
Created December 17, 2015 09:32
prueba de async await con typescript
"use strict";
//Ejemplo de un bucle basado en promises async
// representa el dato devuelto por la promesa, en este caso un contador
var i = 0;
// cada vez que se ejecuta esta funcion se añade 1
// esto podría ser un $http
function accesoAlServidor(milliseconds: number) {
return new Promise<number>((resolve,reject) => {
if (i % 5 == 0) reject({error:"error",i:i++});
@Jviejo
Jviejo / xmltoobject.sql
Created December 30, 2015 12:43
Transformar un xml en una tabla de objectos
create type t_flavio as object(c1 varchar2(100), c2 number);
create type t_flavio_c as table of t_flavio;
declare
tabla t_flavio_c;
begin
with c1 as
(
select xmlelement("root",
@Jviejo
Jviejo / genera type.sql
Created January 5, 2016 13:24
genera type from user_tables oracle
select 'type ' || table_name || '_T is
record (' || chr(13) || listagg(column_name || ' ' ||
table_name ||'.'||column_name || '%type',','||chr(13))
within group (order by column_id)
|| '); ' || CHR(13) ||
'type '||TABLE_NAME||'_T_C is table of '||TABLE_NAME||'_T;' || CHR(13) ||
'T '||TABLE_NAME|| '_T_C;'
from user_tab_columns
where table_name = '<PONER EL NOMBRE DE LA TABLA>'
group by table_name
@Jviejo
Jviejo / gist:404f56395ff97a08a4007eeb27e95312
Created December 25, 2017 15:24
pipe un parent two child, passing integer values
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <wait.h>
void cerrar (int pipe1[2], int pipe2[2])
{
@Jviejo
Jviejo / linux
Created December 27, 2017 21:22
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <wait.h>
#include <signal.h>
@Jviejo
Jviejo / pru.py
Last active October 6, 2018 09:09
#https://github.com/delip/blog-stuff/blob/master/tensorflow_ufp.ipynb
#https://github.com/delip/blog-stuff/blob/master/tensorflow_ufp.ipynb
import tensorflow as tf
import numpy as np
import math, random
np.random.seed(100)
# Load the Pandas libraries with alias 'pd'
import pandas as pd
from matplotlib import pyplot as plt
from scipy.cluster.hierarchy import dendrogram, linkage
from sklearn import datasets
import numpy as np
Provincias NOMBRE Municipios Distritos Secciones Mesas Locales
2 ALBACETE 87 123 295 517 208
3 ALICANTE/ALACANT 141 232 1.222 2.222 718
4 ALMERÍA 103 149 463 808 321
1 ARABA/ÁLAVA 51 56 238 425 100
33 ASTURIAS 78 130 850 1.573 615
5 ÁVILA 248 262 312 361 289
6 BADAJOZ 165 249 553 898 436
7 BALEARS, ILLES 67 148 662 1.215 385
8 BARCELONA 311 495 3.601 5.962 1.611
@Jviejo
Jviejo / car.csv
Created April 29, 2019 20:30
car.csv
PRICE MAINT DOORS PERSONS SAFETY CLASS
40000 2000 2 2 low unacc
40000 2000 2 2 med unacc
40000 2000 2 2 high unacc
40000 2000 2 2 low unacc
40000 2000 2 2 med unacc
40000 2000 2 2 high unacc
40000 2000 2 2 low unacc
40000 2000 2 2 med unacc
40000 2000 2 2 high unacc
PRICE MAINT DOORS PERSONS SAFETY CLASS
20000 2000 4 2 med unacc
40000 1000 4 4 high acc
40000 2000 2 2 low unacc
40000 1000 5 4 low unacc
10000 500 4 4 med acc
30000 1000 4 5 high acc
20000 500 3 2 low unacc
10000 1000 3 2 high unacc
20000 1000 2 5 med acc