Skip to content

Instantly share code, notes, and snippets.

View mriffey's full-sized avatar

Mark Riffey mriffey

  • Fayetteville, Arkansas
View GitHub Profile
@CarlTBarnes
CarlTBarnes / RemoveFileWithAPI.clw
Last active March 21, 2024 17:43
REMOVE() in RTL has bugs and is very slow using ShFileOperation(). My replacement uses API DeleteFile() and sets Clarion ErrorCode() so can replace REMOVE().
!There are a few Remove() things here, what you want is FileApiRemove FUNCTION(STRING Fn2Delete),LONG,PROC
!
!In C8 Clarion REMOVE() was enhanced a second parameter with flags to allow wildcards, recursion, etc
!It was changed from calling API DeleteFile() to use the much more complicated ShFileOperation()
!This makes it much slower and more bug prone
!
!My replacement FileApiRemove() uses API DeleteFile() then sets the Claion Error so it can replace
!an existing REMOVE() in Clarion code. If you are using Remove(FILE) you'll need REMOVE(Name(File))
!or you can create a FileApi2Remove(FILE FileRef) that calls FileApiRemove(FileRef{PROP:Name}) or NAME()
!I named it "FileApiRemove(" so if you are searching "REMOVE(" you'll file it, versus RemoveUsingAPI() would not.
@CarlTBarnes
CarlTBarnes / DateSplit.clw
Last active June 28, 2024 20:11
DateSplit(Date, Month, Day, Year) much faster than calling MONTH() DAY() YEAR() separately
DateSplit PROCEDURE(LONG Date2Split, <*? OutMonth>, <*? OutDay>, <*? OutYear>)
!==========================================================================================================
DateSplit PROCEDURE(LONG Date2Split, <*? OutMonth>, <*? OutDay>, <*? OutYear>)
!Use DateSplit(Today,M,D,Y) instead of M=MONTH(Today) ; D=DAY(Today) ; Y=YEAR(Today)
D1 DATE,AUTO
DG GROUP, OVER(D1)
D BYTE
M BYTE
Y USHORT
END
@fedme
fedme / Run Visual Studio Code for Linux from WSL.md
Last active February 12, 2026 10:57
Run Visual Studio Code for Linux from WSL on Windows 10

Run Visual Studio Code for Linux from WSL

Thanks a lot to mredbishop and others for their insturctions posted here. This is just a recap of what they figured out.

This process was tested on WSL Ubuntu 18.04.

Install VcXsrv on Windows

  1. Dowload the VcXsrv installer from https://sourceforge.net/projects/vcxsrv/
  2. Install the software on Windows

Add VS Code repositories

@jeffbrl
jeffbrl / describe_instances.py
Created February 27, 2018 17:28
How to make datetime.datetime json serializable - boto3 ec2 describe_instances
# Adapted from https://stackoverflow.com/questions/35869985/datetime-datetime-is-not-json-serializable
import datetime
import json
import boto3
def datetime_handler(x):
if isinstance(x, datetime.datetime):
return x.isoformat()
@cvan
cvan / webgl-detect-gpu.js
Last active February 16, 2026 10:15
use JavaScript to detect GPU used from within your browser
var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;
try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
}
import os
import io
from gzip import GzipFile
from urllib.parse import urlparse
import requests
import boto3
# ~18.4MB compressed
@wh13371
wh13371 / output.debug.string.py
Last active October 3, 2024 07:52
python - logging to DbgView with OutputDebugString
#! /usr/bin/python
import logging
import ctypes
# output "logging" messages to DbgView via OutputDebugString (Windows only!)
OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW
class DbgViewHandler(logging.Handler):
def emit(self, record):
@fdanelyan
fdanelyan / generate_html.py
Created April 18, 2014 07:34
Generate HTML from python and open it on default browser
# write-html.py
import webbrowser
import os
print ()
f = open('helloworld.html','w')
message = """<html>
<head></head>
<body><p>Hello World!</p></body>
</html>"""
@turicas
turicas / email_utils.py
Last active May 4, 2025 16:44
Send emails easily in Python (with attachments and multipart)
#!/usr/bin/env python
# coding: utf-8
# This little project is hosted at: <https://gist.github.com/1455741>
# Copyright 2011-2020 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
import os
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText