Skip to content

Instantly share code, notes, and snippets.

View phucat's full-sized avatar

Sugar Ray Tenorio phucat

  • Philippines
View GitHub Profile
@phucat
phucat / app.js
Last active February 27, 2022 02:00
Playing with Node.js and Socket.IO. Testing of socket emit and video, audio streaming.
var app = require('express')(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
fs = require('fs'),
util = require('util');
server.listen(8080);
// set transport fallback order
io.set('transports', [
@phucat
phucat / defer.js
Created July 3, 2013 06:41
Defer method for Javascript.
/*
DEFER OBJECT
- Mimic some parts of reactor on twistd python
AUTHOR : Sugar Ray Tenorio
METHODS :
defer._init : set / initialize variables
defer._run : start reactor
@phucat
phucat / global-timer.js
Created July 3, 2013 06:49
Global Timer for Javascript
/*
* Name : Global Timer Script
* By: Sugar Ray Tenorio ([email protected])
* 8/12/2012 1:01 AM
* dependencies : jQuery, Main Component
* http://www.javascriptph.com
********************************
adding functions in Timer
@phucat
phucat / unique-id.js
Created July 3, 2013 06:54
Unique id generator
// unique id generator
function generateId(){
var S4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength
@phucat
phucat / timezones.html
Created May 20, 2014 12:50
timezones.html
<select name="tz" id="ae-timezone" title="Change the Timezone">
<option value="US/Pacific">
(GMT-7:00)
US/Pacific
</option>
<option value="UTC">
(GMT+0:00)
UTC
</option>
<option value="Indian/Chagos" selected="selected">
@phucat
phucat / ! Windows NXLog | Linux NXLog | LogStash
Created October 20, 2015 13:59 — forked from MattHodge/! Windows NXLog | Linux NXLog | LogStash
Configuration files for NXLog on Windows ---> NXLog on Ubuntu --> LogStash
Covers configuration for NXLog installed on Windows, transfering to NXLog installed on Linux to LogStash.
NXLog is used for IIS logs. (http://nxlog-ce.sourceforge.net/)
Snare is used for Windows Event Logs. (http://www.intersectalliance.com/projects/SnareWindows/index.html#Download)
@phucat
phucat / terminal
Last active October 21, 2015 08:54
Appengine using gcloud throws "Failed to save static file." error.
# set appengine_api to false on your gcloud environment
gcloud config set app/use_appengine_api false
@phucat
phucat / export_xls.py
Created November 12, 2015 14:07
excel export
# download xlsx writer here :XlsxWriter-0.7.7.tar.gz (md5)
#https://pypi.python.org/pypi/XlsxWriter#downloads
#extract and put to "lib" folder under root app directory
from cStringIO import StringIO
import xlsxwriter
out = StringIO()
wb = xlsxwriter.Workbook(out, {'in_memory': True})
@phucat
phucat / node-and-npm-in-30-seconds.sh
Created April 18, 2017 06:19 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh