Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am fennb on github.
  • I am fennb (https://keybase.io/fennb) on keybase.
  • I have a public key ASBADiC1MkWSxXy2wM84ZISNtgCGa3ySBjnMLcqCbK2-DQo

To claim this, I am signing this object:

@fennb
fennb / gist:1284002
Created October 13, 2011 11:22
nginx microcaching, concurrency 500
$ ab -n 10000 -c 500 http://wp-demo.local/
Server Software: nginx/0.8.54
Server Hostname: wp-demo.local
Server Port: 80
Document Path: /
Document Length: 5728 bytes
Concurrency Level: 500
@fennb
fennb / gist:1283999
Created October 13, 2011 11:20
Benchmark, wordpress + apache2 + php-fpm + apc / EC2 small
$ ab -n 200 -c 4 http://wp-demo.local:8080/
Server Software: Apache/2.2.17
Server Hostname: wp-demo.local
Server Port: 8080
Document Path: /
Document Length: 5726 bytes
Concurrency Level: 4
@fennb
fennb / gist:1283573
Created October 13, 2011 06:35
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@fennb
fennb / gist:1139053
Created August 11, 2011 07:00
Sample speech recognition output
{
"hypotheses": [
{
"confidence": 0.88569070000000005,
"utterance": "this is pretty cool"
},
{
"utterance": "thesis pretty cool"
},
{
@fennb
fennb / gist:1139016
Created August 11, 2011 06:25
Chromium speech recognition details
const int SpeechRecognizer::kAudioSampleRate = 16000;
const int SpeechRecognizer::kAudioPacketIntervalMs = 100;
const ChannelLayout SpeechRecognizer::kChannelLayout = CHANNEL_LAYOUT_MONO;
const int SpeechRecognizer::kNumBitsPerAudioSample = 16;
const int SpeechRecognizer::kNoSpeechTimeoutSec = 8;
const int SpeechRecognizer::kEndpointerEstimationTimeMs = 300;
// ...
const char* const kContentTypeSpeex = "audio/x-speex-with-header-byte; rate=";
const int kSpeexEncodingQuality = 8;
const int kMaxSpeexFrameLength = 110; // (44kbps rate sampled at 32kHz).
#!/bin/bash
# FLAC encoded example
curl \
--data-binary @example.flac \
--header 'Content-type: audio/x-flac; rate=16000' \
'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&pfilter=2&lang=en-US&maxresults=6'
# Speex encoded example
curl \
@fennb
fennb / gist:1124580
Created August 4, 2011 05:54
Asynchronous loop issues illustrative example
// Illustrative case
for (var i = 0; i < recentBlogPostIds.length; i++) {
var blogPostId = recentBlogPostIds[i];
var results = [];
// Fetch from DB
asynchronousDB.getBlogPostById(blogPostId, function(err, post) {
htmlFragment = templating.render(post);
results.push(htmlFragment);
});
}
@fennb
fennb / gist:1124579
Created August 4, 2011 05:53
Asynchronous cache failover example
// asynchronous version
asynchronousCache.get("id:3244", function(err, myThing) {
if (myThing == null) {
asynchronousDB.query("SELECT * from something WHERE id = 3244", function(err, myThing) {
// We now have a thing from DB, do something with result
// ...
});
} else {
// We have a thing from cache, do something with result
@fennb
fennb / gist:1124578
Created August 4, 2011 05:52
Synchronous cache failover example
// synchronous version
myThing = synchronousCache.get("id:3244");
if (myThing == null) {
myThing = synchronousDB.query("SELECT * from something WHERE id = 3244");
}
// Do various stuff with myThing here