Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
I wrote a middleware (actually two, but they do the same with different implementations) that logs information about signed in scopes in a Rails + Devise application. The solution works with multiple logins (like having a person logged both as an Admin
and a User
). I tested against Rails 4 and Devise HEAD
, but it should work fine in any Rails 3 application.
This solution doesn't use the log_tags
configuration option since it isn't very helpful when you need to retrieve information stored in cookies/session. That information isn't 'ready' when the Rails::Rack::Logger
is executed, since it happens way down in the middleware chain.
Add one of the following implementations to your application load path and use the following configuration to add the middleware to your application stack:
# application.rb
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Note: This was written using elasticsearch 0.9.
Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:
$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
"_id": 1,
// This is a slightly modified version of two patches. The first suggested at | |
// http://stackoverflow.com/questions/5802461/javascript-which-browsers-support-parsing-of-iso-8601-date-string-with-date-par | |
// and the second, for Date.js suggested at | |
// http://stackoverflow.com/questions/12145437/date-js-parsing-an-iso-8601-utc-date-incorrectly | |
// | |
// Here we override the implementation of Date.parse provided by Date.js. In this implementation we | |
// first check to see if we can construct the date using the Date constructor. If we can, we move | |
// along. If we cannot, we attempt to start the Date.js grammar parser. If that, too, fails us, we | |
// then assume we're running in IE 8, and someone passed in an ISO8601 string, which IE8's date | |
// constructor won't recognize. So we try to manually parse it out, returning a Date instance. |
I received a promotional folder that plays a video with sound when opening the folder. This contains a rechargeable LiPo battery, a TFT display, a speaker, a power switch, a push button, 256 MB flash memory, RAM, and a CPU.
All of this for watching one 1-minute video.
What a waste! Certainly not environmentally friedndly. Until repurposed creatively!
On the back it says that the product can be sent back to the manufacturer for free recycling. Still I was wondering if I could do more with it.
### REINIT | |
DELETE user | |
PUT user | |
{ | |
"mappings": { | |
"properties": { | |
"name": { | |
"type": "text" | |
}, | |
"comments": { |