Skip to content

Instantly share code, notes, and snippets.

@apetrone
apetrone / winpath_startup.py
Last active May 14, 2022 14:51
Set win32 environment variable on startup via python
# This must be run with Administrator privileges in order to set environment variables
# http://code.activestate.com/recipes/55993/, Wolfgang Strobl
import _winreg
import sys
import traceback
import win32gui
import win32api
# this ensures that changes propagate immediately
KeySym sym = XKeycodeToKeysym(display, event.xkey.keycode, event.xkey.state & ShiftMask ? 1 : 0);
XGrabKey(dpy, XKeysymToKeycode(dpy, XK_F1), Mod1Mask, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, XKeysymToKeycode(dpy, XK_F2), Mod1Mask, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
// XK_Tab
// XK_Escape
// move this window back to its original size at 0, 0.
if (ev.type == KeyPress && ev.xkey.keysym == XK_Tab)
@apetrone
apetrone / win_tips.bat
Last active November 11, 2016 19:27
Windows tips
- Determine why Visual Studio is rebuilding a project:
-- add a block to enable debug view output (devenv.exe.config); check DebugView for the reason.
VS2010
<system.diagnostics>
<switches>
<add name="CPS" value="4" />
</switches>
</system.diagnostics>
@apetrone
apetrone / filter_branch.sh
Last active June 25, 2016 22:38
Git Knowledge Base
#!/bin/bash
# Adam Petrone
# May 2012
# USAGE: ./gclean.sh source_repo target_repo source_repo_subfolder git_location
# root/
local_repo=$1
# cerberus
@apetrone
apetrone / bash_aliases
Last active June 2, 2016 14:47
bash_aliases / bash_profile for workstations
alias g='git'
@apetrone
apetrone / aquarium_thermostat.ino
Created January 19, 2014 01:23
aquarium_thermostat
/*
Date: January 2014
Author: Adam Petrone
Aquarium Thermostat
*/
#include <Wire.h>
#include <LiquidCrystal.h>
#include <TinyDHT.h>
#include <OneWire.h>
@apetrone
apetrone / new_years_hat.ino
Last active January 1, 2016 21:19
2014 New Years Hat
/*
Date: December 2013
Author: Adam Petrone
New Year's Hat
*/
#include <Adafruit_NeoPixel.h>
const uint8_t NUM_PIXELS = 16;
const uint8_t PIXEL_DATA_PIN = 3;
@apetrone
apetrone / holiday_lights
Created December 24, 2013 20:51
LPD8806 Holiday Lights
/* So I had 5 meters of LPD8806 lying around with no plans to ever use them.
They will be my holiday lights this year, driven by an Arduino Pro Mini 5v.
Date: December 2013
Author: Adam Petrone
*/
#include <SPI.h>
#include <LPD8806.h>
@apetrone
apetrone / arduino_motor_controller_lightbar
Last active December 24, 2015 20:09
arduino_motor_controller (with red/blue lightbar)
// Arduino-based motor controller
// This was designed to work with a Spektrum AR6200 receiver, but any receiver should work
// with proper calibration and setup of available channels.
#include <Adafruit_NeoPixel.h>
const uint8_t DATA_PIN = 7;
const uint8_t N_PIXELS = 8;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXELS, DATA_PIN, NEO_GRB + NEO_KHZ800);
uint8_t cpix = 0;
int8_t dir = 1;
@apetrone
apetrone / arduino_motor_controller.ino
Last active December 24, 2015 08:49
arduino controller (wip)
// Arduino-based motor controller
// This was designed to work with a Spektrum AR6200 receiver, but any receiver should work
// with proper calibration and setup of available channels.
uint8_t GEAR_INPUT = 5;
uint8_t FLAPS_INPUT = 6;
uint8_t GEAR_OUTPUT = 7;
uint8_t FLAPS_OUTPUT = 8;