Skip to content

Instantly share code, notes, and snippets.

View cyrus-and's full-sized avatar

Andrea Cardaci cyrus-and

View GitHub Profile
@cyrus-and
cyrus-and / pastebin.sh
Created November 4, 2012 19:53
Quick way to pipe data to pastebin.com directly from shell
#!/usr/bin/env bash
# usage: <command> | pastebin [+|++|+++]
#
# (none): paste expires in 10 minutes
# +: paste expires in 1 hour
# ++: paste expires in 1 day
# +++: paste expires in 1 months
HOST='pastebin.com'
@cyrus-and
cyrus-and / deprocrastinator.sh
Last active December 18, 2015 21:09
Track the time spent on X11 applications
#!/usr/bin/env bash
#
# Track the time spent on X11 applications.
#
# Dependencies: coreutils x11-utils xprintidle
#
# Usage:
#
# $ deprocrastinator > out.log # 1. record
# $ deprocrastinator out.log # 2. analyze
@cyrus-and
cyrus-and / this.js
Last active July 9, 2019 11:50
JavaScript `this` examples from http://stackoverflow.com/a/12371105/477168
// JavaScript `this` examples from http://stackoverflow.com/a/12371105/477168
// The value of this in a function is sometimes called the "context" in which
// the function runs. The most important thing to understand is that a function
// object does not have a fixed context -- the value of this changes depending
// on how the function is called.
// If the function is called as a "raw" function (e.g., just do someFunc()),
// this will be window (or undefined if the function runs in strict mode).
@cyrus-and
cyrus-and / qp.sh
Last active August 29, 2015 14:00
Gnuplot wrapper with better defaults for quick line charts
#!/usr/bin/env bash
#
# QuickPlot - Gnuplot wrapper with better defaults for quick line charts
#
# Usage:
# qp < file.dat
# qp file-1.dat file-2.dat ...
#
# File formats:
# - <x>
@cyrus-and
cyrus-and / README.md
Last active November 23, 2015 15:38
Override the behavior of existing functions

Synopsis

override([parent], property, callback);

Override the behavior of existing functions.

  • parent is the object containing the function to be called, it can be:
    • omitted: the window object is used;
    • a constructor function (e.g., String): its prototype is used;
  • an object: used as it is.
@cyrus-and
cyrus-and / hot-spot.sh
Last active December 4, 2015 19:17
Instant Wi-Fi AP
#!/bin/bash -e
# Instant Wi-Fi AP
#
# Dependencies: sudo apt-get install macchanger hostapd
if [ "$#" != '3' ]; then
echo 'Usage: <SSID> <channel> <passphrase>' 1>&2
exit 1
fi
@cyrus-and
cyrus-and / .muteonlogout.plist
Last active January 24, 2016 12:35
Mute audio on logout on Mac OS X
#!/bin/bash
# Install:
# 1. wget -P ~ https://gist.githubusercontent.com/cyrus-and/76e2b92bfc16d65617ff/raw/921a91b765944f0aed3cf85490631ac58182037d/.muteonlogout.plist
# 2. chmod +x ~/.muteonlogout.plist
# 3. sudo defaults write com.apple.loginwindow LogoutHook ~/.muteonlogout.plist
# Uninstall:
# sudo defaults delete com.apple.loginwindow LogoutHook
@cyrus-and
cyrus-and / apk.sh
Last active January 27, 2016 23:43
Stupid ADB wrapper for APK retrival
#!/bin/bash -e
usage() {
echo "Usage:
apk list
apk path <package>
apk fetch <package>
"
}
@cyrus-and
cyrus-and / README.md
Last active July 16, 2023 11:33
let-in - User-initiated reverse shell via OpenSSL

let-in

User-initiated reverse support shell via OpenSSL from a host user behind a firewall to the guest.

Usage

  1. Both parties run:
@cyrus-and
cyrus-and / nic-stats.sh
Last active March 13, 2016 15:31
NIC stats from /sys/class/net/
#!/usr/bin/env bash
width=10
declare -a stats=(rx_bytes tx_bytes rx_packets tx_packets)
declare -a names=('RX Bps ' 'TX Bps' 'RX pps' 'TX pps')
declare -a fmt=('--to iec --suffix B' '--to iec --suffix B' '--to si' '--to si')
function get_stat() {
local iface="$1"
local stat="$2"