Skip to content

Instantly share code, notes, and snippets.

@amoe
amoe / field_encoder_model.cc
Created March 4, 2019 16:05
wrapper for stringlistmodel
#include "field_encoder_model.hh"
FieldEncoderModel::FieldEncoderModel() {
QStringList available = {"foo", "bar", "baz"};
this->innerModel = new QStringListModel(available);
}
Qt::ItemFlags FieldEncoderModel::flags(const QModelIndex& index) const {
return this->innerModel->flags(index);
}
#ifndef FIELD_ENCODER_MODEL_HH
#define FIELD_ENCODER_MODEL_HH
#include <Qt>
#include <QModelIndex>
#include <QStringListModel>
class FieldEncoderModel: public QAbstractItemModel {
public:
@amoe
amoe / gist:f7a7e5fb59efed06a3a4f8aded6907f8
Created April 25, 2019 09:13
spdlog extension example
#include "spdlog/fmt/ostr.h"
class Person {
public:
Person(string name, int age): name(name), age(age) { }
template<typename OStream>
friend OStream &operator<<(OStream &os, const Person& p) {
return os << "<Person name=" << p.name << ">";
}
@amoe
amoe / neo4j_java_11.patch
Created July 19, 2019 14:42
Neo4j Java 11 patch
diff -Naur neo4j-community-3.4.6.orig/bin/neo4j neo4j-community-3.4.6/bin/neo4j
--- neo4j-community-3.4.6.orig/bin/neo4j 2018-08-13 10:43:20.000000000 +0100
+++ neo4j-community-3.4.6/bin/neo4j 2019-07-19 15:20:21.175879490 +0100
@@ -84,15 +84,19 @@
[[ -n "${JAVA_MEMORY_OPTS:-}" ]] && version_command+=("${JAVA_MEMORY_OPTS[@]}")
JAVA_VERSION=$("${version_command[@]}" 2>&1 | awk -F '"' '/version/ {print $2}')
- if [[ "${JAVA_VERSION}" < "1.8" ]]; then
- echo "ERROR! Neo4j cannot be started using java version ${JAVA_VERSION}. "
- _show_java_help
@amoe
amoe / post.py
Last active November 7, 2020 03:54
Omeka-S post item with attached media using API
import requests
import json
import pprint
# Translated from https://forum.omeka.org/t/example-api-usage-using-curl/8083,
# the work of user 'kgoetz'. Thanks.
# Begin quote:
# > The API permits anonymous access to public resources (i.e., reading non-private
# > data). To perform actions or view data that only logged-in users can access,
Downloading template "new-template" to create project "morse" in morse/ ...
The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/amoe/.stack/config.yaml, like this:
templates:
params:
author-email: value
author-name: value
category: value
copyright: value
@amoe
amoe / omeka-s-uv-iiif-pdf-ssl.patch
Created June 15, 2020 08:00
Omeka-S IIIF Server module patch to force SSL on PDF URLs in Universal Viewer
diff -ruN IiifServer-3.5.16.orig/IiifServer/src/View/Helper/IiifManifest.php IiifServer-3.5.16/IiifServer/src/View/Helper/IiifManifest.php
--- IiifServer-3.5.16.orig/IiifServer/src/View/Helper/IiifManifest.php 2020-05-25 11:35:28.000000000 +0100
+++ IiifServer-3.5.16/IiifServer/src/View/Helper/IiifManifest.php 2020-06-15 08:47:35.503831538 +0100
@@ -320,7 +320,7 @@
case 'application/pdf':
$render = [];
- $render['@id'] = $media->originalUrl();
+ $render['@id'] = $this->view->iiifForceBaseUrlIfRequired($media->originalUrl());
$render['format'] = $mediaType;
@amoe
amoe / linode-support.diff
Created July 4, 2020 10:03
linode support patch for ddclient current to debian buster 3.8.3-1.1
--- a/ddclient
+++ b/ddclient
@@ -646,6 +646,16 @@
$variables{'service-common-defaults'},
),
},
+ 'linode' => {
+ 'updateable' => undef,
+ 'update' => \&nic_linode_update,
+ 'examples' => \&nic_linode_examples,
== 7732 -> [ BLOCK 7733 ] -> 7734 ==
[ Len: 4076 ]
-- PUSH 0x20 [ 0x04 ] --
-- PUSH 0x20 [ 0x05 ] --
-- PUSH 0x20 [ 0x43 ] --
-- PUSH 0x20 [ 0x0A ] --
[4].[5].[67].[10].
-- field (0x1E): "[fZ>Yc" => "ZYXÉPZZZ[" --
-- field (0x1E): "[f[Û[¾" => "ZYXÏâZZZ[" --
-- field (0x1E): "[f^U[²" => "ZYXÏçZZZ[" --
@amoe
amoe / block7732.dump
Created February 5, 2021 16:16
Block dumps from fmp file
01e34000: 0000 0000 0000 1e32 0000 1e35 0000 03fd .......2...5....
01e34010: 0e92 50d3 2004 2005 2043 200a 3806 0054 ..P. . . C .8..T
01e34020: 0025 009e 1e06 01ea 006c 0245 0900 0302 .%.......l.E....
01e34030: 923b 0000 0001 1e06 01ec 006c 0286 0900 .;.........l....
01e34040: 0302 924b 0000 0001 1e06 01ec 0207 028c ...K............
01e34050: 0900 0302 9251 0000 0001 1e06 01ed 006c .....Q.........l
01e34060: 022f 0900 0302 9237 0000 0001 1e06 01f6 ./.....7........
01e34070: 006c 0272 0900 0302 9247 0000 0001 1e06 .l.r.....G......
01e34080: 0204 006c 0261 0900 0302 92ae 0000 0001 ...l.a..........
01e34090: 1e06 0204 008c 0262 0900 0302 92af 0000 .......b........