Drupal

add news feed

tweet a story

Please note: the content on this page orginates from ericlondon.com.In this blog post, I'll show an example Ruby module/class structure to allow users to set configuration settings via a do/block, like: Api.config do |c| c.first_na...
Please note: the content on this page orginates from ericlondon.com.In this blog post, I'll show an example Ruby module/class structure to allow users to set configuration settings via a do/block, like: Api.config do |c| c.first_name = 'Eric' c.last_name = 'London' end The following code shows how a simple module/class structure could be defined to allow end-users to set instance variables on a module's singleton class: #!/usr/bin/env ruby module Api # mixes in module methods as class methods extend self def config if block_given? # pass block to settings singleton yield Settings else # return instance variables vars = {} Settings.instance_variables.each do |key| vars[key] = Settings.instance_variable_get key end vars end end end module Api class Settings # dynamic method call def self.method_missing(method, *args, &block) # check for assignment methods if method.to_s =~ /=$/ key = method.to_s.gsub(/=$/,'') set_var(key, args.first) else super end end # or, an explicit method list: # def self.first_name=(value) # # blah # end class Usage and output: Api.config do |c| c.first_name = 'Eric' c.last_name = 'London' end require 'pp'pp Api.config{:@first_name=>"Eric", :@last_name=>"London"}
about 6 hours ago
How to Install the Intelligence ModuleTomMonday, October 7th, 2013 - 4:37PM This post covers the step by step instructions for getting the core of the Intelligence module up and running. Once the steps are complete your Drupal site will ...
How to Install the Intelligence ModuleTomMonday, October 7th, 2013 - 4:37PM This post covers the step by step instructions for getting the core of the Intelligence module up and running. Once the steps are complete your Drupal site will start tracking expanded Google Analytics data and you will be able to generate many of the Intelligence reports. Additional posts will explain how to customize the system and unlock more advanced features. Install the LevelTen Intelligence module Download the Intelligence module and follow the standard process for installing modules. To get started, only enable the base LevelTen Intelligence module without any of the sub modules. We will cover sub modules later on. Also download and install any of the dependent modules if you don’t already have them installed: Google Analytics Google Analytics Reports OAuth Libraries Setup an Intelligence Google Analytics account LevelTen Intelligence works directly with Google Analytics. You will want to setup a dedicated Google Analytics tracking id to use with LevelTen Intelligence. Most Drupal sites are already using Google Analytics via the Google Analytics module and thus have and existing tracking id. If you already have a Google Analytics tracking id, you will want to setup a second one specifically for LevelTen Intelligence. If you don’t currently have a Google Analytics tracking id, you should set up two accounts. One to track standard data via the Google Analytics module and one to track enhanced data via the Intelligence module. You can create tracking id's using Google Analytics’ admin. Tracking ids are associated with a Property. You can create two tracking id's using the same account by setting up two properties. Navigate to the account you want to use in Google Analytics admin, then use the select box under Property and select Create new property. Make sure to select Classic Analytics as the tracking method on the New Property setup page. Get a LevelTen Intelligence API key Next you will need an API key from the LevelTen Intelligence API. Create an account at api.getlevelten.com using the registration page. Once logged in, click My Properties on the right hand menu, then Add new property. Select a name for your property to help you identify which property is associated with this key. Input the Google Analytics tracking id you created for use with LevelTen Intelligence in the previous step. Install Libraries You will need to install the LevelTen Intelligence libraries from the API site into Drupal. To do this, click the 'Downloads' link in the right hand user menu while logged into the API site. Download your preferred archive formats (zip for Windows, tar.gz for Mac & Unix) and unarchive the files into your libraries directory in Drupal. This is the directory created by the Libraries modules. It is usually: [Drupal root]/sites/all/libraries/ Configure LevelTen Intelligence settings Login to your Drupal site and go to admin > config > services > LevelTen Intelligence. Input the tracking id and API key generated on the API site into the form and click Save configuration. If everything is setup properly you will get a status message “LevelTen intelligence API connected.” Next you will need to configure the Google Analytics API by going to admin > config > system > Google Analytics reports. Follow the direction on the configuration page to connect to the Google Analytics API. Make sure you connect with the Google Analytics property (tracking id) that you setup for working with LevelTen Intelligence. LevelTen Intelligence tracking data will follow the parameters set in Drupal's standard Google Analytics module. If you do not have previously configured the Google Analytics module, do that next by going to admin > configure > system > Google Analytics.  Verify install Everything should now be setup. If configured properly your page view analytics should be tracking. To verify this
1 day ago
By the time most large Drupal sites have been around for a year or two, they've accumulated a menagerie of content types. Articles, press releases, product pages, reviews, biographies, landing pages, home pages, promo rotators, phot...
By the time most large Drupal sites have been around for a year or two, they've accumulated a menagerie of content types. Articles, press releases, product pages, reviews, biographies, landing pages, home pages, promo rotators, photo galleries, and more litter the list of content, and making sure they're treated consistently can be a problem.
1 day ago
Download The ToadCast has been revived! I talked with Adam Edgerton to discuss the Digital PM Summit. ToadCast can be found on iTunes. Check us out and give us a rating. Feel free to use our form to submit questions, topic ideas, and t...
Download The ToadCast has been revived! I talked with Adam Edgerton to discuss the Digital PM Summit. ToadCast can be found on iTunes. Check us out and give us a rating. Feel free to use our form to submit questions, topic ideas, and tips! Give it a try. Thanks for listening. Topics discussed: Project Management Philadelphia & names that begin with the letter "A" Filed under podcast, Project Management.
1 day ago
"[notice] child pid 45617 exit signal Segmentation fault (11)": This is usually the start of a very bad day. Since a segfault is a low-level error in native machine code (in this case the PHP interpreter), many typical debugging techniq...
"[notice] child pid 45617 exit signal Segmentation fault (11)": This is usually the start of a very bad day. Since a segfault is a low-level error in native machine code (in this case the PHP interpreter), many typical debugging techniques don't apply. Today I decided to try something new: XCode Instruments Apple's XCode includes an analyzer called Instruments (which is driven by Sun's DTrace). A stack trace from any process can be captured with point-and-click simplicity: Launch Instruments Start recording an activity monitor Attach a spin monitor to an httpd or php process Visit the page causing the segfault (you might have to repeat this a few times depending on how many PHP processes are running) Uncheck "hide missing symbols" (I arrived at the spin monitor with a little trial and error, if someone with more XCode expertise knows of a better procedure please let me know in the comments.) Monkey-patching with Runkit Now we know the segfault is caused by PCRE (the Perl Compatible Regular Expressions library). This isn't a big surprise, since PCRE is by far the most frequent cause of PHP segfaults. However, it still doesn't reveal which regex triggered the error. I wanted a way to log every call to preg_match() (it's not the only regex function, but a good start). Since this is a built-in function it's not possible to add debugging code. That is, unless Runkit is installed. Runkit enables "Monkey patching" – replacing code at runtime. (If this sounds like a bad idea, that's because it usually is.) I added the following code to settings.php: runkit_function_copy('preg_match', 'preg_match_original');   runkit_function_redefine('preg_match', '', 'file_put_contents(\'/tmp/args\', print_r(func_get_args(), TRUE));call_user_func_array (\'preg_match_original\', func_get_args());'); After visiting the page again, my log file contained this: Array ( [0] => /^([0-9]+,)*[0-9]+$/ [1] => 69726,69731,541476,... ) Which matches: profiles/commons/modules/contrib/views/includes/handlers.inc 1157: elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {   1133 function views_break_phrase($str, &$handler = NULL) { ... 1157 elseif (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) { 1158 $handler->operator = 'and'; 1159 $handler->value = explode(',', $str); 1160 } The regex is part of Views's argument handling, and the subject contains almost 10,000 arguments! This strange crash results from the confluence of two issues: Views #1884772: Segfault with large number of arguments in views_break_phrase() Drupal Commons #1863340: Refactor follow argument plugin to scale better At this point you might be wondering why preg_match() is allowed to segfault in the first place. Why doesn't it handle backtracking overflows more gracefully? Rasmus Lerdorf has the answer: The problem here is that there is no way to detect run-away regular expressions here without huge performance and memory penalties. Yes, we could build PCRE in a way that it wouldn't segfault and we could crank up the default backtrack limit to something huge, but it would slow every regex call down by a lot. If PCRE provided a way to handle this in a more graceful manner without the performance hit we would of course use it. Lessons Instruments was fun to expirement with; however if you don't have it available it's usually a good guess that a PHP segfault is PCRE-related. I got lucky by guessing preg_match() on the first try, but the Runkit method would be time-consuming if you had to trace a lot of different functions. XDebug tracing can be triggered with xdebug_start_trace(), and will trace all functions at once. Take an hour to read about and understand Catastrophic Backtracking. Filed under drupal, PHP, debugging.
1 day ago
Topic: DrupalOpinionPeople ask me what it is like to be the head of a big Open Source project, and whether they should Open Source their project or not. I wanted to talk about that a bit more in this blog post so more people can pick up ...
Topic: DrupalOpinionPeople ask me what it is like to be the head of a big Open Source project, and whether they should Open Source their project or not. I wanted to talk about that a bit more in this blog post so more people can pick up my answer. Having been the project lead of the Drupal project for the past 13 years, I’ve watched my dorm-room activity transform into a community filled with passionate people all working toward the same goal: changing the world and making it a better place through open source. Today Drupal powers more than 1.5 million sites. Drupal is a source of innovation for business and government. Most importantly, Drupal has helped individuals build a dream, giving smaller groups and organizations a bigger voice, as tools are democratized. But it has also allowed large businesses to develop new ideas, bring and build transformative experiences to the digital world. The ambitious individuals who would lead the next generation of open source projects will experience moments of joy and excitement. It's exhilarating when your passion drives you to help create solutions to challenging problems. Your joy will be tempered with plenty of moments of frustration and doubt, as roadblocks may stand in your way during crucial points of development. But the successful leaders will be the ones who aren’t dissuaded from their work. Creating a successful open source project requires much more work than writing good code. If your project is growing, then one day you'll start to see that you are a leader. You’re creating a vision, a culture, and inspiring people to come on board. This evangelism requires a lot of travel, conferences, fundraising, people management, project management and more. Make sure this passion is also within you. I’ve had the opportunity to travel the world, evangelizing Drupal and have a leading role in a passionate, active community that is making a real difference. I’ve also founded a non-profit organization and a commercial company on that same promise. As you start to build a community of participants who are willing to commit their time and passion to your project, you’ll soon realize that in life, the luckiest people in the world are those driven by the desire to be a part of something great. When you work in open source, you’ll be surrounded by people like these. Knowing you help make a difference and that hundreds of thousands of people depend on your project, helps you make sense of your commitment. So even on a bad day, it's still exciting. The world would certainly benefit from having more Open Source, but its not small undertaking as others come to depend on it. Only you can decide whether you have what it takes. When I started Drupal, I didn't really understand what I was getting myself into. It has been a lot of work, but knowing what I know today, I'd do it again. In a heartbeat.
2 days ago
Okay, here is my experience with and some solutions to the problem of spasticity, more commonly known as muscle cramping or charlie horses. Other than frozen shoulder syndrome and the recovery from various surgeries, this can be one of t...
Okay, here is my experience with and some solutions to the problem of spasticity, more commonly known as muscle cramping or charlie horses. Other than frozen shoulder syndrome and the recovery from various surgeries, this can be one of the few, albeit annoying, sources of pain suffered by ALS patients. If, like me, you're left in the dark by your neurologist, until it gets to the point where you need medical intervention, fear not, for there are some tricks you can use to make it bearable, or even pain free. read more
4 days ago
Please note: the content on this page orginates from ericlondon.com.In this blog post, I'll share some code to demonstrate ahead-of-time compiling and packaging JRuby code into a standalone Java Jar. This functionality is nice if you dev...
Please note: the content on this page orginates from ericlondon.com.In this blog post, I'll share some code to demonstrate ahead-of-time compiling and packaging JRuby code into a standalone Java Jar. This functionality is nice if you develop locally via RVM, and want to deploy to a JVM server.Created file:.ruby-version jruby-1.7.4 Created file: .ruby-gemset jruby_jar Created file: Gemfile source 'https://rubygems.org' #gem 'warbler' # ^ LoadError: no such file to load -- zip/zip ... gem 'warbler', :git => 'git://github.com/jruby/warbler.git' Executed bundle to install required gems $ bundle Created main module, file: lib/jruby-jar-example.rb require 'jruby-jar-example/some_class' module JRubyJarExample #PATH = File.expand_path(File.dirname(__FILE__)) extend self def my_var @my_var ||= get_my_var end def my_class_var @my_class_var ||= get_my_class_var end private def get_my_var 'JRubyJarExample var' end def get_my_class_var SomeClass.my_var end end Created sample class, file: lib/jruby-jar-example/some_class.rb module JRubyJarExample class SomeClass def self.my_var @my_var ||= get_my_var end class Created main bin file, file: bin/jruby-jar-example-main.rb. This file will be the main bin file that drives the Jar execution. #!/usr/bin/env jruby # include rubygems require 'rubygems' # load main module conditionally require "#{File.expand_path(File.dirname(__FILE__))}/../lib/jruby-jar-example" unless Module.const_defined? 'JRubyJarExample' # do stuff here puts JRubyJarExample.my_var puts JRubyJarExample.my_class_var Created a gemspec file, file: jruby-jar-example.gemspec Gem::Specification.new do |s| s.name = 'jruby-jar-example' s.version = '1.0.0' s.authors = ['Eric London'] s.date = '2013-10-01' s.description = 'JRuby Jar Example' s.email = ['ericlondon@example.com'] s.homepage = 'http://ericlondon.com' s.require_paths = ['lib','bin'] s.rubygems_version = '1.8.24' s.summary = 'JRuby Jar Example' s.files = Dir.glob("{bin,lib}/**/*") #s.licenses = ['MIT'] s.executables = ['jruby-jar-example-main.rb'] end [Optional] Now that the gemspec defines the project, it can be built and tested via IRB: $ gem build jruby-jar-example.gemspec $ gem install ./jruby-jar-example-1.0.0.gem $ gem list *** LOCAL GEMS *** bundler (1.3.5) jruby-jar-example (1.0.0) jruby-jars (1.7.4) jruby-rack (1.1.13.2) rake (10.1.0) rubyzip (1.0.0, 0.9.9) warbler (1.3.8) $ irb jruby-1.7.4 :001 > require 'jruby-jar-example' => true jruby-1.7.4 :002 > JRubyJarExample.my_var => "JRubyJarExample var" jruby-1.7.4 :003 > JRubyJarExample.my_class_var => "JRubyJarExample::SomeClass var" Warbler will use a gemspec if it exists. If you didn't create one, or need to modify additional settings, you can execute "warble config" to generate a config/warble.rb file to override project settings.At this point the code can be compiled and packaged into a Java jar using warble: $ warble compiled jar rm -f jruby_jar.jar Creating jruby_jar.jar rm -f bin/jruby-jar-example-main.class lib/jruby-jar-example.class lib/jruby-jar-example/some_class.class Your Jar can now be executed or deployed to a JVM: $ java -jar jruby_jar.jar JRubyJarExample var JRubyJarExample::SomeClass var View source code on Github
5 days ago
Last week a number of us went to beautiful Prague, Czech Republic to immerse ourselves at DrupalCon. The city was amazing, and the conference was a blast. In this episode Addi, Kyle, Juampy, and Micah share their experiences, favorite se...
Last week a number of us went to beautiful Prague, Czech Republic to immerse ourselves at DrupalCon. The city was amazing, and the conference was a blast. In this episode Addi, Kyle, Juampy, and Micah share their experiences, favorite sessions and news, and give a general rundown on how DrupalCon Prague turned out. We also have a bit of a discussion on European versus US DrupalCons, and talk about some other events that are coming up. Importing Data With Migrate and Drupal 7 Importing Data With Migrate and Drupal 7 video series DrupalCon Prague session videos on YouTube Drupal Dev Days, Szeged, Hungary (March 24 - 30, 2014) DrupalCon Austin (June 2 - 6, 2014) DrupalCon Amsterdam (Sept 29 - Oct 3, 2014) Artifact Conference (Nov 3, 2013) Getting Up to Speed on Drupal 8 Webinar
5 days ago
DrupalCon Prague This year's European DrupalCon took the community to the beautiful city of Prague, in the Czech Republic. From September 23rd to 27th, Drupal users and contributors from around the world gathered for training, code ...
DrupalCon Prague This year's European DrupalCon took the community to the beautiful city of Prague, in the Czech Republic. From September 23rd to 27th, Drupal users and contributors from around the world gathered for training, code sprints, heated technical discussions, and a peek into what's coming in Drupal 8.
5 days ago