Skip to content

Instantly share code, notes, and snippets.

@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" }
]
@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 / 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',
// 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: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 -;
@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 / 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 / dabblet.css
Last active June 16, 2019 08:22 — forked from LeaVerou/dabblet.css
Image interpolation demo #css
/* Image interpolation demo
WebKit-only at the time (April 2012)
*/
@keyframes browsers {
20% { background-image: url('http://lea.verou.me/css-4d/img/chrome-logo.png'); }
40% { background-image: url('http://lea.verou.me/css-4d/img/safari-logo.png'); }
60% { background-image: url('http://lea.verou.me/css-4d/img/opera-logo.png'); }
80% { background-image: url('http://lea.verou.me/css-4d/img/ie-logo.png'); }
}
@quelicm
quelicm / dabblet.css
Last active June 16, 2019 08:21
play a bit with nth-child and nth-last-child #css #selectors #nth-child
/**
* play a bit with nth-child and nth-last-child
*/
div {
width: 40px;
height: 40px;
margin: 2px;
border: solid 2px #444
}
@quelicm
quelicm / hosting, server, symfony2, dinahosting
Last active June 16, 2019 08:21
Configurando proyecto symfony2 en una subcarpeta del hosting #symfony
# En symfony2 por defecto debemos configurar el document_root del dominio para que responda el directorio "web", el problema viene cuando no podemos cambiar donde apunta por defecto el dominio (no tenemos acceso a la configuración del apache), esta solución no es ideal pero funciona.
#1 Nuestro dominio apunta a una carpeta raiz en el servidor web, suelen ser generalmente httpdocs, public_html, www pero podrían ser cualquier otra, en esta carpeta raiz subimos todo el contenido de symfony2
#2 En la carpeta raiz nos creamos un fichero .htaccess, similar al que tenemos dentro de la carpeta web con la siguiente configuración:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /symfony/web/app.php [QSA,L]