Skip to content

Instantly share code, notes, and snippets.

@relyky
relyky / ng_format_datetime.js
Last active December 29, 2016 10:17
Angular JS - dateFormat
# 可引用 $filter 處理
# ref → https://docs.angularjs.org/api/ng/filter/date
// 日期格式處理
$scope.checkTimeFmt = $filter('date')($scope.checkTime, 'yyyy/MM/dd HH:mm:ss');
// 等同在html
{{checkTime | date:'yyyy/MM/dd HH:mm:ss' }}
//-------------------
@relyky
relyky / JavaScript - forEach example
Last active August 29, 2015 14:19
JavaScript - forEach example
//# sub-sequence
$scope.convertDateFormat = function()
{
// 子檔
if (Array.isArray($scope.dataItems.POP_HANDLING_CARGO_LIST)) {
$scope.dataItems.POP_HANDLING_CARGO_LIST
.forEach(function (itm) {
itm.START_DT = new Date(itm.START_DT).dateFormat("Y/m/d h:i");
itm.END_DT = new Date(itm.END_DT).dateFormat("Y/m/d h:i");
});
@relyky
relyky / How to get “GET” request parameters in JavaScript?
Last active August 29, 2015 14:20
How to get “GET” request parameters in JavaScript?
參考自: http://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
答案如下,只需解析出來。
window.location.search
解析函數
function getRequestParam(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
@relyky
relyky / SQL Server 定序衝突.sql
Last active April 27, 2022 08:10
SQL Server 定序衝突, 字集定序, 字串比較
--參考自:http://blog.xuite.net/dlnk/work/38263590-SQL+Server+%E5%AE%9A%E5%BA%8F%E8%A1%9D%E7%AA%81+
--SQL Server 定序衝突 無法解析equal to 作業中"Chinese_Taiwan_Stroke_CI_AS"
--只要將定序不統一的欄位用COLLATE轉換就可以了
select
AutoId,
Account,
CharName,
@relyky
relyky / ComboBox.cs
Last active August 29, 2015 14:23
ComboBox初始化
// 有三種方式使用ComboBox
// 直接看例子比較快
// 法一:純文字
cbxAuthLevel.Items.Add("選項一");
cbxAuthLevel.Items.Add("選項二");
cbxAuthLevel.Items.Add("選項三");
cbxAuthLevel.Text //<-- 操作時,使用此屬性
@relyky
relyky / HTTPS-SSL-TLS bypass.cs
Last active August 28, 2019 14:30
當要求https連線出現:基礎連接已關閉: 無法為 SSL/TLS 安全通道建立信任關係。
//參考來源1:http://blog.darkthread.net/post-2010-05-06-webclient-ssl-dismatch.aspx
//參考來源2:http://awei791129.pixnet.net/blog/post/24463385-%5Bc%23%5D-%E7%95%B6%E8%A6%81%E6%B1%82https%E9%80%A3%E7%B7%9A%E5%87%BA%E7%8F%BE%EF%BC%8C%E5%9F%BA%E7%A4%8E%E9%80%A3%E6%8E%A5%E5%B7%B2%E9%97%9C%E9%96%89%3A-%E7%84%A1
關鍵參教
xxx.ServerCertificateValidationCallback = delegate { return true; };
// 狀況一:改連線設定-範例
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
// 狀況一:使用HttpWebRequest的解法-範例
@relyky
relyky / ComWithoutRegister.cls
Last active July 27, 2018 03:01
VB6不註冊調用ActiveX Dll
'類別名稱:ComWithoutRegister
'程式語言:Visual Basic
'開發平台:Microsft Viaual Basic 6(VB6)
'說明:VB6不註冊調用ActiveX Dll。以下為本人案例, 請依你的需求變更“your”的部份。
'注意:此範例無法處理動態調用。
'注意2:需設定引用項目olelib.tlb (Edanmo's OLE interfaces & functions v1.81),http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip
'注意3:在引用不註冊的COM Class時,其中的 ReDim 指令只能用 private 型態,不然會失效。這不科學但存在。若非用不可需自己多加一道額外的轉換 public 操作。
'參考資料:http://blog.yam.com/wyattkid/article/16416433
Option Explicit
@relyky
relyky / ComWithoutRegister2.cls
Last active April 26, 2023 08:42
ComWithoutRegister第二版,可真的動態載入DLL函式庫,不需註冊COM也能調用。
Option Explicit
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpSectionName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpbuffurnedString As String, ByVal nBuffSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpSectionName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32.dll" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function DispCallFunc Lib "oleaut32.dll" (ByVal pvInstance A
@relyky
relyky / MyTelephoneEqualityComparer.cs
Created July 21, 2015 07:54
自訂電話號碼比較,使用 IEqualityComparer<T>
// 引言:工作上需要,比較電話號碼,排除大小寫與dash
// 使用時搭配LINQ語法,用於 LINQ.Distinct()
// 參考文件:https://msdn.microsoft.com/zh-tw/library/ms132151(v=vs.110).aspx
/// <summary>
/// 自訂電話號碼比較
/// </summary>
class MyTelephoneEqualityComparer : IEqualityComparer<string>
{
public bool Equals(string s1, string s2)
@relyky
relyky / AddressParser.cs
Last active January 10, 2024 05:35
RegEx實戰紀錄;字串解析:String.IndexOf, RegEx, Match, Regular Expression
using System.Text.RegularExpressions;
internal class AddressParser
{
public AddressParser(string address)
{
this.OrginalAddress = address;
this.ParseByRegex(address);
}