This file contains 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 bash | |
# Originally published on https://magnushoff.com/blog/kick-the-bitbucket/ | |
# Copyright (c) 2019 Magnus Hovland Hoff | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains 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
extern crate numtoa; | |
/* | |
real 0m1.080s | |
user 0m0.684s | |
sys 0m0.392s | |
*/ | |
fn one() { | |
let mut i: i32 = 0; | |
while i < 10000000 { |
This file contains 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
#![feature(scoped)] | |
use std::thread; | |
fn greet(peeps: &str) { | |
println!("Hello, {}", peeps); | |
} | |
fn indirect(peeps: &str) { | |
// In this case, `peeps` outlives the thread, but Rust does not |
This file contains 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
#include <iostream> | |
#include <array> | |
#include <vector> | |
#include <algorithm> | |
#include <random> | |
constexpr int pow3(int n) { | |
if (n == 0) return 1; | |
else return 3 * pow3(n-1); |
This file contains 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
extern crate core; | |
use std::io; | |
use std::rand; | |
use std::rand::distributions::{IndependentSample, Range}; | |
#[deriving(PartialEq)] | |
enum Field { | |
N, | |
X, | |
O, |
This file contains 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
# Python 3! | |
import random | |
def show(board): | |
print('+---+') | |
print('|%s|' % board[0:3]) | |
print('|%s|' % board[3:6]) | |
print('|%s|' % board[6:9]) | |
print('+---+') |
This file contains 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 python | |
import sys | |
words_file = "/usr/share/dict/words" | |
suffix = sys.argv[1] | |
candidates = set(w.strip()[:-len(suffix)] for w in open(words_file, 'rb') if w.strip().endswith(suffix)) | |
words = [w.strip() for w in open(words_file, 'rb') if w.strip() in candidates] |
This file contains 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/bash | |
CCS="gcc clang" | |
O_VARIANTS="-O0 -O2 -O3 -Os -O99" | |
SORTS="quick selection radix shell insertion bubble" | |
for CC in $CCS | |
do |