Skip to content

Instantly share code, notes, and snippets.

// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@arve0
arve0 / aoc15_d8.rs
Created July 17, 2018 15:10 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn main() {
let counts: Vec<_> = get_test_input().split("\n").map(|line| (code_count(line), char_count(line))).collect();
let expected = vec![(2, 0), (5, 3), (10, 7), (6, 1)];
assert_eq!(expected, counts);
let solution = get_test_input().split("\n").map(code_count).sum::<usize>() -
get_test_input().split("\n").map(char_count).sum::<usize>();
assert_eq!(12, solution);
let solution = get_input().split("\n").map(code_count).sum::<usize>() -
@arve0
arve0 / lifetime_keep_reference_to_string.rs
Last active July 4, 2018 13:58 — forked from rust-play/playground.rs
Code shared from the Rust Playground
/* how to keep reference to string in struct with lifetime */
fn main() {
let a = A::new("aaaasfd");
println!("{:?}", a);
}
#[derive(Debug)]
struct A<'a> {
s: &'a str,
@arve0
arve0 / mutable_map_closure_and_function.rs
Last active June 22, 2018 12:54 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::ops::Range;
fn map_mut<T, F>(arr: &mut [T], range: Range<usize>, f: F)
where
F: Fn(&T) -> T
{
let slice = arr[range].iter_mut();
for element in slice {
*element = f(element);
@arve0
arve0 / mutable_map.rs
Created June 22, 2018 12:18 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::ops::Range;
fn map_mut<T, F>(arr: &mut [T], range: Range<usize>, f: F)
where
F: Fn(&T) -> T
{
let slice = arr[range].iter_mut();
for element in slice {
*element = f(element);
# Author: Ole Kristian Pedersen
from turtle import *
from time import sleep
TEXT = """
______ _ _
| ___ \ | | | |
| |_/ / _| |_| |__ ___ _ __
| __/ | | | __| '_ \ / _ \| '_ \\