Skip to content

Instantly share code, notes, and snippets.

@damc-dev
damc-dev / prettyprintgist.md
Created November 6, 2015 14:57 — forked from magnetikonline/README.md
Bookmarklet to pretty print Gist pages without the usual page chrome, just content. Handy for Markdown document printing.

Pretty print bookmarklet helper for Gist pages

Create a new bookmark somewhere handy in your browser with the following URL:

javascript:var el=document.createElement('style');el.media='print';el.innerHTML='#header,.pagehead.repohead,.gist-description.container,.file-box .meta,#comments,.js-comment-form,#footer{display:none;}.file-box{border:0!important;}';document.getElementsByTagName('head')[0].appendChild(el);alert('Please consider the environment before printing :)');
  • Navigate to your Gist of choice
  • Hit the bookmarklet
  • Now print
@damc-dev
damc-dev / ReportPlayerPositions.cs
Last active January 9, 2016 16:48
Reign of Kings Oxide Plugin to Update Player Positions to Firebase on interval
using System.Collections.Generic;
using System;
using System.Data;
using System.Reflection;
using Newtonsoft.Json;
using UnityEngine;
using Oxide.Core;
using Oxide.Core.Plugins;
@damc-dev
damc-dev / runBashScript.bat
Last active September 27, 2024 10:08
Execute Bash Script (Using Git Bash) from Windows Task Scheduler
cmd /c ""C:\Program Files (x86)\Git\bin\bash.exe" --login -i -- H:\Daily_Reports\yesterdayTogglReport.sh"
@damc-dev
damc-dev / getOpenLogFileSizes.sh
Last active March 9, 2016 15:06
Print the open log files and their sizes in human readable format
#!/bin/sh
/usr/sbin/lsof +D /logs -s 2>/dev/null | sort -k 7 -g -r | while read x; do
size=`echo $x | awk '{print $7}'`
file=`echo $x | awk '{print $9}'`
SIZE=`echo $size | awk 'function human(x) {
s=" B KiB MiB GiB TiB EiB PiB YiB ZiB"
while (x>=1024 && length(s)>1)
{x/=1024; s=substr(s,5)}
@damc-dev
damc-dev / toLowerCase.sh
Created March 9, 2016 15:09
Simple Bash functions
#!/bin/sh
function toLowerCase {
local word=$1
local lowercaseWord="$(tr '[:upper:]' '[:lower:]' <<< "$word")"
echo "${lowercaseWord}"
}
lowerCaseWord="$(toLowerCase $1)"
echo "$lowerCaseWord"

source: vim.wikia.com - 03/21/2016

Vim: Moving around

You can save a lot of time when navigating through text by using appropriate movement commands. In most cases the cursor keys are not the best choice.

Here are some basic movement commands that may help you acquire a taste for more:

e       Move to the end of a word.

w Move forward to the beginning of a word.

@damc-dev
damc-dev / listJavaDUMemoryAsCsv.sh
Last active October 6, 2016 13:48
Create CSV of running java processes and their memory usage
#!/bin/bash
#
# Description: Create CSV of running java processes and their memory usage
# this script must be run as the same user as the java processes you want to capture
#
# Author: David McElligott<[email protected]> 10/5/2016
#
user="$(whoami)"
@damc-dev
damc-dev / find-free-port.py
Last active December 7, 2016 17:09
Find Free Ports - Linux
#!/usr/bin/env python
# Source: http://unix.stackexchange.com/questions/55913/whats-the-easiest-way-to-find-an-unused-local-port#comment271991_132524
# One liner: python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'
import socket
s=socket.socket()
s.bind(("", 0))
print(s.getsockname()[1])
s.close()
@damc-dev
damc-dev / terminalcolors.sh
Created December 7, 2016 17:18
Check if host supports 256-color
#!/bin/sh
# 256-color mode not supported on this host
if echo $TERM | grep -q -- '-256color'; then
echo -e '\n\n256-color mode not supported on this host. Reverting TERM...\n'
export TERM=`echo -n $TERM | sed 's/-256color//'`
fi
@damc-dev
damc-dev / dateformat.sh
Created December 7, 2016 17:20
Example date formatting
#!/bin/sh
# Datetime in local timezone
echo "* $(date +'%Z'): $(date +'%Y-%m-%dT%H:%M:%S.%N%:z')"
# Datetime in specified timezone
echo "$(TZ=UTC date +'%Z'): $(TZ=UTC date +'%Y-%m-%dT%H:%M:%S.%N%:z')"