This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://rails-bestpractices.com/posts/48-use-openstruct-when-advance-search | |
class Tableless | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
def initialize(props = {}) | |
props.each do |name, value| | |
send("#{name}=", value) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add in Gem file | |
gem devise | |
- Install devise | |
$ rails generate devise:install | |
- Generate user model and routes | |
$ rails generate devise user | |
- Add extra fields |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author: Qawelesizwe Mlilo | |
Email: [email protected] | |
Dependency: Mootools | |
Notes: This code was used in a Joomla! project and can be easily modified to run without a library | |
*/ | |
var slideShow = function (img, o) { | |
this.element = $(img); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@beta_invite.errors.full_messages.join(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'support/discussions' #require module | |
class Admin::DiscussionsController < ApplicationController | |
include Support::Discussions | |
def index | |
# Call class/static method | |
Admin::DiscussionsController.test() | |
#Call instance method | |
test2() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup | |
RewriteEngine on | |
RewriteBase / | |
# product redirection based on iPhone and product request | |
# note: the user agent check is contrived, you should have | |
# a much more robust checker | |
RewriteCond %{HTTP_USER_AGENT} iPhone | |
RewriteCond %{QUERY_STRING} Prodid=(\d+) | |
RewriteRule ^Browse\/Product\.aspx http://m.costco.com/costco/product/productDirectDetail.do?itemId=%1 [R=301,L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## | |
# MySQL DB dump to Git commit | |
# | |
# Dumps the specified mysql database to the given location and commits it and | |
# the previous database to the Git repository. | |
# | |
# It is assumed you have already setup the Git respository to only be the | |
# a checkout of the database backup location |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// General | |
button_tile_map : true, | |
editor_selector : 'lg_mceEditor', | |
mode:'textareas', | |
theme : 'advanced', | |
// Cleanup/Output | |
apply_source_formatting : true, | |
convert_fonts_to_spans : true, | |
convert_newlines_to_brs : false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# we can change the <wbr> and <br> as per our requirement. | |
def wrap_long_string(text, max_width = 20) | |
if text.blank? | |
return text | |
end | |
sp = text.split(/\n/) | |
sp.collect!{|s| | |
s = (s.length < max_width) ? s : s.scan(/.{1,#{max_width}}/).join("<wbr>") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install mysql 5.5.13 | |
Install 5.5.13 from doc for our IM server | |
after installation do | |
( to get ride of ruby issue ) | |
gem pristine --all | |
not found shared libmysqlclient_r.so.16 file | |
sudo chown -R mysql table1 | |
sudo chgrp -R mysql table1 |