Skip to content

Instantly share code, notes, and snippets.

@sgornick
sgornick / open_exclusively.pas
Created August 14, 2023 23:15
Hold a file open exclusively, not even accessible for reading (Python)
Hold a file open exclusively, not even for reading (PowerShell)import os, win32file
while True:
try:
filename_and_path = input("Enter filename and path for the file to hold open exclusively: ")
if not os.path.isabs(filename_and_path):
# If relative path, convert it to an absolute path
filename_and_path = os.path.abspath(filename_and_path)
if os.path.exists(filename_and_path):
break
@sgornick
sgornick / OpenExclusively.ps1
Last active August 14, 2023 23:19
Hold a file open exclusively, not even accessible for reading (PowerShell)
# Open the file in exclusive mode
while ($true) {
try {
$filenameAndPath = Read-Host "Enter filename and path for the file to hold open exclusively"
if ([string]::IsNullOrEmpty($filenameAndPath)) {
Write-Host "No filename was entered. Please provide a valid filename."
continue
}
if (-not [System.IO.Path]::IsPathRooted($filenameAndPath)) {
@sgornick
sgornick / keybase.md
Created January 21, 2021 03:10
Keybase Proof

Keybase proof

I hereby claim:

  • I am sgornick on github.
  • I am sgornick (https://keybase.io/sgornick) on keybase.
  • I have a public key ASBzLPO33xyBaO07kNG_goZWSMwVGfx1ORsnX04d0IMpBAo

To claim this, I am signing this object:

@sgornick
sgornick / bash-cheatsheet.sh
Created February 24, 2017 01:54 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class