Skip to content

Instantly share code, notes, and snippets.

View danmichaelo's full-sized avatar

Dan Michael O. Heggø danmichaelo

View GitHub Profile
@danmichaelo
danmichaelo / gist:3041116
Created July 3, 2012 17:14
mwclient patch to add upload comment
Index: client.py
===================================================================
--- client.py (revision 107)
+++ client.py (working copy)
@@ -348,7 +349,7 @@
def upload(self, file = None, filename = None, description = '', ignore = False, file_size = None,
- url = None, session_key = None):
+ url = None, session_key = None, comment = ''):
@danmichaelo
danmichaelo / gist:3074759
Created July 9, 2012 07:14
mwclient patch to edit sections
Index: page.py
===================================================================
--- page.py (revision 107)
+++ page.py (working copy)
@@ -1,3 +1,4 @@
+#vi:noexpandtab
import client, errors, listing
import compatibility
from page_nowriteapi import OldPage
@@ -10,6 +11,7 @@
@danmichaelo
danmichaelo / gist:4095879
Created November 17, 2012 13:12
Powershell basics
$shell = new-object -com shell.application
$shell2 = new-object -com wscript.shell
# Display members of the shell.application object
$shell | get-member
foreach ($o in $shell.windows()) {
#Write-Host ($o.LocationName + " :: " + $o.LocationUrl)
if ($o.Name -eq "Windows Internet Explorer" -and $o.Visible) {
$winTitle = $o.Document.Title + " - " + $o.Name
@danmichaelo
danmichaelo / gist:4593233
Last active December 11, 2015 11:19
html: simple document
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Untitled</title>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6/html5shiv.min.js"></script>
<![endif]-->
@danmichaelo
danmichaelo / gist:5093843
Created March 5, 2013 20:12
python: matplotlib: validate backends
# Source: http://stackoverflow.com/a/13731150
from pylab import *
import time
import matplotlib.backends
import matplotlib.pyplot as p
import os.path
def is_backend_module(fname):
@danmichaelo
danmichaelo / gist:5171031
Last active December 15, 2015 00:09
Enkelt script som starter en SNetTerm-instans mot BIBSYS og går gjennom alle ordrene for en gitt enhet eller fagkode.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
window.moveTo(1000,0);
window.resizeTo(600, 400);
</script>
<HTA:APPLICATION id="minimalHTA" />
<title>Ordresøk</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@danmichaelo
danmichaelo / gist:5322607
Last active December 15, 2015 20:59
php: curl
<?php
// Request URL
$url = 'http://www.google.com/';
// HTTP headers
$headers = array(
//'Content-Type: application/json',
//'Accept: application/json',
);
@danmichaelo
danmichaelo / gist:5468291
Last active December 16, 2015 17:09
Minimal example HTA causing memory leak in SNetTerm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal test</title>
</head>
<body onload="start_snt()">
<div id="status"></div>
<?php
// Config
$dest_host = 'bash.org';
$proxy_base_url = '/';
$proxied_headers = array('Set-Cookie', 'Content-Type', 'Cookie', 'Location');
//canonical trailing slash
$proxy_base_url_canonical = rtrim($proxy_base_url, '/ ') . '/';
@danmichaelo
danmichaelo / gist:5603581
Created May 18, 2013 07:37
Python: logging
import logging
import logging.handlers
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('[%(asctime)s %(levelname)s] %(message)s')
mailfrom='<mail>'
mailto='<mail>'
smtp_handler = logging.handlers.SMTPHandler(mailhost=('localhost', 25),
fromaddr=mailfrom, toaddrs=mailto,