Skip to content

Instantly share code, notes, and snippets.

@hroi
hroi / config.toml
Last active May 19, 2024 19:24
scm-diff-editor as external editor in Jujutsu (jj)
# Running scm-diff-editor as an external binary fixes the issue where
# deletions are not recorded correctly.
#
# Install scm-diff-editor binary:
# cargo install --git https://github.com/arxanas/scm-record.git --features scm-diff-editor
[ui]
# diff-editor = ":builtin"
diff-editor = "scm-diff-editor"
@hroi
hroi / fish_jj_prompt.fish
Last active May 24, 2024 22:12
Jujutsu (jj) prompt for fish-shell
# Place me in ~/.config/fish/functions
# Then add me to `fish_vcs_prompt`: `funced fish_vcs_prompt`
function fish_jj_prompt --description 'Write out the jj prompt'
# Is jj installed?
if not command -sq jj
return 1
end
# Are we in a jj repo?
{
"EventId": 1844225537,
"LogLevel": "Debug",
"Category": "GraphQLAPI.ExecutionEventListener",
"Message": "Executing query: `query GetPersonAndProperties($personId: ID!, $first: Int, $after: String) {\n personViaId(personId: $personId) {\n ... PersonFields\n }\n ejerskaberViaPersonId(personId: $personId, first: $first, after: $after) {\n ... PersonEjerskabFields\n }\n}\n\nfragment PageInfoFields on PageInfo {\n __typename\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n}\n\nfragment EjerEjerskabEjendomFields on Ejendom {\n __typename\n id\n status\n bfeNummer\n ... on SamletFastEjendom {\n enheder {\n ... EnhederFields\n }\n bygninger {\n ... BygningerFields\n }\n grunde {\n ... GrundFields\n }\n }\n ... on BygningPaaFremmedGrund {\n enheder {\n ... EnhederFields\n }\n bygninger {\n ... BygningerFields\n }\n }\n ... on Ejerlejlighed {\n enheder {\n ... EnhederFields\n }\n }\n}\n\nfragment GrundFields
@hroi
hroi / config.toml
Created September 24, 2023 18:19
Some vim movements in Helix
[keys.normal]
# VIMisms:
# same as "]p"
"}" = "goto_next_paragraph"
# same as "[p"
"{" = "goto_prev_paragraph"
# same as "gh"
"0" = "goto_line_start"
# same as "gs"
"^" = "goto_first_nonwhitespace"
@hroi
hroi / playground.rs
Created July 2, 2019 20:28 — forked from rust-play/playground.rs
Code shared from the Rust Playground
pub struct Sentences<'a> {
pub inner: &'a str,
}
pub fn sentences(input: &str) -> Sentences {
Sentences { inner: input }
}
const TOK_WHITESPACE: u32 = 1;
const TOK_PERIOD: u32 = 1 << 1;
const TOK_UPPERCASE: u32 = 1 << 2;
@hroi
hroi / markup.pest
Last active February 17, 2019 00:38
Document = { SOI ~ (WHITE_SPACE+ | instr_doctype | Text | Element )+ ~ EOI }
Text = { (!(WHITE_SPACE* ~ "<" | ">") ~ ANY)+ }
Comment = { (!(WHITE_SPACE* ~ "-->") ~ ANY)+ }
Element = {
WHITE_SPACE* ~
(
tag_comment |
tag_void |
tag_open ~ WHITE_SPACE* ~ (Element | Text | WHITE_SPACE+)* ~ tag_close |
create table apples (
apple_id int not null generated by default as identity primary key,
apple_name text not null
);
create table oranges (
orange_id int not null generated by default as identity primary key,
orange_name text not null
);
-- Computus
-- Easter in the Gregorian calendar
-- Copied from https://docs.rs/computus/1.0.0/src/computus/lib.rs.html
CREATE OR REPLACE FUNCTION computus_gregorian(_year INTEGER)
RETURNS DATE AS $$
DECLARE
AA INTEGER;
BB INTEGER;
CC INTEGER;
snmptable:
SNMP table: CISCO-ENTITY-SENSOR-MIB::entSensorThresholdTable
index entSensorThresholdSeverity entSensorThresholdRelation entSensorThresholdValue entSensorThresholdEvaluation entSensorThresholdNotificationEnable
1063.1 major greaterOrEqual 900 false false
1063.2 minor greaterOrEqual 850 false false
1063.3 minor lessOrEqual -50 false false
1063.4 major lessOrEqual -100 false false
SNMP table: CISCO-ENTITY-SENSOR-MIB::entSensorValueTable
@hroi
hroi / rawvec.rs
Last active January 9, 2017 23:21
pub struct RawVec<T> {
mem: *mut T,
cap: usize,
}
impl<T> RawVec<T> {
pub fn with_capacity(cap: usize) -> RawVec<T> {
let mut vec = Vec::<T>::with_capacity(cap);
let ptr = vec.as_mut_ptr();
mem::forget(vec);