This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* bind handleAjax native function to a message sent by the webview JavaScript | |
send result to webview | |
*/ | |
WebView { | |
id : webview | |
onMessageReceived: { | |
try { | |
if (message && message.data) { | |
var jsonObj = JSON.parse(decodeURIComponent(message.data)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fix BB10 ajax calls with a native patch | |
var lib=window.Zepto || window.jQuery; | |
lib.ajax=function(options){ | |
navigator.cascades.postMessage(JSON.stringify({ action:"ajax", options:options })); | |
navigator.cascades.onmessage = function(message){ | |
var params=JSON.parse(message); | |
if (params.action=="ajaxCallback"){ | |
if (params.success && options.success){ | |
options.success(params.data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ajax call on BB10 JS side, based on jquery $.ajax options | |
function handleAjaxCall(options,callback){ | |
var url= options.url; | |
var type= (options.type in [ 'POST', 'GET' ]) ? options.type : "GET"; //default to GET | |
var data = options.data ? options.data : {}; //default to empty params | |
var request = new XMLHttpRequest(); | |
request.onreadystatechange=function() { | |
if(request.readyState === XMLHttpRequest.DONE) { | |
if (request.status === 200) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use this code to create a background with a nine patch image. | |
here, 22px is the size of a corner. the full image should have 4 corners of the same width & height. | |
And be bigger than 44x44 in this case. | |
Non symetrical images is also possible but far more complicated. | |
*/ | |
.ninepatch{ | |
border-width: 22px; | |
border-image: url(img/content_background.png) 22 22 22 22 repeat; | |
-webkit-border-image: url(img/content_background.png) 22 22 22 22 repeat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use this to enable divs with overflow:scroll to scroll in android <3 web views. | |
Useful for phonegap apps. | |
Be sure to test for device first. | |
Usage example (needs jquery or zepto lib): | |
if (android_2){ | |
enableTouchScroll( $('#myCrollableContent'), { x: true, y: true } ); | |
} | |
*/ | |
function enableTouchScroll(selector, axis){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is how to connect to a reddis server from a python instance on dotcloud | |
This assume that you have something like this in your dotcloud.yml | |
data: | |
type: redis | |
And that you added "redis" to the list in your requirements.txt pip file. | |
""" | |
import json | |
with open('/home/dotcloud/environment.json') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !isset($_GET['host']) || !isset($_GET['login']) || | |
!isset($_GET['pwd']) || !isset($_GET['base']) | |
){ | |
echo "<h4>script usage : </h4><ul><li>mysqlconnect.php?host=<b>yourHost</b>&login=<b>yourLogin</b>&pwd=<b>yourPassword</b>&base=<b>yourDatabase</b></li></ul>"; | |
}else{ | |
$connection = mysql_connect($_GET['host'],$_GET['login'],$_GET['pwd']); | |
if ( !$connection ){ | |
die ("can't connect"); | |
mysql_error(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import time | |
time.mktime(datetime.strptime("2011-12-19 15:35:54", '%Y-%m-%d %H:%M:%S').timetuple()) | |
#-> 1324305354.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
mydatetime = datetime.now() | |
import time | |
time.mktime(mydatetime.timetuple()) | |
#-> 1324305354.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
datetime.fromtimestamp(1324305354.0857329) | |
#-> datetime.datetime(2011, 12, 19, 15, 35, 54, 85733) |
NewerOlder