How to Parse Query Strings in PHP
Here is a quick snippet for parsing query strings in PHP. You can use the `parse_url` and `parse_str` methods. `parse_str` will create a variable for you populated with results.
$url = "http://www.seanbehan.com/path/?param=key";
parse_str(parse_url...
Written by Sean Behan on 12/04/2017
Using Module Mixins to Extend Classes and Objects in Ruby
The module and class below demonstrate how to use instance methods and class methods from "module mixins". The thing to remember is scope. For instance, to use class methods within instance methods you need to call them from the class itself. This is acco...
Written by Sean Behan on 06/17/2012
named_scope in Rails
Take advantage of the named_scope method in your models and make find queries simple and beautiful!
#app/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
named_scope :pending, :conditions => ["pending = ?", true]
named_scope :...
Written by Sean Behan on 06/17/2012
Convert Array to Object in PHP
function array2obj($data) {
return is_array($data) ? (object) array_map(__FUNCTION__,$data) : $data;
}
Source: http://www.serversidemagazine.com/php/how-to-convert-array-notation-to-object-notation...
Written by Sean Behan on 06/17/2012
Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition
Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I'm going to use my own blog which is a Wordpress installation and serve a Rails application from the subdir...
Written by Sean Behan on 06/17/2012