Skip to content

Instantly share code, notes, and snippets.

function urlencode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
quick one
pipe = io.popen('ls 2>&1', 'rb') --gives both stdout and stderr in pipe
pipe = io.popen('ls 2>/tmp/stderr', 'rb') --redirects stderr to file
Longgggggggggger explainations
http://lua-users.org/lists/lua-l/2010-09/msg00955.html
Is it possible to
> local pipe = io.popen(command, 'rb')
@sysnajar
sysnajar / gist:2e11ca516a7f08359ff6
Created October 22, 2015 19:39
pup (HTML parser) example
extract TR elements from gvWater table and convert html elements to json string
pup --charset utf-8 -f tmp/20151023021651.html.p1.html '#gvWater tr json{}' > tr.html
@sysnajar
sysnajar / google_speech2text.md
Created October 23, 2015 15:11 — forked from alotaiba/google_speech2text.md
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

./getViewState.lua w 10 | jq '.[] | select(.name=="__VIEWSTATE")'
./getViewState.lua w 10 | jq '.[] | select(.name=="__VIEWSTATE")' | .value
./getViewState.lua w 10 | jq '.[] | select(.name=="__VIEWSTATE" or .name=="__EVENTVALIDATION") .value' > tmp2.txt
http://stackoverflow.com/questions/26604952/a-simple-cordova-android-example-including-sqlite-read-write-and-search
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
@sysnajar
sysnajar / gist:181a21d88d8161592d76
Created November 20, 2015 22:16
File upload snippet
<input type='file' id='fileUpload' style='display:none'> <---- 1. file input
<li style='display:inline'> <i class="clip-folder-upload" onclick='uploadAttachment(this);'></i> </li> <--- 2. icon trigger
<script src="assets/js/ajaxfileupload.js"></script> <--3. js file
function upload()
{
var id = 'file';
@sysnajar
sysnajar / gist:9efad678a5db86c39cb9
Last active November 27, 2015 11:58
HTML5 client do pub/sub via Websocket
HTML5 client do pub/sub via Websocket
ws.send('SUBSCRIBE', 'x');
<html>
<head>
<script>
@sysnajar
sysnajar / webssql.htm
Created January 12, 2016 05:11 — forked from andyj/webssql.htm
Look at the basics of WebSQL
<html>
<head>
<title>Look at WebSQL</title>
<script>
// Through the code below remember essentialy there are just 3 core methods we tend to use
// openDatabase
// transaction
// executeSql
// Opening a connection
@sysnajar
sysnajar / gist:c193a6b0a11894d264d770f47ea8b16b
Created August 6, 2016 05:57
เวบที่มีตัวอย่างLine iconให้add friend
https://www.wishbeer.com/th/home/328-hoegaarden-330-ml-49.html