Skip to content

Instantly share code, notes, and snippets.

@philo-ng
philo-ng / gist:f7e312853bccd26b4f4ca77e65355353
Last active December 27, 2016 23:25
Deserialize old Microsoft Json date
private static class MicrosoftJsonDate {
private static final int DATE_GMT0_GROUP = 1;
private static final int OFFSET_GROUP = 2;
private static Pattern json_date_pattern
= Pattern.compile("^\\/Date\\(([-]?\\d+)([-\\+]([01]\\d|2[0-3])[0-5]\\d)?\\)\\/$");
private static HashMap<String, Integer> offsetInMillisMap
= new HashMap<>();
public static Date deserialize(String json_date) throws IllegalStateException {
@philo-ng
philo-ng / oracle.list_of_date
Created March 12, 2016 20:01
Oracle SQL: a list of date
select to_date('01-JAN-0001') + level - 1 as my_date
from dual
connect by to_date('01-JAN-0001') + level < to_date('12-DEC-2999')
@philo-ng
philo-ng / gist:279615dc3dfad90e2a4c
Created February 9, 2016 18:01
Calling the VBA Trim function from Excel Cells
'
' The Excel built in function Trim removes excessive spaces in the string. It may cause data
' problem. The VBA Trim function only remove the leading and trailing spaces.
'
Public Function VBA_Trim(value As String) As String
VBA_Trim = Trim(value)
End Function
@philo-ng
philo-ng / Stopwatch.cls
Created February 6, 2016 21:06
Simple VB6 Stopwatch
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Stopwatch"
Attribute VB_GlobalNameSpace = False
@philo-ng
philo-ng / TrimNullTerminatedString
Last active December 29, 2015 20:35
Trim null terminated VB6 String
Public Function TrimNullTerminatedString(s As String) As String
TrimNullTerminatedString = Trim(Replace(s, Chr(0), ""))
End Function
@philo-ng
philo-ng / Collection2.cls
Last active September 26, 2019 04:29
Enhanced VB6 Collection
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Collection2"
Attribute VB_GlobalNameSpace = False
@philo-ng
philo-ng / cStringBuilder.cls
Last active November 13, 2015 17:33 — forked from bradley219/cStringBuilder.cls
Slightly improved version of Steve McMahon's cStringBuilder for visual basic 6 (and possibly for later versions of visual basic). Adds useful methods such as CharAt() and GetSlice(), and fixes an issue with the Find() method which did not work when the string you were searching for happened to be at the very end of the buffer.
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "cStringBuilder"
Attribute VB_GlobalNameSpace = False