Skip to content

Instantly share code, notes, and snippets.

View vhsalazar's full-sized avatar

Victor Salazar vhsalazar

  • Sydney, Australia
View GitHub Profile
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@mauforonda
mauforonda / bolivia_issues.json
Last active January 28, 2020 18:25
Usuarios bolivianos en Github con más issues abiertos. De los usuarios de Github que declaran ser de Bolivia (o cualquier departamento), selecciono los 1000 con más seguidores (no puedo avanzar más por limitaciones del api) y los ordeno por número de issues abiertos.
[
{
"user": "saldanac",
"issues": 2534
},
{
"user": "djimenezjerez",
"issues": 555
},
{
@Exlord
Exlord / RoutePrefix.js
Last active March 29, 2022 20:32
Add a global Prefix to all routes in Angular 1.3 router
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;
};
}
@wblakecaldwell
wblakecaldwell / google_io_puzzle.py
Last active August 29, 2015 14:00
Google I/O secret invite code finder
#
# 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.
@jameshartig
jameshartig / ioCrawler.go
Last active September 19, 2018 00:23
Google I/O 2014 redeem easter egg crawler
//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
@demisx
demisx / active_record_objects_autosave.md
Last active February 26, 2024 17:31
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the 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.
@kyuden
kyuden / describe vs. context in rspec
Created February 8, 2014 20:27
describe vs. context in rspec
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
@ronivaldo
ronivaldo / rpmLargeFont.ino
Created May 15, 2013 21:02
A set of custom made large numbers for a 16x2 LCD HD44780 Arduino Library
/*
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
@gerryster
gerryster / us_geo_chart_google
Created December 8, 2012 23:13
US State Map using the GeoChart from the Google Chart Tools
// 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],
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet