Skip to content

Instantly share code, notes, and snippets.

@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 / .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: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 / 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: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',
# Recursively add a .gitignore file to all directories
# in the working directory which are empty and don't
# start with a dot. Helpful for tracking empty dirs
# in a git repository.
find . -type d -regex ``./[^.].*'' -empty -exec touch {}"/.gitignore" \;
@nucklearproject
nucklearproject / uploader.py
Created November 29, 2012 12:52
Uploading images to picasa web with python and Gdata
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Este Script sube fotos a tu album de Picasa web.
# Uso : python uploader.py -l <directorio>
###
import gdata.photos.service
import gdata.media
import gdata.geo
import os
@nucklearproject
nucklearproject / gist:4214927
Created December 5, 2012 11:41
timeago() function in php
<?php
define("SECOND", 1);
define("MINUTE", 60 * SECOND);
define("HOUR", 60 * MINUTE);
define("DAY", 24 * HOUR);
define("MONTH", 30 * DAY);
/**
* Humanize by delta.
*
@nucklearproject
nucklearproject / gist:4233314
Created December 7, 2012 13:35
Responsive adsense snipet
<script type="text/javascript"><!--
google_ad_client = "ca-pub-3658299045266116";
/* top */
if ($(window).width()<728 ){
google_ad_slot = "4414183254";
google_ad_width = 320;
google_ad_height = 50;
}else{
google_ad_slot = "1020377061";
google_ad_width = 728;
@nucklearproject
nucklearproject / template.tpl.php
Created December 9, 2012 13:12 — forked from gagarine/template.tpl.php
Working with drupal theme_menu_tree
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {