Skip to content

Instantly share code, notes, and snippets.

View bjorn's full-sized avatar
🇳🇱

Thorbjørn Lindeijer bjorn

🇳🇱
View GitHub Profile
@bjorn
bjorn / WorldScripting.js
Last active January 17, 2024 10:17 — forked from dogboydog/WorldScripting.js
Testing world scripting functionality for Tiled (map editor)
/*
* Testing world scripting functionality
*/
var WorldScripting = {};
WorldScripting.scriptAction = tiled.registerAction("WorldScripting", function (action) {
var state = {
worlds: tiled.worlds,
}
@bjorn
bjorn / main.cpp
Last active January 7, 2020 15:03
QJSEngine and QStringList properties handling, a potential performance issue
#include <QCoreApplication>
#include <QDebug>
#include <QQmlApplicationEngine>
class Object : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList strings READ strings CONSTANT)
public:
@bjorn
bjorn / checks.js
Last active October 9, 2019 20:08
Tiled example extensions
function tryFixPolyline(object) {
const margin = 5 // pixels
let polygon = object.polygon
if (polygon.length < 3)
return false // can't turn into polygon
let first = polygon[0]
let last = polygon[polygon.length - 1]
// check if points are too far away from each other
@bjorn
bjorn / startup.js
Created March 26, 2019 22:32
Tiled Custom Tool
var tool = tiled.registerTool('MyCustomTool', {
name: "My Custom Tool",
icon: "foo.png", // todo: this would be looked up and loaded somehow
shortcut: undefined,
statusInfo: undefined,
cursor: undefined,
activated: function() { tiled.log("tool.activated") },
deactivated: function() { tiled.log("tool.deactivated") },
keyPressed: function(key, modifiers) { tiled.log("tool.keyPressed") },
Verifying my Blockstack ID is secured with the address 19CYP4xMcueYyVkMihF4w8RswsE3hbGKYy https://explorer.blockstack.org/address/19CYP4xMcueYyVkMihF4w8RswsE3hbGKYy
@bjorn
bjorn / gdb backtrace
Created January 19, 2019 10:47
pantheon-mail crash when clicking one of my emails
(pantheon-mail:7989): Gtk-WARNING **: 11:45:01.430: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
(pantheon-mail:7989): Gdk-ERROR **: 11:45:01.487: The program 'pantheon-mail' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
(Details: serial 39899 error_code 11 request_code 53 (core protocol) minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment

Keybase proof

I hereby claim:

  • I am bjorn on github.
  • I am bjorn (https://keybase.io/bjorn) on keybase.
  • I have a public key ASB8S48kmdFyHnCgT7rWX4MlClgShID0FVhnMQg0t3X80wo

To claim this, I am signing this object:

@bjorn
bjorn / FrameTabBarBase.cpp
Last active September 12, 2016 12:37
Drawing tab bar base behind some other control
QStylePainter p(this);
QStyleOptionTab tabOverlap;
int overlap = style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap);
QStyleOptionTabBarBase tabBarStyleOption;
tabBarStyleOption.rect.setRect(0, height() - overlap, width(), overlap);
tabBarStyleOption.tabBarRect = rect();
p.drawPrimitive(QStyle::PE_FrameTabBarBase, tabBarStyleOption);
@bjorn
bjorn / FlexibleScrollBar.cpp
Created December 21, 2015 11:19
A flexible QScrollBar that can take values outside of its original range by automatically extending its range
class FlexibleScrollBar : public QScrollBar
{
Q_OBJECT
public:
FlexibleScrollBar(Qt::Orientation orientation, QWidget *parent = nullptr)
: QScrollBar(orientation, parent)
, mOverrideMinimum(0)
, mOverrideMaximum(0)
, mDesiredMinimum(0)
@bjorn
bjorn / gist:11011338
Created April 17, 2014 21:00
Keybase proof
### Keybase proof
I hereby claim:
* I am bjorn on github.
* I am bjorn (https://keybase.io/bjorn) on keybase.
* I have a public key whose fingerprint is F0F4 30DC 9685 89CA C31D 17B4 10B2 90EF C9F1 1EB9
To claim this, I am signing this object: