Skip to content

Instantly share code, notes, and snippets.

@airencracken
airencracken / gist:2307507
Created April 5, 2012 02:22
Perl Golfed Greedy Change Algo
foreach(0..3){$i=<>;$c=" cents\n";$u="";use integer;{$q=$i/25;$d=($i-$q*25)/10;$n=($i-($d*10+$q*25))/5;$p=($i-($q*25+$d*10+$n*5));}$w=$q==0?$u:$q." x 25".$c;$x=$d==0?$u:$d." x 10".$c;$y=$n==0?$u:$n." x 5".$c;$z=$p==0?$u:$p." x 1".$c;chomp$i;print$i." cents:\n".$w.$x.$y.$z."\n";}
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/files/nginx.initd-r2,v 1.1 2013/05/13 12:18:11 dev-ze
ro Exp $
extra_commands="configtest"
extra_started_commands="upgrade reload"
description="Robust, small and high performance http and reverse proxy server"
@airencracken
airencracken / fact.pl
Created May 27, 2014 07:06
Perl Factorial with Ternary
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
my $input = shift @ARGV || die "Give me a number\n";
sub factorial {
my $n = shift;
@airencracken
airencracken / factorial.pl
Last active August 29, 2015 14:01
Perl Factorial with GOTO TCO Hack
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
my $input = shift @ARGV || die "Give me a number\n";
sub factorial {
my ($n, $total) = @_;
[alias]
hate = blame
@airencracken
airencracken / gist:c63f4bf9d5188664b6e3
Created December 11, 2014 07:03
ASCII Bell function
#!/bin/bash
#function name is an ascii-bell
(){
echo "This is the worst function name ever"
}
#call the function
@airencracken
airencracken / le-renew-webroot
Last active January 22, 2016 05:03 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file="/usr/local/etc/le-renew-webroot.ini"
le_path='/opt/letsencrypt'
exp_limit=30
if [ ! -f $config_file ]; then
echo "[ERROR] config file does not exist: $config_file"
#!/bin/sh
while true; do
ssid=$(/sbin/iwgetid -r)
connected=$?
if [ $connected -eq "0" ]; then
delimiter=" |"
else
delimiter=""