Skip to content

Instantly share code, notes, and snippets.

View kimsk's full-sized avatar
💭
We have two lives, and the second begins when we realize we only have one.

Karlkim Suwanmongkol kimsk

💭
We have two lives, and the second begins when we realize we only have one.
View GitHub Profile
using Nancy;
using Nancy.Conventions;
namespace DurandalNancy
{
public class DurandalNancyBootstrapper : DefaultNancyBootstrapper
{
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
base.ConfigureConventions(nancyConventions);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Nancy;
namespace DurandalNancy
{
public class DurandalNancyModule : NancyModule
{
@kimsk
kimsk / MainPage.xaml
Created November 16, 2013 05:03
Creating ViewModel for WinRT app in F#.
<Page
x:Class="Win8App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Win8App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:fSharpVm="using:FSharpVm"
mc:Ignorable="d">
@kimsk
kimsk / MainPage.xaml
Last active December 26, 2015 20:29
Design-Time WinRT XAML Binding
<Page
x:Class="DebugXamlBinding.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DebugXamlBinding"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
d:DataContext="{d:DesignInstance Type=local:MainPageViewModelSample, IsDesignTimeCreatable=True}">
@kimsk
kimsk / saveFilesAsUTF8-recursive.ps1
Created September 24, 2013 14:26
Saving multiple files in a folder recursively as UTF-8
$files = Get-ChildItem 'c:\temp' -Recurse | ? {Test-Path $_.FullName -PathType Leaf}
foreach($file in $files)
{
$content = Get-Content $file.FullName
$content | Out-File $file.FullName -Encoding utf8
}
@kimsk
kimsk / AboutTheStockExample.fs
Last active December 18, 2015 22:39
Learning F# : AboutTheStockExample
module ``about the stock example`` =
let stockData =
[ "Date,Open,High,Low,Close,Volume,Adj Close";
"2012-03-30,32.40,32.41,32.04,32.26,31749400,32.26";
"2012-03-29,32.06,32.19,31.81,32.12,37038500,32.12";
"2012-03-28,32.52,32.70,32.04,32.19,41344800,32.19";
"2012-03-27,32.65,32.70,32.40,32.52,36274900,32.52";
"2012-03-26,32.19,32.61,32.15,32.59,36758300,32.59";
"2012-03-23,32.10,32.11,31.72,32.01,35912200,32.01";
@kimsk
kimsk / MainPage.xaml
Created June 17, 2013 04:08
How to detect when a user completes changing WinRT XAML Slider value?
<Page
x:Class="WinAppThai_SliderEvent.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinAppThai_SliderEvent"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
@kimsk
kimsk / MainPage.xaml
Created June 17, 2013 03:48
เราจะเช็คได้อย่างไรว่าผู้ใช้หยุดเปลี่ยนค่า XAML slider แล้ว
<Page
x:Class="WinAppThai_SliderEvent.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinAppThai_SliderEvent"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
@kimsk
kimsk / AlternateColorGridView.cs
Created June 7, 2013 03:34
ผมสร้างคลาสใหม่ที่ inherit มาจาก GridView แล้วก็ใน PrepareContainerForItemOverride ก็ใส่โค้ดเช็คว่าเป็นตัวที่เท่าไหร่ ถ้าเป็นเลขคู่ก็เปลี่ยนสีแบ็กกราวนด์เป็นสีนึง ข้อเสียคือต้องบังคับให้ GridView มีจำนวนแถวเป็นเลขคู่ มีตัวอย่าง XAML ในอีกไฟล์ครับ
public class AlternateColorGridView : GridView
{
protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
{
base.PrepareContainerForItemOverride(element, item);
int index = ItemContainerGenerator.IndexFromContainer(element);
var gridViewItem = element as GridViewItem;
if (index % 2 == 0)
@kimsk
kimsk / Win8DevThaiVisualTreeHelper.MainPage.xaml.cs
Created June 3, 2013 19:32
VisualTreeHelper, VisualTreeHelperExtensions และ DataTemplate FrameworkElement.Loaded event http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.frameworkelement.loaded.aspx VisualTreeHelperExtensions http://winrtxamltoolkit.codeplex.com/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;