Skip to content

Instantly share code, notes, and snippets.

View pedrolamas's full-sized avatar

Pedro Lamas pedrolamas

View GitHub Profile
@pedrolamas
pedrolamas / CultureInfoHelper.cs
Last active August 15, 2021 14:36
Helper class to return the correct CultureInfo in UWP apps
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
public class CultureInfoHelper
{
[DllImport("api-ms-win-core-localization-l1-2-0.dll", CharSet = CharSet.Unicode)]
private static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, StringBuilder lpLCData, int cchData);
private const uint LOCALE_SNAME = 0x0000005c;

Keybase proof

I hereby claim:

  • I am pedrolamas on github.
  • I am pedrolamas (https://keybase.io/pedrolamas) on keybase.
  • I have a public key ASC1NVaCf8XHix-iLfc6BG864vBxGvmzdRB6cBG36TdCowo

To claim this, I am signing this object:

@pedrolamas
pedrolamas / Boxstarter.txt
Last active August 29, 2015 14:13
My personal Boxstarter script
Enable-MicrosoftUpdate
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions
cinst DotNet4.5.1
cinst silverlight5developerruntime
cinst 7zip
cinst adobereader
cinst skype
cinst dropbox
cinst fiddler4
@pedrolamas
pedrolamas / UriExtensions.cs
Created September 29, 2014 00:03
UriExtensions class used in Cimbalino Toolkit with some changes to show the usage of optional parameters
// ****************************************************************************
// <copyright file="UriExtensions.cs" company="Pedro Lamas">
// Copyright © Pedro Lamas 2014
// </copyright>
// ****************************************************************************
// <author>Pedro Lamas</author>
// <email>pedrolamas@gmail.com</email>
// <project>Cimbalino.Toolkit.Core</project>
// <web>http://www.pedrolamas.com</web>
// <license>
@pedrolamas
pedrolamas / CustomUiNavigationController.cs
Created September 12, 2014 09:45
Xamarin UINavigationController.ViewDidLoad running before constructor
using System.Text;
using MonoTouch.UIKit;
namespace App2
{
public class CustomUiNavigationController : UINavigationController
{
private readonly StringBuilder _sb;
public CustomUiNavigationController(UIViewController uiViewController)
@pedrolamas
pedrolamas / app.xaml.cs
Created August 7, 2014 13:02
Grid layout in WP8.1
/*
In the "old" Windows Phone grid layout you would have a two columns layout like so:
MMCMCMM
where M is a 12px margin and C is the column width (so 5 * M + 2 * C = Width)
For a 3 columns layout it would be:
MMCMCMCMM
@pedrolamas
pedrolamas / Program.cs
Created July 4, 2014 10:15
Basic app to test and compare the generated IL
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DoIt1();
DoIt2();
using System.Collections.Generic;
using Newtonsoft.Json;
using System;
namespace ConsoleApplication1
{
class Program
{
public static T DeserializeFromJson<T>(string json)
{
@pedrolamas
pedrolamas / ImageHelper.cs
Created May 2, 2012 11:04
Windows Phone ImageHelper class
using System;
using System.IO;
using System.Windows.Media.Imaging;
namespace Helpers
{
public class ImageHelper
{
public static MemoryStream ResizeImage(Stream inputStream, double maxWidth, double maxHeight)
{
@pedrolamas
pedrolamas / gist:2386001
Created April 14, 2012 17:12
Gettings all "a.href" in HTML string
using System.Linq;
using HtmlAgilityPack;
namespace PhoneApp1
{
public class HtmlAgilityPackSample
{
public static string[] GetLinks(string html)
{
// The next line allows for form overlaps (forms inside forms)