Skip to content

Instantly share code, notes, and snippets.

View tianhonghui's full-sized avatar

Zack Fair tianhonghui

View GitHub Profile
apm install react
apm install git-diff-details
apm install git-history
apm install merge-conflicts
apm install project-manager
apm install todo-show
apm install open-recent
apm install highlight-selected
npm i -g eslint
@tianhonghui
tianhonghui / quicksort.swift
Last active August 29, 2015 14:06
quicksort Swift Recursion
// Playground - noun: a place where people can play
func quickSort <T : Comparable>(input : Array<T>)->(Array<T>){
if(input.count <= 1) {
return input
}
let pivot = input[0]
let tail = input[1...input.count-1]
let less = Array(tail.filter{$0<pivot})
var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("MyWav.wav", Windows.Storage.CreationCollisionOption.ReplaceExisting);
await Windows.Storage.FileIO.WriteBytesAsync(file, buffer);
@tianhonghui
tianhonghui / facebookpivot
Created March 29, 2014 03:53
facebook pivot 简单实现
<phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Primitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone"
x:Class="FacebookPivot.MainPage"
mc:Ignorable="d"
SupportedOrientations="Portrait"
@tianhonghui
tianhonghui / gist:8998782
Created February 14, 2014 10:16
attributes
IEnumerable<PropertyInfo> ss = obj.GetType().GetRuntimeProperties();
var ingoreAttribute = Attribute.GetCustomAttribute(s, typeof(IngoreUriSerialize));
@tianhonghui
tianhonghui / ImageExtensions
Created December 31, 2013 03:05
Image Cache Extensions written by 乱舞春秋
using System.IO;
using System.Text;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Controls;
using Windows.Storage;
namespace System.Windows.Media.Imaging
{
@tianhonghui
tianhonghui / gist:7781738
Created December 4, 2013 03:09
build uri with querystring
var builder = new UriBuilder("http://example.com");
builder.Port = -1;
var query = HttpUtility.ParseQueryString(builder.Query);
query["foo"] = "bar<>&-baz";
query["bar"] = "bazinga";
builder.Query = query.ToString();
string url = builder.ToString();
@tianhonghui
tianhonghui / evilConvertor
Last active December 27, 2015 15:29
mars loc to true loc…
using System;
namespace Helpers {
public class LocConverter {
public static double pi = Math.PI;
//
// Krasovsky 1940
//
// a = 6378245.0, 1/f = 298.3
@tianhonghui
tianhonghui / Jsonparse
Created November 7, 2013 03:31
json parse
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace Edooon.Model
@tianhonghui
tianhonghui / Style.xaml
Created October 16, 2013 02:09
Change WPToolkit rating control color
<Style x:Key="RatingStyle" TargetType="toolkit:Rating">
<Setter Property="AllowHalfItemIncrement" Value="True" />
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="20" />
<Setter Property="FilledItemStyle">
<Setter.Value>
<Style TargetType="toolkit:RatingItem">
<Setter Property="Background"
Value="#FF9900" />
</Style>