Skip to content

Instantly share code, notes, and snippets.

View aspyct's full-sized avatar

Antoine d'Otreppe aspyct

View GitHub Profile
@aspyct
aspyct / Project.Droid.csproj
Created April 13, 2017 18:10
Increase java heap size while deploying Xamarin.Android project on device
+ <PropertyGroup>
+ <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
+ </PropertyGroup>
@aspyct
aspyct / AssemblyInfo.cs
Created March 29, 2017 20:26
Show internal classes to the test assembly
// Note: this also works for netstandard libraries. Just create the file and compile it.
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("NightOut.Core.Test")]
@aspyct
aspyct / State.cs
Last active March 17, 2017 23:18
Generate a .immutable.cs containing constructors and Derive() method for an immutable c# class.
using System;
using Monad;
namespace NightOut.Core.ViewModel.CheckIn.LocationSelector
{
[Serializable]
partial class State
{
public readonly Maybe<string> longitude = Nothing<string>.Default;
public readonly Maybe<string> latitude = Nothing<string>.Default;
@aspyct
aspyct / Project.csproj
Created March 17, 2017 20:38
Install non-netstandard libs in a .net core project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>portable-net45+win8+wp8+wpa81</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Compilers" Version="2.0.0" />
@aspyct
aspyct / RecycledViewPool.cs
Created March 3, 2017 09:34
Reusable Xamarin.Android RecycledViewPool
class RecycledViewPool
{
public delegate ViewHolder Factory(ViewGroup parent, int viewType);
// A stack has a O(1) add/remove, so better than a list
Dictionary<int, Stack<ViewHolder>> pool;
Factory factory;
public RecycledViewPool(Factory factory)
{
@aspyct
aspyct / BundleSerializationExtensions.cs
Created February 28, 2017 14:41
Android/Xamarin Bundle serialization
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Android.OS;
namespace Serialization
{
public static class BundleSerializationExtensions
{
public static void PutObject(this Bundle self, string key, object obj)
@aspyct
aspyct / AppDelegate.cs
Created April 28, 2016 08:13
Share on facebook page with Xamarin (Requires "Facebook iOS SDK component")
using Facebook.CoreKit;
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
return ApplicationDelegate.SharedInstance.FinishedLaunching (application, launchOptions);
}
@aspyct
aspyct / flickr.sh
Created February 20, 2015 19:55
Publish images to Flickr
FLICKR="$HOME/Flickr"
for image in "$@"
do
basename=$(basename $image)
imagename=${basename%.*}
extension=${basename##*.}
counter=1
filename=$basename
@aspyct
aspyct / slow_regex.pl
Created December 22, 2014 13:40
Perl killer
# http://swtch.com/~rsc/regexp/regexp1.html
$_ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
if ( m/a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ ) {
print "hello";
}
@aspyct
aspyct / belgian-address.pcre
Last active August 29, 2015 14:10
Parse a belgian street address
^
(?# street - required)([^/\n]+?)
(?# separator)[\s,]+
(?# number - required)(\d[\w-]*)
(?# box - optional)(?:\s*(?:bte|bus|boite|box|/)\s*(.+?))?
(?# trailing whitespaces)\s*
$
(?#
FIXME: how to make a difference between a ‘/‘ and ‘/b’,
when the ‘b’ could be part of the box?