Skip to content

Instantly share code, notes, and snippets.

View richardhozak's full-sized avatar

Richard Hozák richardhozak

View GitHub Profile
@richardhozak
richardhozak / gist:5f4bc2af7451d9e2df107ac14a46b233
Created October 6, 2022 11:16
sensible terminal, copied from i3
•$TERMINAL (this is a non-standard variable)
•x-terminal-emulator (only present on Debian and derivatives)
•mate-terminal
•gnome-terminal
•terminator
•xfce4-terminal
•urxvt
•rxvt
•termit
•Eterm
@richardhozak
richardhozak / pfr.hpp
Created March 23, 2022 18:04
amalgamated c++ pfr library
#pragma once
// Copyright (c) 2016-2022 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef PFR_IO_HPP
#define PFR_IO_HPP
@richardhozak
richardhozak / zip_files.cmake
Created June 4, 2021 12:24
function to zip list of files in cmake
function(create_zip)
set(oneValueArgs NAME)
set(multiValueArgs FILES)
cmake_parse_arguments(CREATE_ZIP "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(ZIP_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${CREATE_ZIP_NAME}")
add_custom_command(
COMMAND ${CMAKE_COMMAND} -E tar cvf ${ZIP_OUTPUT} --format=zip -- ${CREATE_ZIP_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#ifndef _STAB_H_
#define _STAB_H_
// This file is needed so breakpad tools get built on alpine linux.
// This file is taken from src/common/android/include/stab.h
// where it is used for the same reason: glibc has stab.h but
// other libc's such as bionic or musl libc do not.
// I modified it, removed android specific stuff and
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
use com::{co_class, interfaces::iunknown::IUnknown};
#[repr(C)]
struct Test {
__iunknownvptr: *const <dyn IUnknown as com::ComInterface>::VTable,
__refcnt: std::cell::Cell<u32>,
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std;
use com::{co_class, interfaces::iunknown::IUnknown};
#[repr(C)]
struct Test {
__iunknownvptr: *const <dyn IUnknown as com::ComInterface>::VTable,
__refcnt: std::cell::Cell<u32>,
@richardhozak
richardhozak / microseconds_to_time.js
Created October 8, 2018 10:09
Convert microseconds to time
function microsecondsToTime(microseconds) {
let us = microseconds;
let ss = us / (1000 * 1000);
let mm = ss / 60;
let hh = mm / 60;
let u = Math.round(us % (1000 * 1000));
let s = Math.floor(ss % 60);
let m = Math.floor(mm % 60);
let h = Math.floor(hh % 24);
extern crate crossbeam;
extern crate bus;
use std::io::{self, BufRead, BufWriter, Write};
use std::sync::mpsc::sync_channel;
use std::thread;
use std::fs::File;
use bus::Bus;
import pyodbc
connection = pyodbc.connect("DSN=test;")
cursor = connection.cursor()
for row in cursor.tables():
print(row.table_name)