Skip to content

Instantly share code, notes, and snippets.

View cethap's full-sized avatar

Cesar tapasco cethap

  • Arcaris Labs
  • Cali, Colombia
View GitHub Profile
@cethap
cethap / launch-grid.sh
Created October 18, 2016 21:09 — forked from revington/launch-grid.sh
launch selenium grid + phantomjs
#!/usr/bin/env sh
trap 'killall' INT
killall() {
trap '' INT TERM # ignore INT and TERM while shutting down
echo "**** Shutting down... ****" # added double quotes
kill -TERM 0 # fixed order, send TERM not INT
wait
echo DONE
}
@cethap
cethap / redirects.js
Created September 30, 2016 02:43
Phantomjs redirects handling
function renderPage(url) {
var page = require('webpage').create();
var redirectURL = null;
page.onResourceReceived = function(resource) {
if (url == resource.url && resource.redirectURL) {
redirectURL = resource.redirectURL;
}
};
@cethap
cethap / server.js
Created September 2, 2016 02:41 — forked from bellbind/server.js
[nodejs][linux][ffmpeg][chrome][html5]live streaming example on linux
var http = require("http");
var cp = require("child_process");
// live streaming example on linux (for chrome, not for firefox)
// for ubuntu, required libavcodec-extra-53 instead of libavcode53
// for ffmpeg command
// see: http://granular.cs.umu.se/browserphysics/?p=2287
var server = http.createServer(function (req, res) {
console.log(req.url);
@cethap
cethap / percentile.js
Created August 26, 2016 21:40 — forked from IceCreamYou/percentile.js
Utility functions to calculate percentiles and percent ranks in a JavaScript array.
// Returns the value at a given percentile in a sorted numeric array.
// "Linear interpolation between closest ranks" method
function percentile(arr, p) {
if (arr.length === 0) return 0;
if (typeof p !== 'number') throw new TypeError('p must be a number');
if (p <= 0) return arr[0];
if (p >= 1) return arr[arr.length - 1];
var index = arr.length * p,
lower = Math.floor(index),
@cethap
cethap / 01 bluetooth webapp
Created December 29, 2015 22:41 — forked from Cinezaster/01 bluetooth webapp
Node.js Bluetooth integrated web-app
This a bluetooth web-app.
<?php
/**
* NLSClientScript v6.21
*
* a single-file Yii CClientScript extension for
* - preventing multiple loading of javascript files
* - merging, caching registered javascript and css files
*
* The extension is based on the great idea of Eirik Hoem, see
* http://www.eirikhoem.net/blog/2011/08/29/yii-framework-preventing-duplicate-jscss-includes-for-ajax-requests/
browser.actions().mouseMove(element(by.css('#myElement'))).perform();
browser.actions().click(protractor.Button.RIGHT).perform();
@cethap
cethap / smd.js
Created March 21, 2014 15:45 — forked from gordonbrander/smd.js
Create Module js
var __modules__ = {};
function require(id) {
var module = __modules__[id];
if(!module) throw new Error('Module not yet defined');
// Get the module's exports lazily (allows registration in any order as long
// as main script entry point comes last).
return __modules__[id] = (typeof(module) === 'function') ?

JavaScript reference for non-JavaScript programmers

Author: Yotam Gingold
License: Public Domain (CC0)

This document is intended as a reference or introduction to JavaScript for someone familiar with a language like C/C++/Java or Python. It follows best practices and gathers the scattered wisdom from many stackoverflow questions and in-depth JavaScript essays. It relies on no external libraries.

@cethap
cethap / ID.js
Created March 21, 2014 15:22
ShortJsGist
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`