Skip to content

Instantly share code, notes, and snippets.

View wiesson's full-sized avatar

Arne Wiese wiesson

View GitHub Profile
@wiesson
wiesson / frontend.html
Last active August 29, 2015 13:56
XMLHttpRequest "DELETE" call to the flask backend. No jquery is required.
<button id="deleteDevice" class="btn btn-danger btn-xs"
data-link="{{ url_for('monitor.delete_device', id_device=device.id_device) }}">
<span class="glyphicon glyphicon-remove-circle"></span>
Delete Device
</button>
<script type="text/javascript">
var t = document.getElementById('deleteDevice');
t.addEventListener('click', function () {
deleteDevice(t.dataset.link);
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
# !/usr/bin/env python
import os
import argparse
from app import create_app
from flask.ext.script import Manager
parser = argparse.ArgumentParser()
parser.add_argument("go", help="runserver, test, shell")
import arrow
print(tarrow.utcnow().replace(days=-1))
# 2014-10-06T12:09:34.152402+00:00
print(tarrow.utcnow().replace(months=-1))
# 2014-09-13T12:09:34.152573+00:00
print(tarrow.utcnow().replace(months=-3))
# 2014-07-13T12:09:34.152685+00:00
@wiesson
wiesson / functions.php
Last active August 29, 2015 14:17
Super simple responsive Wordpress gallery approach
function responsiveImages($string, $attr) {
$output = "<div id=\"responsive-gallery-test\">";
$posts = get_posts(array('include' => $attr['ids'], 'post_type' => 'attachment'));
foreach ($posts as $image) {
$output .= "<img data-img-small='" . wp_get_attachment_image_src($image->ID, 'thumbnail')[0] . "'" .
" data-img-medium='" . wp_get_attachment_image_src($image->ID, 'medium')[0] . "''" .
" data-img-large='" . wp_get_attachment_image_src($image->ID, 'large')[0] . "''" .
" data-img-full='" . wp_get_attachment_image_src($image->ID, 'full')[0] . "'/>";
}
@wiesson
wiesson / get_attachment_from_eml.py
Created May 12, 2015 12:06
Separate attachments from mails files (*.eml) with Python 2/3
import glob
import email
if __name__ == '__main__':
files = glob.glob("/Users/wiesson/Downloads/mails/*.eml")
for each in files:
msg = email.message_from_file(open(each))
attachments = msg.get_payload()
for attachment in attachments:
try:
Game.goldenCookie.spawn();
var clickNormalCookie = setInterval(function(){ $('#bigCookie').click() }, 1);
var clickGoldenCookie = setInterval(function(){ Game.goldenCookie.time = Game.goldenCookie.maxTime; Game.goldenCookie.click(); }, 5);
// clear setInterval
clearInterval(clickNormalCookie);
clearInterval(clickGoldenCookie);
(moment('2015-04-25').add(6, 'months')).diff(moment(), 'days')
@wiesson
wiesson / functions.php
Last active October 22, 2015 08:31
Responsive Wordpress Background Images
add_image_size('img-l', 1024, 702);
add_image_size('img-m', 768, 372);
add_image_size('img-s', 480, 320);
add_image_size('img-xs', 320, 200);
/**
* Get WP Attachment as responsive background image
* @param int $id
* @return string
*/
@wiesson
wiesson / README.md
Last active December 13, 2015 19:13 — forked from dwtkns/README.md
Faux-3d Shaded Globe

Faux-3d SVG globe using d3.geo.orthographic and a few radial gradients. Labels offset or hidden based on radians from current map center to enhance the effect.

Uncomment svg.append("g").attr("class","countries") for hover-able country outlines.