Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am danlucraft on github.
  • I am danlucraft (https://keybase.io/danlucraft) on keybase.
  • I have a public key whose fingerprint is 7395 C2F4 B97D 3FB8 2CD2 B439 D8D7 ECC8 B94E 2764

To claim this, I am signing this object:

012.rs:82:29: 82:47 error: type mismatch: the type `collections::vec::Vec<collections::vec::Vec<uint>>`
implements the trait `core::iter::FromIterator<collections::vec::Vec<uint>>`, but the trait
`core::iter::FromIterator<&collections::vec::Vec<uint>>` is required (expected &-ptr, found struct
collections::vec::Vec)
012.rs:82 let b: Vec<Vec<uint>> = a.iter().collect();
^~~~~~~~~~~~~~~~~~
error: aborting due to previous error
@danlucraft
danlucraft / choose.rs
Last active August 29, 2015 14:07
choose.rs
use std::os;
fn choose_k<'r, T>(arr: &[&'r T], k: uint) -> Vec<Vec<&'r T>> {
if k > arr.len() {
vec![]
} else if k == 0 {
vec![vec![]]
} else {
let mut result: Vec<Vec<&T>> = choose_k(arr.slice(1, arr.len()), k - 1).into_iter().map(|v| {
let mut x = vec![arr[0]];
<% if !@band_install.last_scraped and
@is_owner and
@artist.concerts.empty? and
@band_install.created_at > Time.now - 5.minutes %>
<center>
Checking your MySpace profile for tour dates...
Check back in a few minutes.
</center>
<% elsif @artist.concerts.empty? and @is_owner %>
<center>
using GLib;
using Gee;
namespace Gtk.Mate {
public class Marker : Object {
}
public class Scanner : Object, Iterable<Marker> {
public class Iterator<Marker> : Object, Gee.Iterator<Marker> {
// Vala string utility functions
// Started: 30 Aug 08
using GLib;
public class StringHelper {
// Replace all occurences of match_string with replacement_string inside start_string.
// Uses GLib.Regex.replace_literal internally. Returns the empty string if there was
// a RegexError.
public static string gsub(string start_string, string match_string, string replacement_string) {
require 'gtk2'
require 'gtksourceview2'
sv = Gtk::SourceView.new
win = Gtk::Window.new
win.set_size_request(800, 600)
win.add(sv)
sv.modify_base(Gtk::StateType::NORMAL, Gdk::Color.parse("#00FF00")); # doesn't work here
win.show_all
# put this into ~/.irbrc
require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:EVAL_HISTORY] = 1000
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = File::expand_path("~/.irbhistory")
# if you get readline missing errors you will need to install readline for your OS, then
# recompile Ruby with readline enabled in the ruby_src/ext/Setup file.
module Cucumber
module Formatters
class FailedFilesFormatter < ProgressFormatter
def initialize(step, _1, _2)
@bad_files = []
puts "Recording fails in bad_features"
@bad_files_io = File.open("bad_features", "w")
super(step)
end
def make_event_button(window, x, y, button, type)
case type
when :press
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON_PRESS)
when :release
event_button = Gdk::EventButton.new(Gdk::Event::BUTTON_RELEASE)
end
event_button.x = x
event_button.y = y