This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Solution to a question in @gayle's "Cracking the Coding Interview" 5th ed. | |
# A child is running up the stairs and can take 1, 2 or 3 steps at a time. | |
# Count how many possible ways the child can run up the stairs. | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use feature qw/ say /; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw(say); | |
######################################################################## | |
package QS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw(say switch); | |
###################################################################### | |
package HashOfHash; | |
use Moose; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
7z a -x'!*/.git' $1.7z $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# I know it's a bit stupid and there's better ways to do it. But who doesn't like playing. | |
# Written for an old CentOS 4 server where people have installed Perl modules any old how. | |
# Is there a way to merge the two matches together? | |
find /usr/*/perl5 | ruby -ne '/^(\/\w+){4}\/.*\.pm/.match($_) && puts( /^(\/\w+){4}\/[\.\d]*\/{0,1}(.*)/.match($_)[2] )' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. /lib/lsb/init-functions | |
pidofproc "$@" &>> /dev/null | |
retval=$? | |
# Ignore cases such as retval=3 (Pid file doesn't exist) | |
if [ $retval -ne 1 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mountpoint=/tmp | |
sleeper=240 | |
# percentage of disk used | |
function percentage { df $1 | tail -1 | awk '{print $4}' | tr -d % ; } | |
# Where we'll write | |
tempdir=$(mktemp -d --tmpdir=${mountpoint}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Linux only, sorry. | |
# | |
# Look for ext[34], xfs and vxfs. Alter the regexp FILESYSTEMS for others | |
# | |
# If you have /root as a separate partition, alter the value of ROOT_USABLE | |
# Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DesignerTest | |
{ | |
class Program | |
{ |