Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
rodolfofadino / gist:2760167
Created May 21, 2012 01:14
Some regex's to format the content in the tweet
// Some regex's to format the content in the tweet
tweet.text = tweet.text.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1<\/a>');
tweet.text = tweet.text.replace(/@([a-zA-Z0-9_]+)/gi, '<a href="http://twitter.com/$1" target="_blank" class="username">@$1<\/a>');
tweet.text = tweet.text.replace(/#([a-zA-Z0-9_]+)/gi, '<a href="http://search.twitter.com/search?q=%23$1" target="_blank" class="hashtag">#$1<\/a>');
@rodolfofadino
rodolfofadino / gist:2779055
Created May 24, 2012 02:16
Cache Set expires
context.Response.Cache.SetExpires(DateTime.Now.AddDays(14));
context.Response.Cache.SetLastModified(dataAlteracao);
context.Response.Cache.SetMaxAge(new TimeSpan(336, 0, 0));
@rodolfofadino
rodolfofadino / gist:3030382
Created July 2, 2012 01:32
Stop instances EC2 AWS
Add-Type -Path "C:\Program Files (x86)\AWS SDK for .NET\bin\AWSSDK.dll"
$instancias = New-Object System.Collections.Generic.List[System.Collections.Hashtable]
$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = ""; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
@rodolfofadino
rodolfofadino / gist:3030388
Created July 2, 2012 01:34
Start instances EC2 AWS
Add-Type -Path "C:\Program Files (x86)\AWS SDK for .NET\bin\AWSSDK.dll"
$instancias = New-Object System.Collections.Generic.List[System.Collections.Hashtable]
$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = ""; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
##$instancias.Add(@{"maquina" = "i-xxxxx"; "ip" = "111.111.1.11"; endpoint= "https://ec2.sa-east-1.amazonaws.com/"})
$secretKeyID="Secret key"
@rodolfofadino
rodolfofadino / checkboxRangeSelection.js
Created July 26, 2012 13:39
CheckBox Range Selection
(function ($) {
$.fn.enableCheckboxRangeSelection = function () {
var lastCheckbox = null;
var $spec = this;
$spec.unbind("click.checkboxrange");
$spec.bind("click.checkboxrange", function (e) {
if (lastCheckbox != null && (e.shiftKey || e.metaKey)) {
$spec.slice(
Math.min($spec.index(lastCheckbox), $spec.index(e.target)),
Math.max($spec.index(lastCheckbox), $spec.index(e.target)) + 1
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
@rodolfofadino
rodolfofadino / HomeController.cs
Created September 19, 2012 03:52
Exemplo Facebook SDK C# (teste)
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Facebook;
namespace MvcApplication1.Controllers
@rodolfofadino
rodolfofadino / ConsoleSpinner.cs
Created October 10, 2012 11:27
ConsoleSpinner
static void Main(string[] args)
{
ConsoleSpinner spin = new ConsoleSpinner();
Console.Write("Working....");
while (true)
{
spin.Turn();
}
}
@rodolfofadino
rodolfofadino / 9-digitos.js
Created October 14, 2012 14:54
9-digitos
$('#Telefone')
.mask("(99) 9999-9999?9")
.live('focusout', function (event) {
var target, phone, element;
target = (event.currentTarget) ? event.currentTarget : event.srcElement;
phone = target.value.replace(/\D/g, '');
element = $(target);
element.unmask();
if (phone.length > 10) {
element.mask("(99) 99999-999?9");
@rodolfofadino
rodolfofadino / BusinessDay.cs
Created October 16, 2012 18:58
Business Day C#
public static class DateExtensions
{
public static int BusinessDay(this DateTime data)
{
var inicioMes = new DateTime(data.Year, data.Month, 1);
int total = 0;
while (inicioMes.Date <= data.Date)
{