Skip to content

Instantly share code, notes, and snippets.

View ianmac45's full-sized avatar

ianross ianmac45

View GitHub Profile
@ianmac45
ianmac45 / qsettings-xml.hpp
Last active November 29, 2023 07:03
XML Format for QSettings
#pragma once
//TODO include appropriate headers
#include <QtCore/QtCore>
#include <QtXml/QtXml>
bool readSettingsXml(QIODevice &device, QMap<QString, QVariant> &map);
bool writeSettingsXml(QIODevice &device, const QMap<QString, QVariant> &map);
static const QSettings::Format xmlFormat = QSettings::registerFormat("xml", &readSettingsXml, &writeSettingsXml);
static const QString rootName = "config";
@ianmac45
ianmac45 / sql.h
Created October 6, 2014 23:08
the "sugar coating" for working with "raw" sql in c++, using qt
#pragma once
#include <QDebug>
#include <QString>
#include <QVariant>
#include <QSqlField>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlDriver>
#include <QSqlRecord>
@ianmac45
ianmac45 / user.h
Created October 6, 2014 23:10
example for object-oriented programming
#pragma once
#include "stable.h"
namespace gui { class UserDialog; class AdminDialog; }
namespace data
{
class User : public QObject
{
Q_OBJECT
@ianmac45
ianmac45 / app.go
Created October 7, 2014 23:08
example for parsing a file & inserting into a database, using golang
package main
import (
// "flag"
"fmt"
"os"
"strings"
"strconv"
"database/sql"
"compress/gzip"
@ianmac45
ianmac45 / app.py
Created October 7, 2014 23:09
example for parsing an excel spreadsheet and loading into a database
#!/opt/local/bin/python
import MySQLdb
from openpyxl import load_workbook
# Connect to Database
database = MySQLdb.connect(host="127.0.0.1", # your host, usually localhost
user="", # your username
passwd="", # your password
db="table") # name of the data base
@ianmac45
ianmac45 / json.php
Created October 7, 2014 23:10
retrieving data as json
<?php
header('Content-Type: application/json');
$db = new PDO("mysql:unix_socket=/opt/local/var/run/mariadb/mysqld.sock;dbname=table", "", "");
$result = array('values' => array());
if(isset($_POST["value"]))
@ianmac45
ianmac45 / gist:18b11c891d46bc64c8b8
Created October 7, 2014 23:10
example angular.js controller
var app = angular.module("successes", [])
.controller("DataList", DataListCtrl)
.controller("FiscalYearList", FiscalYearListCtrl);
function DataListCtrl($scope, $http)
{
$http.get('successes.json.php?req=main')
.success(function(data)
{
$scope.entries = data.values;