This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<TModel> JsonDeserialize<TModel>(HttpResponseMessage response) | |
{ | |
var content = response.Content; | |
using var stream = await content.ReadAsStreamAsync().ConfigureAwait(false); | |
using var reader = new StreamReader(stream); | |
using var json = new JsonTextReader(reader); | |
return serializer.Deserialize<TModel>(json); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Notification CreateNotification( | |
Context context, | |
string title, | |
string description = null, | |
string largeIcon = null, | |
string smallIcon = null, | |
int? progress = null, | |
bool indeterminate = false, | |
bool showProgress = true, | |
bool hasCancelButton = true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.msharp.Test | |
use System.Types | |
use System.Math | |
// Defining a constants | |
config A = 0 | |
config B = 0 | |
config LocalConfig { // enum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Flight | |
{ | |
class Route | |
{ | |
public Route(Fix departure, Fix destination) | |
{ | |
Departure = departure; | |
Destination = destination; | |
} | |
public Fix Departure { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0xdead .classA ; Class B | |
0xdeae :ToString | |
0xdeaf mov ax, al | |
0xdeb0 ... | |
0xbeef .classB ; Class A | |
0xbef0 :ToString | |
0xbef1 mov ax, al | |
0xbef2 ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Data | |
{ | |
"Latitude": 12.123, | |
"Longitude": 123.13 | |
} | |
Point(latitude, longitude) | |
{ | |
Latitude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Entity | |
Product(id) | |
{ | |
Id | |
Name | |
Price | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IDictionary<string, object> AsDictionary(this object source, BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) | |
{ | |
return source.GetType().GetProperties(bindingAttr).ToDictionary | |
( | |
propInfo => propInfo.Name, | |
propInfo => propInfo.GetValue(source, null) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class LayoutObserver(private val view: View, private val callback: (Size) -> Unit) : ViewTreeObserver.OnGlobalLayoutListener { | |
init { | |
if (!view.viewTreeObserver.isAlive) | |
throw IllegalArgumentException("Go fuck yourself") | |
view.viewTreeObserver.addOnGlobalLayoutListener(this) | |
} | |
override fun onGlobalLayout() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hasMoved: Boolean = false | |
get() { | |
if (initialTouchPosition == null) | |
return false | |
if (lastTouchPosition == null) | |
return false | |
val xDiff = abs(initialTouchPosition!!.x - lastTouchPosition!!.x) | |
val yDiff = abs(initialTouchPosition!!.y - lastTouchPosition!!.y) | |
val epsilon = 0.1 | |
return xDiff > epsilon || yDiff > epsilon |