This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# run with: python recursive_touch.py <directory_name> | |
# touches all contents of <directory_name>, and recurses into subdirectories. | |
# WARNING! don't run unless you actually intend to do all that touching. | |
# some things, should not be touched. | |
# | |
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; script for automatically overlaying two images, | |
;; for comparison, in gimp. | |
;; | |
;; 1. save the file in your scripts directory | |
;; (/Applications/Gimp.app/Contents/MacOS/Resources/share/gimp/2.0/scripts/ or | |
;; /Users/[user]/Library/Application Support/GIMP/2.8/plug-ins on my mac) | |
;; 2. generate two images to compare | |
;; 3. run: | |
;; bash: /Applications/Gimp.app/Contents/MacOS/gimp-2.8 -b '(script-fu-overlay "image1.pdf" "image2.jpg")' | |
;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
try: | |
from collections.abc import Mapping | |
except ImportError: | |
from collections import Mapping | |
class FibDict(Mapping): | |
"""A FibDict object stores the Fibonnaci sequence, mapping numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by http://ceasarjames.wordpress.com/2011/07/10/the-quadratic-sieve/ | |
# | |
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
try: | |
from collections.abc import Mapping | |
except ImportError: | |
from collections import Mapping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
def is_palindrome(num): | |
palindrome = str(num) | |
return palindrome == palindrome[::-1] | |
def fn(n): | |
max_palindrome = 1 | |
for x in range(n,1,-1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
for b in range(1,500): | |
c = (- b ** 2 + 1000 * b - 500000)/(b-1000) | |
a = (c**2 - b**2)**0.5 | |
if (a+b+c) == 1000 and int(a) == a and a > 0: | |
print a,b,c | |
print a * b * c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
try: | |
from collections.abc import Mapping | |
except ImportError: | |
from collections import Mapping | |
class TriangleDictionary(Mapping): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Serves static files from multiple local directories at a single external url | |
# usage demo: https://gist.github.com/aausch/7348230 | |
# | |
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
from twisted.web.resource import Resource | |
from twisted.web.static import File | |
class StaticFileScanner(Resource): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2013, Alex Ausch | |
# Free to use under attribution license: http://creativecommons.org/licenses/by/2.0/ca/ | |
from twisted.web.resource import Resource | |
from twisted.application import service | |
from StaticFileScanner import StaticFileScanner | |
root = Resource() | |
root.putChild('static', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#from this post: http://www.linuxquestions.org/questions/programming-9/script-to-see-if-a-process-ir-running-if-not-start-it-339618/ | |
open PROS, "ps -ef|grep process |"; | |
while ($line = <PROS>){ | |
unless ($line =~ m/grep/){ | |
exit; | |
} |
OlderNewer