Skip to content

Instantly share code, notes, and snippets.

module.exports = exports = {
create : function(notCachedClient){
var cachedClient = {};
var cache = {};
Object.keys(notCachedClient).forEach(function(method){
cachedClient[method] = function(){
var args = Array.prototype.slice.call(arguments),
cb = args.pop();
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU L5520 @ 2.27GHz
stepping : 5
microcode : 0x16
cpu MHz : 2266.747
cache size : 8192 KB
physical id : 0
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
(function($, window, document){
$(document).ready(function(){
$(window).blur(function(){
$('h1').text("Cambio il titolo al blur");
});
var os_type = Titanium.Platform.getOsname() == 'android'?'android':'ios';
var xhr = Titanium.Network.createHTTPClient();
var getNotCached = function(url){
var timestamp = new Date().getTime();
if (url.indexOf('?') == -1) {
return url + '?nocache=' + timestamp ;
}
return url + '&nocache=' + timestamp ;
var getAuthString = function(username, password){
return 'Basic ' +Titanium.Utils.base64encode(username+':'+password);
};
var xhr = Titanium.Network.createHTTPClient();
xhr.open("GET", "http://requestb.in/1a0zngb1");
xhr.cache = false;
xhr.enableKeepAlive = false;
xhr.timeout = 30000;
xhr.setRequestHeader("Content-type", "application/json");
@lele85
lele85 / setTimeoutTest.js
Created March 13, 2012 19:35
setTimeout
var count = 1;
var ping = function(cb){
setTimeout(function()
{
console.log("P....... " + count * 200 + "ms");
count++;
cb(ping);
},200);
}
@lele85
lele85 / pomodoroTest.js
Created March 10, 2012 19:40
Pomodoro Test in nodeJS con WRU
wru.test([
{
name: "Can create a pomodoro",
test: function () {
//Arrange
var pomodoroFactory = require('../pomodoro');
//Act
var p = pomodoroFactory.create({});
//Assert
wru.assert(p !== undefined);
@lele85
lele85 / pomodoro.js
Created March 10, 2012 19:38
Pomodoro in nodeJS
function createPomodoro(params) {
var validOrDefaultDuration = function(duration){
var DEFAULT_POMODORO_DURATION = 1000;
return (duration !== undefined) ? duration : DEFAULT_POMODORO_DURATION;
}
var _started = false;
var _finished = false;
var _duration = validOrDefaultDuration(params.duration);
@lele85
lele85 / snow.html
Created February 6, 2012 19:17
Canvas 2D test cosine
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function(){
/*
* Get mouse event coordinate converted to canvas coordinate
* c: The canvas object
* e: A mouse event
@lele85
lele85 / mainloop.html
Created February 4, 2012 17:14
Canvas 2D main loop test
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function(){
function Ball(x, y, radius, speedX, speedY){
this.LEFT_LIMIT = 0;
this.RIGHT_LIMIT = 800;
this.TOP_LIMIT = 0;