Skip to content

Instantly share code, notes, and snippets.

View Cheesebaron's full-sized avatar
🧀
Send cheese please

Tomasz Cielecki Cheesebaron

🧀
Send cheese please
View GitHub Profile
@Cheesebaron
Cheesebaron / AppDelegate.cs
Created February 18, 2015 09:57
iOS Background Tasks
using System;
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Foundation;
using ModernHttpClient;
using UIKit;
namespace App6
@Cheesebaron
Cheesebaron / CherylsBirthday.cs
Last active August 29, 2015 14:19
LINQPad script with a programmatic solution to the following logic puzzle. All credit goes to Peter Norvig's and his solution here: http://nbviewer.ipython.org/url/norvig.com/ipython/Cheryl.ipynb
// LINQPad script with a programatical solution to the following logic puzzle.
// All credit goes to Peter Norvig's and his solution here:
// http://nbviewer.ipython.org/url/norvig.com/ipython/Cheryl.ipynb
// 1. Albert and Bernard just became friends with Cheryl, and they want to know when her birtxhday is.
// Cheryl gave them a list of 10 possible dates:
// May 15 May 16 May 19
// June 17 June 18
// July 14 July 16
// August 14 August 15 August 17
@Cheesebaron
Cheesebaron / outlook.ahk
Created May 6, 2015 12:34
Auto Hotkey remap for Outlook 2013
#IfWinActive ahk_exe OUTLOOK.EXE
^!z::SendInput æ
^!+z::SendInput Æ
^!w::SendInput å
^!+w::SendInput Å
^!l::SendInput ø
^!+l::SendInput Ø
am start --user 0 -n com.android.settings/.DevelopmentSettings
@Cheesebaron
Cheesebaron / BaseView.cs
Created June 17, 2015 13:54
MvvmCross Windows Phone 8.1 BaseView
using System.Windows.Input;
using Windows.Phone.UI.Input;
using Windows.UI.Xaml.Navigation;
using Cirrious.MvvmCross.ViewModels;
using Cirrious.MvvmCross.WindowsCommon.Views;
namespace Lolz.WindowsPhone.Views
{
public abstract class BaseView<T> : MvxWindowsPage<T> where T : MvxViewModel
{
/*
* C# derivative of m_random.c used in DOOM
* https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/m_random.c
*
* Copyright (C) 1993-1996 by id Software, Inc.
*
* This source is available for distribution and/or modification
* only under the terms of the DOOM Source Code License as
* published by id Software. All rights reserved.
*
@Cheesebaron
Cheesebaron / CircularProgressDrawable.cs
Created July 9, 2015 08:42
CircularProgressDrawable, based on castorflex's Java implementation here: https://gist.github.com/castorflex/4e46a9dc2c3a4245a28e
[Register("dk.ostebaronen.droid.CircularProgressDrawable")]
public class CircularProgressDrawable
: Drawable
, IAnimatable
{
private static readonly IInterpolator AngleInterpolator = new LinearInterpolator();
private static readonly IInterpolator SweepInterpolator = new DecelerateInterpolator();
private static readonly RectF _bounds = new RectF();
private const int AngleAnimatorDuration = 2000;
public static class ColorUtils
{
public static class LabConstants
{
public const int Kn = 18;
public const float Xn = 0.950470f;
public const float Yn = 1f;
public const float Zn = 1.088830f;
@Cheesebaron
Cheesebaron / DeviceInfo.cs
Last active August 29, 2015 14:26
Year classification for Android. Based on Facebook's device-year-class: https://github.com/facebook/device-year-class
using System;
using System.IO;
using System.Linq;
using Android.OS;
using Android.Util;
namespace DeviceYearClass
{
public class DeviceInfo
{
@Cheesebaron
Cheesebaron / CaptureUiElements.cs
Created August 25, 2015 08:40
Capture UI elements Windows
protected async Task<RenderTargetBitmap> CaptureUiElementToStreamAsync(FrameworkElement uiElement,
IRandomAccessStream stream)
{
return await CaptureUiElementToStreamAsync(uiElement, stream, BitmapEncoder.PngEncoderId);
}
private async Task<RenderTargetBitmap> CaptureUiElementToStreamAsync(FrameworkElement uiElement,
IRandomAccessStream stream, Guid encoderId)
{
if (uiElement == null) throw new ArgumentNullException(nameof(uiElement));