Skip to content

Instantly share code, notes, and snippets.

View kostasdizas's full-sized avatar

Kostas Dizas kostasdizas

  • Torstone Technology
View GitHub Profile
@kostasdizas
kostasdizas / custom.css
Created January 13, 2016 14:13
ipython stylesheet from http://blog.henryhhammond.com/theming-ipython/ -- ~/.jupyter/custom/custom.css
@import url('http://fonts.googleapis.com/css?family=Crimson+Text');
@import url('http://fonts.googleapis.com/css?family=Kameron');
@import url('http://fonts.googleapis.com/css?family=Lato:200,300,400');
@import url('http://fonts.googleapis.com/css?family=Source+Code+Pro');
/* Change code font */
.CodeMirror pre {
font-family: 'Source Code Pro', Consolas, monocco, monospace;
}
@kostasdizas
kostasdizas / bootstrap_paginate.php
Created December 18, 2015 10:55
A quick and dirty fork of Wordpress' paginate_links function, modified to output HTML code compliant with the Bootstrap Pagination component.
<?php
/**
* A quick and dirty fork of Wordpress' paginate_links function, modified to output HTML code
* compliant with the Bootstrap Pagination component.
*
* @global WP_Query $wp_query
* @global WP_Rewrite $wp_rewrite
*
* @param string|array $args {
* Optional. Array or string of arguments for generating paginated links for archives.
@kostasdizas
kostasdizas / eight_queens.py
Last active December 25, 2016 22:51
A pythonic way to solve the eight queens problem
from itertools import permutations
def x_queens(n=8):
columns = range(n)
total = 0
b = ['-'] * n
for arrangement in permutations(columns):
if (n == len(set(arrangement[c] + c for c in columns)) == len(set(arrangement[c] - c for c in columns))):
total += 1
print("\n".join(["".join(['Q' if x==i else '-' for i in columns]) for x in arrangement]), end = "\n\n")
@kostasdizas
kostasdizas / origami.py
Created October 15, 2015 13:10
Origami Tools
# required paper dimensions for bar money envelope based on desired content size
# (a,b) are the dimensions of the resulting envelope
# the function will return the required paper size
# follow instructions on origami bar envelope to fold it.
# example £20 is 15x8 (maybe add a few millimeters as margin (15.4, 8.4))
# >>> xy(15.4, 8.4)
# (22.12, 26.88)
xy = lambda a, b: ( round(a + 1/4 * (16/5 * b), 2), round(16/5 * b, 2))
@kostasdizas
kostasdizas / README.md
Last active September 12, 2015 22:47
IMAP mailbox count dashing.io widget

Description

Dashing widget to display the number of unread emails in an IMAP mailbox.

##Usage

To use this widget, copy mailchecker.coffee, mailchecker.html, and mailchecker.scss into the /widgets/mailchecker directory. Put the mailchecker.rb file in your /jobs folder.

To include the widget in a dashboard, add the following to your dashboard layout file:

@kostasdizas
kostasdizas / README.md
Last active December 21, 2018 13:16 — forked from mjamieson/README.md
forecast.io for Dashing

Description

Dashing widget to display weather from forecast.io.

##Usage

To use this widget, copy forecast.coffee, forecast.html, and forecast.scss into the /widgets/forecast directory. Put the forecast.rb file in your /jobs folder.

To include the widget in a dashboard, add the following to your dashboard layout file:

@kostasdizas
kostasdizas / comparechecksum.sh
Created September 6, 2015 21:13
Quickly calculate a checksum for a file and compare with input
#!/bin/bash
# compare calculated from file and input checksums for any hash function
if [ $# -lt 3 ] ; then
echo 'usage -- comparechecksum hashfunction filename checksum'
exit 1
fi
[ $($1 $2 | cut -f 1 -d " ") == $3 ] && echo "OK: All good" || echo "NOT OK: File does not match given checksum"
@kostasdizas
kostasdizas / led_control.sh
Last active September 7, 2015 13:59
Control the LEDs on a Raspberry Pi
#! /bin/bash
# led_control [on|off] : Turn the LEDs on or off
function display_usage() {
echo "Control the Raspberry Pi leds"
echo -e "\nUsage:\n$0 [on|off]\n"
exit 1
}
[ $# -eq 0 ] && display_usage
@kostasdizas
kostasdizas / move_and_symlink.sh
Created August 31, 2015 21:36
Quickly copy a file or folder elsewhere and replace it with a symlink pointing to its new location
@kostasdizas
kostasdizas / ass1-test.py
Last active August 29, 2015 14:09
CE151 Assignment Testing
import unittest
from unittest.mock import patch
from io import StringIO
import ass1
def ex_run(func, inputs):
print("-" * 50)
print("running: {0} with inputs {1}".format(func.__name__, ", ".join(inputs)))