Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
AndrewRussellHayes / copyMove.pl
Last active December 20, 2015 19:09
needed a quick script to monitor directory A and whenever files arrived there to copy to directory B and move to directory C. This is what I came up with. Very simple, dies if a directory is placed in A.
#!/usr/bin/perl
#copyMove.pl By: Andrew Hayes <http://AndrewHay.es/>
#Copyright (c) 2013 Andrew Hayes
#
# This takes a file from Dir A and copies it to Dir B and moves it to Dir C.
# When the copy suceedes it prints a line to the stdout
# When a copy fails it Dies. For now. Dies if dir placed in A.
#
use strict;
use warnings;

Requirements

  • Docker Machine + Docker
  • curl
  • A Virtualbox-driven Docker Machine called "default" docker-machine create --driver virtualbox default (this is the default with Docker toolkit).

Usage

The git.io URL (http://git.io/vsk46) is a shortened form of the raw url of the plist.

@AndrewRussellHayes
AndrewRussellHayes / ssh_helper.sh
Created October 22, 2015 18:48
Install local ssh key on remote host
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
@AndrewRussellHayes
AndrewRussellHayes / read.pl
Last active October 21, 2015 18:20
file I/O best practices
my $filename = 'data.txt';
if (open(my $in, '<', $filename)) {
while (my $row = <$in>) {
chomp $row;
print "$row\n";
}
} else {
warn "Could not open file '$filename' $!";
}
"run current perl program
set autowrite
"map <F4> :! perl /cbm/BFH2/APP/Dev.pl<CR>
"map <F5> :! perl ./%<CR>
"map <F5> :! perl /cbm/BFH2/APP/Worker.pl<CR>
map <F2> :pm<CR>
map <F3> :! perl -wc /cbm/BFH2/LIB/WORKERS/XMLQuery.pm<CR>
map <F4> :! perl /cbm/BFH2/APP/Dev.pl<CR>
map <F5> :! perl /cbm/BFH2/APP/Worker.pl 5<CR>
command Ct cd %:p:h
@AndrewRussellHayes
AndrewRussellHayes / build.sh
Last active October 21, 2015 18:09
building an image called andrewrussellhayes/dev with tag of 0.1
docker build -t andrewrussellhayes/dev:0.1 ./.
@AndrewRussellHayes
AndrewRussellHayes / OutputStreamWriter.java
Created October 20, 2015 12:37
OutputStreamWriter is the preferred file write method as it does not make encoding assumptions
try (OutputStreamWriter osw =
new OutputStreamWriter(new FileOutputStream("/FilePath/Here"), "UTF-8")) {
PrintWriter pw = new PrintWriter(osw);
pw.write("Hello World");//does not add newline character
pw.close();
} catch (IOException e) {
e.printstacktrace;
}
<div class="row improve-article-wrapper">
<div class="col-sm-1 col-sm-offset-1">
<a class="btn btn-primary btn-lg" href="https://github.com/{{ site.github.repository_nwo }}/edit/{{ site.branch }}/{{ page.path }}" title="Help Improve article {{ page.path }}">Edit</a>
</div>
<div class="col-sm-3">
<a class="btn btn-success btn-lg" href="{{ site.github.owner_url }}" title="Link to {{site.github.owner_name}} GitHub"><span class="fa fa-github">&nbsp;</span>Author Github</a>
</div>
<div class="col-sm-6 col-sm-offset-1">
<p class="improve-article">This content is open source. <br />
Please <a href="https://github.com/{{ site.github.repository_nwo }}/edit/{{ site.branch }}/{{ page.path }}" title="Help Improve article {{ page.path }}">help improve it</a>.</p>
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do