Skip to content

Instantly share code, notes, and snippets.

View black23's full-sized avatar

black23 black23

View GitHub Profile
#!/usr/bin/env python3
import datetime
import jwt # pip install pyjwt
app_id = 'SIGLA'
shared_secret = 'add_secret_here'
now = datetime.datetime.utcnow()
token_dict = dict(
iss = app_id,
@black23
black23 / librarything.php
Created June 13, 2018 10:13 — forked from atbradley/librarything.php
Retrieve book data from the LibraryThing Common Knowledge API.
<?php
namespace ocra\libraryThing;
/**
* Search LibraryThing's Common Knowledge API for a book and return and array with author/title and maybe year.
*/
function find_by_isbn($isbn) {
$lturl = 'http://www.librarything.com/services/rest/1.1/?method=librarything.ck.getwork&isbn=%s&apikey=%s';
$lturl = sprintf($lturl, $isbn, LIBRARYTHING_API_KEY);
var obalky = obalky || {};
obalky.protocol =
(document.location.protocol == 'https:') ? 'https://':'http://';
obalky.url = obalky.protocol+"www.obalkyknih.cz";
obalky.books = obalky.books || [];
obalky.version = "0.2.0";
obalky.id = 0;
obalky.msie = navigator.userAgent.indexOf("MSIE") != -1 ? 1 : 0;
<?php
// skript který nahradí id_uzivatele carovym kodem uzivatele
$start = microtime(true);
$csv_id = array_map('str_getcsv', file('uid_userPassword_barcode.csv'));
$csv_borrowers = array_map('str_getcsv', file('borrowers.csv'));
$handle_OUT = fopen('./export.aktivni_vypujcky_krok_2.csv', "w+");
@black23
black23 / calendarpi.md
Created February 15, 2018 12:05 — forked from sftsk/calendarpi.md
Raspberry Pi Google Calendar Screen

Using a raspberry pi to display Google Calendars

This explains the set up of our very basic status screen to displays Google calendars here at booncon.

Install the raspberry pi

Download and put the most current https://www.raspberrypi.org/downloads/raspbian/ image to an SD Card. On OSX that works great with http://www.tweaking4all.com/hardware/raspberry-pi/macosx-apple-pi-baker/, just use the restore option and select the unzipped image file.

Set up the operation system basics

After the first boot, the raspi-config utility should load up.

#!/bin/bash
INSTANCE="nazev_instance_kohy"
SIGLA="sigla_knihovny"
USERNAME="vypdilia"
PASSWORD="heslo"
YEAR=$(date "+%Y")
QUARTAL=$(echo "(`date +%m` - 1)/3" | bc)
if [ "$QUARTAL" == "0" ] ; then
SELECT count(*) as 'Počet vrácení'
FROM old_issues
JOIN borrowers on old_issues.borrowernumber = borrowers.borrowernumber
JOIN items ON old_issues.itemnumber = items.itemnumber
WHERE `old_issues`.`timestamp` != `old_issues`.`returndate`
AND DATE(old_issues .timestamp) BETWEEN <<Od|date>> AND <<Do|date>>
ORDER BY old_issues.timestamp
SELECT concat('<a href="/cgi-bin/koha/members/readingrec.pl?borrowernumber=', `old_issues`.`borrowernumber`, '">', firstname, ' ', surname, '</a>') as 'Čtenář',
concat('<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=', items.biblionumber, '">', items.barcode, '</a>') as 'Jednotka',
date_format(old_issues.timestamp, "%e.%c.%Y %H:%i:%s") as 'Zpracováno'
FROM old_issues
JOIN borrowers on old_issues.borrowernumber = borrowers.borrowernumber
JOIN items ON old_issues.itemnumber = items.itemnumber
WHERE `old_issues`.`timestamp` != `old_issues`.`returndate`
AND DATE(old_issues .timestamp) = CURDATE()
ORDER BY old_issues.timestamp
@black23
black23 / convert_from_tag2mrk
Created June 7, 2016 11:02
Skript v Pythonu na konverzi řádkového MARC (TAG) do formátu čitelného MarcEditem
#!/usr/bin/python27
'''
Script pro prevod souboru pro MarcEdit
'''
import string
import sys
import os
def usage():
@black23
black23 / gist:15205a9e14caf24b5c0f
Created December 21, 2015 08:42
SQL výstup na zjištení historie rezervací čtenáře
SELECT CONCAT_WS("", "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=", bor.borrowernumber, "'>", bor.firstname, " ", bor.surname, "</a>") AS "Ctenar",
oldr.reservedate AS "Datum rezervace", br.branchname AS "Knihovna",
IF(ISNULL(cancellationdate), IF(found = "F", "<span style='color:green;font-weight:bold'>Vyřízeno</span>", found), CONCAT("<span style='color:red;'>Zrušeno ", cancellationdate, "</span>")) AS "Stav",
b.author AS "Autor",
CONCAT("<a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=", b.biblionumber, "'>", b.title, "</a>") AS "Nazev",
i.stocknumber AS "P. cislo", i.barcode AS "Carovy kod", it.description AS "Typ jednotky"
FROM old_reserves oldr
JOIN borrowers bor ON oldr.borrowernumber = bor.borrowernumber
JOIN biblio b ON oldr.biblionumber = b.biblionumber
LEFT OUTER JOIN items i ON oldr.itemnumber = i.itemnumber