Skip to content

Instantly share code, notes, and snippets.

David Grayson DavidEGrayson

View GitHub Profile
@DavidEGrayson
DavidEGrayson / commands.sh
Created Feb 20, 2019
ffmpeg commands to extract AAC audio from an MP4, edit it, and replace it
View commands.sh
ffprobe foo.mp4 # Make sure the audio stream is aac.
ffmpeg -i foo.mp4 -vn -acodec copy foo.aac
ffmpeg -i foo.aac -acodec pcm_s16le foo.wav
# Edit foo.wav with audacity, save to foo_edited.wav.
ffmpeg -i foo_edited.wav -acodec aac foo_edited.aac
ffmpeg -i foo.mp4 -codec copy -an foo_silent.mp4
ffmpeg -i foo_silent.mp4 -i foo_edited.aac -shortest -c:v copy -c:a aac foo_edited.mp4
View mingw-nixcrpkgs.md

Building a mingw-w64 GCC cross-compiler with nixcrpkgs: instructions for Terry, October 2018

  1. Install Nix, the functional package manager. You'll need Linux (but macOS might work too).
  2. Make sure you have at least 4 GB of free space available for /tmp and a few GB of free space available for /nix.
  3. To get my recipes, run: git clone https://github.com/DavidEGrayson/nixcrpkgs && cd nixcrpkgs && git checkout 4f7b11d That commit is the current tip of the dev/david/2019 branch.
  4. To build a i686-w64-mingw32 C/C++ cross-compiling toolchain and a hello world program, run: nix-build -A win32.hello
  5. To build Qt and its examples, run: nix-build -A win32.qt.examples
  6. To just build the toolchain itself, run: nix-build -A win32.gcc
View arch_linux_screwup.txt
[root@alderaan gradual]# pacman -Sy archlinux-keyring
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
warning: archlinux-keyring-20180108-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Packages (1) archlinux-keyring-20180108-1
@DavidEGrayson
DavidEGrayson / shell_session.txt
Last active Dec 23, 2017
AllowShortBlocksOnASingleLine is not working with clang-format 5.0.0 on Manjaro Linux
View shell_session.txt
$ clang-format --version
clang-format version 5.0.0 (tags/RELEASE_500/final)
$ cat .clang-format
AllowShortBlocksOnASingleLine: true
$ cat test.cpp
int foo(int x)
{
if (x == 0) { return 1; }
@DavidEGrayson
DavidEGrayson / does_not_compile.txt
Last active Nov 12, 2017
This code does not compile using mingw-w64 gcc in MSYS2 (and probably not in any version of gcc)
View does_not_compile.txt
$ cat somefile.h
struct a;
struct a *init();
void setd(struct a*p, int dd);
int getd(struct a*p);
void cleanup(struct a*p);
$ cat somefile.c
View msys2_path_conv_session.txt
$ cat test.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv)
{
for(int i = 0; i < argc; i ++)
{
printf("%d = %s\n", i, argv[i]);
}
View usb-stuff.txt
$ cat /dev/bus/usb/001/002 | head -c18 | hexdump
0000000 0112 0110 0000 0800 80ee 0021 0100 0301
0000010 0100
0000012
$ lsusb
Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
@DavidEGrayson
DavidEGrayson / flatten_dependency_graph.rb
Created Aug 5, 2017
Flatten a dependency graph in Ruby. This is a little something I built for managing Qt library dependencies in nixcrpkgs.
View flatten_dependency_graph.rb
# 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 Jun 27, 2017
Script for building the Qt 5.8.0 dynamic layouts example in MSYS2, with static linking. Posted here for StackOverflow question.
View build.sh
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
You can’t perform that action at this time.