Skip to content

Instantly share code, notes, and snippets.

View aliozgur's full-sized avatar
🎯
Focusing

Ali Özgür aliozgur

🎯
Focusing
View GitHub Profile
@aliozgur
aliozgur / ApiClient.cs
Last active January 2, 2018 11:14
Xamarin.Forms : ModernHttpClient wrapper for API calls
using System;
using System.Threading.Tasks;
using ModernHttpClient;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading;
using System.Text;
namespace MyNamespace
{
@aliozgur
aliozgur / DeviceOrientation.cs
Last active April 4, 2018 07:12
Xamarin.Forms : Device Orientation Service
using System;
namespace MyNamespace
{
public enum DeviceOrientation
{
Landscape,
Portrait
}
@aliozgur
aliozgur / AppDelegate.cs
Created December 10, 2014 10:36
Xamarin.Forms : Get Notified for device orientation changes with MessagingCenter
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Xamarin.Forms;
using System.Net;
@aliozgur
aliozgur / AppDelegate.cs
Created December 10, 2014 10:46
Xamarin.Forms : Using NSTimer and MessagingCenter
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Xamarin.Forms;
using System.Net;
@aliozgur
aliozgur / FileSystemHelper.iOS.cs
Created December 10, 2014 11:01
Xamarin.Forms : File service to save/load your objects as Json
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using MonoTouch.UIKit;
using System.Collections;
using System.Collections.Generic;
using MonoTouch.Foundation;
/// <summary>
@aliozgur
aliozgur / AppResources.tr.po
Last active August 29, 2015 14:11
Xamarin.Mobile : T4 template to generate resource keys from GNU PO files
msgid ""
msgstr ""
"Project-Id-Version: MyProject\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: Ali Özgür\n"
"Language-Team: Turkish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@aliozgur
aliozgur / lookandsay.fsx
Last active January 5, 2016 15:47
Advent of Code F# Day 10 : look-and-say
// "Elves Look, Elves Say" - Day 10 - Advent of Code http://adventofcode.com/day/10 #AdventOfCode
let lookAndSay(input : string array) =
input
|> Array.fold (fun acc el ->
match acc with
| [||] -> [|(1, el)|]
| _ ->
let count, item = acc.[acc.Length - 1]
if el = item then
acc.[acc.Length - 1] <- (count + 1, el)
@aliozgur
aliozgur / perfectcookie.fsx
Created January 6, 2016 23:05
Advent of Code F# Day 15 : perfect-cookie
(*
Sprinkles: capacity 5, durability -1, flavor 0, texture 0, calories 5
PeanutButter: capacity -1, durability 3, flavor 0, texture 0, calories 1
Frosting: capacity 0, durability -1, flavor 4, texture 0, calories 6
Sugar: capacity -1, durability 0, flavor 0, texture 2, calories 8
*)
let myIngredientsNoCalories =
[|[|5L; -1L; 0L; 0L|];
[|-1L; 3L; 0L; 0L|];
@aliozgur
aliozgur / SqlParameterHelper.cs
Created January 19, 2016 13:41
Convert objects to SqlParameter array or list
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Collections;
using System.Data;
namespace SqlParameterHelper
{
/// <summary>
@aliozgur
aliozgur / railway.fs
Last active January 29, 2017 16:24
Railway oriented programming
// Taken from http://fsharpforfunandprofit.com/posts/recipe-part2/
// the two-track type
type Result<'TSuccess,'TFailure> =
| Success of 'TSuccess
| Failure of 'TFailure
// convert a single value into a two-track result
let succeed x =
Success x