Skip to content

Instantly share code, notes, and snippets.

View dmateos's full-sized avatar

Daniel Mateos dmateos

View GitHub Profile
/*
* Practicing genetic algoritms
* Daniel Mateos
* Problem: find an equation out of 0-9 *+/- that comes up with 42
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define GENES 32
/*
* Practicing genetic algoritms
* Daniel Mateos
* Problem: find an equation out of 0-9 *+/- that comes up with 42
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
daniel@hammerhead:~/Documents/code/scratch/chromnum$ ./a.out
CHROMOSOME 1/16 fitness: 0.100000
1010(10) 0100(4) 0111(7) 0110(6) 0001(1) 0111(7) 1011(11) 0100(4) 0111(7) 1000(8)
+ 4 - 4
0/10
CHROMOSOME 2/16 fitness: 0.200000
1001(9) 1100(12) 1111(15) 0100(4) 1010(10) 1011(11) 1110(14) 0101(5) 0001(1) 1111(15)
* 4 + 5
5/10
CHROMOSOME 3/16 fitness: 0.200000
%{
#include <stdio.h>
%}
%option noyywrap
%%
[0-9]+ {
printf("Integer %s\n", yytext);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include "sockio.h"
#include <unistd.h>
void handle_connection(int sd) {
printf("new connection from %d\n", sd);
}
#include <stdio.h>
#include <stdlib.h>
#include "sockio.h"
#include <unistd.h>
void handle_connection(int sd) {
printf("new connection from %d\n", sd);
}
require 'rubygems'
require 'em-websocket'
clients = {}
EventMachine::WebSocket.start(:host => "localhost", :port =>8080) do |socket|
puts "new connection"
socket.onopen do
socket.send "hello client"
<html>
<script type="text/javascript"
src="http://code.jquery.com/jquery-latest.pack.js">
</script>
<script>
$(document).ready(function() {
function debug(str) {
$("#debug").append(str + "<br/>");
};