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
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 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
# 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 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
var top = window.screen.height - 300; | |
top = top > 0 ? top/2 : 0; | |
var left = window.screen.width - 400; | |
left = left > 0 ? left/2 : 0; | |
var uploadWin = window.open(url,"Upload Chapter content","width=400,height=300" + ",top=" + top + ",left=" + left); | |
uploadWin.moveTo(left, top); | |
uploadWin.focus(); |
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
# Include it in your class | |
include ActionView::Helpers::TextHelper |
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
Global setup: | |
Set up git | |
git config --global user.name "Amitesh Kumar" | |
git config --global user.email [email protected] | |
Next steps: | |
mkdir TinyMCE-YouTube-Plugin | |
cd TinyMCE-YouTube-Plugin | |
git init | |
touch README |
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
Reset Mysql root password | |
$ sudo stop mysql | |
$ sudo start mysql | |
$ mysql -u root | |
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('a_real_pwd'); | |
mysql> exit | |
bye | |
try : mysql -uroot -p |
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 "rails" | |
require 'simple-navigation' | |
module MyEngine | |
class Engine < Rails::Engine | |
#Give the absolute path of file | |
#config.autoload_paths << File.expand_path("../../../config/navigations", __FILE__) | |
SimpleNavigation.config_file_path = File.expand_path("../../../config/navigations", __FILE__) | |
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 "rails" | |
module MyEngine | |
class Engine < Rails::Engine | |
# We can add all of the public assets from our engine and make them | |
# available to use. This allows us to use javascripts, images, stylesheets | |
# etc. | |
initializer "static assets" do |app| | |
app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public") |
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 repo in local gitosis-admin/gitosis.conf | |
~$ mkdir your_repo_name | |
~$ cd your_repo_name | |
~$ git init | |
~$ git remote add origin git@YOUR_SERVER_HOSTNAME:your_repo_name.git | |
# do some work, git add and commit files | |
~$ git add . | |
~$ git commit -m 'Your Message' |
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
https://github.com/elricstorm/baby_dove | |
https://github.com/drhenner/ror_ecommerce | |
http://ror-e.com/info/videos/5 | |
http://edgeapi.rubyonrails.org/classes/Rails/Engine.html | |
https://github.com/krschacht/rails_3_engine_demo/tree/master/app | |
https://github.com/jrwest/authr3 | |
https://github.com/mankind/Rails-3-engine-stub/wiki/How-to-building-a-rails-3-engine-and--set-up-test--with-rspec | |
https://github.com/technicalpickles/jeweler | |
http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/ | |
https://gist.github.com/af7e572c2dc973add221#file_3_plugin.rdoc |