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 / 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'}
@JFFail
JFFail / parse_dna.rb
Last active August 29, 2015 14:17
Solution To Reddit Daily Programmer #207
#!/usr/env/ruby
#Reddit Daily Programmer 207
#Includes bonus.
#Function for parsing a protein sequence.
def proteins(dna)
#Create hash for the codons.
codons = {"TTT"=>"Phe","TTC"=>"Phe","TTA"=>"Leu","TTG"=>"Leu","TCT"=>"Ser","TCC"=>"Ser","TCA"=>"Ser","TCG"=>"Ser","TAT"=>"Tyr","TAC"=>"Tyr","TAA"=>"STOP","TAG"=>"STOP","TGT"=>"Cys","TGC"=>"Cys","TGA"=>"STOP","TGG"=>"Trp","CTT"=>"Leu","CTC"=>"Leu","CTA"=>"Leu","CTG"=>"Leu","CCT"=>"Pro","CCC"=>"Pro","CCA"=>"Pro","CCG"=>"Pro","CAT"=>"His","CAC"=>"His","CAA"=>"Gln","CAG"=>"Gln","CGT"=>"Arg","CGC"=>"Arg","CGA"=>"Arg","CGG"=>"Arg","ATT"=>"Ile","ATC"=>"Ile","ATA"=>"Ile","ATG"=>"Met","ACT"=>"Thr","ACC"=>"Thr","ACA"=>"Thr","ACG"=>"Thr","AAT"=>"Asn","AAC"=>"Asn","AAA"=>"Lys","AAG"=>"Lys","AGT"=>"Ser","AGC"=>"Ser","AGA"=>"Arg","AGG"=>"Arg","GTT"=>"Val","GTC"=>"Val","GTA"=>"Val","GTG"=>"Val","GCT"=>"Ala","GCC"=>"Ala","GCA"=>"Ala","GCG"=>"Ala","GAT"=>"Asp","GAC"=>"Asp","GAA"=>"Glu","GAG"=>"Glu","GGT"=>"Gly","GGC"=>"Gly","GGA"=>"Gly","GGG"=>"Gly"}
#Now loop through.