Skip to content

Instantly share code, notes, and snippets.

@compustar
compustar / CleanWikiCovid.vb
Last active March 13, 2020 03:44
VBA macro to preprocess 2019 nCoV data
Sub CleanWikiCovid()
Selection.Hyperlinks.Delete
Selection.UnMerge
Range("A1").Select
Cells.Find(What:="date", After:=ActiveCell, LookIn:=xlFormulas2, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
While Selection.Column > 1
Selection.EntireColumn.Delete
@compustar
compustar / parse_gmap_json.py
Last active February 9, 2020 07:39
Python script parses Google Map JSON and convert it to Excel parsable JSON
import json
def get_layers(data):
return data[1][6]
def get_items(data):
return data[12][0][13][0]
def parse_item(item):
output = {"latitude": item[1][0][0][0],
@compustar
compustar / MergeWorksheets.vb
Created February 1, 2020 09:34
VBA to merge Excel Worksheets
Sub Macro3()
'
' Macro3 Macro
'
newSheetName = "MergedSheet"
On Error Resume Next
Sheets(newSheetName).Select
If ActiveSheet.Name <> newSheetName Then
@compustar
compustar / NumberAsText.vb
Created December 31, 2019 06:42
Convert numbers to words for check/cheque printing
'
' A VBA macro to convert numbers to words for check/cheque printing
'
' Credit to Rick Rothstein (https://answers.microsoft.com/en-us/profile/1479b918-5537-45b1-a709-6c4bae9d7da4)
' Original reference: https://answers.microsoft.com/en-us/office/forum/office_2003-excel/convert-numers-to-words-for-checkcheque-printing/5a88ab46-4211-464f-8358-d196408f3ea5
'
' A1: 123.45
' In B1:
' =NumberAsText(A1) ==> One Hundred Twenty Three Point Four Five
' =NumberAsText(A1,"And") ==> One Hundred and Twenty Three Point Four Five
import cv2
import numpy as np
import time
# create video capture
filename = "test.mp4"
cap = cv2.VideoCapture(filename)
h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
w = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
@compustar
compustar / embeddings.config
Last active December 11, 2018 07:00
A set of Chinese word embeddings
{
"embeddings": [
{
"tensorName": "三國演義",
"tensorShape": [
3957,
100
],
"tensorPath": "https://gist.githubusercontent.com/compustar/793dce1ea65e26ee38ee97b73e3208b5/raw/f9a32bf3b004145cb011cdb4ce528f12e4370b19/three_kingdoms.tsv",
"metadataPath": "https://gist.githubusercontent.com/compustar/793dce1ea65e26ee38ee97b73e3208b5/raw/f9a32bf3b004145cb011cdb4ce528f12e4370b19/three_kingdoms_meta.tsv"
@compustar
compustar / hugin_stitch.bat
Last active June 16, 2021 12:49
Batch files for Hugin stitching for Mi Sphere or Madv360 with template (https://github.com/pxlartificer/XiaomiMijiaMi-HuginTemplate).
REM Usage: hugin_stitch.bat template-XiaomiMijiaMiJPG.pto IMG_20171231_172305.jpg
@echo off
SET PATH=%PATH%;C:\Program Files\Hugin\bin
FOR %%i IN ("%2") DO (
SET Name=%%~ni
)
pto_gen %2 %2 --output=%Name%_stitched.pto
@compustar
compustar / ChainStream.cs
Last active August 15, 2016 03:10
Streaming Classes
#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2012 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
@compustar
compustar / ping.js
Last active August 3, 2016 04:10
Script to ping a web page to keep AppPool alive
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
// Make the request
http.open("GET", url, false);
http.send();
using System;
using System.Linq;
using System.Text;
public class Program {
public static void Main(string[] args) {
var @base = 16;
var pLength = 4;
var n = (pLength - 1) * 4;
var max = Max(pLength - 1, @base);