Skip to content

Instantly share code, notes, and snippets.

View mishudark's full-sized avatar
:octocat:
Rocking

mishudark mishudark

:octocat:
Rocking
View GitHub Profile
php_installed=`dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
echo $php_installed
sudo apt-get purge $php_installed
@mishudark
mishudark / print_block.php
Created December 24, 2010 03:33
Imprime un bloque desde el code
$bloque = (object) module_invoke('debate','block','view',6);
print theme('block',$bloque);
@mishudark
mishudark / Ti_xhr.js
Created January 18, 2011 23:56
drupal services over json
var url = 'http://drupalcon.tut2tech.com/services/json';
var datos = {method: 'user.get',uid:1};
var data = {};
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function(){
@mishudark
mishudark / validate to Drupal
Created February 4, 2011 01:18
Validate user register o create
function inseguridad_form_user_register_alter(&$form, &$form_state) {
if(preg_match("/register|user\/create/",$_SERVER['REQUEST_URI']) ){
$form['#validate'][] = 'inseguridad_user_register_validate';
}
}
function inseguridad_user_register_validate($form, &$form_state){
$pass1 = $form['#parameters'][1]['post']['pass']['pass1'];
if( preg_match("/[^a-zA-Z0-9]/",$pass1))
form_set_error('inseguridad', t("La contraseña solo admite números y letras mayúsculas y minúsculas."));
$minuit = strtotime("00:00:00.00");
$hora1='00:00:20.00';
$timestamp1 = strtotime($hora1)-$minuit;
$hora2='00:00:40.00';
$timestamp2 = strtotime($hora2)-$minuit;
$SUMA=$timestamp1+$timestamp2+$minuit;
echo date("H:i:s",$SUMA);
var hoy = new Date();
var futuro = new Date(2011,02,30);
var diff = futuro-hoy;
diff /= 1000;
var days = Math.floor(diff / (60*60*24) - 27);
diff = diff - (days+27) *(60*60*24);
var hours = Math.floor(diff/(60*60));
diff = diff - hours * (60*60);
@mishudark
mishudark / sprite.py
Created February 20, 2011 18:40
crea sprite en base a muchas imgs, sacado de debumode on
from PIL import Image
path = '/Users/gimenete/Desktop/famfamfam_silk_icons_v013/icons/'
names = ['add.png', 'accept.png', 'anchor.png', 'bomb.png', 'cd_add.png', 'clock.png']
output = 'sprites.png'
vpadding = 16
padding = 2
w = 0
h = 0
"""
Takes a list of filenames via standard input and uploads them to Amazon S3.
Requires S3.py:
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=134&categoryID=47
Usage:
cd /directory/with/media/files/
find | grep -v ".svn" | python /path/to/update_s3.py
@mishudark
mishudark / flexible_date.py
Created March 27, 2011 17:25
flexible date like '+2 days' 'friday' '+2 thursday'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2011 mishudark <moonsadly@gmail.com><mishudark@astrata.com.mx>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
@mishudark
mishudark / get_class_name.py
Created April 5, 2011 04:33
get class name
def whoami(self):
return type(self).__name__