Skip to content

Instantly share code, notes, and snippets.

View Pandinosaurus's full-sized avatar

Rémi Ratajczak Pandinosaurus

  • France
View GitHub Profile
@Pandinosaurus
Pandinosaurus / flaskplotlib.py
Created April 7, 2018 17:05 — forked from wilsaj/flaskplotlib.py
Example of rendering a matplotlib image directly to Flask view
from flask import Flask, make_response
app = Flask(__name__)
@app.route("/simple.png")
def simple():
import datetime
import StringIO
import random
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
@Pandinosaurus
Pandinosaurus / pi.c
Created July 20, 2018 09:41 — forked from bbengfort/pi.c
OpenMP parallel integration to compute Pi.
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_THREADS 8
static long steps = 1000000000;
double step;
int main (int argc, const char *argv[]) {
@Pandinosaurus
Pandinosaurus / pg-pong.py
Created August 3, 2018 05:22 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@Pandinosaurus
Pandinosaurus / notebook.ipynb
Created August 3, 2018 07:44 — forked from vmarkovtsev/notebook.ipynb
lapjv blog post
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Pandinosaurus
Pandinosaurus / circle_detection.py
Created August 5, 2018 15:05 — forked from martinsik/circle_detection.py
Circle detection with OpenCV 3.0
import cv2
import time
import math
import numpy as np
capture = cv2.VideoCapture(0)
print capture.get(cv2.CAP_PROP_FPS)
t = 100
w = 640.0
@Pandinosaurus
Pandinosaurus / VIMRC
Created August 27, 2018 08:46 — forked from jreyes1108/VIMRC
vimrc config file for VI
" VIMRC
"
" To use: copy to ~/.vimrc
"
"
" Last updated: 6/2009
" Author: Juan C. Reyes
" reyes@ucsd.edu
"
@Pandinosaurus
Pandinosaurus / README.md
Created October 11, 2018 07:49 — forked from luciopaiva/_Full-socketio-client-and-server-example.md
Full socket.io client and server example

Full socket.io client and server example

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

How to use

Create a folder, run npm init -f on it and paste both server.js and client.js there (see files below). Needless to say, you must have Node.js installed on your system.

Install the required libraries:

@Pandinosaurus
Pandinosaurus / rotationMat2Quaternion.cpp
Created January 14, 2019 13:46 — forked from shubh-agrawal/rotationMat2Quaternion.cpp
OpenCV lacks a conversion function from rotation matrix to quaternion. In ROS applications, the rotation of a robot or link is generally described by 4 quaternion numbers. Some people might say that you have "tf" for all such transformations, but it requires your data to be of specific datatype. Here is a small function, that converts opencv Mat…
void getQuaternion(Mat R, double Q[])
{
double trace = R.at<double>(0,0) + R.at<double>(1,1) + R.at<double>(2,2);
if (trace > 0.0)
{
double s = sqrt(trace + 1.0);
Q[3] = (s * 0.5);
s = 0.5 / s;
Q[0] = ((R.at<double>(2,1) - R.at<double>(1,2)) * s);
@Pandinosaurus
Pandinosaurus / sparse_metric.py
Created April 9, 2019 08:37 — forked from kcarnold/sparse_metric.py
Qi, G.-J., Tang, J., Zha, Z.-J., Chua, T.-S., & Zhang, H.-J. (2009). An efficient sparse metric learning in high-dimensional space via l 1 -penalized log-determinant regularization. Proceedings of the 26th Annual International Conference on Machine Learning - ICML ’09 (pp. 1–8). New York, New York, USA: ACM Press. doi:10.1145/1553374.1553482
import numpy as np
from sklearn.covariance import graph_lasso
from sklearn.utils.extmath import pinvh
def compute_K(n, S, D):
K = np.zeros((n,n))
for a, b in S:
K[a,b] = 1
#K[b,a] = 1
for a, b in D:
@Pandinosaurus
Pandinosaurus / hello_world.c
Created April 19, 2019 11:31 — forked from kripken/hello_world.c
Standalone WebAssembly Example
int doubler(int x) {
return 2 * x;
}