Skip to content

Instantly share code, notes, and snippets.

View JosePedroDias's full-sized avatar

José Pedro Dias JosePedroDias

View GitHub Profile
@JosePedroDias
JosePedroDias / README.md
Last active August 29, 2015 14:10
tabular data to the console (js)

this

var cfg = [
    {title:'TS',   attr:'ts',   length: 5, isRight:true},
    {title:'NAME', attr:'name', length:15, isRight:false},
    {title:'DATA', attr:'data', length:35, isRight:false, transform:JSON.stringify}
];

var arr = [
@JosePedroDias
JosePedroDias / SnippetWithAttributes.js
Last active August 29, 2015 14:13
javascript snippet demo
(function() {
'use strict';
var scriptName = 'SnippetWithAttributes.js';
var getScriptEl = function() {
var scriptEls = document.getElementsByTagName('script');
var scriptEl, srcAttr;
for (var i = 0; i < scriptEls.length; ++i) {
scriptEl = scriptEls[i];
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CC receiver</title>
<script type="text/javascript" src="http://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<style id="jsbin-css">
body {
font-family: sans-serif;
@JosePedroDias
JosePedroDias / log.js
Created January 21, 2015 14:13
logging to DOM function
var logEl = document.getElementById('log');
var log = function() {
var l = arguments.length;
var args = new Array(l);
--l;
for (; l >= 0; --l) {
try {
args[l] = JSON.stringify( arguments[l] );
} catch (ex) {
@JosePedroDias
JosePedroDias / index.html
Last active August 29, 2015 14:14
testing multi-document gist
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BLOG PETACULAR</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
@JosePedroDias
JosePedroDias / README.md
Last active August 29, 2015 14:14
traverses json collections.

usage

var obj = {
    a: 'b',
    c: 3,
    e: [
        3,
		null,
        '24',
@JosePedroDias
JosePedroDias / memo.js
Last active August 29, 2015 14:16
memoify 1 argument function. this has no criteria to limit cache size. be careful.
/*
* single argument memo where argument cached as string (no objects please)
*
* @function memo
* @param {Function} fn function to memoize
* @return {Function} memoized version of the function
*/
var memo = function(fn) {
return function(a) {
if (!fn._memo) {
### Keybase proof
I hereby claim:
* I am JosePedroDias on github.
* I am josepedrodias (https://keybase.io/josepedrodias) on keybase.
* I have a public key whose fingerprint is E8ED 4AB1 4635 7643 5351 2EC7 386A 7B19 6F48 3FD3
To claim this, I am signing this object:
@JosePedroDias
JosePedroDias / rndBase32.js
Created March 9, 2015 10:50
random base32 string of length len. works well up to 6 characters. chars are in the range [0-9][a-t]
function rndBase32(len) {
return ( ~~(Math.random() * Math.pow(32, len)) ).toString(32);
}
@JosePedroDias
JosePedroDias / index.html
Created April 14, 2015 15:04
textarea on steroids // source http://jsbin.com/babubo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>textarea on steroids</title>
<style id="jsbin-css">
html, body { height: 100%; }
body {