Skip to content

Instantly share code, notes, and snippets.

View huonw's full-sized avatar

Huon Wilson huonw

View GitHub Profile
@huonw
huonw / blackmagic.rs
Created January 15, 2014 12:42
do-while loops in Rust
while {
let x = foo();
bar(x);
x != 0
} {}
// from http://www.reddit.com/r/rust/comments/27s7ei/comparing_knn_in_rust/ci43euj
use std::kinds::marker;
use std::cmp;
use std::mem;
use std::mem::transmute;
// cribbed from both core::iter and core::slice
struct SliceZipIterator<'lt, A, B> {
@huonw
huonw / bash-tutorial.sh
Last active September 28, 2020 01:57
Bash Tutorial
#!/bin/bash
# (The directive above is called a "shebang": https://en.wikipedia.org/wiki/Shebang_(Unix) )
# Helper function that prints each of the arguments (functions can be
# declared with `function <name> { ... }` or `<name>() { ... })
printArguments() {
# arguments come in as the variables $1, $2, $3, ...
count=1
# (( ... )) does numeric tasks
while (( $# )); do
@huonw
huonw / flaky tests.ipynb
Created June 14, 2020 23:51
Find flaky tests in a Buildkite pipeline
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

The comments on this gist were created by selecting lines 96-98 in https://buildkite.com/bazel/android-studio-plugin/builds/1216#ed6edb2d-83c6-47b0-ba42-76aa09234910, copying, and pasting. The empty lines, whitespace, |s and --s on some lines were the result of the paste. The same behaviour was observed copying from Chrome or Safari, and pasting into either Chrome, Safari or Firefox (e.g. including Chrome -> Safari, and Safari -> Chrome); copying from Firefox had even less useful behaviour.

This only seems to occur in Github's issue/PR descriptions and comments. Pasting into other places, such as a text editor, or this Gist edit box works as expected (no empty lines, whitespace or |):

python3.6 bazelci.py project_pipeline --file_config=.bazelci/android-studio.yml | buildkite-agent pipeline upload'
2019-03-26 21:39:15 INFO   Reading pipeline config from STDIN
bazelci.py:585: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://m
@huonw
huonw / gist:2413449
Created April 18, 2012 13:09
rot13 bookmarklet
javascript:function%20convert(inText){var%20outText='',t;for(i=0;i<inText.length;i++){t=inText.charCodeAt(i);if((t>64&&t<78)||(t>96&&t<110))t%20+=%2013;else%20if((t>77&&t<91)||(t>109&&t<123))t%20-=%2013;outText%20+=%20String.fromCharCode(t);}return%20outText;}var%20sel=window.getSelection().getRangeAt(0);if(sel==''){var%20act=document.activeElement;if(act.type=="textarea"){var%20start=act.selectionStart,end=act.selectionEnd;if(start!=end){var%20prefix=act.value.substring(0,start);var%20middle=convert(act.value.substring(start,end));var%20suffix=act.value.substring(end);act.value=prefix;act.value%20+=%20middle;void(act.value%20+=%20suffix);}}else{void(inText=prompt('Phrase...',''));if(inText)alert(convert(inText));}}else{out=convert(sel.toString());sel.deleteContents();var%20span=document.createElement("span");span.innerHTML=out;sel.insertNode(span);}

Keybase proof

I hereby claim:

  • I am huonw on github.
  • I am huon (https://keybase.io/huon) on keybase.
  • I have a public key ASDY5j40gPNqAE7q8VTyb0c4AzsB1IDyygpi36x0_eMFmgo

To claim this, I am signing this object:

Announcement:

With Rust's first birthday upon us on May 15th, 2016, we should take this opportunity to reflect on where we've been, and where we're going. As part of the celebrations, we are pleased to announce the official 2016 State of the Rust Language Survey! Whether or not you use Rust today, we want to to know your opinions. Your responses will help the project understand its strengths and weaknesses, and to establish development priorities for the future.

The 2016 State of Rust Survey

Completing this survey should take about 5 to 10 minutes, and is anonymous unless you give us your contact information. We will be accepting submissions until June 8th, 2016.

Please help us spread the word by sharing the above link on your social network feeds, at meetups, and around your office and other communities.

@huonw
huonw / gist:8366072
Created January 11, 2014 02:06 — forked from brson/gist:8366039
macro_rules! report_diag (
($f: tt, $name: tt, $msg: tt, $(arg: tt)*) => { {
reg_diag_msg!($name, $msg);
let msg = format!($msg, $($arg)*);
let msg = format!("{}: {}", stringify!($name), msg);
$f(msg);
} };
($f: tt, $name: tt, $msg: tt) => { {
reg_diag_msg!($name, $msg);
let msg = format!("{}: {}", stringify!($name), $msg);
@huonw
huonw / gist:7351219
Created November 7, 2013 08:41 — forked from cnd/gist:7351205
fn ifV<'a, T>(rc : &str, star: &'a T) -> Option<&'a T> {
if (Path::new( rc )).exists() {
Some(star)
} else {
None
}
}