Skip to content

Instantly share code, notes, and snippets.

View marcamillion's full-sized avatar

Marc Gayle marcamillion

View GitHub Profile
@marcamillion
marcamillion / best_in_place_fix.js.coffee
Created December 3, 2012 16:33 — forked from mkelley33/best_in_place_fix.js.coffee
best_in_place: fix disappearing line-breaks in textarea
jQuery ->
$('[id^="best_in_place_your_object_"],[id$="address"]').on 'best_in_place:update', (event) ->
$address = $(event.target)
$address.data('bestInPlaceEditor').original_content = $address.html()
$address.html $address.html().replace(/[\n\r]+/g, '<br>')
def update
@client = current_user.clients.find(params[:id])
respond_to do |format|
if @client.update_attributes(params[:client])
format.html { redirect_to @client, notice: 'Client was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
class Student < ActiveRecord::Base
has_many :grades do
def below_average
where('score < ?', 2)
end
end
end
1.9.2p0 :002 > f = User.first
User Load (0.4ms) SELECT "users".* FROM "users" LIMIT 1
=> #<User id: 1, email: "abc@email.com", encrypted_password: "$2a$10$LTc6zq5VorMZzsDSv7nD2eZpQkV30BaylB2Q6oY4yYjJ...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 2, current_sign_in_at: "2012-06-13 08:12:53", last_sign_in_at: "2012-06-13 08:09:08", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", name: "Ayy Bee Cee", created_at: "2012-06-13 08:08:01", updated_at: "2012-06-13 08:12:53", confirmation_token: nil, confirmed_at: "2012-06-13 08:09:08", confirmation_sent_at: "2012-06-13 08:08:01", unconfirmed_email: nil, authentication_token: nil>
1.9.2p0 :003 > f.categories
Category Load (8.1ms) SELECT "categories".* FROM "categories" INNER JOIN "categories_users" ON "categories"."id" = "categories_users"."category_id" WHERE "categories_users"."user_id" = 1
=> []
1.9.2p0 :003 > f.categories
=> []
1.9.2p0 :007 > f.categories.create({:id => 1})
(0.1ms)
Interactive ruby ready.
> food = ['chi­cken', 'stea­k', 'beef­', 'pork­']
=> ["chicken", "steak", "beef", "pork"]
> food.each do |x|
.. puts x
.. end
=> #<SyntaxError: <script>:1: syntax error, unexpected end-of-file
food = ['chicken', 'steak', 'beef', 'pork'];food.each do |x|;
#(Element:0x8427df88 {
name = "a",
attributes = [
#(Attr:0x841fe3a0 {
name = "href",
value = "http://google.com"
})],
children = [ #(Text "Google Home Page")]
})
# Get a URL's content to play with
content = contents[contents.keys.first]
# => [#<Nokogiri::XML::Element:0x48a9a86 name="p" children=[#<Nokogiri::XML::Text:0x48a9810 "The autobiography of Yohwan Lim, ">, #<Nokogiri::XML::Element:0x48a96ee name="i" children=[#<Nokogiri::XML::Text:0x48a9536 "Crazy As Me">]>, #<Nokogiri::XML::Text:0x48a931a " was released in Korea by BookRoad Publishers in October 25, 2004. This is my translation of the book, except the following four sections which were translated by BinaryStar of Teamliquid.net, which I have made minor changes: \"Hope on the Road Not Taken,\" \"Chapter One: The Game-crazed Kid,\" \"The Birth of the Emperor,\" and \"The Little Prince with Three Sisters.\"">]>, #<Nokogiri::XML::Element:0x48a9194 name="p" children=[#<Nokogiri::XML::Text:0x48a9022 "As of October 4, 2004:">]>, #<Nokogiri::XML::Element:0x48a8e92 name="p">, #<Nokogiri::XML::Element:0x48a8ce4 name="p" children=[#<Nokogiri::XML::Text:0x48a8af0 "The addition of e-sports organizations to major compani
ls /usr/local
bin heroku include mysql mysql-5.5.17-osx10.6-x86_64
git hw_mobile_userdata lib mysql-5.1.52-osx10.6-x86 share
div#divider {
margin-top: 10px;
margin-left: auto;
margin-right: auto;
margin-bottom: 10px;
border-top: 1px solid #acadad;
border-bottom: 1px solid #fff;
width: 80%;
height: 0px;
padding: 0px 0px 0px 0px;
Started GET "/assets/sign-in-with-twitter-56f86819ac755692904d912373db060b.png" for XX.XX.XXX.XX3 at 2011-10-06 10:27:32 -0700
2011-10-06T17:27:32+00:00 app[web.1]: cache: [GET /assets/sign-in-with-twitter-56f86819ac755692904d912373db060b.png] miss, store
2011-10-06T17:27:32+00:00 heroku[router]: GET domain.heroku.com/assets/sign-in-with-twitter-56f86819ac755692904d912373db060b.png dyno=web.1 queue=0 wait=0ms service=21ms status=200 bytes=2490
2011-10-06T17:27:32+00:00 heroku[nginx]: xx.xx.xxx.xx - - [06/Oct/2011:10:27:32 -0700] "GET /assets/sign-in-with-twitter-56f86819ac755692904d912373db060b.png HTTP/1.1" 200 2490 "http://domain.heroku.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1" mydomain.heroku.com
2011-10-06T17:27:56+00:00 app[web.1]:
2011-10-06T17:27:56+00:00 app[web.1]:
2011-10-06T17:27:56+00:00 app[web.1]: Started GET "/auth/twitter?utf8=%E2%9C%93&commit.x=171&commit.y=8&commit=Sign+in" for xx.xxx.xxx.xx at 2011-10-06 1