Skip to content

Instantly share code, notes, and snippets.

@jean-robert
jean-robert / ttt.py
Created November 13, 2014 21:25
Tic-tac-toe Reinforcement Learning
import random
import copy
class TTTGame:
board = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
playerX = None
playerO = None
def showBoard(self):
Verifying that +jean_robert is my openname (Bitcoin username). https://onename.io/jean_robert
@jean-robert
jean-robert / ArduinoTemperatureSketch.ino
Created November 11, 2012 18:55
Temperature recorder with Arduino/Java/R
/* Original code from the Arduino Experimentation Kit Example Code |
* CIRC-10 .: Temperature :. (TMP36 Temperature Sensor) |
* Amended to be used in Java/R
*/
//TMP36 Pin Variables
int temperaturePin = 0;
void setup()
{
@jean-robert
jean-robert / server.R
Created November 20, 2012 22:14
Prime Factorization Visualization in R and Shiny
library(shiny)
library(gmp)
drawStar <- function(center, length, pts, direction=0, segments=F, colour=F) {
if(length(pts)==0) return()
if(segments & (pts[1]==2)) direction <- direction + pi/2
for(i in 1:pts[1]) {
point <- center +
length*c(cos(direction+pi/2+i*2*pi/pts[1]),
sin(direction+pi/2+i*2*pi/pts[1]))
@jean-robert
jean-robert / server.R
Created November 11, 2013 16:20
Vertical align test for Shiny
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
dist <- rnorm(input$obs)
hist(dist)
})
output$distPlot2 <- renderPlot({
@jean-robert
jean-robert / friendscluster.R
Created January 22, 2012 16:18
Cluster your Facebook friends
require(igraph)
require(RCurl)
require(rjson)
# Insert your own token
access_token <- '****'
# Romain François's function to connect to Facebook Graph API
facebook <- function( path = "me", access_token = token, options) {
if( !missing(options) ){