Skip to content

Instantly share code, notes, and snippets.

View monteirobrena's full-sized avatar

Brena Monteiro monteirobrena

View GitHub Profile
require 'open-uri'
url = 'http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&markers=color:0x4E3253%7C40.714728,-73.998672&zoom=15&size=640x640&scale=2&format=png&maptype=roadmap&sensor=false'
target = File.join(File.expand_path('../', __FILE__), '/maps.jpg')
File.open(target, "wb") do |saved_file|
open(url, 'rb') do |read_file|
saved_file.write(read_file.read)
end
end
@monteirobrena
monteirobrena / config.ru
Created May 14, 2014 14:24
Rack::Deflater
# Enable GZIP
use Rack::Deflater

Update and upgrade the system

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo reboot

Here's what you get.

Some JavaScript

// Delete confirmation modals
$('#delete-confirm').on('show', function() {
  var $submit = $(this).find('.btn-danger'),
      href = $submit.attr('href');
  $submit.attr('href', href.replace('pony', $(this).data('id')));
# a.rb
class A < ActiveRecord::Base
has_one :b
accepts_nested_attributes_for :b
end
# b.rb
class B < ActiveRecord::Base
belongs_to :a
attr_accessible :name