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
| How to setup netsed model in Rails 3 | |
| ======================================== | |
| CREATE TABLE `books` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `title` varchar(255) DEFAULT NULL, | |
| `description` text, | |
| `imported_from` varchar(255) DEFAULT NULL, |
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
| Error Type : 1. Use "includes" instead of "joins" with kaminari pagination. | |
| example : | |
| books = Book.joins( :other_category ).where(['books.published_on is not null and other_categories.name like ?', "%#{category_name}%"]).order('books.title').page( page ).per( per ) | |
| it makes sql for counting the record as : | |
| SELECT COUNT(*) FROM `books` WHERE ( books.id IN (SELECT DISTINCT other_categories.book_id FROM other_categories WHERE other_categories.name LIKE '%Fiction%')) LIMIT 10 OFFSET 20 | |
| This sql failed to return the count dues to limit and offset. |
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 |
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
| // 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
| #!/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
| # 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
| 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
| @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
| /* | |
| 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); | |