Skip to content

Instantly share code, notes, and snippets.

View jonathanpv's full-sized avatar
:atom:
coding a better world

Jonathan Padilla jonathanpv

:atom:
coding a better world
  • sf
View GitHub Profile
@jonathanpv
jonathanpv / dynamic_format.c
Last active June 12, 2020 20:25
Print out strings following a format but dynamically, you'll need to calculate how many bytes/bits to reallocate and don't forget about NULL terminators (that explains the +3 and +2)
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int NumberOfDigits (long long int n) {
int count = 0;
while (n != 0) {
n /= 10; // n = n/10
++count;
@jonathanpv
jonathanpv / dynamic_format_window.c
Created June 16, 2020 02:02
window formatting using sprintf, useful for windows in terminal
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int NumberOfDigits (long long int n) {
int count = 0;
while (n != 0) {
n /= 10; // n = n/10
++count;
@jonathanpv
jonathanpv / log.txt
Created September 13, 2022 18:17
error when running "make test"
jon.padilla@COMP-W936N7C769 vector % make test
cargo nextest run --workspace --no-fail-fast --no-default-features --features "default"
Downloading crates ...
Downloaded dirs v1.0.5
Downloaded test-case-macros v2.2.1
Downloaded test-case v2.2.1
Downloaded vec_map v0.8.2
Downloaded tracing-test v0.2.1
Downloaded encode_unicode v0.3.6
Downloaded tracing-test-macro v0.2.1
@jonathanpv
jonathanpv / cargo-run-output.txt
Created September 15, 2022 16:19
keys.rs help what should I return
jon.padilla@COMP-W936N7C769 cli % cargo run
Compiling vrl-stdlib v0.1.0 (/Users/jon.padilla/Documents/datadoge/vector/lib/vrl/stdlib)
Compiling vrl-cli v0.1.0 (/Users/jon.padilla/Documents/datadoge/vector/lib/vrl/cli)
Finished dev [unoptimized + debuginfo] target(s) in 3.42s
Running `/Users/jon.padilla/Documents/datadoge/vector/target/debug/vrl`
> VVVVVVVV VVVVVVVVRRRRRRRRRRRRRRRRR LLLLLLLLLLL
> V::::::V V::::::VR::::::::::::::::R L:::::::::L
> V::::::V V::::::VR::::::RRRRRR:::::R L:::::::::L
> V::::::V V::::::VRR:::::R R:::::RLL:::::::LL
> V:::::V V:::::V R::::R R:::::R L:::::L
@jonathanpv
jonathanpv / keys-output.txt
Created September 15, 2022 18:49
keys.rs how to make key from KeyValue into bytes without cloning
jon.padilla@COMP-W936N7C769 vector % cargo run vrl
Finished dev [unoptimized + debuginfo] target(s) in 2.03s
Running `target/debug/vector vrl`
> VVVVVVVV VVVVVVVVRRRRRRRRRRRRRRRRR LLLLLLLLLLL
> V::::::V V::::::VR::::::::::::::::R L:::::::::L
> V::::::V V::::::VR::::::RRRRRR:::::R L:::::::::L
> V::::::V V::::::VRR:::::R R:::::RLL:::::::LL
> V:::::V V:::::V R::::R R:::::R L:::::L
> V:::::V V:::::V R::::R R:::::R L:::::L
> V:::::V V:::::V R::::RRRRRR:::::R L:::::L
@jonathanpv
jonathanpv / reverse_dns error output
Created October 3, 2022 21:26
reverse_dns() when trying to compile to wasm
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling socket2 v0.4.7
error[E0583]: file not found for module `sys`
--> /Users/jon.padilla/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/lib.rs:124:1
|
124 | mod sys;
| ^^^^^^^^
|
= help: to create the module `sys`, create file "/Users/jon.padilla/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys.rs" or "/Users/jon.padilla/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.7/src/sys/mod.rs"
@jonathanpv
jonathanpv / state.js
Created October 4, 2022 16:54
saving url state
let state = {
program: '.name2 = "jonathan2"\nkeys({"key1": "val1"})',
event: {name: "jonathan"}
}
console.log(btoa(state));
window.history.pushState(state, "", `?state=${ btoa(JSON.stringify(state)) }`);
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const stateParam = urlParams.get('state');
@jonathanpv
jonathanpv / vrl_web_playground.js
Created October 11, 2022 18:13
generated js file
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
@jonathanpv
jonathanpv / log.txt
Created October 12, 2022 18:04
list of imports after running `wasmer inspect` on `wasm-pack` generated `.wasm` binary for vrl playground
Type: wasm
Size: 9.5 MB
Imports:
Functions:
"__wbindgen_placeholder__"."__wbindgen_describe": [I32] -> []
"__wbindgen_placeholder__"."__wbindgen_is_undefined": [I32] -> [I32]
"__wbindgen_placeholder__"."__wbg_log_d0151ef59bf97787": [I32, I32] -> []
"__wbindgen_placeholder__"."__wbindgen_object_drop_ref": [I32] -> []
"__wbindgen_placeholder__"."__wbindgen_string_get": [I32, I32] -> []
"__wbindgen_placeholder__"."__wbg_getTime_f14c1fb12257cc82": [I32] -> [F64]
@jonathanpv
jonathanpv / log.txt
Created October 25, 2022 14:54
showcasing wasm-pack working again
jon.padilla@COMP-W936N7C769 web-playground % wasm-pack build --target web --out-dir public
[INFO]: 🎯 Checking for the Wasm target...
[INFO]: 🌀 Compiling to Wasm...
Compiling proc-macro2 v1.0.47
Compiling quote v1.0.21
Compiling unicode-ident v1.0.0
Compiling syn v1.0.103
Compiling autocfg v1.1.0
Compiling cfg-if v1.0.0
Compiling memchr v2.5.0