Skip to content

Instantly share code, notes, and snippets.

View Godoy's full-sized avatar

Adriano Godoy Godoy

View GitHub Profile
@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 / 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 / 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 / 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 / gist:9890991
Created March 31, 2014 12:13
script sql para alterar a collation de todas as colunas no banco de dados sql server - salvar como txt e rodar os scripts.
declare @NewCollationName sysname
set @NewCollationName = 'SQL_Latin1_General_CP1_CI_AI'
select
'ALTER TABLE ' + QUOTENAME(SCHEMA_NAME(st.schema_id)) + '.' + QUOTENAME(st.name) +
' ALTER COLUMN ' + QUOTENAME(sc.name) + ' ' + styp.name + '(' +
CASE WHEN sc.max_length = -1 THEN 'max' ELSE CONVERT(varchar(10),sc.max_length) END +
') collate ' + @NewCollationName + '
go
'
from
@Godoy
Godoy / gist:10418393
Last active August 29, 2015 13:58
remover tags html de uma string com regex expressão regular
var body = Regex.Replace(HttpUtility.HtmlDecode(item.Body), "<.*?>", string.Empty);
var size = body.Length <= 200 ? body.Length - 1 : 200;
<p>@Html.Raw(body.Substring(0, size))...</p>
@Godoy
Godoy / gist:893a53780bc522529f8c
Created July 22, 2014 15:57
temove tags script em strings - ruby on rails
html_content = html_content.gsub(/<script.*?>[\s\S]*<\/script>/i, "")
@Godoy
Godoy / gist:dc64bd8cab08929b292c
Last active April 5, 2018 17:43
Getting Started Kooboo CMS
  1. Clone o repositório: https://github.com/Kooboo/CMS.git
  2. Execute o arquivo CMS\Kooboo.CMS\Publish\publish.bat para que ele gere o projeto do website para o visual studio.
  3. O projeto estará na pasta CMS\Kooboo.CMS\Publish\Web. Copie todo o conteúdo desta pasta. Este será o seu projeto a partir de agora. Neste ponto já é possível rodar�, customizar o site, criar conteúdo. O CMS está pronto para ser utilizado, mas todo o conteúdo está sendo armazenado em XML. Precisamos trocar o provider.
  4. Para trocar o provider, descompacte o arquivo que se encontra em: CMS\Kooboo.CMS\Publish\Released\Content_Providers.zip. Para utilizar SQL Server, copie os arquivos da pasta SQLServer\Kooboo.CMS.Content.Persistence.SQLServer.dll e SQLServer\SqlServer.config para a pasta Wev\bin do seu projeto, gerado nos passos 1 e 2.
  5. Configure a connection string do arquivo SqlServer.config (veja mais em http://wiki.kooboo.com/?wiki=Setup_database_provider#SQLServer)
@Godoy
Godoy / gist:1c8181c74947c539d9e4
Last active August 29, 2015 14:10
Track Google Analytics video Youtube
<div id="player-id"></div>
<script>
//Load iframe api
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var pauseFlag = false;
@Godoy
Godoy / .htaccess
Created December 2, 2014 18:23
Redirecionamento permanente (31) com www para sem www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]