Skip to content

Instantly share code, notes, and snippets.

View aspyct's full-sized avatar

Antoine d'Otreppe aspyct

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / Project.Core.csproj
Created April 13, 2017 19:48
Enable debugging in .netstandard libraries for Xamarin
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>Full</DebugType>
+ </PropertyGroup>
@aspyct
aspyct / fr-dvorak-bepo-aspyct.keylayout
Created November 17, 2017 09:51
My custom bepo-based keylayout on OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!-- French Dvorak Layout -->
<!-- http://www.clavier-dvorak.org/ -->
<!-- version 0.6.5 -->
<keyboard group="126" id="6542" name="Aspyct French Dvorak" maxout="5">
<!--
This layout is designed for ISO and ANSI keyboards. The extra
key on an ISO keyboard (next to the left Shift) is optional,
characters on it are also accessible through other keys.
public static class BundleExtensions
{
const string SERIALIZED_KEY = "__JSONSERIALIZED__";
static List<IMapItem> typesMapping;
//TODO: put in order of preference (cf string/charseq , serializable/parcelable, ...) because the for loop will stop at the first recognized type
static BundleExtensions() {
typesMapping = new List<IMapItem>{
new TypeMap<IBinder> ((b, i, v) => b.PutBinder(i, v), (b, i) => b.GetBinder(i)),
@aspyct
aspyct / wpa_supplicant.conf
Created September 17, 2018 13:10
Connect to a WPA2 Enterprise network with wpa_supplicant with this .conf file. I used this to connect to my university's wireless network.
# Connect to a WPA2 Enterprise network with wpa_supplicant with this .conf file.
# I used this to connect to my university's wireless network on Arch linux.
# Here's the command I used:
#
# wpa_supplicant -i wlan0 -c ./wpa_supplicant.conf
#
network={
ssid="YOUR_SSID"
scan_ssid=1