This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function vmmem { free="$(free -h)";echo "$free";memtotal=0 ; for i in $(virsh list --name); do mem=$(( $(virsh dommemstat $i |head -1|cut -d " " -f 2) /1024/1024));memtotal=$(( $memtotal + $mem)); printf "%-20s%10s\n" $i $mem; done; echo " Total VM ${memtotal}G"; echo " Difference: $(( $(echo "$free" |grep "Mem:"|cut -d " " -f 12|rev|cut -c 2-|rev) - $memtotal))G"|sort -V; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function zfsswap { pool=${1-rpool}; gigs=${2-50};zfs create -V ${gigs}G -b $(getconf PAGESIZE) -o compression=zle -o logbias=throughput -o sync=always -o primarycache=metadata -o secondarycache=none -o com.sun:auto-snapshot=false $pool/swap && mkswap -f /dev/zvol/$pool/swap && echo /dev/zvol/$pool/swap none swap defaults 0 0 >> /etc/fstab && swapon -av ; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [[ $1 == "" ]] | |
| then | |
| echo "You must specify the copy-to device as the first argument" | |
| echo "You may also specify a source device as the 2nd argument. Default= mmcblk0" | |
| echo "If you want no prompts and incremental, specify -a as the last argument" | |
| echo "i.e.: backup sda [nbd0] [-a]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## Get my external IP | |
| timeout=2 # seconds to wait for a reply before trying next server | |
| #verbose=1 # prints which server was used to STDERR | |
| dnslist=( | |
| "dig +short myip.opendns.com @resolver1.opendns.com" | |
| "dig +short myip.opendns.com @resolver2.opendns.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Below are single-line commands to run in BASH on a Raspberry Pi to rewrite the toner chips to "full" for a Ricoh SP C250DN Printer. | |
| You will need to have the 4 files below in the same directory: "black" "cyan" "magenta" and "yellow". | |
| The chip is near one edge of the cartridge. The pad closest to the edge is GND, followed by VCC, DATA, and Clock. | |
| On the Pi, connect VCC and GND to +3.3V and GND. Connect Data to (physical numbering) 3 and 5. They are the I2C Data and Clock pins. | |
| Be sure i2c is enabled and installed. | |
| modprobe -r i2c_bcm2708 ;modprobe i2c_bcm2708 baudrate=9600 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| OPTS=`getopt -o vhns: --long service:,sha:,server: -n 'parse-options' -- "$@"` | |
| fail=false | |
| if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi | |
| eval set -- "$OPTS" | |
| servers=() | |
| while true; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filldisk(){ | |
| DISKNUM=$2 | |
| if [[ ! $2 =~ [0-9] ]]; then echo must specify disk num as 2nd arg;return 1;fi | |
| SKIP="${3:-0}" | |
| BS="${4:-4}" | |
| SIZE=$(( (2 * 1024 *1024) - ($SKIP * 1024) )) | |
| gnumfmt --format=%.3f --to=iec --from=iec ${SIZE}M\ | |
| case $1 in | |
| random) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker ps --format 'table {{.ID}}|{{.Image}}|{{.Command}}|{{.RunningFor}}|{{.Status}}|{{.Ports}}|{{.Names}}'|sed -e 's/dev\.perfectpitchtech\.com:4567\/service\///' -e 's/\(^.*|.*|.*|.*|.*|\)\(.*\)\(|[^|]*$\)/\1+\2+\3/' -e 's/\(\|[a-z0-9]\{3\}[^\.]+\)\(\.[^|]\{4\}\)[^|]*$/\1\2\.\.\./'|(while read jerk; do ports=$(echo "$jerk"|sed 's/\(^.*+\)\(.*\)\(+.*$\)/\2/');newports=$(echo $ports|sed -e 's/\/[ut][dc]p\(,\)* */\1/g'|cut -c 1-12); echo $jerk|sed "s/+.*+/${newports}.../"; done)|column -tns "|" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # du with only 1 filesystem | |
| du -achxd1 |sort -h | |
| # Ubuntu14 Service Management | |
| update-rc.d -f <service> remove | |
| service --status-all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #$pp_num_raw = split($::hostname, 'pp')[1] | |
| #$pp_num = sprintf("%0#2i", $pp_num_raw) | |
| #$pp_num = split($::hostname, 'pp')[1].sprintf"%0#2i" | |
| #$pp_num = sprintf("%0#2i", "${::hostname}".split('pp')[1]) | |
| $pp_num = sprintf("%0#2i", "${::hostname}".match(/(pp)([0-9]+)([^[0-9]]*)/)[2]) | |
| ["api", "live", "upload"].each|$local_suffix|{ | |
| file { "/etc/nginx/conf.d/ppcc.local.$local_suffix": | |
| content => template("pp_nginx_manager/conf.d/ppcc.local.${local_suffix}.erb"), | |
| ensure => present, | |
| } |
NewerOlder