Skip to content

Instantly share code, notes, and snippets.

View AlbertoMonteiro's full-sized avatar
😎
Writting every day lines fo happy code

Alberto Monteiro AlbertoMonteiro

😎
Writting every day lines fo happy code
View GitHub Profile
@AlbertoMonteiro
AlbertoMonteiro / gist:2522989
Created April 29, 2012 00:55 — forked from alexsandro-xpt/gist:2522945
Async CTP exemplo 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
class Program
{
<xml? version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
<UsingTask TaskName="CompressorTask" AssemblyFile="Yahoo.Yui.Compressor.MsBuildTask.dll" />
<PropertyGroup>
<CssOutputFile Condition=" '$(CssOutputFile)'=='' ">$(ProjectDir)..\Content\CssFinal.css</CssOutputFile>
<JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">$(ProjectDir)..\Scripts\JsFinal.js</JavaScriptOutputFile>
</PropertyGroup>
<Target Name="MyTaskTarget">
<ItemGroup>
<CssFiles Include="'$(ProjectDir)'\..\..\Content\Site.css"/>
@AlbertoMonteiro
AlbertoMonteiro / gist:2659777
Created May 11, 2012 13:49 — forked from icarocamelo/gist:2659726
SQL Lambda Expression
1) Using SQL-like Expression
var iNames = from i in employees
select i.name;
2) Using Lambda Expression
var iNames = employees.Select(r => r.name);
@AlbertoMonteiro
AlbertoMonteiro / gist:2730844
Created May 19, 2012 13:23
Knockout bindingHandlers para Date
ko.bindingHandlers.date = {
update: function(element, valueAccessor) {
ko.bindingHandlers.value.update.apply(this, arguments);
var value = ko.utils.unwrapObservable(valueAccessor());
var prop = $(element).is('input') ? 'value' : 'innerText';
if (Date.isDate(value))
element[prop] = $.datepicker.formatDate("dd/mm/yy", value);
}
@AlbertoMonteiro
AlbertoMonteiro / gist:3092741
Created July 11, 2012 19:40
Ajax + jQuery + 302 = Weird behavior
$.ajax({
type: 'POST',
url: url,
data: $('form').serialize(),
success: function(a) {
console.log("success",a);
} ,
statusCode: {
200: function(a) {
console.log("200",a);
using System;
using System.IO;
using System.Net;
namespace ConsoleApplication9
{
class Program
{
static string str = @"------WebKitFormBoundaryoCMA9W1hTtsLzZ8e
@AlbertoMonteiro
AlbertoMonteiro / gist:3297419
Created August 8, 2012 18:41
Get expression equal from string
Func<T, bool> GetExpressionOfEquals<T>(string propertyName, string equalsTo)
{
var parameter = Expression.Parameter(typeof(T));
var property = Expression.Property(parameter, propertyName);
var binaryExpression = Expression.Equal(property, Expression.Constant(equalsTo));
var lambda = Expression.Lambda<Func<T, bool>>(binaryExpression, "Teste", new[] { parameter });
var expression = lambda.Compile();
return expression;
@AlbertoMonteiro
AlbertoMonteiro / Program.cs
Created August 8, 2012 21:11
Division with IL and Expression Tree
using System;
using System.Linq.Expressions;
using System.Reflection.Emit;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
@AlbertoMonteiro
AlbertoMonteiro / form2json.js
Created September 26, 2012 21:00
Converter to urlformencoded to JSON
module("dado um deserializador de url encoded posso criar objetos");
//"Nome=Alberto&Idade=22&Endereco.Logradouro=Rua%20Paulino%20Nogueira&Endereco.Numero=283&Telefones[0]=30211083&Telefones[1]=96234779&Linguagens[0].Nome=C#&Linguagens[0].Tipo=FortementeTipada&Linguagens[1].Nome=Javascript&Linguagens[1].Tipo=DinamicamenteTipada";
test("com so uma propriedade a partir de uma url encoded", function () {
var url = "Nome=Alberto&Idade=22";
var obj = form2json(url);
equal(obj.Nome, "Alberto");
equal(obj.Idade, "22");
});
@AlbertoMonteiro
AlbertoMonteiro / opa.cs
Created September 29, 2012 23:09
Marquim!!!!
using System;
using System.IO;
using System.Net;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{