Skip to content

Instantly share code, notes, and snippets.

View rram's full-sized avatar
😅
Breaking things

Ricky Ramirez rram

😅
Breaking things
View GitHub Profile
@rram
rram / lame-pv
Created July 25, 2022 19:27
Show a file read process counter for a specific file and program
#!/bin/bash -e
pid=${1?No PID given}
file=${2?No File given}
size=$(stat --printf %s $file)
cd /proc/$pid/fd
for fd in *
do
if [ "$file" == "$(readlink $fd)" ]; then
@rram
rram / highlight
Created July 25, 2022 19:26
Highlight a word on standard input
#!/usr/bin/perl -w
use strict;
$| = 1;
die "No word provided" unless $ARGV[0];
my $word = $ARGV[0];
shift;
while(<>) {
s/$word/$&/g;
@rram
rram / count
Created July 25, 2022 19:24
Count the frequency of values on standard input
#!/usr/bin/perl -w
my %buckets;
while(<>) {
chomp;
unless (defined $buckets{$_}) {
$buckets{$_} = 1;
} else {
$buckets{$_}++;
}
}
@rram
rram / add
Created July 25, 2022 19:22
Add values on standard input
#!/usr/bin/perl -w
$sum = 0;
while (<>) {
chomp;
$sum += $_;
}
print "$sum\n";
@rram
rram / dh-hashicorp
Last active February 13, 2019 17:58
Downloads the specified version of a Hashicorp program into your bin directory.
#!/bin/bash -e
PROG=${1?-Program name is required}
VERSION=${2?-Program version is required}
os=$(uname -s | tr A-Z a-z)
# MacOS has a quirk with `arch`:
# https://apple.stackexchange.com/questions/140651/why-does-arch-output-i386
case "$(uname -m)" in
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="text" />
<xsl:param name="skip_self_posts" select="true()" />
<xsl:template match="/">
<xsl:variable name="subreddit" select="/atom:feed/atom:category/@term" />

Keybase proof

I hereby claim:

  • I am rram on github.
  • I am rram (https://keybase.io/rram) on keybase.
  • I have a public key whose fingerprint is F9E2 4A14 5455 2705 5660 6D89 773B F85C 7AD5 737E

To claim this, I am signing this object: