Skip to content

Instantly share code, notes, and snippets.

View dhhdev's full-sized avatar

Daniel Hyldebrandt Hemmingsen dhhdev

View GitHub Profile
@dhhdev
dhhdev / flatpak.zsh
Last active April 4, 2020 23:46
A collection of custom scripts mainly for sourcing, setting PATH etc.
# Making aliases for CLI to run flatpak sandboxes.
# I use zsh, but should be useable in bash as well.
# Requires find, basename
FLATPAK_ALIAS_PREFIX="fp"
FLATPAK_EXPORTS_PATH="/var/lib/flatpak/exports/bin"
FLATPAK_LIST=($(find $FLATPAK_EXPORTS_PATH -type l))
for FLATPAK_EXEC in "${FLATPAK_LIST[@]}"
@dhhdev
dhhdev / dst.c
Created January 22, 2018 21:53
Distance, speed, and time calculator. Measure time taken with certain distance and speed, or get the speed needed to travel a certain distance within a certain time.
#include <stdio.h>
#include <stdlib.h>
#define PROGRAM_NAME "dst"
#define AUTHOR "Daniel H. Hemmingsen"
typedef enum {FALSE, TRUE} BOOLEAN;
/*
* distance = speed * time
@dhhdev
dhhdev / wam.c
Last active December 18, 2017 08:19
Calculating moment, using (Q) kg * (D) m = (M) kgm.
#include <stdio.h>
#include <stdlib.h>
typedef enum {FALSE, TRUE} BOOLEAN;
void usage(char *program)
{
printf("Usage:\n");
printf("\tExample: %s 0 50 0.6\n\n", program);
printf("First argument is moment. (kgm)\n");
@dhhdev
dhhdev / fibonacci.c
Last active December 4, 2017 22:16
Fibonacci sequence between start and end term.
/*
* Fibonacci squence between start and end term.
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a = 0;

Keybase proof

I hereby claim:

  • I am dhhdev on github.
  • I am dhh (https://keybase.io/dhh) on keybase.
  • I have a public key whose fingerprint is C989 405D 350B 3DCB 1598 B202 9434 9D73 2CDB C9D6

To claim this, I am signing this object:

@dhhdev
dhhdev / christmas.sh
Last active October 17, 2016 19:36
BSD date version of how many days until Christmas :-)
#!/bin/sh
# Today, as day-of-year (1-366)
TODAY=$(date -j +"%j")
# Christmas day, in d-B-y format converted to days
CHRISTMAS=$(date -jf "%d-%B-%y" "25-DEC-16" +"%j")
echo "There are $(($CHRISTMAS - $TODAY)) days until Christmas."
@dhhdev
dhhdev / gcc.zsh
Last active July 1, 2016 06:21
A very simple set of .zsh (oh-my-zsh) custom stuff. Can be loaded in your ~/.oh-my-zsh/custom/ directory.
#
# ~/.oh-my-zsh/custom/gcc.zsh
#
# gcc wrapper for compiling ansi
# Usage: compile_ansi [output][files]
compile_ansi()
{
OUTPUT=$1
shift
@dhhdev
dhhdev / tmux-teacher.sh
Last active March 2, 2021 12:21
Only allow students to access sessions in progress with the read only flag, teachers can create tmux sessions as they wish.
#!/bin/bash
#
# ~/.tools/tmux-teacher.sh
#
# Author: Daniel H. Hemmingsen <[email protected]>
# Usage: tmux-teacher.sh session-name /path/to/start/from"
#
TEACHER_GROUP="teacher"
@dhhdev
dhhdev / tmux.sh
Created June 19, 2016 02:30
Create a named session to tmux with three panes, or attach if already present
#!/bin/bash
#
# ~/.tools/tmux.sh
#
# Author: Daniel H. Hemmingsen <[email protected]>
# Usage: tmux.sh session-name /path/to/start/from"
#
# Could make a simple check, with groups or something.
# To see if the students should get write access or not.
@dhhdev
dhhdev / compile.sh
Last active April 23, 2016 00:00
A script to quickly compile a file using gcc.
#!/bin/bash
# Save the file in /usr/local/bin/ and call it whatever you like.
# I simply call mine: compile
# Now I can compile a .c file with compile test.c command.
if [ -z "${1}" ]; then
echo "We can't take over the world, without compiling a file!"
else
if [ -z "${2}" ]; then