Skip to content

Instantly share code, notes, and snippets.

View igorkulman's full-sized avatar

Igor Kulman igorkulman

View GitHub Profile
private void Update()
{
if (string.IsNullOrEmpty(Text) || string.IsNullOrEmpty(HighlightedText))
{
TB.Inlines.Clear();
return;
}
TB.Inlines.Clear();
var parts = Regex.Split(Text, HighlightedText, RegexOptions.IgnoreCase);
private string GetGoogleSuccessCode(string data)
{
if (string.IsNullOrEmpty(data)) return null;
var parts = data.Split('=');
for (int i = 0; i < parts.Length; ++i)
{
if (parts[i] == "Success code")
{
return parts[i + 1];
}
/// <summary>
/// Custom DateTime JSON serializer/deserializer
/// </summary>
public class CustomDateTimeConverter : DateTimeConverterBase
{
/// <summary>
/// DateTime format
/// </summary>
private const string Format = "dd. MM. yyyy HH:mm";
<Page.Resoruces>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Resources/PlayerFramework.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resoruces>
MediaPlayer.ResourceLoader = ResourceLoader.GetForCurrentView("PlayerFramework"); //using PlayerFramework.resw in the project
/// <summary>
/// Gets stream data from the server. Uses ETag to cache data locally
/// </summary>
/// <param name="url">Url to get data from</param>
/// <returns>Stream data</returns>
[NotNull]
private async Task<Stream> GetData([NotNull] string url)
{
var client = new HttpClient();
/// <summary>
/// Gets response with ETag. Returns empty body if ETag matches (no data changes)
/// </summary>
/// <param name="data">Data to match with ETag</param>
/// <param name="model">Model to return</param>
/// <returns>Response</returns>
protected Response GetResponseWithEtag(object data, object model)
{
string etag = Utils.ComputeHash(data);
@igorkulman
igorkulman / Extensions.cs
Last active April 18, 2016 17:30
SRT plugin for PlayerFramework
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace AlzaMedia.Code.PlayReady
{
public static class Extensions
cat /sys/bus/w1/devices/28-000004e23e98
@igorkulman
igorkulman / backspace.cs
Last active August 29, 2015 14:16
Global Backspace key handler for Windows 8.1 apps
Window.Current.CoreWindow.KeyUp += (_, args) =>
{
if (args.VirtualKey == VirtualKey.Back)
{
var element = FocusManager.GetFocusedElement();
if (element is TextBox || element is PasswordBox)
{
return; //do not disturb user when typing
}