Skip to content

Instantly share code, notes, and snippets.

@pckujawa
pckujawa / gist:2870718
Created June 4, 2012 20:35
Hotkey controls for various music services (Pandora, Napster, Spotify, etc)
;
;#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;
; ############## Pandora ##############
; Ctrl+Forward -> next song
; Play/Pause -> play/pause
;
@pckujawa
pckujawa / gist:2919894
Created June 12, 2012 20:19
Quick backup of environment variables (including PATH) in windows
cmd /k "date /t >> envvars.txt && time /t >> envvars.txt && set >> envvars.txt"
@pckujawa
pckujawa / gist:2950232
Created June 18, 2012 19:29
Helper class for efficiently invoking tasks with timeout
#region (c)2009-2011 Lokad - New BSD license
// Copyright (c) Lokad 2009
// Company: http://www.lokad.com
// This code is released under the terms of the new BSD licence
#endregion
#if !SILVERLIGHT2
@pckujawa
pckujawa / copyToNonexistentFiles.bat
Created August 10, 2012 19:16
Windows batch script to copy a file to multiple output files if they don't already exist
@if "%1"=="" (
@echo Usage: %0 sourceFile file1 [file2 file3 ...]
goto :eof
)
@set sourceFile=%1
@shift
:parseparams
@if [%1] neq [] (
@if not exist %1 echo F | xcopy %sourceFile% %1 /F /-Y
REM If you don't want the prompts displayed onscreen, use the next line instead (but it won't show the paths of the files copied)
@pckujawa
pckujawa / gist:3916480
Created October 19, 2012 06:14
Value iteration in grid world for AI
#-------------------------------------------------------------------------------
# Author: Pat Kujawa
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import numpy as np
from pprint import pprint, pformat
class Cell(object):
def __init__(self):
self.is_terminal = False
@pckujawa
pckujawa / gist:3957444
Created October 26, 2012 07:37
Active and passive temporal difference learning in grid world for AI
#-------------------------------------------------------------------------------
# Author: Pat Kujawa
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import numpy as np
import random
from collections import defaultdict
from pprint import pprint, pformat
#-------------------------------------------------------------------------------
# Purpose: Coffee cooling simulation
# Author: Pat (Hecuba)
#-------------------------------------------------------------------------------
#!/usr/bin/env python
from pprint import pprint, pformat
## Coffee cooling
# Start at 90 C, target temp is 75 C
# Cream drops temp 5 C immediately
#-------------------------------------------------------------------------------
# Purpose:
# Author: Pat
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import math
import numpy as np
import pylab as pl
from pprint import pprint, pformat
#-------------------------------------------------------------------------------
# Purpose:
# Author: Pat
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import math
import numpy as np
import pylab as pl
from pprint import pprint, pformat
@pckujawa
pckujawa / comparison of integrators for SHO sim.py
Last active December 11, 2018 16:05
Runge-Kutta, Euler-Richardson midpoint, and Euler methods compared for a simple harmonic oscillator simulation.
#-------------------------------------------------------------------------------
# Purpose:
# Author: Pat
#-------------------------------------------------------------------------------
#!/usr/bin/env python
from __future__ import division
import math
import numpy as np
import pylab as pl