Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@alotaiba
alotaiba / google_speech2text.md
Created February 3, 2012 13:20
Google Speech To Text API

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

@apk
apk / websock.sh
Created April 18, 2012 15:51
A web socket server as a bash script.
#!/bin/bash
# WebSocket shell, start & browse to http://<Host>:6655/
# Requires bash 4.x, openssl.
# Author: rootshell@corelogics.de (which isn't me, apk)
coproc d { nc -l -p 6656 -q 0; }
nc -l -p 6655 -q 1 > /dev/null <<-ENDOFPAGE
HTTP/1.1 200 OK
<html><head><script language="javascript">
var url = location.hostname + ':' + (parseInt(location.port) + 1);
@yorkxin
yorkxin / avoid-jquery-when-possible.md
Created July 7, 2012 13:04
Avoid jQuery When Possible

Avoid jQuery When Possible

jQuery does good jobs when you're dealing with browser compatibility. But we're living in an age that fewer and fewer people use old-school browsers such as IE <= 7. With the growing of DOM APIs in modern browsers (including IE 8), most functions that jQuery provides are built-in natively.

When targeting only modern browsers, it is better to avoid using jQuery's backward-compatible features. Instead, use the native DOM API, which will make your web page run much faster than you might think (native C / C++ implementaion v.s. JavaScript).

If you're making a web page for iOS (e.g. UIWebView), you should use native DOM APIs because mobile Safari is not that old-school web browser; it supports lots of native DOM APIs.

If you're making a Chrome Extension, you should always use native APIs, not only because Chrome has almost the latest DOM APIs available, but this can also avoid performance issue and unnecessary memory occupation (each jQuery-driven extension needs a separate

@t-book
t-book / fix_urls.sh
Last active December 2, 2019 15:02
#!/bin/bash
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET thumbnail_url = replace(thumbnail_url, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET ows_url = replace(ows_url, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET layer_params = replace(layer_params, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_maplayer SET source_params = replace(source_params, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE maps_mapsnapshot SET config = replace(config, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET supplemental_information = replace(supplemental_information, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE base_resourcebase SET csw_anytext = replace(csw_anytext, '$1', '$2')"
sudo -u postgres psql -d geonode -c "UPDATE django_site SET domain = replace(domain, '$1', '$2')"
@yakky
yakky / pico.py
Last active March 16, 2018 09:36
Micro hello world Python Web Framework Royal Rumble @PyCon 7
import django
DEBUG, ROOT_URLCONF, DATABASES, SECRET_KEY = 1, 'pico', {'default': {}}, 'p'
urlpatterns = [django.conf.urls.url(r'^(?P<name>\w+)?$', lambda request,
name: django.http.HttpResponse('hello %s!' % (name or 'world')))]