Skip to content

Instantly share code, notes, and snippets.

View deJaVisions's full-sized avatar

deJaVisions deJaVisions

View GitHub Profile
@deJaVisions
deJaVisions / 0_reuse_code.js
Created November 18, 2013 05:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@deJaVisions
deJaVisions / route
Created June 20, 2012 14:58
rails 3 easy route match
match "/doktorj", :to => '/jeremiah'
@deJaVisions
deJaVisions / gist:2364526
Created April 12, 2012 04:03
rake db:migrate chokes on multi-line scope with custom sql
phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:drop
phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:create
phong:~/Sites/forks/doktorj/tmp/rhodes-ror[master]$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
SQLite3::SQLException: no such table: materials: SELECT * from materials
WHERE title NOT LIKE '%antique%'
ORDER BY created_at DESC
{ newChatMsg:
{ gameId: 99,
fromId: 44,
toId: 55,
msg: 'feh',
sent: "Thu, 12 Apr 2012 01:02:13 GMT"
}
}
@deJaVisions
deJaVisions / materials_controller.rb
Created April 5, 2012 00:05
slugged gem getting ActiveModel::MassAssignmentSecurity::Error in Admin::MaterialsController#update all of the sudden
def update
@material = Material.find_using_slug(params[:id])
redirect_to admin_material_url if @material.nil?
respond_to do |format|
if @material.update_attributes(params[:material])
unless params[:material][:pdf].nil?
@material.pdf = params[:material][:pdf]
@material.save!
@deJaVisions
deJaVisions / Gemfile
Created March 31, 2012 16:48
my working automated test::unit setup now with guard/spork working nicely together, and much faster test
group :development do
gem 'ruby-prof'
gem 'guard-spork'
end
group :development, :test do
gem 'test-unit', '2.4.8'
gem 'spork', '~> 1.0rc'
gem 'spork-testunit'
gem 'rb-fsevent', '0.4.3.1', :require => false
@font-face
font-family: 'LucidaSans'
src: url("<%= asset_path('LucidaSans/lucidasansstd-webfont.eot') %> ")
src: url("<%= asset_path('LucidaSans/lucidasansstd-webfont.eot?#iefix') %> ") format("embedded-opentype"), url("<%= asset_path('LucidaSans/lucidasansstd-webfont.woff') %>") format("woff"), url("<%= asset_path('LucidaSans/lucidasansstd-webfont.ttf') %>") format("truetype"), url("<%= asset_path('LucidaSans/lucidasansstd-webfont.svg#LucidaSansStdRoman') %>") format("svg")
font-weight: normal
font-style: normal
@deJaVisions
deJaVisions / test.rb
Created March 28, 2012 10:39
why shoulda can be handy
# without shoulda
test "invalid name gives error message" do
@z.name = nil
assert_presence(@z, :name)
end
# with shoulda
class ZombieTest < ActiveSupport::TestCase
@deJaVisions
deJaVisions / gist:2146479
Created March 21, 2012 12:02
delete mat image working but has some gui issues
// hey eph - fyi i just got delete image (which includes db info and all associated/resized images,and removes from the dom) but i think it needs some gui cleanup as i was having a hard time selecting the thumbnail .close classes even when i would put the parent classes before hand in the selector. i think it's probably cuz it's conflicting with the other top level .close (for error msg's) - so if you could add a new class like .close_image or better yet, .remove_image that just inherit's the same stylez from .close i think that would help. while you're at it, if you could make the the error/notice message close also inherhit from .close with a name like .close_alert that would be more clear...
i renamed the partial _image_thumbs to _gallery fyi.
also, i couldn't get the = link_to below working, perhaps because of the double .close.close2 class, which means no confirmation popup when you delete an image, even tho it still works.
// _gallery.haml
// = link_to "X", :method => :delete, :confir
@deJaVisions
deJaVisions / gist:2042594
Created March 15, 2012 06:53
jquery data selector
<img class="material_thumb" data-large_image="/system/images/1/large/lighthouse.jpg?1331724339" id="material_thumb_1" name="al" src="/system/images/1/thumb/lighthouse.jpg?1331724339"/>
hi - if i have that tag, how to i extract the data-large_image value with coffeescript and or jquery?
[11:47pm] doktorj: it must be simple
[11:48pm] doktorj: i keep thinking it's something like: large_image = $("material_thumb_#{thumb_id}").data('large_image') and have tried all kinds of combinations, but can't' seem to get the single data value out