Skip to content

Instantly share code, notes, and snippets.

View SeriaWei's full-sized avatar
:octocat:
Focusing

Wayne SeriaWei

:octocat:
Focusing
View GitHub Profile
@SeriaWei
SeriaWei / gist:4d347134f00891aada64610f9b2b1dce
Created January 17, 2017 03:54
C# Creating a Huge Dummy File
FileStream fs = new FileStream(@"c:\tmp\huge_dummy_file", FileMode.CreateNew);
fs.Seek(2048L * 1024 * 1024, SeekOrigin.Begin);
fs.WriteByte(0);
fs.Close();
@SeriaWei
SeriaWei / gist:7b11e9db369a07d4dcbe1e06e7dac2b3
Created June 5, 2017 00:46
SQLite Database connection string
Data Source=App_Data/Database.sqlite
@SeriaWei
SeriaWei / parseDate.js
Last active July 17, 2017 07:57
parse date with format
function parseDate(date,format) {
var year=0,month=0,day=0,hour=0,minute=0,seconds=0;
function toNumber(n){
if(n == ''){
return -1;
}
return Number(n);
}
function yearSetter(y,p){
FROM jenkins/jenkins:lts
USER root
WORKDIR /dotnet
RUN wget -O dotnet.tar.gz https://download.visualstudio.microsoft.com/download/pr/72ce4d40-9063-4a2e-a962-0bf2574f75d1/5463bb92cff4f9c76935838d1efbc757/dotnet-sdk-3.0.100-preview6-012264-linux-x64.tar.gz
RUN tar zxf dotnet.tar.gz -C ./
ENV PATH="${PATH}:/dotnet:/var/jenkins_home/.dotnet/tools"
ENV DOTNET_ROOT="/dotnet"
RUN rm -rf dotnet.tar.gz
RUN apt update -y
RUN apt install icu-devtools vim zip unzip -y
using HtmlAgilityPack;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq.Expressions;
using System.Net;
using System.Net.Http;
using System.Reflection;
https://codeplexarchive.blob.core.windows.net/archive/projects/simproexpr/simproexpr.zip
@SeriaWei
SeriaWei / WATCH.ps1
Created April 22, 2020 02:08
Powershell watch file change
$watchPath = Read-Host "Please input a path to watch"
### SET FOLDER TO WATCH + FILES TO WATCH + SUBFOLDERS YES/NO
$filewatcher = New-Object System.IO.FileSystemWatcher
#Mention the folder to monitor
$filewatcher.Path = $watchPath
$filewatcher.Filter = "*.*"
#include subdirectories $true/$false
$filewatcher.IncludeSubdirectories = $true
$filewatcher.EnableRaisingEvents = $true
@SeriaWei
SeriaWei / gist:aeae127c364b4af9144e8b2bba1d752a
Last active December 9, 2020 13:52
C# Get Property Value With Emit
private static void Emit()
{
People people = new People { Name = "Wayne" };
Type type = typeof(People);
var property = type.GetProperty("Name");
DynamicMethod method = new DynamicMethod("GetPropertyValue", typeof(object), new Type[] { type }, true);
ILGenerator il = method.GetILGenerator();
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Callvirt, property.GetGetMethod());
@SeriaWei
SeriaWei / gist:f63df2c91a3d24de2ec9a6a6ee95402d
Created December 9, 2020 13:55
C# Fast get property value
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;