Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
nucklearproject / gist:3895429
Created October 15, 2012 20:59
Jquery regex plugin
:regex
jQuery.expr[':'].regex = function(elem, index, match) {
var matchParams = match[3].split(','),
validLabels = /^(data|css):/,
attr = {
method: matchParams[0].match(validLabels) ?
matchParams[0].split(':')[0] : 'attr',
property: matchParams.shift().replace(validLabels,'')
},
regexFlags = 'ig',
@nucklearproject
nucklearproject / gist:3804738
Created September 29, 2012 18:03
PHP: remove spaces in url argument - views D7
$handler->argument = str_replace('_', ' ', $argument);
return TRUE;
@nucklearproject
nucklearproject / gist:3791340
Created September 26, 2012 23:43 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@nucklearproject
nucklearproject / .gitignore
Created September 26, 2012 22:27
My .gitignore DRUPAL
#IDE resources
.project
*.config
.idea
.settings
resources
nbproject
private
.idea
*.sublime-project
@nucklearproject
nucklearproject / gist:3781785
Created September 25, 2012 13:22
Drupal imagecache, resize image only if large with imagacache_customactions
imagecache, imagacache_customactions example
if($image->info['width'] < 500 || $image->info['height'] < 500 ){
//imageapi_image_scale($image, $width = 500 );
return $image;
} else {
imageapi_image_scale($image, $width = 500 );
return $image;
}
@nucklearproject
nucklearproject / gist:3768738
Created September 23, 2012 03:30
Drush commands
Generate makefile
FOLDER$drush generate-makefile NAMEFILE.make
Download with make files
$drush make FILE.make FOLDER
Fresh install
FOLDER$drush site-install --account-name=admin --account-pass=admin --db-url=mysql://root:PASS@localhost/DATABASE
List installed themes and modules
@nucklearproject
nucklearproject / gist:3762249
Created September 21, 2012 15:43
Save and return to edit new or update node.
<?php
/**
* @file
* Replace the submit button to node creation forms that
* allows the content author to return to edit the node
*/
/**
* Implementation of hook_form_alter().
@nucklearproject
nucklearproject / gist:3758096
Created September 20, 2012 20:16
CCK field Update with drupal_write_record()
File created in webroot.
<?php
error_reporting(E_ALL);
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
$results = db_query('select nid from node where type="store"');
My .gitignore YII
#editors
*.swp
.buildpath
.project
.settings
nbproject
.idea
*.sublime-project
*sublime-workspace
@nucklearproject
nucklearproject / gist:3725549
Created September 14, 2012 23:15
Usar un campo tipo ENUM como un select list en YII
/* Suponiendo que hemos creado nuestro CRUD. creamos un componente - Obviamente lo guardamos como ZHtml.php dentro de nuestra carpeta components, no hace falta inicializarlo si en nuestro main.php tenemos el autoload
'import'=>array(
'application.models.*',
'application.components.*',
),
.....
*/
<?php