Skip to content

Instantly share code, notes, and snippets.

View euyuil's full-sized avatar
🎯
Focusing

Liu Yue euyuil

🎯
Focusing
View GitHub Profile
@euyuil
euyuil / MyUserControl.xaml.cs
Last active September 13, 2018 10:37
WPF: in custom UserControl, create custom DependencyProperty, where you can bind some value to.
public partial class MyUserControl : UserControl
{
// The dependency property definition.
public static readonly DependencyProperty MyStateProperty =
DependencyProperty.Register
(
"MyState", // Name of dependency property.
typeof(string), // Type of dependency property.
typeof(MyUserControl), // Type of the class who owns the dependency property.
new FrameworkPropertyMetadata
@euyuil
euyuil / MyUserControl.xaml
Last active January 3, 2016 10:39
WPF: in custom UserControl, expose its children's DependencyProperties.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:my="clr-namespace:MyProject"
x:Class="MyProject.MyUserControl"
mc:Ignorable="d" d:DesignHeight="100" d:DesignWidth="640"
>
@euyuil
euyuil / matrix.m
Last active August 29, 2015 13:56
Octave: matrix notes.
% 定义一个行向量:
x = [1 2 3]
x =
1 2 3
% 定义一个列向量:
x = [1; 2; 3;]
@euyuil
euyuil / matrix2.m
Last active August 29, 2015 13:56
Octave: matrix notes 2.
% a : b 可以得到一个从 a 到 b 的整数组成的行向量,其中 a、b 是整数:
1 : 3
ans =
1 2 3
% a : b : c 可以得到一个从 a 到 c 并且相隔 b 的行向量,其中 a、b、c 都是实数:
1 : 2 : 10
@euyuil
euyuil / A.cpp
Last active January 28, 2020 01:42
Codeforces Round #230 (Div. 2): solved A, B and D during the contest and C afterwards (http://codeforces.com/contest/393).
// Problem A - Nineteen
// http://codeforces.com/contest/393/problem/A
#include <string>
#include <cstdlib>
#include <iostream>
#include <algorithm>
int cnt[256];
@euyuil
euyuil / 395A.cpp
Created February 21, 2014 03:19
Codeforces 395A: Skis. 2-Sum problem. 1 solution for both 395A1 and 395A2. (http://codeforces.com/problemset/problem/395/A1, http://codeforces.com/problemset/problem/395/A2)
// 395A1 & 395A2 - Skis
// http://codeforces.com/problemset/problem/395/A1
// http://codeforces.com/problemset/problem/395/A2
#include <cstdlib>
#include <iostream>
#include <algorithm>
const int N = 1111111;
@euyuil
euyuil / EventTest.cs
Created February 25, 2014 02:54
C#: event polymorphism test. Avoid 'overriding' events of parent class.
namespace EventTest
{
using System;
class Parent
{
public event Action Event;
public virtual void DoEvent()
{
@euyuil
euyuil / home.html
Created April 1, 2014 05:11
CSS: fixed-width sidebar with fluid-width content container.
<div id="content-wrapper">
<div id="content">
<!-- blah blah blah -->
</div>
</div>
<div id="sidebar">
<ul>
<!-- blah blah blah -->
</ul>
@euyuil
euyuil / StringUtils.cs
Last active October 21, 2016 10:22
C#: String named format parameters.
// Modified based on http://stackoverflow.com/questions/1322037/
public static class StringUtils
{
private static Regex FormatPattern =
new Regex(@"(\{+)([^\}]+)(\}+)", RegexOptions.Compiled);
public static string Format(this string pattern, object template)
{
if (template == null)
@euyuil
euyuil / findstr.cmd
Created July 3, 2014 06:17
Cmd: find string in files
findstr /s /i /m "stringToFind" *