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 / 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: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]
@Godoy
Godoy / gist:f4d317884cae91d614bb
Created December 5, 2014 12:20
Lista os diretórios ordenados por ocupação de espaço em disco
sudo du -sx /* 2>/dev/null | sort -n
@Godoy
Godoy / gist:61310c563116ff5664ad
Created February 26, 2015 20:44 — forked from rodrigogmdias/Benchmark Ruby Each
Benchmark Ruby Each
@array = 1..100000000
def case0 #### 5s
i = Time.now
@array.each do |o|
# puts "#{o}"
end
(Time.now - i)
end
@Godoy
Godoy / .gitignore
Created June 9, 2015 12:07
gitignore asp.net mvc visual studio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
*.DS_Store
# Build results
@Godoy
Godoy / gist:69a15a56563f8edee0b7
Created June 12, 2015 13:20
regex email validation
[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}
http://www.regexr.com/3b6ln
@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);
}