- Detect when two AABBs are intersecting in a given moment (true/false)
- Instead of true/false, when they intersect, obtain the minimum displacement vector that would make the first one stop intersecting.
- Do the same when one of the elements is a circle.
- Same as before, but the boxes are not axis-aligned any more; they are Oriented Bounding Boxes (OBB)
- Do the same if one of the boxes is a polygon
- Now the two shapes can be moving. Given their initial positions, velocities and a time interval, calculate if they collide, and if so, the displacement vector that would move each one "backwards on their trajectory" to the point where they touch but don't intersect any more.
- Take into account all the special cases: Two objects might already be intersecting. They could also not be intersecting now, but have intersected along their trajectory.
- Divide the space in subregions so you can test pairs more efficiently. Take into account moving that ob
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
<books> | |
<book> | |
<title>Tom Sawyer</title> | |
</book> | |
<book> | |
<title>The origin of the species</title> | |
</book> | |
<book> | |
<title>Life and death of Albert Camus</title> | |
</book> |
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
# app/views/photos/_photo.html.haml | |
.photo[photo] | |
= image_tag photo.image_url(:thumb) if photo.image? | |
= link_to "Delete", property_photo_path(@property, photo), :method => :delete, :confirm => "Are you sure?", :remote => :true | |
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
This is an example of how I'd like to prevent mass_assignment using cancan. | |
On this example, the application has 4 roles: admin, owner, employee and contractor. | |
Each user has 4 fields: login, password, role and company_id. | |
Admin is the only role capable of creating owners and admins. | |
Owner can create users, but only of type employee and contractor, and only for their own company. They can not see or otherwise interact in any with users from other companies or admins. |
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
<div class="modal hide fade"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> | |
<h3>I want to change the header!</h3> | |
</div> | |
<div class="modal-body"> | |
<p>And also the body!</p> | |
</div> | |
<div class="modal-footer"> | |
<p>And the footer too!</p> |
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
$ time lua callbacks.lua | |
lua callbacks.lua 0.52s user 0.00s system 97% cpu 0.534 total | |
$ time lua coroutines.lua | |
lua coroutines.lua 1.12s user 0.00s system 99% cpu 1.123 total | |
$ time lua next.lua | |
lua next.lua 1.35s user 0.00s system 99% cpu 1.358 total |
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
local floor = math.floor | |
local function abs(x) | |
return x < 0 and -x or x | |
end | |
local function toGrid(cellSize, x,y) | |
return floor(x / cellSize) + 1, floor(y / cellSize) + 1 | |
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
{ :title => "Frodo's Todos", | |
:items => [ | |
{:name => "Walk into Mordor", :first => true}, | |
{:name => "Throw Ring"} | |
] | |
} |
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
Template: "I can’t do this, {{name}}" | |
Context: {:name => 'Sam'} | |
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
function simpleFormat(str) { | |
return '<p>' + | |
str.replace(/\r\n?/, "\n") | |
.replace(/\n\n+/g, '</p>\n\n<p>') | |
.replace(/([^\n]\n)(?=[^\n])/g, '$1<br/>') + | |
'</p>'; | |
} |