Skip to content

Instantly share code, notes, and snippets.

#!/opt/local/bin/perl -w
use strict;
our($fac0, $fac1, $fac2); #keep "use strict" happy
my $num = shift;
#Take 0
#Everyone's first implementation of factorial (except using function
#pointers instead of functions). Get used to function pointers; I'll be using
@emacdona
emacdona / Main.java
Created June 23, 2011 13:13
Compound Interest and Rounding
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main{
private static Transformer<BigDecimal> floor = new BigDecToDiscreteViaFloor();
private static Transformer<BigDecimal> ceil = new BigDecToDiscreteViaCeil();
private static Transformer<BigDecimal> round = new BigDecToDiscreteViaRound();
private static Transformer<BigDecimal> i = new BigDecIdentity();
#!/usr/bin/perl
use strict;
use warnings;
my $dictionary = "/usr/share/dict/words";
open DICTIONARY, "<$dictionary" or die "$!";
my $map = {};
while(my $word = <DICTIONARY>){
chomp $word;
#!/usr/bin/perl
my $letters = shift or die "Specify letters";
my @letters = split //, $letters;
my $size = shift or die "Specify count";
open(DICT, "</usr/share/dict/words");
my $words = {};
GVM has been detected on your system...
This update will upgrade GVM to SDKMAN!
Do you want to continue with the upgrade? (Y/n)y
Thanks for upgrading to...
@emacdona
emacdona / main.js
Last active November 15, 2018 17:29
// Run this file by typing this at the terminal while in the directory you saved this file to:
// (assuming you called the file 'main.js'
// node main.js
/*********************************************************************************
*
* PART I: Setup
*
*********************************************************************************/
@emacdona
emacdona / co.sh
Created August 20, 2020 18:41
Ever get tired of having to type out branch names when you're trying to switch between local branches? This four line function will prompt you for a number instead (warning: uses zsh function and 'read' builtin syntax; you'll need to modify for bash).
# "checkout". Shows you local git branches and prompts you to select one by ordinal
co() {
echo "Which branch do you want to switch to?"
git branch | cat -n
read "NUM?> "
git checkout $(git branch | head -n $NUM | tail -n 1)
}
I’ve got a really strange problem that I’ve been trying to get to the bottom of for three days and I’m really stuck. Posting here hoping someone has an idea of where I could look.
I’ve got a Vagrantfile that provisions a minimal ubuntu VM to use as a local Sandbox to test what follows (the production target is EC2 instance in AWS).
I’ve got some Ansible code that I run against that VM to configure it.
I’ve got a script that runs Ansible via a docker container (so that I — and my coworkers — don’t need to install/mange Ansible on our machines.)
Ansible installs (among other things) Jenkins onto the VM. It is preconfigured with all the credentials it needs (to pull from git, to connect to VPNS) and a few default pipelines.
@emacdona
emacdona / solution.js
Last active September 26, 2021 01:46
#!/usr/bin/env node
function testInputs(f, ...inputs){
inputs.forEach( i =>
console.log(`${i} becomes: ${f(i)}`)
);
}
// Quick and easy solution.
// Problems:
#!/usr/bin/env node
(function(){
function aFunction(){
var a = "A1";
let b = "B1";
console.log(`Inside function, BEFORE variable assignments in "inner" lexical scope:\n\t<a: ${a}, b: ${b}>`);
// Prints:
// Inside function, BEFORE variable assignments in "inner" lexical scope: