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
| require "benchmark/ips" | |
| def f(x) | |
| x + 1 | |
| end | |
| a = (1..1000).to_a | |
| raise unless a.map(&method(:f)) == a.map { |x| f(x) } |
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
| class Array | |
| def sum | |
| reduce(0, :+) | |
| end | |
| def avg | |
| sum.fdiv(size) | |
| end | |
| end |
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
| use std::{fs::File, io::prelude::*}; | |
| fn main() { | |
| let mut file = File::open("numbers.txt").unwrap(); | |
| let mut s = String::new(); | |
| file.read_to_string(&mut s).unwrap(); | |
| let mut acc: Vec<i32> = s.lines().map(|line| line.parse().unwrap()).collect(); | |
| acc.sort_unstable(); | |
| acc.iter().take(10).for_each(|n| println!("{}", n)); |
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
| $ ruby ./factory_bot_issue.rb | |
| Fetching gem metadata from https://rubygems.org/.......... | |
| Resolving dependencies... | |
| Using rake 12.3.1 | |
| Using concurrent-ruby 1.0.5 | |
| Using i18n 1.0.0 | |
| Using minitest 5.11.3 | |
| Using thread_safe 0.3.6 | |
| Using tzinfo 1.2.5 | |
| Using activesupport 5.2.0 |
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
| :verbose NeomakeInfo #### Neomake debug information | |
| Async support: 1 | |
| Current filetype: rust | |
| Windows: 0 | |
| [shell, shellcmdflag, shellslash]:['/bin/bash', '-c', 0] | |
| ##### Enabled makers | |
| For the current filetype ("rust", used with :Neomake): |
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
| use std::collections::HashMap; | |
| use std::hash::Hash; | |
| trait GroupBy<T, F, K> { | |
| fn group_by(self, get_key: F) -> HashMap<K, Vec<T>>; | |
| } | |
| impl<T, F, K> GroupBy<T, F, K> for Vec<T> | |
| where | |
| F: Fn(&T) -> K, |
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 ruby | |
| require "active_support/core_ext/date" | |
| require "pp" | |
| def extract_date(line) | |
| regex = /HEAD@{(?<date>[^}]+)}/ | |
| return unless line =~ regex | |
| line.match(regex)[:date] | |
| end |
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
| [package] | |
| name = "instant-replay" | |
| version = "0.1.0" | |
| authors = ["davidpdrsn"] | |
| [dependencies] | |
| postgres = { version = "0.15", features = ["with-openssl"] } |
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
| Compiling diesel_demo v0.1.0 (file:///Users/davidpdrsn/Desktop/diesel_demo) | |
| error[E0277]: the trait bound `(schema::users::columns::id, schema::users::columns::slug, schema::users::columns::facebook_id, schema::users::columns::email, schema::users::columns::firstname, schema::users::columns::lastname, schema::users::columns::primary_pos_id, schema::users::columns::converted_at, schema::users::columns::country_id, schema::users::columns::role_id, schema::users::columns::last_active_at, schema::users::columns::created_at, schema::users::columns::updated_at, schema::users::columns::device_token, schema::users::columns::state, schema::users::columns::terms_accepted_at, schema::users::columns::gender, schema::users::columns::locale, schema::users::columns::digits_id, schema::users::columns::phone_number, schema::users::columns::google_id, schema::users::columns::profile_picture, schema::users::columns::time_zone, schema::users::columns::cached_number_of_followers, schema::users::columns::intercom_id, schema::us |