Skip to content

Instantly share code, notes, and snippets.

View craig-m's full-sized avatar
💾

Craig-M craig-m

💾
View GitHub Profile
@craig-m
craig-m / kodi-rpc-post_notification.sh
Created November 22, 2015 10:42
Kodi notification
#!/bin/bash -v
VAR="some notification"
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"Title","message":"'$VAR'"},"id":1}' http://10.1.1.5:80/jsonrpc
@craig-m
craig-m / gist:4783e78f9c281da2cc85
Created November 22, 2015 10:43
List shells without a tty
ps -ef | awk '$6=="?"&&$8~/^(\/bin\/)?(ba|da|z|k|c|tc)*sh-?/{print}'
@craig-m
craig-m / gist:6f2c48e09dd9f37a99fc
Created November 22, 2015 10:44
list active pcaps
ss -f link -n -l -p
@craig-m
craig-m / drop_memcache.sh
Created November 22, 2015 10:50
Drop cached memory
#!/bin/bash
#
# Writing to this will cause the kernel to
# free pagecache, dentries and inodes.
# This causes that memory to become free.
#
# non-destructive & safe for production:
# ref: https://www.kernel.org/doc/Documentation/sysctl/vm.txt
freebefore=`free -k | awk '/^Mem:/{print $4}'`
@craig-m
craig-m / hugo_webdev_playbook.yml
Created December 16, 2016 10:47
single page ansible playbook for gohugo.io webdev
---
# everything needed for n0de.cloud Hugo web dev
#
# $ ansible-playbook webdev_playbook.yml -i localhost
- name: hugo webdev complete
hosts: localhost
connection: local
@craig-m
craig-m / gist:0ebb7c70b37436d254858db7dc089c38
Created February 6, 2018 01:58
curl unix socket request
pi@host:~ $ curl -X GET --unix-socket /opt/path/some.socket http/hello/curltest
<!DOCTYPE html>
<html>
<head>
<title>Hello from flask</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
</head>
<body>
<h1>Hello curltest!</h1>
</body>
@craig-m
craig-m / gist:714a465d7e7e4ae739ff1311850a9228
Created February 6, 2018 02:04
a setuid c wrapper for /sbin/reboot
Setuid reboot wrapper script
The reboot_setuid.c file (11 lines):
```
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
@craig-m
craig-m / .screenrc
Created February 8, 2018 02:29
A screenrc file. top bar for info, bottom bar for shell tabs.
# ~/.screenrc
#
# look and feel
caption always "%{= bb}%{+b w}%h ${USER}@%H %= %c %{=b rw} %l %{= db}%{= dg}"
hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
#
# skip the startup message
startup_message off
#
# go to home dir
@craig-m
craig-m / ufw_install.sh
Last active December 12, 2018 13:18
simple inbound/outbound UFW for debian linux
#!/bin/bash
apt-get install -y ufw;
# default
ufw default deny outgoing
ufw default deny incoming
# inbound
ufw allow 8080/tcp
@craig-m
craig-m / gist:df4250bd95849581cbcfb9eaf690bb65
Created November 27, 2018 02:44
disable onboard LEDs on beaglebone
sudo sh -c "echo none > /sys/class/leds/beaglebone\:green\:usr0/trigger"