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 / Update-Package-Reinstall.ps1
Created February 15, 2015 09:15
NuGet: reinstall all the packages
# If you want to reinstall the packages for a project
Update-Package -Reinstall -ProjectName Your.Project.Name
# If you want to reinstall the packages for a solution
Update-Package -Reinstall
@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 / disable-alt-drag.sh
Last active October 21, 2016 10:19
Gnome: Change the shortcut to move window from Alt-Drag to Super-Drag.
gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "<Super>"
@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 / 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 / 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 / install-and-configure-shadowsocks-server.sh
Last active March 1, 2019 04:50
Shadowsocks: Server installation and configuration on Ubuntu 14.04.
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -y python-gevent python-pip python-m2crypto supervisor
sudo pip install shadowsocks
sudo mkdir -p touch /etc/shadowsocks
@euyuil
euyuil / gandi-ddns.sh
Last active April 10, 2019 06:53
Gandi.net: Dynamic DNS crontab script
#!/bin/bash
# https://doc.livedns.gandi.net/
# https://www.ipify.org/
APIKEY='YourKeyGoesHere'
DOMAIN='example.com'
NAME='@'
IPADDR=`curl -s https://api.ipify.org/`
@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 / setup.sh
Last active March 13, 2020 16:30
Setup script for GitLab Runner and other tools with China mirrors
#!/bin/bash
# OS: Ubuntu 18.04
sudo apt-get update
sudo apt-get upgrade -y
# Reference: https://mirror.tuna.tsinghua.edu.cn/help/gitlab-runner/
curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
sudo echo 'deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-runner/ubuntu bionic main' > /etc/apt/sources.list.d/gitlab-runner.list