Skip to content

Instantly share code, notes, and snippets.

View DavidEGrayson's full-sized avatar

David Grayson DavidEGrayson

View GitHub Profile
@DavidEGrayson
DavidEGrayson / flatten_dependency_graph.rb
Created August 5, 2017 16:17
Flatten a dependency graph in Ruby. This is a little something I built for managing Qt library dependencies in nixcrpkgs.
# Given an array of dependencies and a block for retrieving dependencies of an
# dependency, returns an array of dependencies with three guarantees:
#
# 1) Contains all the listed dependencies.
# 2) Has no duplicates.
# 3) For any dependency in the list, all of its dependencies appear before it.
#
# Guarantee 3 only holds if the underlying graph has no circul dependencies. If
# there is a circular dependency, it will not be detected, but it will not cause
# an infinite loop either.
@DavidEGrayson
DavidEGrayson / build.sh
Created June 27, 2017 15:32
Script for building the Qt 5.8.0 dynamic layouts example in MSYS2, with static linking. Posted here for StackOverflow question.
set -ue
pacman -S --needed "${MINGW_PACKAGE_PREFIX}-qt5-static"
if [ ! -d qt ]; then
wget https://download.qt.io/official_releases/qt/5.8/5.8.0/submodules/qtbase-opensource-src-5.8.0.tar.xz -O qt.tar.xz
tar -xf qt.tar.xz
mv qtbase-opensource-src-5.8.0 qt
fi
@DavidEGrayson
DavidEGrayson / patch.sh
Last active May 17, 2017 14:09
How to fix libstdc++v3 to not use __in and __out, which conflict with Microsoft.
sed -ri 's/\b(__in|__out)\b/_&/g' $(egrep -rl '\b(__in|__out)\b' libstdc++-v3/{include,config})
@DavidEGrayson
DavidEGrayson / setuperr.log
Last active March 13, 2017 16:58
$Windows.~BT\Sources\Panther\setuperr.log file that I got after attempting to update Windows using the Media Creation Tool. See https://superuser.com/questions/1188252/cannot-update-windows-10-get-winload-efi-error-0xc0000225
2017-03-12 14:22:46, Error MOUPG CDlpActionImpl<class CDlpErrorImpl<class CDlpObjectInternalImpl<class CUnknownImpl<class IMoSetupDlpAction> > > >::Suspend(1066): Result = 0xC1800104
2017-03-12 14:22:46, Error MOUPG CSetupManager::ExecuteInstallMode(735): Result = 0x800705BB
2017-03-12 14:22:46, Error MOUPG CSetupManager::ExecuteDownlevelMode(391): Result = 0x800705BB
2017-03-12 14:22:46, Error MOUPG CSetupManager::Execute(236): Result = 0x800705BB
2017-03-12 14:22:46, Error MOUPG CSetupHost::Execute(372): Result = 0x800705BB
2017-03-12 14:43:08, Error SP pSPRemoveUpgradeRegTree: failed to delete reg tree HKLM\SYSTEM\Setup\Upgrade[gle=0x00000005]
2017-03-12 14:43:16, Error [0x080831] MIG CSIAgent: Invalid xml format: FormatException: "id" attribute is mandatory. void __cdecl Mig::CMXEMigrationXml::LoadSupportedComponent(class UnBCL::XmlNode *,int,class Mig::CMXEMigrationXml *,class Mig::CMXEXmlComp
@DavidEGrayson
DavidEGrayson / send_email.rb
Created January 16, 2017 23:34
Ruby script for sending email
require 'net/smtp'
Net::SMTP.start("mail1.pololu.com", nil, 'alderaan.tmphax.com') do |smtp|
from = "david@tmphax.com"
to = "david@pololu.com"
message = <<END
From: david@tmphax.com
To: david@pololu.com
Subject: just a test of our serer's firewall
@DavidEGrayson
DavidEGrayson / nixpkgs-pr-test.nix
Last active December 24, 2016 05:37
Test file for version 2 of my Nix cross-compiling pull request: https://github.com/NixOS/nixpkgs/pull/21388
rec {
pkgsFunMine = import ./nixpkgs/pkgs/top-level;
releaseCross = import ./nixpkgs/pkgs/top-level/release-cross.nix;
pkgsFunBase = import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "1590461887333e2fda46f4bd74aef3785b253089";
sha256 = "0c446b6kamn4nvg729vd081w5560rsgplchi1m3l4cplz7w84l92";
} + "/pkgs/top-level");
WTF, I did something that affected the architecture of my cross-built ELF files?
base = d4eac0278ca188aa236b6a7f0fbb15f8ee4273d0
me = 9cedf1b7a794e70706804b7239807f39c0a76ecb
degzeg = downloaded from the URL in nixpks
$ objdump -x bootstrap_degzeg/busybox | grep arch
architecture: arm, flags 0x00000102:
$ objdump -x bootstrap_base/busybox | grep arch
@DavidEGrayson
DavidEGrayson / I2CBus.cpp
Last active October 6, 2016 17:18
Better I2CBus.cpp. I want to integrate this into minimu9-ahrs.
#include "I2CBus.h"
#include <cerrno>
#include <cstring>
#include <system_error>
#include <string>
#include <unistd.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
static inline std::system_error posix_error(const std::string & what)
rec {
myNixpkgsFunc = import ./nixpkgs;
myNixpkgs = myNixpkgsFunc {};
baseNixpkgsFunc = import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "d4eac0278ca188aa236b6a7f0fbb15f8ee4273d0";
sha256 = "0mpx6bjvix7dfmgn6a2chmmicamz9v941fki0lgzfk2gw90fqg6w";
});
@DavidEGrayson
DavidEGrayson / drvdiff
Created September 1, 2016 04:18
Shell script for comparing two Nix derivations to see the differences between them.
#!/usr/bin/bash
set -ue
A="$1"
B="$2"
diff -u <(tr ',' '\n' <"$A") <(tr ',' '\n' <"$B")