Skip to content

Instantly share code, notes, and snippets.

View richard087's full-sized avatar

Richard C richard087

  • Melbourne, Australia
View GitHub Profile
@richard087
richard087 / phi3-strictjson-test.ipynb
Last active May 1, 2024 05:50
phi3-strictjson-test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@richard087
richard087 / run_CP2077_patches.ps1
Last active June 28, 2023 12:33
USE AT OWN RISK! A collection of functions to make it easier to manage Cyberpunk 2077 mods. This is NOT a mod manager. You will need to understand how to use/manage Subversion to get any value from this.
# install SVN
# tested with Slik SVN 1.14.2 from https://sliksvn.com/download/
#CONFIGURATION
#where should Subversion store its data?
$svn_data = "D:\Temp\repo"
#where will your downloaded mod files be kept?
$dir_download = "$env:USERPROFILE\Downloads"
@richard087
richard087 / T-SQL-ABN-validation-test.sql
Last active August 28, 2020 18:23
Validate Australian Business Number (ABN) in T-SQL for SQL Server WHERE clause, including test cases
select * from (
select '43077535605' as abn, 1 as correct
union all
select '33 102 417 032' as abn, 1 as correct
union all
select '29002589460' as abn, 1 as correct
union all
select '33 102 417 032asdfsf' as abn, 0 as correct
union all
select '444' as abn, 0 as correct
@richard087
richard087 / T-SQL-ACN-validation-test.sql
Last active August 28, 2020 18:08
Validate Australian Company Number (ACN) in T-SQL for SQL Server WHERE clause, including test cases
select * from (
select '000 000 019' as acn, 1 as correct
union all
select '009 749 964' as acn, 1 as correct
union all
select '006 999 980' as acn, 1 as correct
union all
select '005999977' as acn, 1 as correct
union all
select '000 000 019asdfsf' as acn, 0 as correct
@richard087
richard087 / MySql-ACN-validation-test.sql
Last active August 28, 2020 17:57
Validate Australian Company Number (ACN) in MySql 5.7 WHERE clause, including test cases
select * from (
select '000 000 019' as acn, 1 as correct
union all
select '009 749 964' as acn, 1 as correct
union all
select '006 999 980' as acn, 1 as correct
union all
select '005999977' as acn, 1 as correct
union all
select '000 000 019asdfsf' as acn, 0 as correct
@richard087
richard087 / MySql-ABN-validation-test.sql
Last active August 28, 2020 17:12
Validate Australian Business Number (ABN) in MySql 5.7 WHERE CLAUSE, including unit tests.
select * from (
select '43077535605' as abn, 1 as correct
union all
select '33 102 417 032' as abn, 1 as correct
union all
select '29002589460' as abn, 1 as correct
union all
select '33 102 417 032asdfsf' as abn, 0 as correct
union all
select '444' as abn, 0 as correct
@richard087
richard087 / forking-tiny-web-server.pl
Last active March 14, 2019 23:16
Forking tiny HTTP server in perl. Compatible with almost any perl v5 - very handy with git bash on Windows.
#!/usr/bin/env perl
# forking tiny HTTP server
# a toy web server
# thanks to
# keiya_21@yahoo.co.jp - https://gist.githubusercontent.com/keiya/2782414/raw/811565ccfa479a9e12d0653e2f5118e68e7fda37/server.pl
use strict;
use warnings;
@richard087
richard087 / tokenReplace.bat
Last active April 15, 2024 09:53
Batch file to do a token replacement on a text file, in Windows.
@echo off
rem sourced from http://stackoverflow.com/questions/5273937/how-to-replace-substrings-in-windows-batch-file
setlocal enabledelayedexpansion
set INTEXTFILE=test.txt
set OUTTEXTFILE=test_out.txt
set SEARCHTEXT=bath
set REPLACETEXT=hello
set OUTPUTLINE=
for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
# described at http://lastinfinitetentacle.blogspot.com.au/2013/06/viewing-d-link-dcs-932l-ip-camera-from.html
avconv -r 15 -f mjpeg -i http://USERNAME:PASSWORD@IP-ADDRESS/video.cgi -i http://USERNAME:PASSWORD@IP-ADDRESS/audio.cgi -vcodec mpeg4 -f mpegts file:///dev/stdout | vlc file:///dev/stdin
# silent version
avconv -r 15 -f mjpeg -i http://USERNAME:PASSWORD@IP-ADDRESS/video.cgi -vcodec mpeg4 -f mpegts file:///dev/stdout | vlc file:///dev/stdin
// hosted at http://lastinfinitetentacle.blogspot.com.au/2011/10/csv-parser-in-javascript.html
var textToArray = function (txtLine, del, txtQual) {
"use strict";
var datArr = [], newStr = "";
while (txtLine.length > 0) {
if (txtLine.substr(0, txtQual.length) === txtQual) {
// get quoted block
newStr = txtLine.substr(0, txtQual.length + txtLine.indexOf(txtQual, txtQual.length));
datArr.push(newStr.substr(txtQual.length, newStr.length - txtQual.length * 2));
}