Skip to content

Instantly share code, notes, and snippets.

View Godoy's full-sized avatar

Adriano Godoy Godoy

View GitHub Profile
@Godoy
Godoy / gist:9417362
Created March 7, 2014 18:47
criar comando de atalho para abrir textmate pelo terminal
ln -s /Applications/TextMate.app/Contents/Resources/mate /bin/mate
@Godoy
Godoy / pt-BR.resx
Created October 9, 2013 14:52
Arquivo .resx (localize) com a tradução Kooboo CMS para pt-BR - Português (Brasil).
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
@Godoy
Godoy / Migrations\Configuration.cs
Last active December 23, 2015 12:49
Seed para criar Role e User no Membership .NET MVC Code First
protected override void Seed(Inspire.Models.DBContext context)
{
WebSecurity.InitializeDatabaseConnection(
"DefaultConnection",
"UserProfile",
"UserId",
"UserName", autoCreateTables: true);
if (!Roles.RoleExists("Administrator"))
Roles.CreateRole("Administrator");
@Godoy
Godoy / gist:6564097
Created September 14, 2013 17:57
"Re-salvar" todos os registros de determinado model no console do rails (para que executem algum novo before_filter, por exemplo)
News.find_each(&:save)
@Godoy
Godoy / gist:6311383
Created August 22, 2013 19:04
cabeçalhos para gerar excel (xls) no .net C#
HttpContext.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Response.AddHeader("content-disposition", "attachment;filename=nome_arquivo-" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm") + ".xls");
// HttpContext.Response.Charset = "utf-8";
HttpContext.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
@Godoy
Godoy / gist:6234925
Created August 14, 2013 19:55
Correção de posicionamento do gráfico para o plugin de Wordpress Iced Visualization Charts
<?php
function iced_chart_display($atts, $content = null)
{
global $chart_id;
wp_enqueue_script('google-visualization', 'http://www.google.com/jsapi', array('jquery'), '1.0', true);
wp_enqueue_script('iced-visualization', plugins_url('iced-visualization.js', __FILE__), array('google-visualization'), '1.0', true);
$type = $atts['type'];
@Godoy
Godoy / gist:6155683
Created August 5, 2013 12:49
busca de parte do valor por regex em um IEnumerable
.Where(u => Regex.IsMatch(u.Nome, busca, RegexOptions.IgnoreCase))
@Godoy
Godoy / application.rb
Created April 16, 2013 12:56
Enviando e-mail com Action Mailer em Rails.
config.action_mailer.smtp_settings = {
:address => "mail.adrianogodoy.com",
:port => 587,
:domain => "adrianogodoy.com",
:user_name => "[email protected]",
:password => "senha",
:authentication => :login,
:enable_starttls_auto => false
}
config.action_mailer.raise_delivery_errors = true
@Godoy
Godoy / MeuController.cs
Last active December 15, 2015 20:49
Obter access_token do facebook após o callback de login usando a lib Facebook C# SDK (https://github.com/facebook-csharp-sdk/facebook-csharp-sdk/)
using Facebook;
....
public ActionResult actionCallback()
{
try
{
if (String.IsNullOrEmpty(Request["code"]))
throw new Exception("Não foi possível efetuar login na aplicação.");
@Godoy
Godoy / gist:5256851
Last active December 15, 2015 11:59
Pegar a URL absoluta de uma aplicação .NET C#
string UrlAplicacao = Request.Url.Scheme+"://"+Request.Url.Authority + Request.ApplicationPath;