Skip to content

Instantly share code, notes, and snippets.

View nonelement's full-sized avatar
📝

Anthony Kirkpatrick nonelement

📝
View GitHub Profile
@nonelement
nonelement / ANSI.md
Created January 16, 2023 21:28 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@nonelement
nonelement / playground.rs
Created December 20, 2017 19:50 — forked from anonymous/playground.rs
Rust code shared from the playground
// 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;
@nonelement
nonelement / notes.html
Created December 13, 2017 02:10
editable pane
<html>
<body>
<a href="data:text/html,<style>textarea{width:100%;height:100%}</style><textarea></textarea>" target="_blank">notes</a>
</body>
</html>
@nonelement
nonelement / .time.me.sh
Created September 21, 2017 18:40
Add right hand timer to shell
# 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%}"
@nonelement
nonelement / increase_track.sh
Last active September 5, 2017 00:46
Increase Mouse Track Speed OSX
# 3.0 current ui max. Requires relogin.
defaults write -g com.apple.mouse.scaling -float 4.0
@nonelement
nonelement / keybase.md
Created August 16, 2017 02:28
Keybase Proof

Keybase proof

I hereby claim:

  • I am nonelement on github.
  • I am nonelement (https://keybase.io/nonelement) on keybase.
  • I have a public key ASCRvVBcH9Zp3V1C0Wy7YMUy-Lx4eKR9D87ezcS88jtAkQo

To claim this, I am signing this object:

@nonelement
nonelement / main.rs
Created May 12, 2017 20:30
Deoblique
// 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);
@nonelement
nonelement / playground.rs
Last active May 8, 2017 17:01 — forked from anonymous/playground.rs
Find integers in a list which sum to 0
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
})
}
@nonelement
nonelement / playground.rs
Last active May 8, 2017 17:03 — forked from anonymous/playground.rs
Apply Vigenere cipher to plaintext
// 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() {
@nonelement
nonelement / playground.rs
Last active May 8, 2017 17:04 — forked from anonymous/playground.rs
Determine if any list of integers has three consecutive, increasing integers
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));