Skip to content

Instantly share code, notes, and snippets.

@xeor
xeor / asus.py
Created December 19, 2016 20:41
Basic asus-router webscraping base
#!/usr/bin/env python
import requests
import xml.etree.ElementTree as ET
class InvalidRequestException(Exception):
pass

Keybase proof

I hereby claim:

  • I am xeor on github.
  • I am xeor (https://keybase.io/xeor) on keybase.
  • I have a public key ASB0Vd__o-uW0qnIt9EUAK6jkssnx5GtgQUaTHQJJ9drqQo

To claim this, I am signing this object:

@xeor
xeor / gist:631c0b0b29c5d80074bb
Created January 28, 2016 11:22
A tiny confluence user-macro to set a page property based on the output of another macro
## Macro title: Add macro output as property
## Macro has a body: Y
## Body processing: Convert macrooutput to page property. Visible in example bobswift's "run" macro as %property_varname%
## Output: Variable
##
## Developed by: Lars Solberg
## Date created: 25/01/2016
## Installed by: Lars Solberg
## @param Name:title=Name|type=string|required=true|desc=Name of property to create
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler()) # Defaulting to null output in case Caculator class is imported
logging.basicConfig(filename='/error.log', filemode='a', level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
@xeor
xeor / rsync.sh
Created October 30, 2015 19:01
rsync backup with rules fule
#!/bin/bash
RSYNC="/usr/bin/rsync"
mydir=$(cd $(dirname $0);pwd)
todir="/backup"
cat "${mydir}/rules" | grep ^[+-] | $RSYNC -v -azr -T "${mydir}/tmp" --include-from=- / server:${todir}
@xeor
xeor / mydir.sh
Created October 29, 2015 08:39
Store the scripts folder in a variable
#!/bin/bash
# Finding out which script-folder your bash-script runs in can be problematic.
# Here is a quick solution that tries to be cross-platform and support every odd-cases. Like if your script is runned via a symlink.
mydir=$(cd $(dirname $(readlink -f "${BASH_SOURCE:-$0}"));pwd)
cd ${mydir}
@xeor
xeor / gist:285f3a0d56d3ff93a558
Created January 9, 2015 22:59
breadcrumb.scss
$breadcrumb-color: rgb(70, 70, 90);
$breadcrumb-lighten-by: 8;
.breadcrumb {
font: 18px Helvetica, Arial, Sans-Serif;
list-style: none;
overflow: hidden;
li {
float: left;
@xeor
xeor / gist:2a0de36f7d686448408a
Created October 29, 2014 21:31
Set this as middleware in your Django app if you need to get reverse urls to work, and dont access Django on port 80 or 443 (as is often the case on developer environments (specially using Docker))
import os
class ServerURLWithPortHackMiddlware(object):
"""
A way to set HTTP_HOST to HTTP_HOST + (a port number).
This is usefull when you want to run Django on your local computer as a
developer server. Example in Docker.
Django doesn't know which PORT you are using all the way to the browser,
@xeor
xeor / markdown2evernote.rb
Created October 3, 2012 21:54 — forked from kopischke/markdown2evernote.rb
OS X service scripts
#!/usr/bin/env ruby -wKU
# Adapted from Brett Terpstra’s original “Markdown to Evernote” service (http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/)
# Martin Kopischke 2011 – License: Creative Commons Attribution Share-Alike (CC BY-SA) 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/)
# Changes: – create only one Evernote note per (Multi)Markdown input passed (instead of one per line)
# – do not choke on shell escape characters (use Tempfile instead of shell pipe for osascript)
# – default to MultiMarkdown 3 executable (instead of MMD 2 Perl script)
# – make smart typography processing optional (set SMARTY to 'false' to bypass processing;
# note smart typography cannot be disabled in MMD 3.0 and 3.0.1
# – handle both smart typography processing scripts (ie. SmartyPants.pl)