Skip to content

Instantly share code, notes, and snippets.

View Godoy's full-sized avatar

Adriano Godoy Godoy

View GitHub Profile
@Godoy
Godoy / my_function-sdk.js
Last active April 25, 2016 16:09
Test load async
function my_function(param) {
console.log("in correct function");
console.log(param);
}
@Godoy
Godoy / analytics.js
Created April 21, 2016 12:59
async load analytics javascript script tag
(function(){
window['GoogleAnalyticsObject'] = 'ga';
window['ga'] =
window['ga']
||
function(){
(window['ga'].q = window['ga'].q || [])
.push(arguments)
},
window['ga'].l = 1 * new Date();
@Godoy
Godoy / _form.html.erb
Created March 8, 2016 13:23
envia formulário ruby on rails via ajax e exibe erros automaticamente com script
<%= form_for(@model, remote: true, html: {role: :form, 'data-model' => 'MODEL_NAME', class: 'send_ajax'}) do |f| %>
<% if @model.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@model.errors.count, "error") %> prohibited this tip from being saved:</h2>
<ul>
<% @model.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
@Godoy
Godoy / production.rb
Created February 11, 2016 12:23
configuração para diminuir tempo de compilação de assets (ckeditor slow precompile assets)
require 'uglifier'
Rails.application.configure do
# ...
# config.assets.js_compressor = :uglifier
config.assets.js_compressor = Uglifier.new(compress: { unused: false })
#...
end
@Godoy
Godoy / application_helper.rb
Last active January 14, 2016 12:31
helper rails active menu link
module ApplicationHelper
def menu_li_link(content, path, controller="")
options = current_page?(path) || controller_name == controller ? { class: "active" } : {}
content_tag(:li, options) do
link_to content, path
end
end
end
@Godoy
Godoy / Steps.md
Last active June 20, 2017 21:38
deploy ruby on rails 4 with capistrano nginx unicorn - ubuntu 14.04

Steps

These steps were made with Ubuntu 14.04 e ruby 2.3.1. To enjoy the ease of step-by-step, I suggest not change folders and application name - just change the server ip and git

Create user to deploy

# Server console
sudo adduser deployer
sudo gpasswd -a deployer sudo
@Godoy
Godoy / gist:050d70137a2ec2d66b23
Created September 24, 2015 14:32
Instalar mvc mailer bug visual studio 2013 template t4
Install-Package MvcScaffolding -Version 1.0.8-vs2013 -Pre
Install-Package MvcMailer-vs2013 -Version 4.5.1-pre
@Godoy
Godoy / gist:e39148b15b1f0e3f28d2
Created September 11, 2015 13:03
web.config woff font load problem static content
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
</staticContent>
</system.webServer>
@Godoy
Godoy / gist:7e561134ec688bf24e6d
Created July 21, 2015 11:55
bug ssl em windows (rails) sass ssl_connect certificate verify failed
- Fazer download do arquivo e salvar no Desktop
https://gist.github.com/fnichol/867550/raw/win_fetch_cacerts.rb
- Abra o cmd e cole codigo abaixo
ruby "%USERPROFILE%\Desktop\win_fetch_cacerts.rb"
- Insira a variável de ambiente abaixo:
Variavel: SSL_CERT_FILE
Valor: C:\RailsInstaller\cacert.pem
@Godoy
Godoy / gist:c423cce4a3c2f8d8a39e
Created June 12, 2015 18:42
dispose context controller asp.net c# mvc
private Context context = new Context();
protected override void Dispose(bool disposing)
{
if (disposing) {
context.Dispose();
}
base.Dispose(disposing);
}