Skip to content

Instantly share code, notes, and snippets.

View KurtJacobson's full-sized avatar

Kurt Jacobson KurtJacobson

View GitHub Profile
@KurtJacobson
KurtJacobson / halunits.py
Last active May 10, 2017 17:36
Userspace HAL component for LinuxCNC that creates two HAL pins indicating the current G20/G21 state
#!/usr/bin/python
# Author: Kurt Jacobson
# Date: 04/15/17
# Email: kurtcjacobson@gmail.com
# License: GPL
# DESCRIPTION
# Userspace HAL component for LinuxCNC that creates two HAL pins
# indicating the current G20/G21 state
@KurtJacobson
KurtJacobson / colored_log.py
Last active September 29, 2017 12:23
Colored formatter for logging in python. Supports logging to a file without the escape sequences.
#!/usr/bin/env python
# Copyright (c) 2017 Kurt Jacobson
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme id="kcj" _name="KCJ" version="1.0">
<author>Kurt Jacobson</author>
<_description></_description>
<!-- COLORS -->
<color name="comment_color" value="#608b4e"/>
<color name="number_color" value="#b5cea8"/>
<color name="string_color" value="#d69d62"/>
@KurtJacobson
KurtJacobson / grub
Created August 4, 2017 16:37
Auto boot Ubuntu with RTAI
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.4-9-rtai-686-pae"
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KurtJacobson
KurtJacobson / drag.c
Last active March 24, 2023 21:37
Re-positioning Gtk widget with a mouse drag in C and Python
#include <gtk/gtk.h>
// Source:
// http://www.linuxforums.org/forum/programming-scripting/117713-gtk-moving-widget-mouse-post906490.html#post906490
// higher values make movement more performant
// lower values make movement smoother
const gint Sensitivity = 1;
const gint EvMask = GDK_BUTTON_PRESS_MASK | GDK_BUTTON1_MOTION_MASK;
@KurtJacobson
KurtJacobson / hidepyc.py
Last active May 7, 2021 10:26
Simple python script to write .hidden files to hide all the annoying .pyc files in a project directory
#!/usr/bin/env python
# Copyright (c) 2017 Kurt Jacobson
# License: https://kcj.mit-license.org/@2017
import os
import sys
import mimetypes
try:
@KurtJacobson
KurtJacobson / UsefulCommands.md
Last active September 29, 2017 01:37
Random Useful Commands

git

Count number of lines in a git working tree
git diff --shortstat `git hash-object -t tree /dev/null`

Current branch name
git rev-parse --abbrev-ref HEAD

Gets current sort hash
git rev-parse --short HEAD

@KurtJacobson
KurtJacobson / move_widget.py
Created September 23, 2017 04:38
A simple example demonstrating how to move GTK+ widgets with the mouse.
#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class MoveButton(Gtk.Fixed):
def __init__(self):
@KurtJacobson
KurtJacobson / header_bar.py
Last active August 22, 2022 10:25
Custom GTK+ HeaderBar with fullscreen toggle button
#!/usr/bin/env python
# Copyright (c) 2017 Kurt Jacobson
# License: https://kcj.mit-license.org/@2017
import os
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')