Skip to content

Instantly share code, notes, and snippets.

View willnss's full-sized avatar
:shipit:
Focusing

Wilian N. Santos willnss

:shipit:
Focusing
  • Brazil
View GitHub Profile
@willnss
willnss / gist:1380185
Created November 20, 2011 11:43
Exemplo Menu básico reutilizável para ASP.NET MVC - ASPXViewEngine
//MvcApplicationFolder\Views\Shared\Site.Master
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html>
<html>
<head></head>
<body>
<!--Local onde será renderizado o menu-->
<%:Html.Action("Menu", "Home") %>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</body>
@willnss
willnss / gist:1395579
Created November 26, 2011 12:32
Modificando o Layout/MasterPage via atributo no ASP.NET MVC
//MvcApplication1\Infrastructure\ChangeLayoutAttribute.cs
using System.Web.Mvc;
namespace MvcApplication1.Infrastructure
{
public class ChangeLayoutAttribute : ActionFilterAttribute, IResultFilter
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var viewResult = filterContext.Result as ViewResult;
@willnss
willnss / gist:1412052
Created November 30, 2011 23:58
Tempo de execução de uma Action/ASP.NET MVC 'manualmente'
//TesteApp\TimeExecutionAttribute.cs
using System.Diagnostics;
namespace TesteApp
{
public class ExecutionTimeAttribute : ActionFilterAttribute
{
private Stopwatch _stopwatch;
public ExecutionTimeAttribute()
@willnss
willnss / gist:1878806
Created February 21, 2012 20:43
explained email regex
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i full regex
/ start of regex
\A atch start of a string
[\w+\-.]+ at least one word character, plus, hyphen, or dot
@ literal “at sign”
[a-z\d\-.]+ at least one letter, digit, hyphen, or dot
\. literal dot
[a-z]+ at least one letter
\z match end of a string
/ end of regex
@willnss
willnss / filtro_git_log.sh
Created March 4, 2012 20:09 — forked from vquaiato/filtro_git_log.sh
filtro git log
git log --before="2 weeks ago" --after="2009-01-26" --pretty=oneline
git log --pretty=format:'%h por %an em %ar, mensagem {%s}'
git log --pretty=format:'%h : %s (%an em %ar)' --graph
@willnss
willnss / gist:2622803
Created May 6, 2012 15:01
Amend last commit without editor for the new message
git config alias.amend 'commit --amend -C HEAD'
@willnss
willnss / gist:2623613
Created May 6, 2012 18:16
Implementando ajax com ASP.NET (Versão .Net Framework 2.0) (baiano mode-on)
//ASPX com o código HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WTRFramework._Default" %>
<%@ Register src="WebControl.ascx" tagname="WebControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
// ( -> Install-Package JQuery)
<script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
@willnss
willnss / gist:2623629
Created May 6, 2012 18:20
Revision manual - git
$ git hist
* 328ce3f 2011-08-12 | Added anything (HEAD, master) [Manolo]
* d74e780 2011-08-12 | Some like... [Manolo]
* 6494c77 2011-08-12 | First [Manolo]
$ git checkout 6494c77
$ cat application.rb
#revision mode-on :)
$ git checkout -b branch_revision
@willnss
willnss / gist:3246637
Created August 3, 2012 10:52 — forked from leonardofaria/gist:1037052
Gerador de CPF, NIT, CNPJ e CEI válidos
<html>
<head>
<title>Gerador de CPF, CNPJ e NIT Válidos</title>
<script language="javascript">
function gera_random(n) {
var ranNum = Math.round(Math.random()*n);
return ranNum;
}
function mod(dividendo,divisor) {