Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1B
- Decimal:
27
// Advent of Code 2017, Day 3 | |
// Author: Nonelement (Anthony Kirkpatrick) | |
fn close_travel(start: i32, step: i32, target: i32) -> Box<FnMut() -> (i32, i32)> { | |
let mut x = 0; | |
let mut y = 0; | |
let mut _sum = target; | |
let mut _current = start; | |
let mut _stride = step; | |
let _step = step; |
<html> | |
<body> | |
<a href="data:text/html,<style>textarea{width:100%;height:100%}</style><textarea></textarea>" target="_blank">notes</a> | |
</body> | |
</html> |
# Lifted from: https://coderwall.com/p/kmchbw/zsh-display-commands-runtime-in-prompt | |
# `source .time.me.sh` to add timer to shell nonelement@null | |
function preexec() { | |
timer=${timer:-$SECONDS} | |
} | |
function precmd() { | |
if [ $timer ]; then | |
timer_show=$(($SECONDS - $timer)) | |
export RPROMPT="%F{cyan}${timer_show}s %{$reset_color%}" |
# 3.0 current ui max. Requires relogin. | |
defaults write -g com.apple.mouse.scaling -float 4.0 |
I hereby claim:
To claim this, I am signing this object:
// Makes a sequential matrix of the given dimensions | |
fn mk_seq_matrix(x: i32, y: i32) -> Vec<Vec<i32>> { | |
let mut matrix: Vec<Vec<i32>> = Vec::new(); | |
let mut row: i32 = -1; | |
for v in 0..(x * y) { | |
if (v % x) == 0 { | |
matrix.push(vec![]); | |
row += 1; | |
} | |
matrix[row as usize].push(v); |
use std::collections::HashSet; | |
// Make HashSet from a list of integers | |
fn as_hs(v: Vec<i32>) -> HashSet<i32> { | |
v.iter().fold(HashSet::new(), |mut a, e| { | |
a.insert(*e); | |
a | |
}) | |
} |
// Apply Vigenere cipher to plaintext. Will convert to lower case, wont remove special characters (spaces, punctuation). | |
fn vigenere<'a>(text: &'a str, key: &'a str) -> String { | |
let alphabet: Vec<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect(); | |
let key_set: Vec<char> = key.to_lowercase().chars().collect(); | |
let mut expanded_key: Vec<char> = Vec::new(); | |
let mut cipher_text = String::new(); | |
for i in 0..text.len() { | |
expanded_key.push(key_set[i % key_set.len()]); | |
} | |
for (i, c) in text.to_lowercase().chars().filter(|c| *c != ' ').enumerate() { |
fn has_increasing(v: Vec<i32>) -> bool { | |
v.windows(3).any(|w| w[0] < w[1] && w[1] < w[2]) | |
} | |
fn main() { | |
let a = vec![1, 3, 4, 5, 7]; | |
let b = vec![7, 5, 4, 3, 1]; | |
println!("{:?}", has_increasing(a)); | |
println!("{:?}", has_increasing(b)); | |