Skip to content

Instantly share code, notes, and snippets.

@pckujawa
pckujawa / multilayerPerceptron.py
Created September 27, 2013 16:56
Copied from http://arctrix.com/nas/python/bpnn.py. Example of an artificial neural network.
# Back-Propagation Neural Networks
#
# Written in Python. See http://www.python.org/
# Placed in the public domain.
# Neil Schemenauer <nas@arctrix.com>
import math
import random
import string
@pckujawa
pckujawa / unzipall.bat
Created September 19, 2013 21:35
Unzip all zip files in this directory (or all dirs, recursively) and optionally delete the zip file when done. Uses 7zip.
:: To actually include the path expansion character (tilde), I had to give valid numbers; see http://ss64.com/nt/rem.html for bug reference. Also, try call /? for more info.
@REM The %~n0 extracts the name sans extension to use as output folder. If you need full paths, use "%~dpn0". The -y forces overwriting by saying yes to everything. Or use -aoa to overwrite.
@REM Using `x` instead of `e` maintains dir structure (usually what we want)
:: If you want recursive, use FOR /R
@FOR %%a IN (*.zip) DO @(
@if [%1] EQU [/y] (
@7z x "%%a" -o"%%~dpna" -aoa
) else if [%1] EQU [/yd] (
@7z x "%%a" -o"%%~dpna" -aoa
@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
#-------------------------------------------------------------------------------
# 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
#-------------------------------------------------------------------------------
# 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
@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
@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 / 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: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