Skip to content

Instantly share code, notes, and snippets.

View denmojo's full-sized avatar
😎

Dennis M denmojo

😎
View GitHub Profile
@denmojo
denmojo / latlong2maidenhead.c
Created June 9, 2019 07:47
Converts decimal longitude and latitude to Maidenhead Grid Square
void calcLocator(char *dst, double lat, double lon) {
int o1, o2, o3;
int a1, a2, a3;
double remainder;
// longitude
remainder = lon + 180.0;
o1 = (int)(remainder / 20.0);
remainder = remainder - (double)o1 * 20.0;
o2 = (int)(remainder / 2.0);
remainder = remainder - 2.0 * (double)o2;
@denmojo
denmojo / find_ip_cli.sh
Created September 18, 2017 02:23
Finding IP via CLI
dig +short myip.opendns.com @resolver1.opendns.com
@denmojo
denmojo / spoof_mac_addr.sh
Created July 12, 2017 06:46
Spoof MAC address on macOS
#!/bin/sh
sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's%\(..\)%\1:%g; s%.$%%')
@denmojo
denmojo / .zshrc
Created July 8, 2017 06:43
zsh prompt (macOS)
setopt HIST_IGNORE_SPACE
alias cleardns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache flushed"
PROMPT='%W %* ${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}%{$reset_color%}'
@denmojo
denmojo / restart.sh
Created January 13, 2017 00:59
Restarting a unix process unless exit 0
until myserver; do
echo "Server 'myserver' crashed with exit code $?. Respawning..." >&2
sleep 1
done
@denmojo
denmojo / amex.js
Created December 1, 2015 20:00 — forked from cardi/amex.js
automatically add all card offers on american express website
// instructions:
// 1. log in to american express
// 2. open the developer console in chrome
// 3. run the script below (at your own risk)
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
#!/bin/bash
MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=~\`{[}]|\\:;\"\'<,>.?/"
# ==> Password will consist of alphanum and punct characters.
LENGTH="24"
while [ "${n:=1}" -le "$LENGTH" ]
# ==> So, if 'n' has not been initialized, set it to 1.
do
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
@denmojo
denmojo / .tmux.conf
Created September 11, 2015 22:03 — forked from david-thorman/tmux.conf
Wooo tmux
set -g prefix C-a
unbind C-b
bind a send-prefix
# Setting vi style stuff
set -g status-keys vi
set -g history-limit 10000
setw -g monitor-activity on
unbind ,
bind-key A command-prompt -I "#W" "rename-window '%%'"
bind-key '"' choose-window
@denmojo
denmojo / dynmotd
Created June 30, 2015 21:55
Useful info for MOTD
<?php
exec("system_profiler SPFirewallDataType SPPowerDataType SPNetworkDataType SPSoftwareDataType 2>/dev/null", $systemvars);
$tree = array();
foreach($systemvars as $var){
if(preg_match("`^(\s+)(.*):\s+(.*)$`", $var, $match)){
$variable = $match[2];
$value = $match[3];
@denmojo
denmojo / .screenrc
Created June 9, 2015 19:01
GNU Screen configuration to show informative footer bar
# no annoying audible bell, please
vbell on
# detach on hangup
autodetach on
# don't display the copyright page
startup_message off
# Here comes the pain...