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
require 'parser/current' | |
code = <<-RUBY | |
class Model | |
def initialize | |
@a = 1 | |
@b = 2 | |
end | |
def a1 |
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
class InjectMe | |
def initialize( | |
kernel:, | |
name_utils_class:, | |
text_helper_class:, | |
email_class:, | |
car:, | |
pet:, | |
payment_processor:, | |
random_class:, |
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
use sha2::{Digest, Sha256}; | |
use std::fmt::Write; | |
fn main() { | |
println!("Answer is {:?}", rust_mine("hello")); | |
} | |
pub fn rust_mine(text: &str) -> String { | |
let mut hasher = Sha256::new(); | |
let mut text = text.to_string(); | |
(0..std::usize::MAX) | |
.find_map(|nonce| { |
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
use sha2::{Digest, Sha256}; | |
fn main() { | |
println!("Answer is {:?}", rust_mine("hello")); | |
} | |
pub fn rust_mine(text: &str) -> String { | |
let mut hasher = Sha256::new(); | |
(0..std::usize::MAX) | |
.find_map(|nonce| { | |
hasher.input(&format!("{}{}", text, nonce)); | |
let result = hasher.clone().result(); |
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
use std::collections::HashMap; | |
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn it_works() { | |
let ints = vec![1, 3, 5, 7, 8, 1]; | |
assert_eq!(average(&ints), 4.166666666666667); | |
assert_eq!(median(&ints), 6.0); |
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
def handle_event(persisted_event) do | |
with :not_handled <- ActionFramework.handle_event(persisted_event), | |
:not_handled <- Action.handle_event(persisted_event), | |
:not_handled <- Comment.handle_event(persisted_event) do | |
:error |
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 ruby | |
# Open Buildkite builds for the current repo and branch | |
repo = `git config --get remote.origin.url | sed -nE 's/.*\\.com[:\\/]?(.*)?/\\1/p' | sed -E 's/.git//'`.chomp | |
branch = ARGV.length > 0 ? ARGV[0] : `git rev-parse --abbrev-ref HEAD`.chomp | |
`open https://buildkite.com/#{repo}/builds?branch=#{branch}` |