Skip to content

Instantly share code, notes, and snippets.

@rprichard
rprichard / gist:f0528270cd2f65ded875
Last active August 29, 2015 14:16
Current libcore/libstd single-argument panic call overhead
libcore panic!("message")
-------------------------
12 bytes:
48 8d 3d 53 dc 3a 00 lea 0x3adc53(%rip),%rdi #_MSG_FILE_LINE
e8 ce d7 ff ff callq ba540 # core::panicking::panic
40 bytes excluding string bytes:
@rprichard
rprichard / build.sh
Last active August 29, 2015 14:18
#[allow_internal_unstable], syntax extension plugin
#!/bin/sh
set -e
rustc foo_macro.rs
rustc main.rs -L.
@rprichard
rprichard / foo_macro.rs
Last active August 29, 2015 14:18
#[allow_internal_unstable] plugin #2
#![crate_type="dylib"]
#![feature(plugin_registrar, rustc_private, slice_patterns)]
extern crate syntax;
extern crate rustc;
use syntax::codemap::Span;
use syntax::ast;
use syntax::ext::base::*;
use syntax::ext::build::AstBuilder;
@rprichard
rprichard / test.mly
Created November 5, 2015 17:51
Menhir test grammar (also works with yacc)
%token ID
%token DOT
%token DOTDOT
%token EOF
%start prog
%type <Prog> prog
%nonassoc DOTDOT
%nonassoc DOT
@rprichard
rprichard / main.js
Created November 13, 2015 20:45
Crash Electron even with event.preventDefault
var BrowserWindow = require("browser-window");
var app = require("app");
var request = require('request');
app.on("ready", function() {
var dummyWindow = new BrowserWindow({
title: "Parent",
show: true,
});
var w = new BrowserWindow({
@rprichard
rprichard / main.html
Last active November 24, 2015 20:49
Electron remote showOpenDialog w/callback bug (https://github.com/atom/electron/issues/3565)
<html>
<head>
<script>
var blink = false;
window.setInterval(function() {
blink = !blink;
document.getElementById("blinkDiv").style.display =
blink ? "block" : "none";
}, 300);
1. In an empty directory, check out:
$ git clone -bwindows_fixes https://github.com/rprichard/tty.js.git
$ git clone -bwindows_fixes https://github.com/rprichard/pty.js.git
$ (cd pty.js/deps && rm -fr winpty)
$ (cd pty.js/deps && git clone -bnodejs_fix https://github.com/rprichard/winpty.git)
2. Establish an npm link from your user-global repo to your pty.js:
@rprichard
rprichard / output.txt
Last active April 4, 2016 19:27
Verbose MinGW-w64 compiler output from cross-compiling 32-bit Hello World on Cygwin64
rprichard@VBWIN7 ~/mess
$ i686-w64-mingw32-g++.exe --version
i686-w64-mingw32-g++ (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rprichard@VBWIN7 ~/mess
$ i686-w64-mingw32-g++.exe -v
@rprichard
rprichard / output.txt
Created April 6, 2016 20:34
Cygwin installer doesn't complain if -P package is missing
I opened an elevated command prompt, then started mintty with Cygwin bash inside it:
C:\>c:\cygwin64\bin\mintty c:\cygwin64\bin\bash -l
In the elevated mintty terminal, I ran setup-x86_64.exe:
rprichard@VBWIN7 ~
$ cd c:/Users/rprichard/Downloads
rprichard@VBWIN7 /cygdrive/c/Users/rprichard/Downloads
@rprichard
rprichard / output.txt
Created April 7, 2016 00:59
mpv debugserver output
rprichard@ATOM-W10 MSYS /c/rprichard/work
$ winpty-debugserver.exe
[90707.587 winpty.exe,p1520,t5064]: Created agent successfully, pid=5624, cmdline="C:\msys64\usr\bin\winpty-agent.exe" \\.\pipe\winpty-1520-1-control \\.\pipe\winpty-1520-1-data 113 52
[90707.624 winpty-agent.exe,p5624,t5000]: Agent starting...
[90707.624 winpty-agent.exe,p5624,t5000]: setSmallFont: attempting to set a small font (CP=437 OutputCP=437)
[90707.624 winpty-agent.exe,p5624,t5000]: previous font: nFont=8 dwFontSize=(8,16) FontFamily=0x36 FontWeight=400 FaceName=Consolas (43 6F 6E 73 6F 6C 61 73)
[90707.624 winpty-agent.exe,p5624,t5000]: previous font table: fonts 00-09: 4x6 6x8 8x8 16x8 5x12 - 7x12 8x12 16x12 8x16 8x16
[90707.624 winpty-agent.exe,p5624,t5000]: previous font table: fonts 10-11: 12x16 10x18
[90707.624 winpty-agent.exe,p5624,t5000]: setFontVista: setting font to: nFont=0 dwFontSize=(0,8) FontFamily=0x0 FontWeight=400 FaceName=Consolas (43 6F 6E 73 6F 6C 61 73)
[90707.625 winpty-agent.exe,p5624,t5000]: set