Skip to content

Instantly share code, notes, and snippets.

@jcraig77
jcraig77 / idle.py
Created January 13, 2015 16:08
A python script that monitors idle time on a Windows machine. After the idle threshold is hit, windows media player is started and it plays a playlist. After the playlist is finished or when the operating system is no longer idle, the windows media player is killed.
''' A python script that monitors idle time on a Windows machine.
After the idle threshold is hit, windows media player is started
and it plays a playlist. After the playlist is finished or when the
operating system is no longer idle, the windows media player is killed. '''
from ctypes import Structure, windll, c_uint, sizeof, byref
import subprocess
import time
# how long before the playlist should begin
@jcraig77
jcraig77 / gist:74d415784d17f3130845
Last active August 29, 2015 14:20
Write a program that outputs all possibilities to put +, - or nothing between the numbers 1, 2...9 (in this order) such that the result is always 100. For example, 1+2+34-5+67-8+9
from math import pow
def find_all_numbers():
# this is the loop of numbers 1,2...9
for x in range(1, 10):
# build a dict with each number as a key;
# 1: [1, 12, 123, ...]
numbers[x] = []
# loop to increase multiplier which is a power of 10;
# 1*10^0, 1*10^1, ...