This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // clang++ --std=c++11 clang-crash.cpp | |
| template<typename F> | |
| auto foo(F f) -> decltype(f()) { } | |
| void bar() { | |
| foo([&]() { return *bogus; }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| if pgrep unity-settings > /dev/null; then | |
| exit | |
| fi | |
| xsetroot -solid black | |
| # sleeps: evade, don't solve, concurrency problems | |
| unity-settings-daemon& sleep 1; | |
| wmdocker & sleep 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This compiles without error on stable and beta but gives a borrow | |
| // error on nightly. It worked as of nightly 6e5a32547. | |
| // Replacing the .by_ref() with explicitly taking a &mut ref fixes it. | |
| // Other more dubious things fix it also. | |
| pub type Session = i32; | |
| pub struct StreamParser<'a, T: Iterator<Item=i32>> { | |
| _tokens: T, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Michael J. Sullivan (http://www.msully.net/) | |
| # Stupid little script to make gnome/unity media keys work when running | |
| # weirdo window managers like xmonad and notion. | |
| # Directions: | |
| # With unity-settings-daemon running, run this script in the background. | |
| # Tested on Ubuntu 15.04 using notion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This code is all kinds of illegal and tests whether other threads | |
| // keep running while there is an outstanding vfork | |
| #include <atomic> | |
| #include <thread> | |
| #include <iostream> | |
| #include <unistd.h> | |
| std::atomic<bool> child_running; | |
| std::atomic<bool> child_signaled; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let time_execution func = | |
| let start_time = Sys.time () in | |
| let ret = func () in | |
| let end_time = Sys.time () in | |
| end_time -. start_time, ret | |
| (* val time_execution : (unit -> 'a) -> float * 'a *) | |
| let print_stuff () = Printf.printf "hello, world\n" | |
| let compute_stuff () = 10 + 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copying variables into a tmp using __typeof__ is a common | |
| // pattern in hacky gcc C macros, but it can backfire and | |
| // allow the value to be evaluated twice! | |
| // This is because __typeof__ will evaluate its argument if | |
| // the value has a variably sized type! | |
| // gcc added __auto_type to get around this problem in its stdatomic.h, but I'm | |
| // not losing any sleep over this. | |
| // See http://patchwork.ozlabs.org/patch/290802/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Make a copy of a value that the compiler doesn't know anything about. | |
| #define launder_value(v) \ | |
| ({ \ | |
| __typeof__(v) __v = v; \ | |
| __asm__ __volatile__("" : "+r" (__v)::); \ | |
| __v; \ | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Control.Monad | |
| type Var = Integer | |
| type Subst = [(Var, Term)] | |
| type State = (Subst, Integer) | |
| type Program = State -> KList State | |
| data Term = Atom String | Pair Term Term | Var Var deriving Show | |
| -- Apply a substitution to the top level of a term |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Run a command with a lock if it looks like it is a linker command: that is, | |
| # if none of its arguments are -c. | |
| # Then you can do a build where compilation is parallel but linking is serial | |
| # by doing something like (for llvm/clang): | |
| # make -j4 'CXX=lock-linking /tmp/llvm-build-lock clang++' | |
| LOCKFILE="$1" |