Using jQuery Migrate plugin
We all know these tricky situations, like introducing a new feature on top of old code, when it seems we’re about to step into a tedious swamp of workarounds and dirty hacks. Fortunately, jQuery Migrate plugin is here to make these situations easier, at least in JavaScript. So for any of you who wondered about a real-life example of using jQuery Migrate plugin I have one!
My task was to add an editable combomonster, oh sorry, combobox (even though editable comboboxes remind me of UX Frankenstein’s Monster, they are still requested a lot) to a rather old website built on jQuery v1.4.2.
I downloaded the most recent jQuery UI (at that time it was v1.10.4) and a very neat editable combobox component to go with it. It was expected that it wouldn’t work out of box with the rather outdated jQuery we had. It didn’t work and the page produced the following JavaScript error:
TypeError: t.cssHooks is undefined
...t(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,n){var a,o,r="";if("trans...
No problem, I grab the newer compatible jQuery v1.10.2 from the website and yield it into head in that particular page.
<% content_for :head do %>
javascript_include_tag …
javascript jquery
Solving pg_xlog out of disk space problem on Postgres
Running out of disk space in the pg_xlog directory is a fairly common Postgres problem. This important directory holds the WAL (Write Ahead Log) files. (WAL files contain a record of all changes made to the database—see the link for more details). Because of the near write‑only nature of this directory, it is often put on a separate disk. Fixing the out of space error is fairly easy: I will discuss a few remedies below.
When the pg_xlog directory fills up and new files cannot be written to it, Postgres will stop running, try to automatically restart, fail to do so, and give up. The pg_xlog directory is so important that Postgres cannot function until there is enough space cleared out to start writing files again. When this problem occurs, the Postgres logs will give you a pretty clear indication of the problem. They will look similar to this:
PANIC: could not write to file "pg_xlog/xlogtemp.559": No space left on device
STATEMENT: insert into abc(a) select 123 from generate_series(1,12345)
LOG: server process (PID 559) was terminated by signal 6: Aborted
DETAIL: Failed process was running: insert into abc(a) select …
postgres
Some metaprogramming examples from RSpec
I’m quite the curious cat and one thing that has interested me for a while has been how RSpec and its describe and it methods work. In digging through the rspec-core gem source code (v3.1.4), specifically the example_group.rb file, I came across some syntax that I had not been exposed to:
# https://github.com/rspec/rspec-core/blob/v3.1.3/lib/rspec/core/example_group.rb
module RSpec
module Core
class ExampleGroup
# ...
def self.define_singleton_method(*a, &b)
(class << self; self; end).__send__(:define_method, *a, &b)
end
# ...
def self.define_example_method(name, extra_options={})
define_singleton_method(name) do |*all_args, &block|
# ...
end
end
# ...
define_example_method :it
# ...
end
end
end
“What’s with all this passing around of blocks? And what’s :define_method doing?” I asked. The documentation for the define_method is straightforward enough, yet I still wondered what was being accomplished in the code above. In pursuit of answers, here’s what I found out.
Metaprogramming
Metaprogramming is the writing of code that acts on other code instead of …
ruby testing
Spree Authorization Failure for Customized Role
Hello again all. Recently I was working on another Spree site running Spree 2.1.1. The client wanted to create some custom roles. For example, the client wanted there to be a Sales Manager role. A Sales Manager could log in and have read and write access to all the orders. However, a sales manager should not have read/write access to products, configuration, promotions, users, etc. This was easily accomplished by following the steps in the Spree documentation. As I will describe, this documentation assumes that the custom role will have access to Orders#index.
The client wanted to create a second custom role that had create, read, update and delete access to the Training model and nothing more. The training model belongs to a taxon and has a unique event date and taxon id. An example would be a training instance with an event date of September 9th, 2014 that belongs to a taxon with the name “Fire Safety 101” and a description “Teaching fire safety in accordance with OSHA standards. 10 hours and lunch is provided”. So, I planned to create a training personnel role that should be able to log in and only have read/write access to Trainings. However, the Spree documentation did not …
ruby rails spree
Piggybak: Recent Updates and Upgrades
Piggybak, an open source Ruby on Rails ecommerce gem, implemented as a mountable solution, has continued to be upgraded and maintained over the last several months to keep up to date with Rails security releases and Ruby releases. Here are some quick notes on recent work:
- Piggybak (version 0.7.5) is now compatible with Rails 4.1.6, which is the most up to date release of Rails. See the Rails release notes for more details on this recent release. The Piggybak Demo is now running on Rails 4.1.6.
- Piggybak is compatible with Ruby 2.1.2, and the demo is running on Ruby 2.1.2.
- Recent updates in Piggybak include migration fixes to handle table namespace issues, and updates to remove methods that are no longer present in Rails (that were previously deprecated).
- Recent updates to the demo include updates to the integration testing suite to allow testing to be compatible with Rails 4.1.6, as well as modifications to how the demo handles exceptions.
Make sure to check out Piggybak on github repository for more details on these recent updates.
piggybak ruby rails
Aliasin’ and Redmine plugins
Recently I was tasked with creating a plugin to customize End Point’s Redmine instance. In working through this I was exposed for the first time to alias_method_chain. What follows is my journey down the rabbit hole as I wrap my head around new (to me) Ruby/Rails magic.
The Rails core method alias_method_chain encapsulates a common pattern of using alias_method twice: first to rename an original method to a method “without" a feature, and second to rename a new method “with" a feature to the original method. Whaaaa? Let’s start by taking a look at Ruby core methods alias and alias_method before further discussing alias_method_chain.
alias and alias_method
At first glance, they achieve the same goal with slightly different syntax:
class Person
def hello
"Hello"
end
alias say_hello hello
end
Person.new.hello
=> "Hello"
Person.new.say_hello
=> "Hello"
class Person
def hello
"Hello"
end
alias_method :say_hello, :hello
end
Person.new.hello
=> "Hello"
Person.new.say_hello
=> "Hello"
Let’s see what happens when we have a class inherit from Person in each of the cases above.
class Person
def …
extensions ruby rails
Analyzer Reports with Geo Map Option in Pentaho 5 BI Server
The “Geo Map” option in Analyzer Reports provides a feature to visualize data with geographic locations. We will learn how to design a Mondrian schema and configure Pentaho to make use of the “Geo Map” feature in the Analyzer Reports. This article will show us how to set this feature up step by step.
Enable Geo Map feature on Geographic fields in Mondrian Schema
The Mondrian schema has two main categories called Dimensions and Measures. The Dimensions are defined as levels in the Mondrian schema. The Geographic fields should have two additional annotations to use Geo Map. The two annotations are:
-
Data.Role — defines the type of level generally; for this type of node, this must be set to ‘Geography’.
-
Geo.Role — defines the geographical classification in a hierarchy. These can be either predefined roles (‘country’, ‘state’, ‘city’, ‘postalcode’) or custom roles.
Sample Level with Annotation:
<Level name="Country Name" visible="true" column="country" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
<Annotations>
<Annotation name="Data.Role"> …
gis pentaho postgres reporting casepointer
Today’s Internet Slowdown
Today End Point is participating in an Internet-wide campaign to raise awareness about net neutrality, the FCC’s role in overseeing the Internet in the United States, and the possible effects of lobbying by large consumer Internet providers.
Many companies and individuals are in favor of specific “net neutrality” regulation by the FCC, and make good arguments for it, such as these by Battle for the Net, Etsy and ThoughtWorks and Reddit.
There are also plenty speaking out against certain specific regulatory proposals out there: TechFreedom, Google, Facebook, Microsoft, Yahoo!, Todd Wasserman, and with a jaunty propagandistic style, NCTA, the cable company’s lobby.
I think we are all sympathetic to free-market arguments and support non-governmental solutions that allow companies and individuals to create things without getting permission, and to arrange services and peering as they see fit. It seems that most people and companies understand the need to pay for more bandwidth, and more data transfer. (Marketers are the ones promising unlimited everything, then hiding limits in the fine print!) Many of us are worried about further entrenching government in private networks, whether …
community