Skip to content

Instantly share code, notes, and snippets.

float catalan_nums_rec(int numTerms){
return catalan_nums_aux(numTerms, 1, 1.0);
}
float catalan_nums_aux(int numTerms, int n, float lastC){
if( n < numTerms )
return catalan_nums_aux(numTerms, n+1, 2*(2*n+1)*lastC/(n+2)));
else
return 2*(2*n+1)*lastC/(n+2);
}
var chart = new Highcharts.Chart({
'chart': {
'renderTo': 'yw0'
},
'exporting': {
'enabled': true
},
'title': {
'text': 'Past Hour'
},
@selbyk
selbyk / threaded_vectors.clj
Created April 18, 2013 20:38
10 threads manipulating one shared data structure, which consists of 100 vectors each one containing 10 (initially sequential) unique numbers. Each thread then repeatedly selects two random positions in two random vectors and swaps them. All changes to the vectors occur in transactions by making use of Clojure's software transactional memory sys…
(defn run [nvecs nitems nthreads niters]
(let [vec-refs (vec (map (comp ref vec)
(partition nitems (range (* nvecs nitems)))))
swap #(let [v1 (rand-int nvecs)
v2 (rand-int nvecs)
i1 (rand-int nitems)
i2 (rand-int nitems)]
(dosync
(let [temp (nth @(vec-refs v1) i1)]
(alter (vec-refs v1) assoc i1 (nth @(vec-refs v2) i2))
@selbyk
selbyk / php.ini
Created April 24, 2013 00:31
PHP5 Apache php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
#include <vector>
#include <fstream>
#include <iostream>
#include <ctype.h>
#include "fann.h"
#include "fann_cpp.h"
using namespace std;
void error(const char* p, const char* p2 = ""){
/* Since script loading is dynamic, we take
a callback function with our loadScript call
that executes once the script is done downloading/parsing
on the page.
*/
var loadScript = function(src, callbackfn) {
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.setAttribute("async", "true");
newScript.setAttribute("src", src);
VERSION=1.4.2
sudo apt-get update
sudo apt-get install openjdk-6-jdk
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.deb
sudo dpkg -i elasticsearch-$VERSION.deb
# be sure you add "action.disable_delete_all_indices" : true to the config!!
insert into image (
id,
name,
description,
album_id,
album_position,
path,
type,
size,
url,
@selbyk
selbyk / results.json
Created April 17, 2015 15:04
RAID Configurations on Performance ({"Raid Type": {"Stripe Size": { 'performce' }, ... })
{
"Noredun": {
"4": {
"responseTime": 47.73792,
"rps": 505.446884
},
"16": {
"responseTime": 38.438951,
"rps": 387.339675
},
<MacGyver> selby: ssh user@host "tar -czf - /folder/to/backup" | tar -xzf - /folder/where/it/should/go