Skip to content

Instantly share code, notes, and snippets.

View monteirobrena's full-sized avatar

Brena Monteiro monteirobrena

View GitHub Profile
@SteveDeWald
SteveDeWald / delayed_job.rb
Created February 26, 2011 22:47
Better way to handle background processing w/ uploads to s3
# lib/carrier_wave/delayed_job.rb
module CarrierWave
module DelayedJob
module ActiveRecordInterface
def delay_carrierwave
@delay_carrierwave ||= true
end
def delay_carrierwave=(delay)
@delay_carrierwave = delay
@torrick
torrick / companies.rb
Created May 23, 2011 13:55
Example Active Admin config using auto_link
ActiveAdmin.register Company do
filter :name
filter :customer_type, :as => :check_boxes
index do
column :name, :sortable => :name do |company|
auto_link(company)
end
column :active do |company|
company.active? ? icon(:check) : icon(:x)
@trey
trey / rails_bootstrap_delete_confirmation_modal.md
Created February 8, 2012 05:12
A nice delete confirmation modal in Rails courtesy of Bootstrap

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')));
@markmarkoh
markmarkoh / gist:2969317
Created June 21, 2012 23:55
World Map Geo JSON data
var countries_data = {"type":"FeatureCollection","features":[
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[74.92,37.24],[74.57,37.03],[72.56,36.82],[71.24,36.13],[71.65,35.42],[71.08,34.06],[69.91,34.04],[70.33,33.33],[69.51,33.03],[69.33,31.94],[66.72,31.21],[66.26,29.85],[62.48,29.41],[60.87,29.86],[61.85,31.02],[60.84,31.5],[60.58,33.07],[60.94,33.52],[60.51,34.14],[61.28,35.61],[62.72,35.25],[63.12,35.86],[64.5,36.28],[64.8,37.12],[66.54,37.37],[67.78,37.19],[69.32,37.12],[70.97,38.47],[71.59,37.9],[71.68,36.68],[73.31,37.46],[74.92,37.24]]]]},"properties":{"name":"Afghanistan"},"id":"AF"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[19.44,41.02],[19.37,41.85],[19.65,42.62],[20.07,42.56],[20.59,41.88],[20.82,40.91],[20.98,40.86],[20.01,39.69],[19.29,40.42],[19.44,41.02]]]]},"properties":{"name":"Albania"},"id":"AL"},
{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[2.96,36.8],[8.62,36.94],[8.18,36.52],[8.25,34.64],[7.49,33.89],[9.06,3
@rcaetano
rcaetano / gist:5999184
Last active January 16, 2024 18:46 — forked from cluePrints/gist:2521535
Configure Amazon Linux EC2

Steps

  • Build tools:

      sudo yum groupinstall "Development Tools"
      sudo yum install openssl openssl-devel
      sudo yum install git-core
    
  • Dependencies:

@stevenyap
stevenyap / Rails Controller.md
Created October 19, 2013 13:58
Rails controller cheatsheet

Flash

# supports only notice and alert by default
# the rest has to go into flash hash
redirect_to :index, notice: "success"
redirect_to :new, notice: "errors"
redirect_to :new, flash: { success: "yeah" }
flash[:info] = "updated"
@jtadeulopes
jtadeulopes / server.md
Last active March 29, 2024 10:23
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

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

Configure timezone

@jtadeulopes
jtadeulopes / download_map.rb
Created July 24, 2014 18:09
Download staticmap
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
@peczenyj
peczenyj / input.txt
Last active August 29, 2015 14:09
remover bloco para fim de arquivo.
lala
begin
sddasdas
asdasdasd
asdasd
end
lolo
@alrocar
alrocar / index.html
Last active September 27, 2018 18:50
WIX iframe
<html>
<head>
</head>
<style type="text/css">
.topad {
height: 26px;
position: absolute;
z-index: 999999999;
top: 0;