Skip to content

Instantly share code, notes, and snippets.

@Achifaifa
Achifaifa / card.py
Created July 18, 2014 16:45
This code reads and displays data from Spanish social security magnetic cards.
#!/usr/bin/env python
import os, sys, termios, tty
def getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(33)
finally:
@Achifaifa
Achifaifa / muncher.py
Created July 10, 2014 17:06
Small script for product photography sessions with hundreds of files. Take photo, note the number (DSC_XXXX.nef), and add the product name and the weight (Requirements for this particular assignment). run [python this_file.py reference_file], and all the photos will be renamed to product_(weight kg).nef. Fiddling a lite with the code allows to w…
#! /usr/bin/env python
import os, sys
if __name__=="__main__":
try: os.chdir(os.path.dirname(__file__))
except OSError: pass
filepath="./"+sys.argv[1]
with open (filepath,"r") as listfile:
for line in listfile:
for filename in os.listdir("./"):
@Achifaifa
Achifaifa / comas.py
Created July 9, 2014 16:31
Simple file to automatically add commas to MySQL .csv dumps. Use python comas.py [filename]. CSV file must be in the same directory. Output in ./comas_out
#! /usr/bin/env python
import sys
if __name__=="__main__":
try:
path="./"+sys.argv[1]
except:
print "Use: python comas.py [filename]"
print "Wrong syntax or file not found"