Skip to content

Instantly share code, notes, and snippets.

@JFFail
JFFail / gist:6442b27225eb71b30d26
Created January 6, 2015 15:27
Script to pull the end of netlogon.log files on a list of DCs to check for entries in the last two months.
#Get the list of servers.
$serverList = Get-Content -Path .\servers.txt
#Loop through each.
foreach($server in $serverList) {
#Get the contents of the netlogon file.
$netlogonContent = Get-Content -Path \\$server\C$\Windows\debug\netlogon.log -Tail 5
#Boolean to only write the server name once if at all.
$serverNameWritten = $false
@JFFail
JFFail / gist:7782e19a35169e4e925c
Last active August 29, 2015 14:12
Script to parse a text file, extract IPs, and print unique values.
#!/usr/bin/env perl
use strict;
use warnings;
#Array to hold the results.
my %uniqueIPs;
my $index_of;
my $sub;
#Open the file.
#!/bin/bash
letters=`echo $HOSTNAME | wc -m | tr -d ' '`
if [[ $letters -gt 15 ]]; then
echo "Your name is too long at $letters."
else
echo "Domain join can continue."
fi
@JFFail
JFFail / wwe.sh
Last active August 29, 2015 14:13
Shell Script for Reddit Daily Programmer - #198 Easy
#!/usr/local/bin/zsh
#Get the left word.
echo -n "Enter the left word: "
read leftWord
echo -n "Enter the right word: "
read rightWord
#Get the length of each.
llen=${#leftWord}
@JFFail
JFFail / parse-numbers.ps1
Last active August 29, 2015 14:14
Solution To Reddit Daily Programmer 199 - Bank Number Banners
<#
# Challenge is here:
# http://www.reddit.com/r/dailyprogrammer/comments/2tr6yn/2015126_challenge_199_bank_number_banners_pt_1/
#>
#Function to loop through each of the supplied inputs.
function ParseNums
{
param([string] $passedNum)
@JFFail
JFFail / deparse-numbers.ps1
Created January 30, 2015 16:07
Solution To Reddit Daily Programmer 199 - Bank Number Banners Part 2
<#
# Reddit Daily Programmer 199 Part 2
# http://www.reddit.com/r/dailyprogrammer/comments/2u0fyx/2015126_challenge_199_bank_number_banners_pt_2/
#>
#Create the strings for the inputs.
$inputTop = " _ _ _ _ _ _ _ "
$inputMid = "|_| |_| | | |_| |_ | | | |_ "
$inputBot = " | _| |_| |_| |_| | | | _|"
@JFFail
JFFail / count_days.sh
Last active July 31, 2020 22:08
Solution to Reddit Daily Programmer 201
#!/usr/pkg/bin/zsh
dateMath() {
todayMonth=$(date "+%m/%d/%y" | awk -F\/ '{print $1}' | sed "s/^0//")
todayDay=$(date "+%m/%d/%y" | awk -F\/ '{print $2}' | sed "s/^0//")
todayYear=$(date "+%m/%d/%y" | awk -F\/ '{print $3}' | sed "s/^0//")
today="$todayMonth/$todayDay/$todayYear"
current=$(date -d $today +%s)
submitted=$(date -d $1 +%s)
diffDays=$((($submitted - $current) / 86400))
echo "You must wait $diffDays days from $today to $1"
@JFFail
JFFail / recursive_sum.rb
Created February 21, 2015 18:56
Simple example for myself of a recursive function to compute the sum of a list.
#!/usr/bin/ruby
def sums(list)
if list.length > 1
return list.pop + sums(list)
else
return list.pop
end
end
#Make a list.
@JFFail
JFFail / parse-lines.ps1
Created March 3, 2015 21:54
Solution to Reddit Daily Programmer 204
<# Reddit Daily Programmer
# http://www.reddit.com/r/dailyprogrammer/comments/2xoxum/20150302_challenge_204_easy_remembering_your_lines/
#>
function MoveBack
{
param
(
$text,
$location
@JFFail
JFFail / generate-dna.ps1
Created March 23, 2015 18:23
Solution To Reddit Daily Programmer #207 - Generating DNA Sequences
<#
DNA Sequence - Daily Programmer #207
http://www.reddit.com/r/dailyprogrammer/comments/2zyipu/20150323_challenge_207_easy_bioinformatics_1_dna/
#>
#Main input.
$inputSequence = "A A T G C C T A T G G C"
#Hash defining the pairs.
$pairs = @{'A'='T';'T'='A';'G'='C';'C'='G'}