let data: vec![0u8; 1024];
foo(data.as_ref()); // Passes an immutable slice
fn foo(data: &[u8]) {
...
}
This file contains 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
# Search only within a single file | |
rg <pattern> <filename> | |
rg <pattern> -g <filename pattern> | |
rg <pattern> --glob <filename pattern> | |
# Use ripgrep to extract unique 4 digit numbers from a file | |
`rg -o '\b\d{4}\b' <file_name> | sort -u` |
This file contains 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
package main | |
import ( | |
"fmt" | |
"os/exec" | |
) | |
func main() { | |
app := "echo" | |
arg0 := "-e" |
This file contains 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
// From: https://doc.rust-lang.org/rust-by-example/std_misc/file/read_lines.html | |
use std::fs::File; | |
use std::io::{self, BufRead}; | |
use std::path::Path; | |
fn main() { | |
// File hosts.txt must exist in the current path | |
if let Ok(lines) = read_lines("./hosts.txt") { | |
// Consumes the iterator, returns an (Optional) String |
This file contains 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strings" | |
) | |
func main() { |
This file contains 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
project(cpp_condition) | |
set(CMAKE_CXX_STANDARD 17) | |
add_executable(cpp_condition cpp-condition.cpp) |
This file contains 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
#include <iostream> | |
#include <string> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
std::mutex m; | |
std::condition_variable cv; | |
std::string data; | |
bool ready = false; |
This file contains 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
#![allow(non_upper_case_globals)] | |
#![allow(non_camel_case_types)] | |
#![allow(non_snake_case)] | |
include!("../bindings.rs"); | |
fn main() { | |
unsafe { | |
let size = fooGetCtxSize(); | |
println!("Ctx Size: {}", size); |
This file contains 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
#include <iostream> | |
#include <stdint.h> | |
#include <x86intrin.h> | |
#include "ippcp.h" | |
#include "examples_common.h" | |
#define DATA_SIZE 1024*1024 | |
#define DIGEST_SIZE 32 | |
#define ITERATIONS 10000 |
This file contains 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
# Read N lines of input, splitting each line and storing the result in a numpy array. | |
import numpy as np | |
a = np.array([input().split() for _ in range(N)], int) |
NewerOlder