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 / jsonToFormUrlencoded.js
Created December 10, 2011 03:29
Json to formUrlencoded
function jsonToFormUrlencoded(obj, currentLevel) {
var serialized = "";
for (var item in obj) {
if (obj[item] instanceof Array) {
for (var i = 0; i < obj[item].length; i++) {
if (obj[item][i] instanceof Object) {
if (currentLevel)
serialized += jsonToFormUrlencoded(obj[item][i], "{0}.{1}[{2}]".format(currentLevel, item, i)) + "&";
else {
serialized += jsonToFormUrlencoded(obj[item][i], "{0}[{1}]".format(item, i)) + "&";
@AlbertoMonteiro
AlbertoMonteiro / GitForPS1.ps1
Created February 9, 2012 13:16 — forked from AbraaoAlves/GitForPS1.ps1
Git for power shell
#Com git instalado, via powershell:
Set-ExecutionPolicy Unrestricted
if(!$env:path.Contains("C:\Program Files (x86)\Git\cmd"))
{
$env:path += ";C:\Program Files (x86)\Git\cmd"
}
if(!$env:path.Contains("C:\Program Files (x86)\Git\bin"))
{
@AlbertoMonteiro
AlbertoMonteiro / ScrollPositionBehavior.cs
Created February 11, 2012 04:10
Custom WP7 Behaviors
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
namespace Custom.Behaviors
{
public class ScrollPositionBehavior : Behavior<ScrollViewer>
{
public double Position
@AlbertoMonteiro
AlbertoMonteiro / gist:1884566
Created February 22, 2012 12:13
Exibindo mini tabs no Chrome como o IE
Abra as propriedades e adicione isso ao caminho: --enable-aero-peek-tabs
(não esqueça de deixar um espaço entre o caminho do programa e o código)
Se você usa o atalho do Chrome na barra de tarefas do Windows 7, abra o explorer e vá aqui:
"%appdata%/Microsoft/Internet Explorer/Quick Launch/User Pinned/Taskbar "
@AlbertoMonteiro
AlbertoMonteiro / Program.cs
Created March 11, 2012 17:08
Auto Implement INotifyPropertyChanged
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using FluentIL.Cecil;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MethodAttributes = Mono.Cecil.MethodAttributes;
@AlbertoMonteiro
AlbertoMonteiro / program.cs
Created March 16, 2012 19:11
DynamicMethod with IL vs Delegate creation with Expression
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using FluentIL;
namespace ConsoleApplication1
{
@AlbertoMonteiro
AlbertoMonteiro / openpopup.js
Created March 27, 2012 18:49
Avoid popup blocker with bookmarklet
window.onload = function () {
document.querySelector("#abc").onclick = function() {
window.location = 'javascript:window.open("http://www.google.com.br", null, "scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,left=685,top=0");void(0);'
};
};
@AlbertoMonteiro
AlbertoMonteiro / geradorcpf.cs
Created April 3, 2012 11:12
Gerador de CPF
using System;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
[STAThread]
static void Main(string[] args)
{
@AlbertoMonteiro
AlbertoMonteiro / NHibernateProxyRemover.cs
Created April 18, 2012 15:20
Proxy remover from objects returned by NHibernate
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
namespace Nash.Core
{
public class NHibernateProxyRemover
{
public static T From<T>(T objeto)
@AlbertoMonteiro
AlbertoMonteiro / For.cs
Created April 20, 2012 16:25
Trying to simulate list comprehension of Python in C#
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication3
{
public class Comprehension
{
public Comprehension()
{