Posts

Showing posts from 2017

Importing Posts from Blogger to Drupal

Importing posts from blogger to Drupal is a piece of cake if you have the feeds module installed. All you need is the common RSS XML parser setting and the field mappings to Drupal's own core blog module. A working importer configuration (which too can be imported) is given here. The node author can be changed here, or in the node processor configuration settings. PS: You can use blogger's backup setting to first export all your posts as an XML file. $feeds_importer = new stdClass(); $feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */ $feeds_importer->api_version = 1; $feeds_importer->id = 'knownexception'; $feeds_importer->config = array( 'name' => 'knownexception', 'description' => 'knownexception', 'fetcher' => array( 'plugin_key' => 'FeedsFileFetcher', 'config' => array( 'allowed_exten...

iPhone vs Android

Image
When I first moved from Windows (ThinkPad) to OSX (MacBook Pro) in 2009, it was a life changing experience. I’ve been a huge fan of Steve Jobs ever since, and am on my third Mac (an Air) now. The Macs were always well worth the higher price tag. But it’s been two months now since I moved from my Google Nexus 5 to an iPhone SE; and even though the SE is newer and costlier than the N5, it under-performs in almost all areas. Just a few things that Androids have had for years, and iPhones still don't: No universal return button No automatic favorites in calls No SMS delivery reports No call blocking No app cache clearing No clear button in blocked contacts Swipe keyboard requires app Downloading videos requires app with payment info Constant network issues Software bugs on every update (too many to list) There have been 3 software updates in the last 2 months, and each one of them has been buggier than the last; with bugs that are quite obvious and visible. Maybe ...

Delete Account Link on Facebook

Doesn't seem to be displayed on the site anymore. The link is: www.facebook.com/help/delete_account

Get Unique Line Counts on Linux

From terminal: cat Duplicates.txt | sort | uniq -c > Counts.txt Within vi: :%sort         // sort the results as required by "uniq" :%!uniq -c   // use the *nix "uniq" tool to prepend counts :%sort!        // sort in reverse order

Drupal Contact Form - Missing or Disappearing Emails

Linux sendmail sometimes drops emails mysteriously without any error message or log of the written email. /var/log/maillog will show an entries such as: Unauthenticated email from xyz.com is not accepted due to [DMARC] The way to fix this is to have the domain name of the current server in the from field, and the actual from address in the reply-to field. This can easily be done with Drupal 7 using the contact_reply_to module. Drupal 8 does not require the module.

Drupal's Confusing Online Readme Text Files

Module pages usually say: "The most complete and up to date documentation is included with the module, in the README.txt file." But the online README.txt files linked to there usually include documentation for unreleased updates. This can cause considerable confusion / unnecessary trouble-shooting when newly installing modules. Always use the README files included with the module, not the ones online.

Drupal DDoS Prevention Code

// The following code will ensure that there are no more than 30 non-cached requests in 60 seconds. // Please adjust the first two variables below in a manner optimal to your server config. // Note that this only protects heavier non cached pages. // A powerful enough attack can even overload your server with requests for cached pages. function hook_init() {     $MinTime = 60;     $MaxAttmpts = 30;     $MyAppDDoSCheckUrl = variable_get('MyAppDDoSCheckUrl');     $TimeCheckNow = time();     if ($MyAppDDoSCheckUrl == '')     {         variable_set('MyAppDDoSCheckUrl',$TimeCheckNow.',1');         return;     }     $SerDDosVars = explode(',',$MyAppDDoSCheckUrl);     $TimeLast = intval($SerDDosVars[0]);     $ReqAttmt = intval($SerDDosVars[1]);        ...

Toggle #input_group on fields in Drupal 7x

Here's the code for iterating through all fields in a form and setting $element [ '#input_group' ] = TRUE ;     function hook_form_alter ( & $form , $form_state , $form_id ) { if ( $form_id == 'nodetype1_node_form' ) { iterateForm ( $form , 'setIgt' ) ; } } // Generic iterate function. Can be used with any callback. function iterateForm ( & $form , callable $callback ) { foreach ( element_children ( $form ) as $key ) { $element = & $form [ $key ] ; $children = element_children ( $element ) ; if ( empty ( $children ) ) { call_user_func_array ( $callback , array ( & $element , & $key ) ) ; } else { iterateForm ( $element , $callback ) ; } } } // Custom callback function setIgt ( & $element , & $key ) { if ( $element [ '#type' ] == 'textfield' ) $element [ '#input_group' ] = TRUE ; }