Skip to content

Instantly share code, notes, and snippets.

View rduarte's full-sized avatar
🏠
Working from home

Ricardo Duarte rduarte

🏠
Working from home
View GitHub Profile
@rduarte
rduarte / gerar-certificado-icp-brasil.md
Created June 20, 2024 14:22 — forked from weltonrodrigo/gerar-certificado-icp-brasil.md
Como gerar um certificado ICP-Brasil A3 (pessoa física) para testes

O formato do certificado ICP-Brasil está disponível nas políticas das autoridades certificadoras autorizadas pelo ICP-Brasil. Exemplo: https://repositorio.acdigital.com.br/docs/pc-a3-ac-digital-multipla.pdf

Ver item 7.1.2.3.a.

Para certificado CNPJ, o procedimento é parecido, só montar os campos de acordo com o item 7.1.2.3.b

openssl req -new -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 \
-subj '/C=BR/O=ICP-Brasil/OU=AC DIGITAL Múltipla G1/OU=33989214000191/OU=presencial/OU=Certificado PF A3/CN=Fulano de tal:58765136012' \
@rduarte
rduarte / csv-to-json.php
Created January 18, 2020 15:37 — forked from devfaysal/csv-to-json.php
CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses the csv file of this gist
*/
$feed="https://gist.githubusercontent.com/devfaysal/9143ca22afcbf252d521f5bf2bdc6194/raw/ec46f6c2017325345e7df2483d8829231049bce8/data.csv";
//Read the csv and return as array
$data = array_map('str_getcsv', file($feed));
//Get the first raw as the key
$keys = array_shift($data);
echo -e "\n\n** Atualizando apt-get"
sudo apt-get update -y
echo -e "\n\n** Instalando git"
sudo apt-get install -y git-core
echo -e "\n\n** Instalando apache e mod_rewrite"
sudo apt-get install -y apache2
sudo a2enmod rewrite
sudo service apache2 restart

gurizei.

quando tu faz no rails "render :xml => @any_collection", ele chama o to_xml passando uma série de parâmetros no options, logo, se tu implementa teu to_xml assim:

    def to_xml(options = {})
        super(:include => [:children])
    end

tu não vai estar repassando pro super o "options" - que nesse caso vem com algo do tipo:

@rduarte
rduarte / Gemfile
Created January 17, 2011 18:23 — forked from carlosbrando/Gemfile
group :development, :test do
gem 'ruby-debug', :platforms => :ruby_18
gem 'ruby-debug19', :platforms => :ruby_19
end
# How to give your devise controllers all the same layout (e.g. "authentication" below)
class ApplicationController < ActionController::Base
layout :setup_layout
protected
def setup_layout
devise_controller? ? "authentication" : "application"
end
end
$(function () {
var toc = $("<ul>").css("margin-bottom", "20px !important");
$("div.main div.wikistyle h2").each(function() {
var id = $(this).text().replace(/\s+/g, "_").replace(/[^0-9a-zA-Z_.-]/g, "")
$(this).attr("id", id)
toc.append(
$("<li>").append($("<b>").append($("<a>").attr("href", "#" + id).text($(this).text())))
)
});
$("div.wikistyle").prepend(toc).prepend($("<h2>").text("Table of Contents"));
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
Rails CMS alternatives
======================
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
"the cutting edge Rails CMS platform"
@rduarte
rduarte / template.rb
Created November 12, 2009 23:22 — forked from elomar/template.rb
run 'gem sources -a http://gemcutter.org'
git :init
file '.gitignore', <<TXT
log/*.log
tmp/**/*
db/*.sqlite3
.DT_Store
TXT