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 | |
## USAGE: | |
## - put this file into your $PATH e.g. /usr/local/bin | |
## - make it executable: chmod a+x /usr/local/bin/cargo-bump | |
## - in your rust project just call: cargo bump | |
BAK_BRANCH=$(git branch --show-current) | |
B=chore/update-minor-versions-$(date +'%Y-%m-%d') |
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
# convert an ssh key to pem format | |
ssh-keygen -f ~/.ssh/id_rsa.pub -e -m pem > ~/.ssh/id_rsa.pub.pem |
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 <Carbon/Carbon.h> | |
// compile with: | |
// clang -framework carbon get-win.c -o get-win | |
int main(int argc, const char *argv[]) { | |
CGWindowListOption options = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; | |
CFArrayRef windows = CGWindowListCopyWindowInfo(options, kCGNullWindowID); | |
CFIndex count = CFArrayGetCount(windows); |
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
<script> | |
let s = 0; | |
let m = 0; | |
let active = false; | |
let timer; | |
function setActive(a) { | |
active = a; | |
if(!active) { | |
clearInterval(timer) |
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
#[derive(Debug)] | |
pub struct List { | |
head: Link, | |
} | |
#[derive(Debug)] | |
pub struct Node { | |
next: Link, | |
data: i32, | |
} |
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
FROM rust:latest as builder | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
musl-tools | |
RUN rustup target add x86_64-unknown-linux-musl | |
RUN rustup component add clippy | |
WORKDIR /x |
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
// test/alphabet_position_test.rs | |
use dev_challenge_47::alphabet_position; // <-- we don't have this function yet | |
#[test] // <-- how to define a test in rust | |
fn it_should_replace_the_a_with_1() { // <-- we express the requirement as name | |
let replaced = alphabet_position("a"); | |
assert_eq!(replaced, "1"); // <-- we assert that the both are equal | |
} |
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
// src/lib.rs | |
pub fn alphabet_position(s: &str) -> String { | |
String::from("Hello") | |
} |
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
// src/lib.rs | |
pub fn alphabet_position(s: &str) -> String { | |
s.chars() // <-- get an iterator over all chars | |
.map(|x| -> u8 { x as u8 - 'a' as u8 + 1 }) // <-- substract the ascii value of 'a' | |
.map(|x| -> String { x.to_string() }) // <-- convert the char to a String | |
.collect::<Vec<String>>() // <-- collect a Vector of String | |
.join(" ") // <-- join the Strings by whitespace | |
} |
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
// test/alphabet_position_test.rs | |
#[test] | |
fn it_should_replace_the_capital_a_with_1() { | |
let replaced = alphabet_position("A"); | |
assert_eq!(replaced, "1"); | |
} |
NewerOlder