This file contains 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
Global setup: | |
Set up git | |
git config --global user.name "Amitesh Kumar" | |
git config --global user.email amitesingh@gmail.com | |
Next steps: | |
mkdir TinyMCE-YouTube-Plugin | |
cd TinyMCE-YouTube-Plugin | |
git init | |
touch README |
This file contains 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
# Include it in your class | |
include ActionView::Helpers::TextHelper |
This file contains 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
# MyModel Model | |
class MyModel < ActiveRecord::Base | |
has_attached_file :my_image, | |
:styles => { :small_thumb => "50x50", | |
:medium_thumb => "100x100" | |
}, | |
:default_url => "/images/missing/prints/:style.png" | |
end |
This file contains 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
1) Following regex in ruby is throwing server start (compile) time error on Mac Book Pro while on Ubuntu it is working. | |
# Clean all new line character | |
string.gsub!(/(?<!\n)\n(?!\n)/, '') | |
Error : | |
undefined (?...) sequence: /(?<!\n)\n(?!\n)/ (SyntaxError) | |
Solution : | |
string.gsub!(/\r/,"") | |
string.gsub!(/\n/," ") |
This file contains 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
svn checkout https://server.example.com/srv/svn/agaric myworkingcopyfolder | |
svn status | |
svn update | |
svn add yournewfilehere | |
svn add yournewdirectoryincludingfiles/ | |
svn commit -m "I made changes. Woohoo." files1 files2 | |
Use 'add' for only new file. | |
http://www.linuxfromscratch.org/blfs/edguide/chapter03.html#ch03-add |
This file contains 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
//using jquery date picker | |
function getPreviousDay(event){ | |
event.preventDefault(); | |
var currDate = $('#date_box').val(); | |
currDate = $.datepicker.parseDate('mm/dd', currDate); | |
var d = currDate.getDate(); | |
var m = currDate.getMonth(); | |
var y = currDate.getFullYear(); |
This file contains 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://mathiasbynens.be/demo/url-regex |
This file contains 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 sphinx for Rails 3 | |
================================= | |
http://freelancing-god.github.com/ts/en/installing_sphinx.html | |
1) Download : http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz | |
2) ./configure (It will configure with mysql default) | |
3) make | |
4) sudo make install | |
5) goto (cd) rails project directory | |
6) bundle exec rake ts:index RAILS_ENV=staging |
This file contains 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
# It works for pure text only. It will fail for html and url type of text. | |
# http://henrik.nyh.se/2007/03/ruby-wordwrap-method | |
def wrap_long_string(text,max_width = 20) | |
(text.length < max_width) ? | |
text : | |
text.scan(/.{1,#{max_width}}/).join("<wbr>") | |
end |
This file contains 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, |