Skip to content

Instantly share code, notes, and snippets.

// Simple single player tic-tac-toe in C
// Computer player uses minimax algorithm and has adjustable skill
// by introducing randomness.
// MurphyMc @ github, 2023
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <stdbool.h>
@MurphyMc
MurphyMc / load_psf_2.c
Last active January 8, 2023 19:04
rfbLoadConsoleFont() replacement for better Linux PSF console font file support in libvncserver
// rfbLoadConsoleFont()'s documentation says that it loads a Linux console
// font, but this is only kind of true. It's limited to loading 256 glyphs,
// which... okay. It's also limited to fonts which are 8x16, which many are.
// More annoyingly, however, it can't actually load from a PSF font file used
// by Linux console fonts, since it doesn't account for the header. In many
// cases, this means that just skipping the first four bytes would make it
// work (it would have been nice if there were just a parameter to tell it
// to do this, or if there was a version you could give a prepared FILE *).
// This function *does* actually load from a PSF file. It wouldn't be too
// hard to make it support v2, but it currently only supports v1 (however,
@MurphyMc
MurphyMc / rfb_cursor.c
Created January 8, 2023 09:13
Creates a nice cursor for libvncserver
static void init_cursor (rfbScreenInfoPtr rfbScreen)
{
char * cursor =
"X "
"XX "
"X X "
"X X "
"X X "
"X X "
"X X "
@MurphyMc
MurphyMc / loadPSF.c
Created January 8, 2023 06:57
rfbLoadConsoleFont() replacement for better Linux PSF console font file support in libvncserver
// rfbLoadConsoleFont()'s documentation says that it loads a Linux console
// font, but this is only kind of true. It's limited to loading 256 glyphs,
// which... okay. It's also limited to fonts which are 8x16, which many are.
// More annoyingly, however, it can't actually load from a PSF font file used
// by Linux console fonts, since it doesn't account for the header. In many
// cases, this means that just skipping the first four bytes would make it
// work (it would have been nice if there were just a parameter to tell it
// to do this, or if there was a version you could give a prepared FILE *).
// This function *does* actually load from a PSF file. It wouldn't be too
// hard to make it support v2, but it currently only supports v1 (however,
@MurphyMc
MurphyMc / pox-pydoc.diff
Created March 21, 2020 23:42
diff between original pydoc.py circa August 2011 and pox-pydoc.py
--- pydoc.py 2020-03-21 16:30:43.000000000 -0700
+++ pox-pydoc.py 2020-03-21 16:39:25.000000000 -0700
@@ -44,6 +44,9 @@
Richard Chamberlain, for the first implementation of textdoc.
"""
+import sys
+sys.path.append('..')
+
# Known bugs that can't be fixed here:
@MurphyMc
MurphyMc / git_cola_icon_stage_unstage.diff
Created April 24, 2018 06:22
Patch git-cola so that clicking icon toggles staged/unstaged
diff --git a/orig.status.py b/usr/share/git-cola/lib/cola/widgets/status.py
index 4761228..852c057 100644
--- a/orig.status.py
+++ b/usr/share/git-cola/lib/cola/widgets/status.py
@@ -786,6 +786,23 @@ class StatusTreeWidget(QtWidgets.QTreeWidget):
"""Called when an item is double-clicked in the repo status tree."""
cmds.do(cmds.StageOrUnstage)
+ def mousePressEvent(self, event):
+ """Handle clicks on icon"""
@MurphyMc
MurphyMc / superdrive_enable.py
Created February 11, 2018 04:28
Enables Apple USB SuperDrive on 64 bit Linux
"""
Enables Apple USB SuperDrive on 64 bit Linux
.. when you have no C compiler or Internet connection
"""
from ctypes import *
from fcntl import *
from os import *
import sys
m = (c_ubyte * 7)()
@MurphyMc
MurphyMc / arp_helper.py
Created November 22, 2017 20:34
Proposed new arp_helper
# Copyright 2011,2012,2013,2017 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# Copyright 2015 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# Copyright 2015 James McCauley
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,