Skip to content

Instantly share code, notes, and snippets.

@mbiette
mbiette / example_send_email_with_attachment.py
Created September 24, 2015 17:44
Simple python script to send an email with a csv attached
# coding=utf-8
__author__ = 'Maxime Biette'
conf = {
'from': 'maximebiette@gmail.com',
'to': 'maximebiette+test@gmail.com',
'server': 'smtp.gmail.com',
'port': '587',
'tls': 'yes',
'login': 'maximebiette@gmail.com',
@mbiette
mbiette / CSVToOracle.cs
Created July 29, 2015 17:01
C# Script to dump a CSV to an Oracle Database
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oracle.DataAccess.Client;
using Microsoft.VisualBasic.FileIO;
namespace CSVToOracle
{
@mbiette
mbiette / as400_odbc.py
Last active October 6, 2019 21:54
Connect to an AS/400 (iSeries) using ODBC.
import pyodbc
class CommitMode:
NONE = 0 #Commit immediate (*NONE) --> QSQCLIPKGN
CS = 1 #Read committed (*CS) --> QSQCLIPKGS
CHG = 2 #Read uncommitted (*CHG) --> QSQCLIPKGC
ALL = 3 #Repeatable read (*ALL) --> QSQCLIPKGA
RR = 4 #Serializable (*RR) --> QSQCLIPKGL
class ConnectionType:
@mbiette
mbiette / as400_adodb_xls.txt
Last active June 29, 2019 21:25
Connect to an AS/400 (iSeries) using ADODB in VBA.
Function GetFileContentFromAS400(host As String, iasp as String, library As String, filename As String) As String
Dim myConnect As New ADODB.Connection
Dim rsRecords As New ADODB.Recordset
Dim fileContent As String
With myConnect
If .State = adStateOpen Then
myConnect.Close
End If
.Open "Driver=iSeries Access ODBC Driver;SYSTEM=" + host + ";DATABASE=" + iasp + ";COMPRESSION=1;TRANSLATE=1;"
End With
@mbiette
mbiette / as400_adodb.py
Last active August 29, 2015 14:14
Connect to an AS/400 (iSeries) using ADODB.
import win32com.client
def main(host, iasp, library, file):
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN=('DRIVER=iSeries Access ODBC Driver;SYSTEM='+host+';DATABASE='+iasp+';COMPRESSION=1;TRANSLATE=1;')
conn.Open(DSN) # Will prompt for username/password or connect with Kerberos
rs = win32com.client.Dispatch(r'ADODB.Recordset')
rs.Open("SELECT * FROM "+library+"."+file, conn, 1, 3)
# Get records and fields one by one
@mbiette
mbiette / Monty Hall_.idea_.name
Created July 17, 2014 02:42
Monty Hall game simulation
Monty Hall
@mbiette
mbiette / ical-tzcorrect.py
Created May 7, 2013 08:48
Script to correct the timezone of an ical feed via Google App Engine
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api import urlfetch
class MainHandler(webapp.RequestHandler):
def get(self):
url = ""
result = urlfetch.fetch(url)
if result.status_code == 200:
@mbiette
mbiette / db.py
Last active December 15, 2015 20:59
This really simple script written in Python that send by email job offers published on a RSS feed. (I left the RSS feed that work well with the name of fields I put) It runs every 5 minutes. It downloads a RSS feed with feedparser, put the content in a simple object named offer, track new offers and save them in a pickle file, send an email with…
from offer import offer
import psycopg2
class dbOffer:
def __init__(self,sourcename,host="localhost",port="5432",database="rsstracker",user="rsstracker",password="rsstracker"):
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
self.conn = psycopg2.connect(host=host,port=port,database=database,user=user,password=password)
self.sourcename = sourcename