This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MYSTRING="hello there" | |
STRLEN=${#MYSTRING} | |
let STARTPOS=$[STRLEN-5] | |
echo "First 5: ${MYSTRING:0:5}" | |
echo "Last 5: ${MYSTRING:$STARTPOS:5}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
http.createServer(function(request, response) { | |
var proxy = http.createClient(80, request.headers['host']) | |
var proxy_request = proxy.request(request.method, request.url, request.headers); | |
proxy_request.addListener('response', function (proxy_response) { | |
proxy_response.addListener('data', function(chunk) { | |
response.write(chunk, 'binary'); | |
}); | |
proxy_response.addListener('end', function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"hypotheses": [ | |
{ | |
"confidence": 0.88569070000000005, | |
"utterance": "this is pretty cool" | |
}, | |
{ | |
"utterance": "thesis pretty cool" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
OlderNewer