Skip to content

Instantly share code, notes, and snippets.

View ycaroafonso's full-sized avatar

Ycaro Afonso ycaroafonso

  • Campo Grande, Mato Grosso do Sul, Brasil
View GitHub Profile
<configuration>
<system .webserver="">
<rewrite>
<rules>
<!-- Se possuir mais de um blog no servidor, mude a "name" da linha abaixo para um nome qualquer -->
<rule name="wordpress" stopprocessing="true">
<match url="^(.*)">
<conditions>
<add input="{REQUEST_FILENAME}" matchtype="IsFile" negate="true">
<add input="{REQUEST_FILENAME}" matchtype="IsDirectory" negate="true">
CREATE FUNCTION [dbo].[NExtenso_Extenso](@Num INTEGER)
RETURNS VARCHAR(50)
AS
BEGIN
-- Por Ycaro Afonso 03/12/2011
-- V 0.1
RETURN CASE @Num
WHEN 1000 THEN 'Mil' WHEN 1000000 THEN 'Milhões' WHEN 1000000000 THEN 'Bilhões'
WHEN 100 THEN 'Cento' WHEN 200 THEN 'Duzentos' WHEN 300 THEN 'Trezentos' WHEN 400 THEN 'Quatrocentos' WHEN 500 THEN 'Quinhentos' WHEN 600 THEN 'Seiscentos' WHEN 700 THEN 'Setecentos' WHEN 800 THEN 'Oitocentos' WHEN 900 THEN 'Novecentos'
WHEN 10 THEN 'Dez' WHEN 11 THEN 'Onze' WHEN 12 THEN 'Doze' WHEN 13 THEN 'Treze' WHEN 14 THEN 'Quartorze' WHEN 15 THEN 'Quinze' WHEN 16 THEN 'Dezesseis' WHEN 17 THEN 'Dezesete' WHEN 18 THEN 'Dezoito' WHEN 19 THEN 'Dezenove'
using DotNetXmlHttpRequest;
class Program
{
static void Main(string[] args)
{
XMLHttpRequest xml = new XMLHttpRequest();
xml.Open(XMLHttpRequest.EnumMethod.GET, "http://ycaro.net/");
xml.Send();
System.Console.Write(System.Text.RegularExpressions.Regex.Match(xml.responseText, "(.*)"));
System.Console.ReadLine();
ALTER FUNCTION [dbo].[Split](@Input VARCHAR(MAX), @Var VARCHAR(MAX))
RETURNS @Return TABLE (ID INT, Item VARCHAR(MAX))
BEGIN
DECLARE @ID INT
SET @ID = 0
WHILE CHARINDEX(@Var, @Input) > 0 BEGIN
SET @ID = @ID + 1
INSERT INTO @Return VALUES (@ID, LTRIM(SUBSTRING(@Input, 0, CHARINDEX(@Var, @Input))))
SET @Input = SUBSTRING(@Input, CHARINDEX(@Var, @Input) + 1, LEN(@Input) - 1)
END
public static System.Drawing.Image Redimensionar(System.Drawing.Image image, int NewWidthMax, int NewHeightMax)
{
float Fator = 0;
if (image.Width / WidthMaximo > image.Height / HeightMaximo)
Fator = (float)image.Width / WidthMaximo;
else
Fator = (float)image.Height / HeightMaximo;
int NewWidth = (int)((float)image.Width / Fator);
int NewHeight = (int)((float)image.Height / Fator);
[HttpPost]
public ActionResult Edit(Pessoa pessoa)
{
if (ModelState.IsValid)
{
db.PessoaSet.Attach(pessoa);
System.Data.Objects.ObjectStateEntry entry = db.ObjectStateManager.GetObjectStateEntry(pessoa);
entry.SetModifiedProperty("Nome");
entry.SetModifiedProperty("DataNascimento");
@ycaroafonso
ycaroafonso / ConvertDecimalParaRealPorExtenso.sql
Created September 18, 2013 20:23
Converte números no formato Decimal para R$ por extenso. Precisa da Function https://gist.github.com/ycaroafonso/6614586
CREATE FUNCTION ConvertDecimalParaRealPorExtenso(@Num DECIMAL(8, 2))
RETURNS VARCHAR(500)
AS BEGIN
DECLARE @Ret VARCHAR(500) = ''
DECLARE @N1 INT = FLOOR(@Num)
DECLARE @N2 INT = REPLACE(CAST(@Num - FLOOR(@Num) AS VARCHAR(20)), '0.', '')
IF(@N1 > 0) BEGIN
@ycaroafonso
ycaroafonso / ConvertNumerosParaExtenso.sql
Last active December 23, 2015 09:29
Converte números decimais inteiros para extenso
ALTER FUNCTION NumeroExtenso(@Num INT)
RETURNS VARCHAR(500)
AS BEGIN
--Por Ycaro Afonso 2013-09-18
--V 2.0
DECLARE @FAT INT, @_FAT INT
DECLARE @NumRes INT = @Num, @_NumRes INT, @_NumT INT
DECLARE @Ret VARCHAR(500) = ''