Skip to content

Instantly share code, notes, and snippets.

View jogonba2's full-sized avatar

José González jogonba2

View GitHub Profile
@jogonba2
jogonba2 / geneticpoc
Created February 22, 2015 03:15
Genetic algorithm to generate a super single hardcoded.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Overxfl0w13 - 2015
from random import randint
# El objetivo es generar el super individuo #
super_single = 0b101010101
# Usaremos como función de evaluación el propio número, tendrá mayor valor cuanto mayor sea el número y por tanto más cerca del super individuo esté #
def genetic_algorithm():
@jogonba2
jogonba2 / AC Unidimensional
Created March 8, 2015 23:24
Autómata celular unidimensional con conjunt de estados binario y condición de frontera periódica (CMC).
(* Practica 2 Autómatas celulares *)
(* Ovexfl0w13 *)
(* Ejercicio AC unidimensional *)
SimulacionACDimensional[configInicial_List, enteroRegla_Integer,
t_Integer] :=
Module[{reglaWolfram, configuraciones, d, i, configActual},
reglaWolfram = GenerarReglaWolfram[enteroRegla];
configActual = configInicial;
configuraciones = {ArrayPlot[{configActual}]};
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class NodeList:
def __init__(self,data,skip):
self.data = data
self.skip = skip
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class NodeTrie:
def __init__(self,data):
self.data = data
self.pointers = [None for i in xrange(97,123)]
@jogonba2
jogonba2 / KernelPerceptron.py
Created March 29, 2015 13:06
Kernel Perceptron
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Overxfl0w13 #
"""You can define more kernel functions to test its performance whenever it respect the following condition:
http://latex.codecogs.com/gif.latex?\forall i\in K(x,y)\rightarrow i\geq 0
Some examples: http://gyazo.com/3b1d3ae355c2638f5ac4d98c82c31d12 (Theme 4: representation based on kernels.) Perception (PER), DSIC-UPV)
"""
# Kernel test -> hamming distance #
@jogonba2
jogonba2 / posting_compression.py
Created April 2, 2015 14:03
Posting lists compression.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def get_gaps_list(posting_lists): return [posting_lists[0]]+[posting_lists[i]-posting_lists[i-1] for i in xrange(1,len(posting_lists))]
def vb_encode_number(number):
bytex = []
while True:
bytex.insert(0,number%128);
@jogonba2
jogonba2 / logarithmic_merge.py
Created April 2, 2015 14:05
Logarithmic merge for dynamic indexing
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Logarithmic merge, dynamic indexing #
def create_indexes(n_indexes,n): return [[0 for x in xrange(n**i)] for i in xrange(1,n_indexes+1)]
def merge_add_token(indexes,z,token,n,filled):
z.append(token)
if len(z)==n:
// Author: Overxfl0w13 //
BEGGIN begin
END end
DIGIT [0-9]
LETTER [a-zA-Z]
BLANK [ \t]
LINE \n
SCOMMENT ("//"({LETTER}|{BLANK})*)
MCOMMENT ("/**"({LETTER}|{BLANK}|{LINE})*"**/")
EOS ";"
// Author: Overxfl0w13 //
%token BEGGIN END PLUS MINUS MULT DIV PRINT EOS LP RP INTEGER FLOAT VARIABLE
%left GT LT EQ
%left '+' '-'
%left '*' '/'
%{
#include <stdio.h>
int yylex(void);
void yyerror(char *);
@jogonba2
jogonba2 / spimi.py
Created April 12, 2015 14:46
One step memory indexation -> SPIMI algorithm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Overxfl0w13 #
# One step memory indexation -> SPIMI algorithm #
from string import ascii_uppercase,ascii_lowercase,digits
from random import choice
try: from cPickle import HIGHEST_PROTOCOL,dump,load
except: from pickle import HIGHEST_PROTOCOL,dump,load
from sys import argv