Skip to content

Instantly share code, notes, and snippets.

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

chengzi ichengzi

🥇
coding...
View GitHub Profile
@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 / 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 / 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 / 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 / flatObj.js
Last active June 4, 2022 04:27
flat deep js object
// https://gist.github.com/ichengzi/fa90fede6c7ce91bbb083ea2e5466a38
const entry = {
a: {
b: {
c: {
dd: "abcdd"
}
},
d: {
@ichengzi
ichengzi / menu.css
Last active June 4, 2022 05:10
目录树 html5 detail + summay
/* https://www.bilibili.com/video/BV1mA4y1Z7cy */
/* https://m.php.cn/article/473454.html 画三角形文章 */
details {
position: relative;
width: 300px;
padding-left: 20px;
}
summary {
// https://www.bilibili.com/video/BV1BL411K7Dy
const arr = [
[1, 2, 2],
[3, 4, 5, 5],
[6, 7, 8, 9,
[11, 12,
[12, 12,
[13]
]
@ichengzi
ichengzi / Base64Url.cs
Created July 19, 2022 12:08 — forked from igorushko/Base64Url.cs
Base64Url C#
public static class Base64Url
{
public static string Encode(byte[] arg)
{
if (arg == null)
{
throw new ArgumentNullException("arg");
}
var s = Convert.ToBase64String(arg);
@ichengzi
ichengzi / RandomIDCardGenerator.cs
Created July 20, 2022 09:36
c# 随机身份证生成器
public class RandomIdCardUtil
{
[Test]
public void generate()
{
for (int i = 0; i < 100; i++)
{
var cusId = RandomIDCardGenerator.GetRandomCard(14, 14);
Console.WriteLine($"{cusId.Substring(0, 6)}" +
$"-{cusId.Substring(6, 4)}" +
@ichengzi
ichengzi / MimeType.cs
Created September 18, 2022 06:25
c# simple http server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace demo
{
public class MimeType
{
public static string GetOrDefault(string fileExtension, string defaultMime)