A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| [ | |
| { | |
| "user": "saldanac", | |
| "issues": 2534 | |
| }, | |
| { | |
| "user": "djimenezjerez", | |
| "issues": 555 | |
| }, | |
| { |
| if (!Array.prototype.indexOf) { | |
| Array.prototype.indexOf = function (needle) { | |
| for (var i = 0; i < this.length; i++) { | |
| if (this[i] === needle) { | |
| return i; | |
| } | |
| } | |
| return -1; | |
| }; | |
| } |
| # | |
| # Google I/O 2014 secret invite code finder | |
| # | |
| # Blake Caldwell, 2014 | |
| # | |
| # Blog Post: http://blakecaldwell.net/blog/2014/4/23/solving-a-2014-google-io-secret-invite-puzzle.html | |
| # | |
| # Repeatedly hit https://developers.google.com looking two-colored "I/O" on the page, | |
| # with a secret code in comments below it. Using the color codes of the "I" and "O", | |
| # calculate the 6-character Google URL-shortened link code, and print the code out. |
| //before running make sure you setup a GOPATH env variable and ran: "go get code.google.com/p/go.net/html" | |
| //to run: go run ioCrawler.go -url="http://developers.google.com/" | |
| //also try http://developer.android.com/index.html | |
| //output goo.gl links to try and redeem will be sent to foundLinks.txt | |
| //by the way there's an artificial "rate limit" in func crawler, you can lower that or raise it as you wish | |
| //You can also comment out the onlyGoogleRegex code if you don't want to limit to google.com/youtube | |
| //if you're getting I/O timeout errors, then you might need to increase the timeouts on line 231 |
belongs_to association does not automatically save the object. It does not save the associated object either.has_one association, that object is automatically saved (in order to update its foreign key).has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.| describe vs. context in rspec | |
| http://lmws.net/describe-vs-context-in-rspec | |
| In Rspec world, you often see people using both “describe” blocks and “context” blocks together, like this | |
| describe "launch the rocket" do | |
| context "all ready" do | |
| end | |
| context "not ready" do |
| /* | |
| A set of custom made large numbers for a 16x2 LCD using the | |
| LiquidCrystal librabry. Works with displays compatible with the | |
| Hitachi HD44780 driver. | |
| The Cuicuit: | |
| LCD RS pin to D12 | |
| LCD Enable pin to D11 | |
| LCD D4 pin to D5 | |
| LCD D5 pin to D4 |
| // GeoChart from https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart | |
| // Try out by pasting code into: https://code.google.com/apis/ajax/playground/?type=visualization#geo_chart | |
| function drawVisualization() { | |
| var data = google.visualization.arrayToDataTable([ | |
| ['State', 'Foo Factor'], | |
| ['US-IL', 200], | |
| ['US-IN', 300], | |
| ['US-IA', 20], |
http://guides.rubyonrails.org/migrations.html