Skip to content

Instantly share code, notes, and snippets.

@tqc
tqc / render.js
Created April 30, 2013 12:40
Create app icons and splash images from html with PhantomJS
var fs = require("fs");
var system = require('system');
var page = require("webpage").create();
var destinationFolder = system.args[1];
var iconSource = system.args[2];
var splashSource = system.args[3];
function generate(url, w, h, fn, callback) {
@tqc
tqc / gist:4151090
Created November 26, 2012 22:30
Generate random array for js graph
var min = -5;
var max = 10;
var dataset = [];
for (var i = 0; i < 60; i++) {
var newNumber = Math.random() * (max-min) + min;
dataset.push(newNumber);
}
@tqc
tqc / rgbatorgb.js
Created May 1, 2012 01:39
Convert RGBA to RGB
function RGBAtoRGB(r, g, b, a, r2,g2,b2){
var r3 = Math.round(((1 - a) * r2) + (a * r))
var g3 = Math.round(((1 - a) * g2) + (a * g))
var b3 = Math.round(((1 - a) * b2) + (a * b))
return "rgb("+r3+","+g3+","+b3+")";
}
$("#result").html(RGBAtoRGB(225,110,0,0.5,255,255,255));
@tqc
tqc / MainViewController.h
Created April 19, 2012 14:36
PhoneGap / Cordova Splash Screen Fix
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVViewController.h>
#else
#import "CDVViewController.h"
#endif
@interface MainViewController : CDVViewController
@property (nonatomic, readwrite, retain) UIImageView *splashView;
@tqc
tqc / detectphonegap.js
Created April 19, 2012 13:45
Detect Phonegap / Cordova on startup
if (document.location.protocol == "file:") {
// file protocol indicates phonegap
document.addEventListener("deviceready",
function() { $(initInternal);}
, false);
}
else {
// no phonegap, start initialisation immediately
$(initInternal);
}
@tqc
tqc / jqmdialogfix.css
Created April 19, 2012 12:24
jQuery mobile dialog transparency fix
.ui-dialog-background {
opacity: 0.5;
display: block !important;
-webkit-transition: opacity 0.5s ease-in;
}
.ui-dialog-background.pop.in {
opacity: 1;
-webkit-transition: opacity 0.5s ease-in;
}