Skip to content

Instantly share code, notes, and snippets.

@ss81
ss81 / gist:4596527
Last active December 11, 2015 11:48
Embed Drupal block region into node page. Snippet to insert or embed Drupal block region into a node template.
YOUR_THEME.info:
...
regions[BLOCK_REGION_NAME] = Block region name
...
template.php:
<?php
/**
@ss81
ss81 / gist:4611289
Created January 23, 2013 18:26
Get the list of all elements of a form (for https://github.com/cheezy/page-object).
$('#user-register input, #user-register select').each(function(){
console.log("text_field :" + $(this).attr('name') + ", :id => '" + $(this).attr('id') + "'");
});
@ss81
ss81 / gist:5395271
Created April 16, 2013 11:37
Feed Parser
import urllib2
import feedparser
import time
import sys
url = 'http://www.zurnal24.si/index.php?ctl=show_rss'
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
# Try to connect a few times, waiting longer after each consecutive failure
@ss81
ss81 / gist:6777586
Created October 1, 2013 12:17
How do I disable the confirmation email sent out from Drupal?
In Drupal 7, the conf variable you should add the following line in your settings.php
$conf['user_mail_register_no_approval_required_notify'] = FALSE;
The bold could take this value:
register_admin_created: Welcome message for user created by the admin.
register_no_approval_required: Welcome message when user self-registers.
register_pending_approval: Welcome message, user pending admin approval.
password_reset: Password recovery request.
status_activated: Account activated.
@ss81
ss81 / gist:7213661
Created October 29, 2013 12:21
How to change element inside iFrame
var img = jQuery('iframe[id="google_ads_iframe_1111/circle.example_1"]').contents().find('img')
img.attr('width', 280)
img.attr('height', 230)
@ss81
ss81 / gist:7222483
Created October 29, 2013 20:59
Initiate Django development environment
virtualenv django_env
cd django_env/
source bin/activate
pip install -r requirements/common.txt
pip install -r requirements/dev.txt
.....
deactivate
@ss81
ss81 / gist:9056554
Created February 17, 2014 18:48
Remove those Word copy and paste smart quotes
function _lym_sanitize_text($text) {
$text = mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8');
$find[] = '“'; // left side double smart quote
$find[] = '”'; // right side double smart quote
$find[] = '‘'; // left side single smart quote
$find[] = '’'; // right side single smart quote
$find[] = '…'; // elipsis
$find[] = '—'; // em dash
$find[] = '–'; // en dash
@ss81
ss81 / gist:9098276
Created February 19, 2014 18:25
Drupal.equalHeight
Drupal.equalHeight = function(group) {
if ($(group).length > 0) {
var tallest = 0, thisHeight = 0;
$(group).each(function() {
thisHeight = $(this).height();
if (thisHeight > tallest) {
tallest = thisHeight;
}
});
$('body').css('cursor', 'wait');
$('body').css('cursor', 'default');
@ss81
ss81 / gist:7e0773ad942d8c2be82f
Last active August 29, 2015 14:03
Defining Custom Field Types in Drupal
<?php
/**
* Implements hook_field_schema().
*/
function license_plate_field_schema($field) {
return array(
'columns' => array(
'plate_number' => array(
'type' => 'varchar',