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
import fetch, { Response } from 'node-fetch'; | |
interface ResponseWithParsedJson extends Response { | |
parsedJson?: any; | |
} | |
const toResponseWithParsedJson = ( | |
res: Response, | |
json: any, | |
): ResponseWithParsedJson => { |
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
_oo0oo_ | |
o8888888o | |
88" . "88 | |
(| -_- |) | |
0\ = /0 | |
___/`---'\___ | |
.' \\| |-- '. | |
/ \\||| : |||-- \ | |
/ _||||| -:- |||||- \ | |
| | \\\ - --/ | | |
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
local calls, total, this = {}, {}, {} | |
debug.sethook(function(event) | |
local i = debug.getinfo(2, "Sln") | |
if i.what ~= 'Lua' then return end | |
local func = i.name or (i.source..':'..i.linedefined) | |
if event == 'call' then | |
this[func] = os.clock() | |
else | |
local time = os.clock() - this[func] | |
total[func] = (total[func] or 0) + time |
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
#! /usr/bin/env bash | |
set -e | |
target=$1; shift | |
for file; do | |
case $target in | |
mp3) sox "$file" -S -r 22k -c 1 -L "${file%.*}.mp3" ;; | |
caf) afconvert -d 'ima4' -f 'caff' "$file" "${file%.*}.caf" ;; | |
esac |
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
#include "HttpClientTest.h" | |
#include "../ExtensionsTest.h" | |
#include <string> | |
USING_NS_CC; | |
USING_NS_CC_EXT; | |
HttpClientTest::HttpClientTest() | |
: m_labelStatusCode(NULL) | |
{ |
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 oop = require('oop'); | |
var EventEmitter = require('events').EventEmitter; | |
function KitchenTimer(properties) { | |
this._interval = null; | |
this._timeout = null; | |
this._minutes = null; | |
this._start = null; | |
oop.inherits(this, EventEmitter); |
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
// trigger me onclick | |
function share(){ | |
try { | |
var img = canvas.toDataURL('image/jpeg', 0.9).split(',')[1]; | |
} catch(e) { | |
var img = canvas.toDataURL().split(',')[1]; | |
} | |
// open the popup in the click handler so it will not be blocked | |
var w = window.open(); | |
w.document.write('Uploading...'); |
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 net = require('net'); | |
var path = require('path'); | |
var sys = require('sys'); | |
var Worker = require('webworker/webworker').Worker; | |
var NUM_WORKERS = 5; | |
var workers = []; | |
var numReqs = 0; |
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
document.addEventListener('visibilitychange', function(e) { | |
console.log('hidden:' + document.hidden,'state:' + document.visibilityState); | |
}, false); |