Skip to content

Instantly share code, notes, and snippets.


Ted Mielczarek luser

View GitHub Profile
luser /
Created Feb 1, 2021
Canonicalize filename case in system Python 2.7 on macOS
from __future__ import print_function
from Carbon.File import FSPathMakeRef
import os
import sys
import unicodedata
def actual_path(path):
luser /
Created Jan 14, 2021
Illustration of a potential issue with subprocesses in Go

I ran into this issue at work in a test runner we have that is written in Go and runs a test suite which is a node module, which itself spawns several subprocesses. The issue was that one of the subprocesses inherited its parents' stdout file descriptor, but would outlive the parent process being killed. If you use Go's exec.Cmd to run a process and set its Stdout or Stderr to something that is not a File, a goroutine will be spawned to drive that I/O when calling Cmd.Start, and all such goroutines will be run to completion as part of Cmd.Wait. In this situation, because the grandchild process stays alive, it keeps the stdout pipe open, thus Cmd.Wait blocks until it exits.

subprocess.go is a minimal testcase to display the issue. It spawns itself as a child process with piped stdout, then waits one second before killing the subprocess and waiting on it. The child process spawns itself as a grandchild with inherited stdout and sleeps for 5 seconds before exiting. The grandchild process simply

use std::char::{decode_utf16, DecodeUtf16Error};
pub struct wstr([u16]);
impl wstr {
pub fn to_wstring(&self) -> WString {
luser /
Last active Dec 1, 2020
GDB Mozilla symbol server
# Any copyright is dedicated to the Public Domain.
# A GDB Python script to fetch debug symbols from the Mozilla symbol server.
# To use, run `source /path/to/` in GDB 7.9 or newer, or
# put that in your ~/.gdbinit.
from __future__ import print_function
View compile error
In file included from /build/mcpelauncher/fake-jni/examples/src/main.cpp:3:
In file included from /build/mcpelauncher/fake-jni/include/fake-jni/jvm.h:5:
/build/mcpelauncher/fake-jni/include/fake-jni/internal/meta/field.h:61:73: error: conversion from 'FakeJni::JString' to 'jvalue' is ambiguous
((T*)inst)->*((type_t)field) = ValueTranslator<F>::convert_set(env, *((F*)value));
/build/mcpelauncher/fake-jni/include/fake-jni/jvm.h:1465:59: note: in instantiation of member function 'FakeJni::_CX::FieldAccessor<FakeJni::JString ExampleClass::*>::set' requested here
proxySetFunc((void (*)())&_CX::FieldAccessor<T (M::*)>::set),
/build/mcpelauncher/fake-jni/include/fake-jni/jvm.h:1386:38: note: in instantiation of function template specialization 'FakeJni::JFieldID::JFieldID<FakeJni::JString, ExampleClass>' requested here
return clazz->registerField(new JFieldID(fie
This file has been truncated, but you can view the full file.
use std::prelude::v1::*;
extern crate std;
pub use bevy_hecs::{Query as HecsQuery, *};
mod resource {
luser / dump_pe_pdb_info.cpp
Created Oct 29, 2015
Dump PDB information from a PE file
View dump_pe_pdb_info.cpp
#include <stdio.h>
#include <stdint.h>
#include <Windows.h>
#include <string>
#include <DbgHelp.h>
#pragma comment(lib, "dbghelp.lib")
const DWORD CV_SIGNATURE_RSDS = 0x53445352; // 'SDSR'
luser /
Created Apr 29, 2020
/// Create a `Future` that will resolve after `idle_period` has elapsed, along with an `IdleReset` that can be used to reset the time period or cancel the timeout.
/// This can be used to trigger an event that should happen after a period of inactivity. Activity in this situation is indicated by calling
/// `idle_reset` on the returned `IdleReset`. The timeout can be cancelled by calling `cancel` on the `IdleReset`.
/// Returns a tuple of (`IdleReset`, `Future`)
pub fn idle_timeout_reset(
idle_period: Duration,
) -> (IdleReset, impl Future<Output = bool> + Send + 'static) {
// ...
luser / servo-cross-mac
Created May 26, 2016
Cross-compile Servo from Linux to OS X
View servo-cross-mac
#TODO: you will need to manually get an OS X SDK.
set -e
# Install the proper Rust nightly with rustup, and add the OSX target.
rustup install nightly-`cat rust-nightly-date`
rustup override add nightly-`cat rust-nightly-date`
rustup target install x86_64-apple-darwin
View moco-group-april-2007.exif
ExifTool Version Number : 11.65
File Name : moco-group-april-2007.jpg
Directory : /mnt/photos
File Size : 3.0 MB
File Modification Date/Time : 2008:02:21 08:50:50-05:00
File Access Date/Time : 2008:02:21 08:50:50-05:00
File Inode Change Date/Time : 2008:02:21 08:50:50-05:00
File Permissions : rwxr-xr-x
File Type : JPEG
File Type Extension : jpg