Skip to content

Instantly share code, notes, and snippets.

View nicdoye's full-sized avatar
🚲
All shall be well, and all shall be well, and all manner of thing shall be well

Nic Doye nicdoye

🚲
All shall be well, and all shall be well, and all manner of thing shall be well
View GitHub Profile
@nicdoye
nicdoye / gotcha.sh
Created February 8, 2017 17:30
bash gotcha
# This is what you'd expect - prints 1
declare var
var=$(false)
echo $?
# This does not do what you'd expect - prints 0
declare var2=$(false)
echo $?
@nicdoye
nicdoye / jira-regex.md
Created January 18, 2017 10:56
Replace JIRA project-numbers with Markdown Links in VS Code/regex

Replace JIRA Project numbers with links

Assuming

  1. your project prefix is EXAMPLE
  2. your JIRA installation is at https://example.com/jira then regex to match is
(EXAMPLE-(\d)*)
@nicdoye
nicdoye / google-dmarc-parser.rb
Created January 4, 2017 15:27
Parse GSuite DMARC Reports
#!/usr/bin/env ruby
require 'nokogiri'
require 'optparse'
require 'resolv'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: google-dmarc-parser.rb [options]"
@nicdoye
nicdoye / csvwriter.groovy
Created November 29, 2013 17:52
Quick example of using Apache Commons CSV (1.0-Snapshot) to write to a CSV file in groovy.
import org.apache.commons.csv.CSVPrinter
import org.apache.commons.csv.CSVFormat
CSVPrinter printer = new CSVPrinter(
new PrintWriter("test.csv"),
CSVFormat.DEFAULT
)
answer = [ [5,6,"asdf",7],[9,10,"a b","z,x",12]]
# A quick alias for those of us without such a command
tiff2png ()
{
local ifile=$1
local ofile=$(dirname "${ifile}")/$(basename "${ifile}" .tiff).png
tifftopnm < "${ifile}"| pnmtopng > "${ofile}"
}
@nicdoye
nicdoye / lgrep.sh
Created October 11, 2016 14:47
Find a string in any file (note may include binaries) in the current folder, but exclude anything under a .git folder
function lgrep {
local str=$1
find . -type f -not -path '*/.git/*' -exec grep -l ${str} {} \;
}
@nicdoye
nicdoye / Reboot.xml
Created September 21, 2016 13:50
Reboot scheduled task for Windows 2008r2. For those with finer grained security, you could use a lower-privileged account than Administrator.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2016-09-20T11:25:05.3204</Date>
<Author>SOMESERVER\Administrator</Author>
<Description>Simple reboot task</Description>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<StartBoundary>2016-09-21T06:00:00</StartBoundary>
Verifying that +nicdoye is my blockchain ID. https://onename.com/nicdoye
@nicdoye
nicdoye / incr.sh
Created May 26, 2016 16:16
Incrementing variables on the command line/in scripts for fun and profit
# replace with your variable name
variable=$(echo ${variable} 1 + f | dc)
@nicdoye
nicdoye / rpmlibs.sh
Created April 3, 2016 16:08
Find all RPMs providing libraries to your custom-built software
# Find all RPMs of libraries for binaries in this folder
rpm -qf $(ldd * | grep = | awk '{print $3}' | sort -u | grep ^/) | sort -u
# Similarly, for all .so files under this folder
rpm -qf $(find . -name \*.so -exec ldd {} \; | grep = | awk '{print $3}' | sort -u | grep ^/) | sort -u