Skip to content

Instantly share code, notes, and snippets.

View thelebster's full-sized avatar
:octocat:
Do nothing, it is ok.

Anton Lebedev thelebster

:octocat:
Do nothing, it is ok.
View GitHub Profile
@thelebster
thelebster / HelloWorld.php
Last active December 12, 2015 09:39
Hello, World!
<?php
echo "Hello, World!";
?>
@thelebster
thelebster / drupal.form.helper.fields.disable.inc.php
Last active December 13, 2015 17:58
Disable selected form fields by name. #drupal #form #helper
<?php
/**
* Disable selected form fields by name.
*
* @param array $fields
* Array of fields names that needs to be disabled.
*/
function MYMODULE_form_helper_disable_fields(&$form, $fields = array()) {
if (is_array($fields)) {
foreach ($fields as $field) {
@thelebster
thelebster / drupal.form.helper.fields.deny.inc.php
Created February 14, 2013 09:29
Deny (hide) selected form fields by name. #drupal #form #helper
<?php
/**
* Deny (hide) selected form fields by name.
*
* @param array $fields
* Array of fields names that needs to be denied.
*
* Values of these fields will not be passed to $form_state['values'].
*
* @example
@thelebster
thelebster / drush.comments.sh
Last active December 13, 2015 19:19
#drupal #drush
#!/bin/bash
# 0 - no
# 1 - closed (read only)
# 2 - open (read/write)
# Disable comments for content of NODETYPE
drush vset --yes comment_NODETYPE 1
# Disable comments for the already created content of NODETYPE
drush php-eval "variable_set('uc_recurring_payment_methods', array('paypal_wps' => 'paypal_wps'));"
<?php
function MYMODULE_preprocess_html(&$vars) {
/**
* Disable Skype phone highlighting in Internet Explorer.
* Add meta: <meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
* @see http://bacsoftwareconsulting.com/blog/index.php/web-development/prevent-skype-from-highlighting-phone-numbers/
*/
$meta = array(
'#type' => 'html_tag',
<?php
function writeLog($string) {
$log_file = dirname(__FILE__) . '/log.txt';
if ($fh = @fopen($log_file, "a+")) {
fputs($fh, $string, strlen($string));
fclose($fh);
return true;
}
else {

Use "drush solr-index" instead of running cron. This saves more and more time exponentially the more nodes you have to index. Here's a shell script to run if you have a ton of nodes to index:

for i in {1..100}; do drush solr-index; done

drush sql-dump > DATABASENAME-$(date +%Y-%m-%d-%H.%M.%S).sql
tar -czf FOLDERNAME-$(date +%Y-%m-%d-%H.%M.%S).tar.gz FOLDERNAME