Skip to content

Instantly share code, notes, and snippets.

View nremond's full-sized avatar

Nicolas Rémond nremond

View GitHub Profile
@nremond
nremond / gist:1343554
Created November 6, 2011 21:44
Compute wilson score
# Compute the comment score
def compute_comment_score(c)
upcount = (c['up'] ? c['up'].length : 0)
downcount = (c['down'] ? c['down'].length : 0)
n = upcount + downcount
return 0 if n==0
#1.6 = 95%,1.0 = 85%
z = 1.6
phat = Float(ups) / n
Math.sqrt(phat+z*z/(2*n)-z*((phat*(1-phat)+z*z/(4*n))/n))/(1+z*z/n)
@nremond
nremond / flask_geventwebsocket_example.py
Created May 2, 2012 22:26 — forked from lrvick/flask_geventwebsocket_example.py
Simple Websocket echo client/server with Flask and gevent / gevent-websocket
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@nremond
nremond / gist:2630253
Created May 7, 2012 20:41
Issue with two http confs in Gatling
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
class BasicExampleSimulation extends Simulation {
def apply = {
val urlBase = "http://excilys-bank-web.cloudfoundry.com"
val urlBase2 = "https://excilys-bank-web.cloudfoundry.com"
@nremond
nremond / gist:2972382
Created June 22, 2012 12:10
Account feeder
class AccountFeeder() extends com.excilys.ebi.gatling.core.feeder.Feeder {
import org.joda.time.DateTime
import scala.util.Random
private val RNG = new Random()
// random number in between [a...b]
def randInt(a:Int, b:Int) = RNG.nextInt(b-a) + a
def daysOfMonth(year:Int, month:Int) = new DateTime(year, month, 1, 0, 0, 0, 000).dayOfMonth().getMaximumValue()
@nremond
nremond / gist:3046804
Created July 4, 2012 11:12
Gatling : simulation w/ 2 scenarii
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
class BasicExampleSimulation extends Simulation {
def apply = {
val httpConf = httpConfig
.baseURL("http://localhost:5000")
@nremond
nremond / gist:3539727
Created August 30, 2012 20:12
Gatling simulation that breaks Netty 3.5.6
package computerdatabase
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
class BasicSimulation extends Simulation {
def apply = {
val urlBase = "http://computer-database.herokuapp.com"
@nremond
nremond / graphite_pip_uwsgi_recipe.sh
Created September 3, 2012 17:01 — forked from bohde/graphite_pip_uwsgi_recipe.sh
installing graphite-web with pip and running under uwsgi
# graphite-web install is hardcoded in setup.cfg to /opt/graphite
sudo mkdir /opt/graphite
sudo chown brad.users /opt/graphite
# run under python2.7 virtualenv
virtualenv --python=python2.7 ~/ve/graphite
source ~/ve/graphite/bin/activate
# install the necessary python packages (simplejson is for flot graphs)
pip install graphite-web carbon whisper django django-tagging uwsgi simplejson
@nremond
nremond / install_graphite_statsd_ubuntu_precise.sh
Created September 4, 2012 12:48 — forked from bhang/install_graphite_statsd_ubuntu_precise.sh
Install Graphite and statsd on Ubuntu 12.04 LTS (Precise Pangolin)
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.http.check.HttpCheck
import org.glassfish.grizzly.http.util.HttpStatus._
import com.excilys.ebi.gatling.http.request.builder.AbstractHttpRequestWithBodyBuilder
import com.excilys.ebi.gatling.core.structure.ChainBuilder
import jodd.util.StringUtil
import com.ning.http.client._
/**
* Copyright 2011-2012 eBusiness Information, Groupe Excilys (www.excilys.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software