Skip to content

Instantly share code, notes, and snippets.

View Phyyl's full-sized avatar
🥖

Philippe Paré Phyyl

🥖
View GitHub Profile
@Phyyl
Phyyl / locks.cs
Last active December 8, 2015 20:24
class LockSimple // Un seul access, pas de async/await
{
private readonly object lockObj = new object();
public void DoStuff()
{
// Si ya personne qui a lock "lockObj", on rentre et on lock.
// On unlock a la fin du block "lock (lockObj) {}"
lock (lockObj)
{
class LockSimple // Un seul access, pas de async/await
{
private readonly object lockObj = new object();
public void DoStuff()
{
// Si ya personne qui a lock "lockObj", on rentre et on lock.
// On unlock a la fin du block "lock (lockObj) {}"
lock (lockObj)
{
private string CalcLatitude()
{
float reste = (float)Math.Abs(Y - 0.5f) * 180;
int deg = (int)reste;
reste -= deg;
reste *= 60;
int min = (int)reste;
reste -= min;
reste *= 60;
int sec = (int)reste;
@Phyyl
Phyyl / server
Created September 10, 2015 15:17
        static void Main(string[] args)
        {
            Console.WriteLine("Local addresses: ");
            foreach (var address in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                Console.WriteLine($"    {address}");
            }
public class ControllerDictionary<TKey, TValue, TCast> : Dictionary<TKey, TValue> where TValue : UIViewController where TCast : TValue
{
public new TValue this[TKey key]
{
get
{
if (ContainsKey(key))
{
return base[key] as TCast;
}