Skip to content

Instantly share code, notes, and snippets.

View billowdood's full-sized avatar

Rodolfo Islas billowdood

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void numeros(int random[20]);
int menu();
void todos(int random[20]);
void pares(int random[20]);
void impares(int random[20]);
void maxmin(int random[20]);
@billowdood
billowdood / random_number.c
Last active August 29, 2015 14:14
Basic random generation in c
//Standard stuff
#include <stdio.h>
// rand(),srand()
#include <stdlib.h>
//time()
#include <time.h>
/*
References:
http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c
@billowdood
billowdood / Ex.sh
Last active December 19, 2015 05:49
Diffie-Hellman
$ python difhel.py 997 258
Alice generated: 531, using 258 ^ 91 mod 997
Bob generated: 550, using 258 ^ 46 mod 997
Alice's key: 550 ^ 91 mod 997 = 682
Bob's key: 531 ^ 46 mod 997 = 682
Eve's key using bob's private number: 682
Eve's key using alice's private number: 682
@billowdood
billowdood / decr.py
Last active December 19, 2015 01:09
One Time Pad
#Descifrado del mensaje
def D(c,key):
#Alfabeto para descifrar,se utilizo la ref(2)
alf = ascii_lowercase
alf += ' .'
deStr = ''
for partC in c:
for car in range(len(partC)):
deStr += alf[int(partC[car]) - int(key[c.index(partC)][car])]
return deStr
@billowdood
billowdood / Client.java
Created November 20, 2012 02:36
Contract net
public class Client{
/*Class which will represent the client who wants to send a package*/
private float budget;
private int xValue,yValue;
public void setClient(float budget,int xValue,int yValue){
this.budget = budget;
this.xValue = xValue;
this.yValue = yValue;
i = 0
j = 0
suma = 0
suma2 = 0
grados = []
while(i<33):
while(j<33):
suma += mat[i][j]
suma2 += mat[i][j]
j = j + 1
public void setOnOff(int environmentTemp){
System.out.println("SETONOFF");
if(environmentTemp <= 20){
this.onOff = false;
}
if(environmentTemp > 20 && environmentTemp < 25){
this.onOff = true;
/*Set the speed to slow*/
this.speed = false;
import math
from random import randint
from aspirante import aspirante
class mejorAspirante:
def __ini__(self):
print
## self.aspirantes = aspirantes
## self.centroides = centroides
#Training!
#For the training,the image of the digit is displayed and it is expected that the user press on his keyboard the digit is shown on screen
def training(contoursObj):
#Empty array for the labels
samples = np.empty((0,100))
#Empty array for the corresponding value
valueDigit = []
#Loop over all the images,in this case we have 9 images per digit,so in total we have 90 images(we included 0 as a digit)
for num_image in range(1,91):
#Get the image and find the contours of the number(rectangle)
import numpy as np
import cv2
#Training!
def training(contoursObj):
samples = np.empty((0,100))
#Empty array for the corresponding value
valueDigit = []
#Loop over all the images,in this case we have 9 images per digit,so in total we have 90 images(we included 0 as a digit)