Skip to content

Instantly share code, notes, and snippets.

View LinZap's full-sized avatar
🔬
copilot

Zap LinZap

🔬
copilot
View GitHub Profile
@LinZap
LinZap / formdata.js
Last active October 22, 2019 02:12
formdata v2.0
/**
* create by Zap Lin
* this is a magic function for collecting form data and convert it to object
*
* ref: https://developer.mozilla.org/zh-TW/docs/Web/API/FormData/FormData
*/
/**
* collecting data from <form> element and convert to Object (JSON)
create function fn_split(@str nvarchar(max),@separator as nvarchar(max))
returns @splits table(segment nvarchar(max))
as
begin
declare @anchor int=CHARINDEX(@separator,@str),@gram int=len(@separator)
while @anchor>0 and @gram<=len(@str)
begin
insert into @splits values(SUBSTRING(@str, 1, @anchor-1))
set @str=SUBSTRING(@str,@anchor+@gram,len(@str)-@anchor+@gram+1)
set @anchor=CHARINDEX(@separator,@str)
@robertgonzales
robertgonzales / Frame.js
Created December 12, 2017 03:03
Use React portals to render inside shadow dom and iframes
class Frame extends Component {
componentDidMount() {
this.iframeHead = this.node.contentDocument.head
this.iframeRoot = this.node.contentDocument.body
this.forceUpdate()
}
render() {
const { children, head, ...rest } = this.props
return (
@LinZap
LinZap / format.md
Last active December 5, 2017 10:21
messenger data format

Facebook Messenger Data Format

Text Message

{
  "entry": [
    {
      "id": "1944407515840583",
      "time": 1512469177548,
      "messaging": [
@LinZap
LinZap / mydevopsfornet.md
Last active March 31, 2018 10:35
手刻 DevOps for .NET 專案

手刻 DevOps for .NET 專案-----------------------------

本文以 .NET 專案開發人員的的角度撰寫

DevOps 是現在非常主流的開發方式,目的只有一個:開發、測試與佈署自動化一氣呵成,減少開發過程中繁複的工作。

假設今天要測試一個功能,我們在本機將程式碼改好, 測試無誤後,還要手動放到遠端測試機器上,在遠端測試機器上也測試無誤後,才算完成。但如果在遠端測試機有錯誤,勢必又得回本機進行修正,修正完再佈署一次...,即使只改一行 code,也必須如此...,無形中便增加了非常多的開發成本...

其中最關鍵的部分是:自動化持續整合(CI)和持續部署(CD)。而 Microsoft Team Foundation Server 2017 已經有非常完整的 solution for DevOps,.NET 開發人員可以使用其提供的介面,方便的設定符合自己專案的 CI/CD pipeline,無需使用其他第三方工具。

回歸本質,這類的工具雖然提供了十分方便的功能,但我們還是能透過最原始的指令,來兜出仿 CI/CD 效果的功能,以下將逐步介紹。

@LinZap
LinZap / c_sharp_reflection.md
Last active September 23, 2017 17:39
怎麼在 C# 的強型別中玩動態型別

怎麼在 C# 的強型別中玩動態型別

這個篇幅會介紹不常見的 C# 撰寫風格與大量的型態運算,深入淺出地剖析這些技術的本質,也讓你對這個語言既定的撰寫風格有更多不同面向的思考。

Anonymous Types

首先我先用 Anonymous Types (匿名類型) 作為開場,C# 允許將一組唯讀屬性封裝成一個物件,而不需要事先明確定義類型。

var v = new { 
 Amount = 108, 
@LinZap
LinZap / se.md
Last active February 6, 2017 07:20
Search Engine

Search Engine

for I3S Schema Search Engine

Table

Token  

字段表

@LinZap
LinZap / README.md
Last active August 18, 2016 14:23
React + D3

淺談 React + D3

這邊簡單說明 React 如何無痛與 D3 結合

思路

主要的作法有兩種

  • 由 React 控制 svg 的 DOM 結構
  • D3 控制 svg 的 DOM 結構,但需要實做更新邏輯
@LinZap
LinZap / index.js
Last active December 2, 2016 02:08
Call other process use Node.js
const exec = require('child_process').exec
exec('py main.py', (error, stdout, stderr) => {
if(error)
console.log('print',stderr)
else
console.log('print',stdout)
})
@LinZap
LinZap / control.js
Last active April 11, 2016 14:33
Node.js static data - 猜猜看 index.js 最後印出什麼?
var d = require('./data');
module.exports = {
add: function(item){
d.data.push(item);
}
}