Skip to content

Instantly share code, notes, and snippets.

@quelicm
quelicm / phonegap-photofetcher.js
Created April 19, 2012 05:57 — forked from pamelafox/phonegap-photofetcher.js
PhoneGap Convert Photo File URI to Data URI
function getPhoto() {
navigator.camera.getPicture(onPhotoSuccess, onPhotoFail,
{quality: 70, targetWidth: 500, targetHeight: 500,
sourceType: navigator.camera.SourceType.PHOTOLIBRARY,
destinationType: navigator.camera.DestinationType.FILE_URI,
});
}
function onPhotoSuccess(imageUri) {
var $img = $('<img/>');
@quelicm
quelicm / Base64Image.php
Created April 14, 2012 07:33 — forked from simme/Base64Image.php
Returns the Base64 encoded version of an image. Has basic support for Drupal module ImageCache. Does not depend on Drupal.
<?php
/**
* @file
* Helper class for encoding images as Base64.
* Has support for the Drupal module ImageCache, just provide it with your
* preset name if you'd like the class to use that version of an image instead.
* Is by no means dependent on Drupal though. Just a nice feature.
* Feel free to use it as you like.
*
* @author Simon Ljungberg <[email protected]>
@quelicm
quelicm / gist:1772813
Created February 8, 2012 19:52
How to add a new string to a .po or create new .po
1) Add new strings to php files with function __('TEXT')
Sample:
----------
<?php
__('edit');
__('delete');
----------
2) execute command: find . -type f -iname "*.php" | xgettext --from-code=utf-8 --keyword=__ --keyword=_e -j -f -;
// Simple debug output helper
function debug(message) {
Ti.API.info(message);
}
/**
*
* @param thisControl The control you wish to dump
* @param goDeep boolean Do you want deep introspection
* @param incFuncs boolean Do you want to include functions in the output when going deep
@quelicm
quelicm / gist:1743796
Created February 5, 2012 07:25 — forked from vivirenremoto/gist:1730750
cron bufferapp rss updates
<?php
// CONFIG
$access_token = '';
$profile_ids = '';
$limit = 1;
$urls = array(
'http://feeds.feedburner.com/betabeersjobs',
@quelicm
quelicm / date is weekend PHP
Created February 4, 2012 08:58
Checking if date is weekend PHP
// PHP >= 5.1:
function isWeekend($date) {
return (date('N', strtotime($date)) >= 6);
}
var_dump(isWeekend('2012-02-04'));
// PHP < 5.1:
function isWeekend($date) {
return date('w', strtotime($date)) % 6 == 0;
}
@quelicm
quelicm / Setting SublimeText (MAC)
Created January 25, 2012 08:09
Keyboard shortcuts as eclipse in SublimeText 2 (MAC)
[
{ "keys": ["super+d"], "command": "run_macro_file", "args": {"file": "Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["super+alt+down"], "command": "duplicate_line" },
{ "keys": ["alt+up"], "command": "swap_line_up" },
{ "keys": ["alt+down"], "command": "swap_line_down" },
{ "keys": ["alt+super+y"], "command": "lower_case" },
{ "keys": ["alt+super+x"], "command": "upper_case" }
]