Skip to content

Instantly share code, notes, and snippets.

View dmarcelino's full-sized avatar

Dário dmarcelino

  • AppsCot
  • Lisbon, Portugal
View GitHub Profile
@dmarcelino
dmarcelino / HintTextArea.js
Created May 19, 2012 02:43
A Titanium Mobile implementation of a TextArea with hintText compatible with iOS
/**
* @author Dario Marcelino
*/
var defaultHintTextColor = 'gray';
var filter = function (/*Object*/ source){
var newObj = {};
for(name in source){
@dmarcelino
dmarcelino / stress.sh
Last active April 27, 2017 05:00
Raspberry Overclock stability test
#!/bin/bash
# Simple stress test for system. If it survives this, it's probably stable.
# Free software, GPL2+
# Based on http://elinux.org/RPiconfig#Overclocking
# but using 'cat' instead of 'yes' since OpenELEC for Raspberry doesn't have yes
CORES=1
NO_READS=1
NO_WRITES=3
/**
* Example on how to get cursor position programatically with JS
*/
var stdin = process.stdin;
var firstAttempt = true;
function callback() {
var buf = stdin.read();
@dmarcelino
dmarcelino / testDecode.js
Last active August 29, 2015 14:16
Decoding OrientDB RID: decodeURIComponent vs string.replace
var n = 5000000;
var encodedRid = '%2310%3A23'; // #10:23
console.time('decodeURIComponent 1/2');
for (var i = 0; i < n; i++) {
decodeURIComponent(encodedRid);
}
console.timeEnd('decodeURIComponent 1/2');
@dmarcelino
dmarcelino / c120_air_mouse.keymap.xml
Created February 28, 2015 20:07
Kodi keymaps for some remotes
<keymap>
<global>
<keyboard>
<key id="61654">contextmenu</key>
</keyboard>
<mouse>
<leftclick>Select</leftclick>
<rightclick>Back</rightclick>
<middleclick>noop</middleclick>
<doubleclick id="0">noop</doubleclick>
@dmarcelino
dmarcelino / waterline-sequel_badges.md
Last active August 29, 2015 14:19
waterline-sequel badges

New:

Waterline-Sequel

build integration tests npm dependencies
Build Status Circle CI npm version Dependency Status
@dmarcelino
dmarcelino / mocha.optional.js
Created April 24, 2015 14:12
Optional Mocha tests: if not pass mark as pending
/**
* Sometimes there is the need to have optional tests that may need to run conditionally as discussed in:
* http://stackoverflow.com/questions/19075792/unit-tests-for-optional-units
* This solution is good but if our tests are part of a test suite that runs against many different kinds of implementations
* it may be desirable to have optional tests that "pass" if they are supported and become "pending" if they fail.
* This way we don't have to break the whole test suit because of an optional test breaksing and, if it passes, we'll know about it.
*/
function runOptionalTest(testName, failedMessage, testFn){
if(!testFn){
@dmarcelino
dmarcelino / angular.adsense.js
Created May 22, 2015 11:07
Angular adsense example that shows ad more than 3 times
'use strict';
var adSenseTpl = '<div id="adsenses-ad-1"><ins class="adsbygoogle"' +
'style="display:inline-block;width:336px;height:280px"' +
'data-ad-client="ca-pub-000000000000000000"' +
'data-ad-slot="00000000000"></ins></div>';
var adsenseAd1;
angular.module('MyApp')
@dmarcelino
dmarcelino / b62.vs.base-x.js
Created May 27, 2015 10:25
Node Base62 libraries: b62 vs. base-x
var baseX = require('base-x')('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
var b62 = require('./b62');
var buf = new Buffer([0x30, 0x17, 0xe8, 0x92, 0xe2, 0x3d, 0xff]);
var str = "Hello World!";
var encodedX, encoded62, decodedX, decoded62, runs=100;
// warm up
console.time('base-x');
@dmarcelino
dmarcelino / npm-debug.log
Created June 2, 2015 09:32
npm ERR! registry error parsing json
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'publish' ]
2 info using npm@2.11.0
3 info using node@v0.10.36
4 verbose publish [ '.' ]
5 silly cache add args [ '.', null ]
6 verbose cache add spec .
7 silly cache add parsed spec { raw: '.',
7 silly cache add scope: null,
7 silly cache add name: null,