Skip to content

Instantly share code, notes, and snippets.

@wturyn
wturyn / nginx server block
Last active April 24, 2017 11:21
nginx server blocks
List of nginx server block examples
@wturyn
wturyn / countries.json
Last active August 29, 2015 14:15
Countries json
[
{
"code": "ad",
"name": "Andorra",
"nativeName": "Andorra"
},
{
"code": "ae",
"name": "United Arab Emirates",
"nativeName": "دولة الإمارات العربية المتحدة"

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@wturyn
wturyn / sha256.js
Created December 16, 2013 21:43
Javascript sha256
function SHA256(s){
var chrsz = 8;
var hexcase = 0;
function safe_add (x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
@wturyn
wturyn / cors.php
Created August 14, 2013 22:10
PHP enabling cors
/**
* An example CORS-compliant method. It will allow any GET, POST, or OPTIONS requests from any
* origin.
*
* In a production environment, you probably want to be more restrictive, but this gives you
* the general idea of what is involved. For the nitty-gritty low-down, read:
*
* - https://developer.mozilla.org/en/HTTP_access_control
* - http://www.w3.org/TR/cors/
*
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);