Skip to content

Instantly share code, notes, and snippets.

@MatejLach
MatejLach / asound.conf
Created September 4, 2018 21:48
Alsa config for Pi carwarings
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speakerbonnet {
type hw card 0
}

Keybase proof

I hereby claim:

  • I am matejlach on github.
  • I am matejlach (https://keybase.io/matejlach) on keybase.
  • I have a public key ASDeZ_P8SeBjxLxDy8msngThxsarPrPHpVVoJQhtHQMSIQo

To claim this, I am signing this object:

/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+apacheconf+bash+c+cpp+coffeescript+css-extras+dart+erlang+fsharp+git+go+haml+handlebars+haskell+http+jade+java+julia+latex+less+markdown+nasm+perl+php+php-extras+python+r+jsx+rest+ruby+rust+sas+scss+scala+sql+swift+typescript+wiki+yaml&plugins=autolinker+file-highlight+show-language+highlight-keywords */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
@MatejLach
MatejLach / struct.rs
Last active August 29, 2015 14:04
Showcases a Rust struct...
fn main() {
struct Date {
m: int,
y: int
}
let today = Date {m: 8i, y: 2014i};
println!("\"August\" is the {}th month in {} (and every other year)", today.m, today.y); // access individual fields
}
@MatejLach
MatejLach / tuples.rs
Created August 4, 2014 16:24
How to use tuples in Rust...
fn main() {
let date = ("Today", 4i, 8i, 2014i); // simple tuple
println!("{}", date);
let (wd, d, m, y) = ("Today", 4i, 8i, 2014i); // destructuring let
println!("{} is {}/{}/{}", wd, d, m, y); // accessing individual variables from the tuple
}
@MatejLach
MatejLach / integer_addition.rs
Created August 4, 2014 10:23
Showcases integer addition using a function in Rust...
use std::io;
fn add(x: int, y: int) -> int { // takes two integers and returns an integer
x + y
}
fn main() {
println!("Simple Addition Calculator, written in Rust!");
println!("Enter 1st number: ");
@MatejLach
MatejLach / user_input.rs
Created August 2, 2014 15:03
Showcases standard input in Rust...
use std::io;
fn main() {
println!("Type something:");
let input = io::stdin()
.read_line() // read user input
.ok().expect("unable to read input!"); // Display this in case of a problem reading user input
// convert to &str and get rid of the newline
@MatejLach
MatejLach / constant.rs
Created August 1, 2014 15:46
Example of a global constant in Rust
static Pi: f64 = 3.14;
fn display_pi() {
println!("{}", Pi);
}
fn main() {
display_pi()
}
@MatejLach
MatejLach / &str2String.rs
Created August 1, 2014 14:53
An example of how to convert a &'static str to a String in Rust
fn main() {
// Example of a &str to a String conversion
use std::str;
let str_slice = "Here is a \"&'static str\"";
let str_repl = str::replace(str_slice, "is", "was"); // String replacement
println!("{}, now it's a \"String\".", str_repl.to_string()); // String conversion
// To go from a String to a &str, use the as_slice() method.
}
@MatejLach
MatejLach / reference.rs
Created July 30, 2014 15:50
An example of borrowing using references in Rust...
fn main() {
let x = box 5i; // Creates a box
let y = x; // Transfers ownership to "y"
let x = &y; // "x" now references what "y" owns
println!("{}", x); // This will compile successfully
}