Skip to content

Instantly share code, notes, and snippets.

View andfoy's full-sized avatar

Edgar Andrés Margffoy Tuay andfoy

View GitHub Profile
unsigned char* bitmap = img -> informacion; //Se solicita el apuntador a los componentes de la imagen.
int word_size = CHAR_SIZE; //Tamaño inicial de palabra
int cant_char = 0; //Cantidad de caracteres extraídos
int bitmap_pos = 0; //Índice del componente actual de la imagen
int extracted_chunks = 0; //Paquetes recuperados por componente
int num_chunks = CHAR_SIZE / n; //Número de paquetes que se pueden extraer de acuerdo al tamaño n solicitado
int offset = CHAR_SIZE % n; //Sobrante sujeto al número de paquetes por n.
#define NOFIELD 505L // Analog output with no applied field, calibrate this
// Uncomment one of the lines below according to device in use A1301 or A1302
// This is used to convert the analog voltage reading to milliGauss
#define TOMILLIGAUSS 1953L // For A1301: 2.5mV = 1Gauss, and 1024 analog steps = 5V, so 1 step = 1953mG
// #define TOMILLIGAUSS 3756L // For A1302: 1.3mV = 1Gauss, and 1024 analog steps = 5V, so 1 step = 3756mG
int ticks = 0;
unsigned long time_e;
// isis1304-111-proyecto2.cpp: define el punto de entrada de la aplicación de consola.
//
// DESARROLLADO POR:
// Camila García, carnet
// Daniel Ordoñez, carnet
// Edgar A. Margffoy, 201412566
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@andfoy
andfoy / bmp_s.c
Last active August 29, 2015 14:19
// isis1304-111-proyecto2.cpp: define el punto de entrada de la aplicación de consola.
//
// DESARROLLADO POR:
// Camila García, carnet
// Daniel Ordoñez, carnet
// Edgar A. Margffoy, 201412566
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
package words_server;
//Import required java libraries
import java.io.*;
import java.util.*;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
const char* byte_to_binary(int x)
{
static char b[9];
b[0] = '\0';
int z;
#include<math.h>
#define G 9.8 // m/s^2
int analogPin = 0;
void setup()
{
Serial.begin(9600);
}
@andfoy
andfoy / jsonP.py
Last active August 29, 2015 14:14
Minimal JSON object parser
import re
KEY_REGEX = '^[,]?["][a-zA-Z_][\w-]*["]$'
VALUE_REGEX = '^["].*["][,]?$'
CURLY_PAIR = ('{', '}')
SQ_PAIR = ('[', ']')
class JSONException(Exception):
def __init__(self, value):
private static int[][] swap_values(int[][] sq, int times)
{
int[][] temp_sq = (int[][]) sq.clone();
Random rand = new Random();
for(int i = 0; i < times; i++)
{
r1 = rand.nextInt(len(sq));
c1 = rand.nextInt(len(sq));
r2 = rand.nextInt(len(sq));
c2 = rand.nextInt(len(sq));
@andfoy
andfoy / SA.py
Created November 27, 2014 04:17
def eval_constraints(sq, n):
fitness = 0
totalRowDiff = 0
totalColDiff = 0
rightDiagonal = 0
leftDiagonal = 0
for row in range(0, len(sq)):
sum_row = 0
sum_col = 0
for col in range(0, len(sq)):