Skip to content

Instantly share code, notes, and snippets.

@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: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: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: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: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:4546841
Created January 16, 2013 12:35
Drupal 6/7. Set one error message for several form elements.
<?php
$msg = t('Your message here.');
form_set_error('field_shopdata_paypal][0][value', $msg);
form_set_error('field_shopdata_paypal_fname][0][value', $msg);
array_pop($_SESSION['messages']['error']); // Remove doubled mesage.
form_set_error('field_shopdata_paypal_lname][0][value', $msg);
array_pop($_SESSION['messages']['error']); // Remove doubled mesage.
@ss81
ss81 / gist:4452537
Created January 4, 2013 13:19
Get list of changes, which were committed since a revision, provided in command line.
`svn diff -r #{ARGV[0]}:HEAD --summarize`.lines().each { |file|
p file.chomp.gsub(/[AM ]/, "")
}
@ss81
ss81 / gist:4374498
Created December 25, 2012 18:03
Get the list of form elements
$('#user-register :input').each(function(){
console.log($(this).attr('name'))
});
@ss81
ss81 / gist:4086579
Last active October 12, 2015 20:58
Only one product in shopping cart.
<?php
/**
* Implementation of hook_form_alter()
*/
function hook_form_alter(&$form, $form_state, $form_id) {
if (drupal_match_path($form_id, 'uc_product_add_to_cart_form_*')) {
array_unshift($form['#submit'], 'uc_product_before_add_to_cart_submit');
}
}
@ss81
ss81 / gist:4079387
Created November 15, 2012 16:02
Draft of Selenium Test
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://example.com/" />
<title>checkout</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">