Skip to content

Instantly share code, notes, and snippets.

View jyotty's full-sized avatar

Joshua Yotty jyotty

View GitHub Profile
@jyotty
jyotty / fw.sh
Last active August 29, 2015 14:04
show iptables rules clearly
#!/usr/bin/env bash
set -e
set -o pipefail
BOLD="$(printf "\x1B[1m")"
CLEAR="$(printf "\x1B[0m")"
ruledir="$(mktemp -d /tmp/fw.XXXXXX)"
@jyotty
jyotty / rbenv-vars.rake
Created April 16, 2014 19:54
(somewhat lame) manipulation of .rbenv-vars in capistrano 3
namespace :rbenv do
namespace :vars do
desc "Display .rbenv-vars on all servers"
task :show do
on roles(:all) do |host|
execute "cat #{fetch(:deploy_to)}/.rbenv-vars"
end
end
desc "Add or update single .rbenv-vars setting (cap stage rbenv:vars:set[NAME,value])"
@jyotty
jyotty / gist:7833656
Created December 6, 2013 23:03
rubygems quality
$ irb
irb(main):001:0> require 'net/ping'
=> true
irb(main):002:0> p = Net::Ping::External.new('www.google.com; touch /tmp/hello')
=> #<Net::Ping::External:0x007fc95a949488 @host="www.google.com; touch /tmp/hello", @port=7, @timeout=5, @exception=nil, @warning=nil, @duration=nil>
irb(main):003:0> p.ping?
=> true
irb(main):004:0> ^D
$ ls -l /tmp/hello
-rw-r--r-- 1 josh wheel 0 Dec 6 14:57 /tmp/hello
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
APP_DIRECTORY = "/srv/apps/example"
worker_processes 4
working_directory "#{APP_DIRECTORY}/current" # available in 0.94.0+
listen "#{APP_DIRECTORY}/shared/tmp/unicorn.sock", :backlog => 64
timeout 30
@jyotty
jyotty / fix-psql-utf8.pl
Created September 17, 2013 17:46
mouth of madness
#!/usr/bin/env perl
use strict;
use warnings;
use Encode qw(encode decode);
use 5.10.0;
use DBI;
@jyotty
jyotty / utf8_psql.pl
Created August 2, 2013 23:24
scan for non-utf8 data in a pgsql dump and print it
#!/usr/bin/env perl
use strict;
use warnings;
use Encode;
while (<>) {
print "\n$_" if /^COPY/;
@jyotty
jyotty / gist:5059686
Created February 28, 2013 20:08
Testing chef cookbook recipes on two instances with test-kitchen 1.0 and kitchen-bluebox in just under three minutes
$ be kitchen test all -p
-----> Starting Kitchen
-----> Cleaning up any prior instances of <default-ubuntu-1204>
-----> Cleaning up any prior instances of <default-sl-63>
-----> Destroying <default-ubuntu-1204>
-----> Destroying <default-sl-63>
Called 'load_file' without the :safe option -- defaulting to safe mode.
Finished destroying <default-sl-63> (0m0.00s).
-----> Testing <default-sl-63>
-----> Creating <default-sl-63>
@jyotty
jyotty / procnetdev.pl
Last active September 11, 2019 14:42
Parsing /proc/net/dev with perl for @ChrisLundquist
#!/usr/bin/env perl
use strict;
use warnings;
my @lines = `cat /proc/net/dev`;
my @rx_fields = qw(bytes packets errs drop fifo frame compressed multicast);
my @tx_fields = qw(bytes packets errs drop fifo frame compressed);
for my $line (@lines) {
next if $line !~ /:/;
@jyotty
jyotty / gist:4574626
Created January 19, 2013 19:36
using '*' in format strings
for i in {1..10}; do printf "%*sbutts\n" $i ""; done
butts
butts
butts
butts
butts
butts
butts
butts
butts
@jyotty
jyotty / e8.pl
Created January 4, 2013 03:56
euler #8 in perl6
my @a=$*IN.get.comb;
say [max] gather { take [*] @a[$_..$_+4] for ^(@a.elems-4) }