Skip to content

Instantly share code, notes, and snippets.

View monteirobrena's full-sized avatar

Brena Monteiro monteirobrena

View GitHub Profile
# 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

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')));

Update and upgrade the system

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo reboot
@monteirobrena
monteirobrena / config.ru
Created May 14, 2014 14:24
Rack::Deflater
# Enable GZIP
use Rack::Deflater
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
lala
begin
sddasdas
asdasdasd
asdasd
end
lolo

List with Thumbnails and Summary Text

A list of items that contain a thumbnail image and a large block of text. Small screens hide the summary content but gets exposed once screen space becomes available.

Considerations Normally it's not a good idea to hide content for small screens, so make sure the content being hidden (article excerpt, further product info, etc) is supplementary and not essential for the user to make an informed decision. Make sure that hidden content is still accessible somewhere (it would most likely live on the linked page). Read: The media object saves hundreds of lines of code

A Pen by Brad Frost on CodePen.

@monteirobrena
monteirobrena / azure.rake
Created April 9, 2016 19:57
Rails assets on MS Azure CDN
require 'azure_blob_service'
namespace :azure do
desc 'Uploads application assets to Azure'
task upload_assets: :environment do
service = AzureBlobService.new(
Rails.application.secrets.azure['account_name'],
Rails.application.secrets.azure['access_key'])
service.ensure_container_exists('assets')
@monteirobrena
monteirobrena / install-comodo-ssl-cert-for-nginx.rst
Created September 7, 2016 19:21 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@monteirobrena
monteirobrena / template-vmss-autoscale-lb-vhd-https.json
Created November 30, 2016 18:26
Template JSON Azure VMSS Auto Scale Load Balancer VHD HTTPS
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"vmSku": {
"type": "string",
"defaultValue": "Standard_F1s",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}