Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
rodolfofadino / 1x1transparentGIF.cs
Created November 7, 2011 13:39
1x1 transparent GIF
// 1x1 transparent GIF
private readonly byte[] GifData = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61,
0x01, 0x00, 0x01, 0x00, 0x80, 0xff,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0x00, 0x00, 0x02,
0x02, 0x44, 0x01, 0x00, 0x3b
};
@rodolfofadino
rodolfofadino / regexRemoveGa.cs
Created November 11, 2011 00:36
Remove GA from url
var regex = new Regex(@"((\?|\&)?utm(.*$))");
urlLimpa = regex.Replace(urlLimpa, string.Empty);
@rodolfofadino
rodolfofadino / js_baseUrl.js
Created November 22, 2011 18:02
js_baseUrl
var baseUrl = location.href.split('?')[0];
@rodolfofadino
rodolfofadino / AuthFacebook.cs
Created November 27, 2011 00:58
AuthFacebook .NET C#
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Collections.Specialized;
using System.IO;
using System.Web;
using System.Configuration;
@rodolfofadino
rodolfofadino / ExampleAlternatingView.cs
Created December 16, 2011 02:18
Example [MailMessage.AlternateViews Property ]
MailMessage mailMsg = new MailMessage();
// To
mailMsg.To.Add(new MailAddress("to@example.com", "To Name"));
// From
mailMsg.From = new MailAddress("from@example.com", "From Name");
// Subject
mailMsg.Subject = "subject";
//Texto
@rodolfofadino
rodolfofadino / gist:1628435
Created January 17, 2012 19:47
String Capitalization SQL
CREATE FUNCTION Captalize( @InputString varchar(max))
RETURNS varchar(max)
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @PrevChar CHAR(1)
DECLARE @OutputString VARCHAR(max)
public static System.Drawing.Image PadImage(System.Drawing.Image originalImage)
{
int largestDimension = Math.Max(originalImage.Height, originalImage.Width);
int h = originalImage.Size.Height;
int w = originalImage.Size.Width;
int final = 0;
if (w >= h)
final = h;
else
@rodolfofadino
rodolfofadino / ConvertBytesToImage.cs
Created April 9, 2012 17:04
ConvertBytesToImage
public Image ConvertBytesToImage(byte[] byteArray)
{
MemoryStream ms = new MemoryStream(byteArray);
Image imagemRetorno = Image.FromStream(ms);
return imagemRetorno;
}
@rodolfofadino
rodolfofadino / ConvertImageToBytes.cs
Created April 9, 2012 17:04
ConvertImageToBytes
public byte[] ConvertImageToBytes(Image imageToConvert, System.Drawing.Imaging.ImageFormat formatOfImage)
{
byte[] ret;
try
{
using (var ms = new MemoryStream())
{
imageToConvert.Save(ms, formatOfImage);
ret = ms.ToArray();
}
@rodolfofadino
rodolfofadino / gist:2691325
Created May 14, 2012 02:11
Script de Backup no S3
Add-Type -Path "C:\Program Files (x86)\AWS SDK for .NET\bin\AWSSDK.dll"
$secretKeyID="secret key"
$secretAccessKeyID="access key"
$bucket="BucketName"
$backup_directory="C:\teste"
$new_folder_format = Get-Date -uformat "Backup_%Y_%m_%d/"
foreach($file in Get-ChildItem -Path $backup_directory){