Skip to content

Instantly share code, notes, and snippets.

// You come upon a column of four floors that have been entirely sealed off from the rest of the
// building except for a small dedicated lobby. There are some radiation warnings and a big sign
// which reads "Radioisotope Testing Facility".
struct Facility<'a> {
floors: Vec<Floor<'a>>,
}
struct Floor<'a>(Vec<Item<'a>>);
❯ cargo test
Compiling git2 v0.6.0 (file:///.../git2-rs)
error: borrowed value does not live long enough
--> src/config.rs:560:23
|
560 | for entry in &cfg.entries(None).unwrap() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value created here
...
564 | }
| - temporary value only lives until here
extern crate rand;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum Nationality {
Dane,
Brit,
Swede,
Norwegian,
German,
}
use std::env::args;
use std::fs::{read_dir, File};
use std::io::prelude::*;
use std::path::PathBuf;
fn main() {
let dirs = args().skip(1);
let paths = dirs.flat_map(|dir| {
read_dir(&dir)
.expect(&format!("unable to read dir {}", dir))
@kejadlen
kejadlen / main.rb
Last active July 19, 2016 15:42
Cleaning Alfred workflows
#!/usr/bin/env ruby
require 'tempfile'
plist = ARGF.read
Tempfile.create('info.plist') do |f|
f << plist
f.flush
vars = `/usr/libexec/PlistBuddy -c "Print :variablesdontexport" #{f.path}`
module Scrabble
POINTS = {}
{
'EAIONRTLSU' => 1,
'DG' => 2,
'BCMP' => 3,
'FHVWY' => 4,
'K' => 5,
'JX' => 8,
'QZ' => 10,
let authors = match config["authors"].as_hash() {
Some(v) => {
v.iter()
.filter_map(|(k, v)| {
vec![k.as_str(), v.as_str()]
.into_iter()
.collect::<Option<Vec<_>>>()
})
.map(|v| (v[0].into(), v[1].into()))
.collect::<HashMap<_, _>>()
require 'open-uri'
require 'rexml/document'
module GettingToPhilosophy
module Crawler
def self.crawl(*trail)
until trail.last == Wikipedia::PHILOSOPHY || trail.uniq.size != trail.size
puts trail.last
doc = Wikipedia.article(trail.last)
#!/usr/bin/env ruby
fan_speed = (ARGV.shift || 1100).to_i
smc = '~/Applications/smcFanControl.app/Contents/Resources/smc'
fan_speed = (fan_speed << 2).to_s(16)
`#{smc} -k F1Mx -w #{fan_speed}`
"Dodo" Doubleday: Fall In (1942)
3 Ninjas: High Noon at Mega Mountain (1998)
91:an Karlsson: Alla tiders 91 Karlsson (sv) (1953)
A Cry in the Wild/White Wolves: White Wolves III: Cry of the White Wolf (2000)
A Dennis the Menace Christmas (2007) (V)
A Nightmare on Elm Street 4: The Dream Master (1988)
A Thief on the Night: The Prodigal Planet (1983)
Abbott and Costello Meet Universal Monsters: Abbott and Costello Meet the Mummy (1955)
Aces Go Places 4 (1986)
Adams Apples: Torn (2011)