This file contains hidden or 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
# https://adventofcode.com/2021/day/3 | |
require 'pp' | |
require_relative 'get_response' | |
# Abstracted getting/parsing input | |
raw = GetResponse.new(day: 3).call | |
# ----- Part 2 ------ | |
# writing my own transpose just for fun |
This file contains hidden or 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
fn use_v() { | |
let mut v = make_v(); | |
let w = &mut v; | |
w.push(8); // error! Cannot borrow `v` as immutable | |
print_v(&v); // because it is also borrowed as mutable | |
} | |
fn print_v(v: &Vec<i32>) { | |
println!("{}", v[0]); |
This file contains hidden or 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
fn use_x() { | |
let v = make_v(); | |
print_v(&v); | |
print_v(&v); | |
} | |
fn print_v(v: &Vec<i32>) { | |
println!("{}", v[0]); | |
} |
This file contains hidden or 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
fn use_v() { | |
let v = make_v(); | |
print_v(v); // error! use of moved value: `v` | |
print_v(v); // value used here after move | |
} | |
fn print_v(v: Vec<i32>) { | |
println!("{}", v[0]); | |
} |
This file contains hidden or 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
fn use_v() { | |
let v = make_v(); | |
print_v(v); | |
} | |
fn print_v(v: Vec<i32>) { | |
println!("{}", v[0]); | |
} | |
fn make_v() -> Vec<i32> { |
This file contains hidden or 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
fn make_v() { | |
let mut v = vec![2, 4]; // owned by make_v's scope | |
v.push(8); | |
// scope ends, `v` is destroyed | |
} |
This file contains hidden or 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
navigator.getUserMedia = navigator.getUserMedia || | |
navigator.webkitGetUserMedia || | |
navigator.mozGetUserMedia; | |
var SKYWAY_API_KEY = 'XXXXXXXXXXXXXXX'; | |
var peer =null; | |
var selfId = null; | |
var localStream = null; | |
function initializePeer(callback) { |
This file contains hidden or 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
<!-- Video element (live stream) --> | |
<label>Video Stream</label> | |
<video autoplay id="video" width="640" height="480"></video> | |
<!-- Canvas element (screenshot) --> | |
<label>Screenshot (base 64 dataURL)</label> | |
<canvas id="canvas" width="640" height="480"></canvas> | |
<!-- Capture button --> | |
<button id="capture-btn">Capture!</button> |
This file contains hidden or 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
Proc.new do |elem| | |
elem.send(:to_s) | |
end |
This file contains hidden or 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
{ | |
"timezone": "GMT+0000 (UTC)", | |
"results": [ | |
{ | |
"date_parser": "chronic", | |
"date_elem": [ | |
"(m|mm)/(d|dd)/yy", | |
"yyyy.mm.dd" | |
] | |
} |
NewerOlder