Skip to content

Instantly share code, notes, and snippets.

@Thomashrb
Thomashrb / count numbers
Created January 27, 2017 09:50
c++ count bits lab04
//calculate
void util_heltall::beregn_data(){
antall_enere=0;
lengde=0;
pos_max_signifikant=0;
//calculate length of number
unsigned long long i = heltall;
while (i > 0){
# http://datakurre.pandala.org/2015/10/nix-for-python-developers.html
with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "env";
# Mandatory boilerplate for buildable env
env = buildEnv { name = name; paths = buildInputs; };
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup; ln -s $env $out
'';
@Thomashrb
Thomashrb / .spacemacs
Created June 18, 2018 10:50 — forked from adetokunbo/.spacemacs
.spacemacs enabling dante mode/nix/cabal in spacemacs main branch
;;; ...
;;; ...
;; List of additional packages that will be installed without being
;; wrapped in a layer. If you need some configuration for these
;; packages, then consider creating a layer. You can also put the
;; configuration in `dotspacemacs/user-config'.
;; Cabal/Nix haskell setup
dotspacemacs-additional-packages '(dante nix-sandbox)
@Thomashrb
Thomashrb / togglexkbmap.sh
Created November 5, 2019 22:28
toggle keyboard layout
#!/bin/bash
(setxkbmap -query | grep -q "layout:\s\+us") && setxkbmap no || setxkbmap us
@Thomashrb
Thomashrb / microcosm-onix-bisac-codes.csv
Created June 15, 2020 09:04 — forked from natebeaty/microcosm-onix-bisac-codes.csv
ONIX BISAC codes from microcosm publishing database, with some manually entered codes — use at your own risk!
ANT000000 Antiques & Collectibles / General
ANT001000 Antiques & Collectibles / Americana
ANT002000 Antiques & Collectibles / Art
ANT003000 Antiques & Collectibles / Autographs
ANT005000 Antiques & Collectibles / Books
ANT006000 Antiques & Collectibles / Bottles
ANT007000 Antiques & Collectibles / Buttons & Pins
ANT008000 Antiques & Collectibles / Care & Restoration
ANT009000 Antiques & Collectibles / Transportation
ANT010000 Antiques & Collectibles / Clocks & Watches
@Thomashrb
Thomashrb / 00-gentoo-btrfs-disk
Last active September 23, 2020 08:07 — forked from renich/00-gentoo-installation-partitioning.bash
Install Gentoo Desktop into BtrFS subvolumes
#!/usr/bin/env bash
## PARTITION DISKS
##################
# zap-all and clear partition table
sgdisk -Z /dev/sda && sgdisk -o /dev/sda
# create bios_grub partition
sgdisk -n 1::+8M -t 1:ef02 /dev/sda
# create boot partition
sgdisk -n 2::+512M -t 2:8300 /dev/sda
use "collections"
primitive Day01
fun val test_input(): String => "199\n200\n208\n210\n200\n207\n240\n269\n260\n263\n"
fun solve_part1(input: String): USize =>
let depths = _parse_entries(input)
var last_depth: USize = 0
// hack because the first will always be an increase
var incs: USize = -1
#include "matching_brackets.h"
#include <string.h>
struct Stack {
int top;
char data[20];
};
void push(struct Stack *s, char elem) {
s->top++;
@Thomashrb
Thomashrb / sequenced.sh
Last active November 25, 2022 13:59
Sequence 2 commands behind a lock
#!/usr/bin/env bash
# Locking from: https://gist.github.com/jpclipffel/0b8f470be029fc9e3f07
# Run two bash commands in sequence using flock to prevent
# from running multiple instances in paralell
# ./sequenced.sh -g echo 'Hello' > test.txt -t cat test.txt -n lock_name
while getopts 1:2:n: flag; do
case "${flag}" in
1) FIRST_CMD=${OPTARG} ;;
❯ npm i
npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
npm WARN deprecated @types/testing-library__react@10.2.0: This is a stub types definition. testing-library__react provides its own type definitions, so you do not need this installed.
added 1725 packages, and audited 1726 packages in 20s