Skip to content

Instantly share code, notes, and snippets.

#Show internet IP
import socket
import urllib2
import re
def get_local():
data = ""
data += str(socket.gethostbyname(socket.gethostname()))
return data
#Return The Internet Time by Swatch
from time import strftime
def internet_time() :
return (int(strftime("%H:%M:%S")[0:2]) + (int(strftime("%H:%M:%S")[3:5]) / 60.0)) / 24.0 * 1000
#Return Free Space of a diwk in % and in size
import string
import win32api
import win32file
def PrintSpaceReport(drive):
sectorsPerCluster, bytesPerSector, numFreeClusters, totalNumClusters = win32file.GetDiskFreeSpace(drive + ":\\")
sectorsPerCluster = long(sectorsPerCluster)
bytesPerSector = long(bytesPerSector)
numFreeClusters = long(numFreeClusters)
#Return a String Calendar formatted
import re, datetime, calendar
def datetoday(day, month, year):
d = day
m = month
y = year
if m < 3:
z = y-1
else:
z = y
#Return Unix Time
import time
def timeunix():
t = time.time()
return str(t)
#what : get the historical value on google finance
#why : A beginnig for a stock analyze program.
import urllib2
import re
from table_parser import *
"""
By bussiere bussiere @at gmail.com
#what :give this program an url from a pciture and it will try to download all the list of existing picture exemple : downloader.py #http://www.example.com/picture01.jpg
#why : some times i've got a link like http://www.example.com/picture01.jpg and i guess that there are more picture of it this program will try #to find them all and download them all
"""
By bussiere : bussiere @at gmail.com
"""
__Author__ ="bussiere"
__Email__ = "bussiere @at gmail.com"
__Titre__ = "downloading a serial list of picture from the web"
#what : Changing the drive of a list of shortcut automatically must be placed in the shortcut directory on the usb key
#why : i've made some shortcut on my usb key for launchy and i had always to change them if on one pc the usb drive was i: on an other it was k: #it was such a pain each time. Now it change all the shortcut automatically.
import sys,glob,re
import pythoncom
from win32com.shell import shell
import win32com
import win32com.client
import string
"""
# send images to a gmail account
#need to apply a patch to work : http://bugs.python.org/file17551/python-email-encoders-base64-str.patch
#bug :
# generator.py", line 155, in _handle_text raise TypeError('string payload expected: %s' % type(payload)) TypeError: string payload expected: <class 'bytes'>
#
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
#imprimer la stack
import traceback
traceback.format_stack()