Skip to content

Instantly share code, notes, and snippets.

import urllib3
from bs4 import BeautifulSoup
from dateutil import parser
my_date = '26/05/2016'
dt = parser.parse(my_date)
url_to_scrape = "http://www.analogman.com/kotdelay.htm"
http = urllib3.PoolManager()
@hybridjosto
hybridjosto / excel.py
Created April 20, 2014 10:00
is excel open? if not open it!
from win32com.client import Dispatch
import subprocess
import socket_client
def openExcel(workbook):
xl = Dispatch("Excel.Application")
xl.visible = True
wb = xl.Workbooks.Open(workbook)
def checkOpenApp(appname):
@hybridjosto
hybridjosto / dcsdba.ahk
Created April 20, 2014 09:56
sql developer shortcuts
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive, Oracle SQL Developer
::header ::dcsdba.order_header oh
::line ::dcsdba.order_line ol
@hybridjosto
hybridjosto / SaveTheTrees.py
Created April 20, 2014 09:45
saves folder structure to json file allowing it to be recovered
#! /usr/bin/env python
import os
import json
import time
def listFolders(folderpath):
"""
Iterates through the child folders of folderpath
and adds items to a list object.
@hybridjosto
hybridjosto / outlookReg.py
Created April 20, 2014 09:40
change outlook Registry settings in python
import _winreg
outlook_security = _winreg.OpenKey(
_winreg.HKEY_CURRENT_USER,
"Software\\Policies\\Microsoft\\office\\12.0\\Outlook\\Security"
)
settings = {'PromptOOMItemPropertyAccess':2,
'PromptOOMSend' : 2,
'PromptOOMAddressBookAccess' : 2,
#! /usr/bin/env python
import os
import json
import time
def listFolders(folderpath):
"""
Iterates through the child folders of folderpath
and adds items to a list object.
@hybridjosto
hybridjosto / messageServer.py
Created April 2, 2014 06:19
message Server
import socket
import sys
PORT = 8000
IP = '197.168.1.67'
serversocket = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@hybridjosto
hybridjosto / messageClient.py
Created April 2, 2014 06:19
Message Server
import socket
from time import strftime
IP = "192.168.1.67"
PORT = 8000
MESSAGE = "Hi there!"
def sendMessage(message, ip_address=IP, port=PORT):
message = strftime("%Y-%m-%d %H:%M:%S") + message
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@hybridjosto
hybridjosto / fiscCal.py
Created February 21, 2014 14:12
fiscal calendar functions
from datetime import *
# date, timedelta
week = {
0: 1, # remap so Sunday = 0
1: 2,
2: 3,
3: 4,
4: 5,
5: 6,
@hybridjosto
hybridjosto / sql-dicts join.py
Last active August 29, 2015 13:56
python sql-dictionary join
#!/usr/bin/env
# goal is to use the dictionary and return the value
# using the key in a sql statement.
# eg instead of having this table in the DB we can hack it in
# even import it from excel.
import sqlite3