Skip to content

Instantly share code, notes, and snippets.

View nathan-osman's full-sized avatar

Nathan Osman nathan-osman

View GitHub Profile
@nathan-osman
nathan-osman / build-qt5
Last active April 23, 2024 12:33
This script provides an easy way to build Qt5 for both 32 and 64-bit Windows. This script assumes that the Mingw-w64 compilers are installed on the host as well as Perl.
#!/bin/bash
#===========================================
# Download URLs for the required libraries.
#===========================================
# NOTE: if you add a URL here, you also need to add it to the
# $packages_to_build list to ensure the proper order.
declare -A urls=(
@nathan-osman
nathan-osman / CMakeLists.txt
Last active April 2, 2024 21:27
Generates a self-signed x509 certificate using OpenSSL.
# A simple CMake script for building the application.
cmake_minimum_required(VERSION 2.8)
project(create-x509)
# Our only dependency is OpenSSL
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
add_executable(create-x509 create-x509.cpp)
@nathan-osman
nathan-osman / CMakeLists.txt
Created November 13, 2023 06:41
Hibernate your PC
project(wintray)
add_executable(hiber WIN32
hiber.cpp
)
set_target_properties(hiber PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
@nathan-osman
nathan-osman / CMakeLists.txt
Last active September 8, 2023 08:05
Create a very basic system tray icon
project(wintray)
add_executable(wintray WIN32
main.cpp
resource.rc
wintray.exe.manifest
)
set_target_properties(wintray PROPERTIES
CXX_STANDARD 11
@nathan-osman
nathan-osman / win32.go
Last active August 31, 2023 22:01
Simple Windows GUI application written in Go
package main
import (
"log"
"syscall"
"unsafe"
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
@nathan-osman
nathan-osman / smsformat.py
Created April 1, 2020 05:53
Format XML files produced by SMS Backup & Restore
from argparse import ArgumentParser
from datetime import datetime, timezone
from html import escape
import xml.etree.ElementTree as ET
class SmsFormat:
def __init__(self, f_in, f_out):
@nathan-osman
nathan-osman / CMakeLists.txt
Last active March 19, 2022 23:43
Enumerate network interfaces and addresses assigned to them
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
project(netenum)
find_package(Qt5Network 5.4 REQUIRED)
add_executable(netenum main.cpp)
target_link_libraries(netenum Qt5::Network)
@nathan-osman
nathan-osman / ppastats.py
Created July 14, 2017 16:56
Updated script for retrieving PPA download counts - https://askubuntu.com/a/296200/5
#!/usr/bin/env python2
from argparse import ArgumentParser
from sys import exit
try:
from launchpadlib.launchpad import Launchpad
from tabulate import tabulate
except ImportError:
print "python-launchpadlib and python-tabulate are required"
@nathan-osman
nathan-osman / main.go
Created March 9, 2021 04:34
Custom dialector to force sqlite driver in GORM to use "integer" type for booleans instead of "numeric".
package main
import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/schema"
)
// CustomDialector allows for customization of the type affinity for booleans.
type CustomDialector struct {
@nathan-osman
nathan-osman / puzzle.py
Last active April 5, 2020 04:06
Calculate the answer to this puzzle: https://i.stack.imgur.com/4MMS7.jpg
# Build a list of all possible combinations
a = []
for i in range(0, 10):
for j in range(0, 10):
for k in range(0, 10):
a.append('{}{}{}'.format(i, j, k))
# For each of the possible answers, check the five constraints
for v in a:
pass_1 = \