Skip to content

Instantly share code, notes, and snippets.

@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 / 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
# 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 / 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().