Skip to content

Instantly share code, notes, and snippets.

View stephenquan's full-sized avatar

Stephen Quan stephenquan

View GitHub Profile
@stephenquan
stephenquan / appstudio-sql-troubleshooter.qml
Last active January 28, 2019 21:04
appstudio-sql-troubleshooter.qml
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Sql 1.0
Item {
Flickable {
anchors.fill: parent
function consoleTrace() { console.log(new Error()).stack.split("\n")[1]; }
@stephenquan
stephenquan / qvariant_test.cpp
Created November 28, 2018 11:52
qvariant_test.cpp
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <QObject>
#include <QVariant>
#include <QDebug>
using namespace std;
template <typename A>
@stephenquan
stephenquan / UpdatePortalItem.sh
Last active November 1, 2018 21:47
UpdatePortalItem.sh
#!/bin/bash -xe
portal_url=https://www.arcgis.com
cache_dir=/tmp/cache
rest_json=${cache_dir}/rest.json
token_json=${cache_dir}/token.json
user_json=${cache_dir}/user.json
content_json=${cache_dir}/content.json
item_json=${cache_dir}/item.json
@stephenquan
stephenquan / Evaluator.qml
Created November 1, 2018 01:29
Evaluator.qml
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Evaluator")
@stephenquan
stephenquan / CertTest.qml
Created October 31, 2018 22:02
CertTest.qml
import QtQuick 2.9
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import Qt.Test 1.0
Window {
visible: true
width: 640
height: 480
@stephenquan
stephenquan / aamva_decode.js
Last active July 4, 2018 02:05
aamva_decode.js
// Convert AAMVA string to JSON
function aamva_decode(data) {
var m = data.match(/^@\n\u001e\r(ANSI )(\d{6})(\d{2})(\d{2})(\d{2})/);
if (!m) {
return null;
}
var obj = {
header: {
@stephenquan
stephenquan / flatjson.py
Last active July 16, 2018 03:05
flatjson.py
import json, sys
def combine(attr, prefix):
return attr if prefix == "" else prefix + "." + attr
def flatjson(obj, prefix = ""):
if isinstance(obj, list):
print combine("len", prefix) + "\t" + str(len(obj))
for i, row in enumerate(obj):
flatjson(obj[i], prefix + "[" + str(i) + "]")
@stephenquan
stephenquan / ResourceCopyTest.pro
Last active May 18, 2018 02:05
ResourceCopyTest
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
@stephenquan
stephenquan / appstudio-filefolder-check.qml
Last active January 24, 2019 23:19
appstudio-filefolder-check.qml
import QtQuick 2.7
import QtQuick.Controls 2.1
import ArcGIS.AppFramework 1.0
Item {
TextField {
text: AppFramework.userHomeFolder.filePath(":/abc.txt")
}
}