Skip to content

Instantly share code, notes, and snippets.

@stevedoyle
stevedoyle / journlctl.md
Last active July 9, 2021 09:54
Linux journlctl usage notes

Journalctl

On newer Linux systems, especially Fedora based, journalctl often replaces the syslog output in /var/log/messages.

Monitoring syslog

Monitor new syslog entries (similar to tail -f /var/log/messages):

journalctl -f

@stevedoyle
stevedoyle / vscode-notes.md
Last active July 12, 2021 09:42
Visual Studio Code Notes

Visual Studio Code Notes

Remote SSH

Add proxy details for the remote host to use when loading extensions. Details are added to the settings.json on the remote host.

"http.proxy": "proxy_url:port"

@stevedoyle
stevedoyle / Using-Conda.md
Last active November 26, 2021 11:11
Using Conda

Using Conda

Creating a new environment. In this example, the environment is setup to use python 3.10

    $ conda create --name py10 python=3.10

Activating an environment

 $ conda activate py10
# 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)
@stevedoyle
stevedoyle / rust-snippets.md
Last active October 20, 2022 09:01
Rust code snippets

Rust Snippets

Pass a Vec<> by reference to a function

let data: vec![0u8; 1024];
foo(data.as_ref()); // Passes an immutable slice

fn foo(data: &[u8]) {
    ...
}
@stevedoyle
stevedoyle / ipp_sha_hash_example.cpp
Created January 25, 2023 15:09
Example of using IPP Crypto Primitives for SHA hashing
#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
@stevedoyle
stevedoyle / RustCallingCCodeWithOpaquePointers.rs
Created February 9, 2023 16:45
Rust code for calling C APIs that use opaque pointers
#![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);
@stevedoyle
stevedoyle / cpp-condition.cpp
Created February 20, 2023 20:39
Example of using a condition variable with a mutex using std C++
#include <iostream>
#include <string>
#include <thread>
#include <mutex>
#include <condition_variable>
std::mutex m;
std::condition_variable cv;
std::string data;
bool ready = false;
@stevedoyle
stevedoyle / CMakeLists.txt
Created February 20, 2023 20:43
Example CMakeLists.txt template
project(cpp_condition)
set(CMAKE_CXX_STANDARD 17)
add_executable(cpp_condition cpp-condition.cpp)
@stevedoyle
stevedoyle / scanner.go
Last active March 5, 2023 21:35
Go: Reading a string with spaces from stdin using bufio
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {