Skip to content

Instantly share code, notes, and snippets.

@hsinjungwu
hsinjungwu / footnotes.js
Last active August 29, 2015 14:03
Hexo plugin for parse footnotes
hexo.extend.filter.register('pre', function(data, callback) {
var footContent = ""
var ReLink = new RegExp('\\[[^](\\d+)\\]:(.+)', 'g');
data.content = data.content.replace(ReLink, function(x, y, z) {
footContent += '<li id="fn:' + y + '">' + z + '<a href="#fnref:' + y + '" rev="footnote">↩</a></li>';
return "";
});
var ReSup = new RegExp('\\[[^](\\d+)\\]', 'g');
data.content = data.content.replace(ReSup, '<sup id="fnref:$1"><a href="#fn:$1" rel="footnote">$1</a></sup>');
if (footContent.length > 0)
@hsinjungwu
hsinjungwu / Demo_RIPCE.cs
Created July 7, 2014 05:42
An Example of Use DevExpress.XtraEditors.Repository.RepositoryItemPopupContainerEdit
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;
RepositoryItemPopupContainerEdit ripce = new RepositoryItemPopupContainerEdit();
GridControl gc = new GridControl();
GridView gv = new GridView();
gc.MainView = gv;
@hsinjungwu
hsinjungwu / YearMonthEditor.cs
Last active August 29, 2015 14:03
DevExpress DateEditor Popout YearMonth View
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Calendar;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraEditors.Repository;
DateTime MinDateTime = new DateTime(1900, 1, 1);
/// <summary>
/// DateEditor that display year-month and only can select year-month view
/// </summary>
@hsinjungwu
hsinjungwu / PrintFile.cs
Created July 15, 2014 02:58
Print File
public void PrintFile()
{
var fileName = @"D:\1.pdf";
ProcessStartInfo psInfo = new ProcessStartInfo();
psInfo.Verb = "Print"; // or "PrintTo"
psInfo.FileName = fileName;
psInfo.Arguments = String.Format("/p /h \"{0}\"", fileName);
psInfo.CreateNoWindow = true;
using System;
using System.IO;
using System.Net;
public static void DownloadFile(string server, int port, string username, string password, string remoteFilePath, string localFilePath, bool useBinary, bool usePassive)
{
FtpWebRequest ftpReq = WebRequest.Create(string.Format("ftp://{0}:{1}/{2}", server, port, remoteFilePath)) as FtpWebRequest;
ftpReq.Method = WebRequestMethods.Ftp.DownloadFile;
ftpReq.UseBinary = useBinary;
ftpReq.UsePassive = usePassive;
@hsinjungwu
hsinjungwu / DoMergeTxtFile.cs
Last active August 29, 2015 14:04
Some Simple Examples
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
private void DoMerge()
{
using (FolderBrowserDialog fbd = new FolderBrowserDialog())
{
StringBuilder sb = new StringBuilder();
@hsinjungwu
hsinjungwu / PMdC.sql
Last active August 29, 2015 14:04
Calculate Properties of Bond
/*---------------------------------
內容 : 計算零息、永續跟一般債券之百元價、存續期間及凸性
INPUT :
@settlement : 交割日
@redemdate : 到期日
@yield : 殖利率
@rate : 票面利率
@perpetual : 是否為永續債券
@freq : 每年付息次數
@hsinjungwu
hsinjungwu / ObfuscateByDotfuscator.cs
Last active August 29, 2015 14:04
example of obfuscate application
using System;
using System.ComponentModel;
using System.Drawing;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
namespace ftpTEST
{
public class Form1 : Form
{
@hsinjungwu
hsinjungwu / MERGE.sql
Last active August 29, 2015 14:08
SQL Example
DECLARE @candy TABLE (buydate SMALLDATETIME, name VARCHAR(10), piece INT)
INSERT @candy VALUES ('2014-09-01', 'candy1', 10)
INSERT @candy VALUES ('2014-09-01', 'candy2', 20)
INSERT @candy VALUES ('2014-10-01', 'candy2', 40)
INSERT @candy VALUES ('2014-10-01', 'candy3', 80)
DECLARE @delta TABLE (name VARCHAR(10), sep_count INT, oct_count INT)
INSERT @delta
SELECT name, piece, 0 FROM @candy WHERE buydate = '2014-09-01'
@hsinjungwu
hsinjungwu / IntToChineseNumerals.cs
Last active August 29, 2015 14:08
Convert Integer To Words
using System;
using System.IO;
using System.Threading;
public class CSharpLab
{
public static void Test()
{
string[] chtInt = new string[]{"零","壹","貳","參","肆","伍","陸","柒","捌","玖"};
string[] moneyUnit1 = new string[] {"拾","佰","仟",};