Skip to content

Instantly share code, notes, and snippets.

View ichengzi's full-sized avatar
🥇
coding...

chengzi ichengzi

🥇
coding...
View GitHub Profile
@ichengzi
ichengzi / winnt.h
Created October 10, 2020 13:23 — forked from JamesMenetrey/winnt.h
WinNT.h in Windows 10 SDK (10.0.17763.0)
/*++ BUILD Version: 0073 Increment this if a change has global effects
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
winnt.h
Abstract:
@ichengzi
ichengzi / Mac Classic.tmTheme
Created April 24, 2020 03:30 — forked from Arc0re/Mac Classic.tmTheme
Mac Classic theme for Sublime Text 3. To install under v3.2.1 ( build 3207 ): Preferences > Browse Packages... > new folder called "Mac Classic.tmTheme", copy .tmTheme file in there. The colorscheme will be instantly added to Sublime's list.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Chris Thomas</string>
<key>name</key>
<string>Mac Classic</string>
<key>settings</key>
<array>
@ichengzi
ichengzi / InsertNewLine.cs
Created August 16, 2018 07:12
SplitString and InsertNewLine
public static string InsertNewLine(string source, int len = 76)
{
var sb = new StringBuilder(source.Length + (int)(source.Length / len) + 1);
var start = 0;
while ((start + len) < source.Length)
{
sb.Append(source.Substring(start, len));
sb.Append(Environment.NewLine);
start += len;
}
@ichengzi
ichengzi / Extensions.cs
Created December 27, 2016 03:56
Extensions
public static class Extensions
{
public static void AddRange<T>(this ObservableCollection<T> oc, IEnumerable<T> collection)
{
if (collection == null)
{
throw new ArgumentNullException("collection");
}
collection.ToList().ForEach( oc.Add);
}
@ichengzi
ichengzi / enter2tab_Key.cs
Created December 1, 2016 08:02
wpf技巧
//enter键转tab键:
private void EnterKey_To_TabKey(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
((FrameworkElement)sender).MoveFocus(request);
}
}
@ichengzi
ichengzi / mysql异常处理.sql
Created November 25, 2016 10:11
mysql数据库
DROP PROCEDURE IF EXISTS demo;
CREATE PROCEDURE demo()
BEGIN
DECLARE EXIT HANDLER FOR SQLWARNING,NOT FOUND,SQLEXCEPTION
BEGIN
set @o_ret=-1;
SELECT -2;
ROLLBACK;
END;
START TRANSACTION;
@ichengzi
ichengzi / DataTable2List.cs
Created November 13, 2016 11:20
LINQ - via cz
var input = "PQR";
DataTable dt = new DataTable();
dt.Columns.Add("PId", typeof(Int32));
dt.Columns.Add("PName", typeof(string));
dt.Columns.Add("Qty", typeof(Int32));
dt.Rows.Add(123, "XYZ", 2);
dt.Rows.Add(223, "ABC", 4);
dt.Rows.Add(434, "PQR", 33);
var stkLists = dt.AsEnumerable().ToList();
@ichengzi
ichengzi / triggers.xaml
Created November 5, 2016 12:06
wpf triggers(property,data,event)
<TextBlock Text="Hello">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Blue"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red" />
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Text}" Value="Hello">
@ichengzi
ichengzi / create-new-file.ahk
Created April 22, 2016 15:05
AutoHotKey: Create a new file with Ctrl+Alt+N keyboard shortcut in Windows Explorer
; This is part of my AutoHotKey [1] script. When you are in Windows Explorer it
; allows you to press Ctrl+Alt+N and type a filename, and that file is created
; in the current directory and opened in the appropriate editor (usually
; [gVim](http://www.vim.org/) in my case, but it will use whatever program is
; associated with the file in Windows Explorer).
; This is much easier than the alternative that I have been using until now:
; Right click > New > Text file, delete default filename and extension (which
; isn't highlighted in Windows 7), type the filename, press enter twice.
; (Particularly for creating dot files like ".htaccess".)
@ichengzi
ichengzi / latency.txt
Created January 17, 2016 06:26 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD