Skip to content

Instantly share code, notes, and snippets.

View rsperl's full-sized avatar

Richard rsperl

  • North Carolina, United States
View GitHub Profile
@rsperl
rsperl / ssh-config.pl
Last active July 25, 2022 15:55
display ssh config as a table #perl #ssh #snippet
#!/usr/bin/env perl
use strict;
use Data::Dumper;
my $action = shift @ARGV || "ls";
sub usage {
print "Usage: $0 ls <entry>\n";
exit 1;
@rsperl
rsperl / bitmask.py
Last active July 25, 2022 15:58
using bitmasks #python #ldap #snippet
import pprint
class Bitmask(object):
def __init__(self, bitdict):
super(Bitmask, self).__init__()
self.bitdict = bitdict
def dump_bits(self):
return pprint.pprint(self.bitdict)
@rsperl
rsperl / send_email.py
Last active July 25, 2022 15:56
send standardized emails #python #snippet
import smtplib
email_defaults = {
"from": "replies-disabled@domain.com",
"content-type": "text/html",
"X-Automation": "true",
}
style_sheet = """
<style>
@rsperl
rsperl / common_ldap_utils.py #snippet
Last active July 25, 2022 12:33
common ldap utilities #python #ldap
import yaml
import logging
import ldap
from ldap.controls import SimplePagedResultsControl
from pprint import pprint as pp
import sys
import ldap.modlist as modlist
DEFAULT_PAGE_SIZE = 10
@rsperl
rsperl / bitmask.go
Last active July 25, 2022 15:55
manage bitmasks #go #ldap #snippet
package bitmask
import "sort"
type Decoder struct {
Flags map[string]int
}
func NewDecoder(flags map[string]int) *Decoder {
return &Decoder{Flags: flags}
@rsperl
rsperl / dynamic_use.pl
Last active July 25, 2022 15:54
dynamically use a package and instantiate an instance #perl #snippet
#!/usr/bin/env perl
use Try::Tiny
# determine which package to use
my $pkg = "My::Package";
# call require (runtime) instead of use (compile-time)
try {
require $pkg;
@rsperl
rsperl / fifty_writing_tools_quick_list.txt
Last active July 25, 2022 14:06
Fifty Writing Tools: Quick List #gdocs
Fifty Writing Tools: Quick List
src: http://www.poynter.org/2006/fifty-writing-tools-quick-list/76067/
Click to share on Twitter (Opens in new window)Click to share on Facebook (Opens in new window)11Click to share on LinkedIn (Opens in new window)11Click to share on Google+ (Opens in new window)Click to email this to a friend (Opens in new window)
By Roy Peter Clark • June 30, 2006
Use this quick list of Writing Tools as a handy reference. Copy it and keep it in your wallet or journal, or near your desk or keyboard. Share it and add to it.
I. Nuts and Bolts
@rsperl
rsperl / zsh_left_padding.zsh
Last active July 25, 2022 14:43
add left-padding to a value in #lang-zsh #snippet
#!/bin/zsh
# left padding parameter expansion flag
value=145
echo ${(l:10::0:)value}
# 0000000145
@rsperl
rsperl / zsh_writing_your_own_completion_functions.md
Last active July 25, 2022 14:13
Writing own completion functions for #lang-zsh #nosnippet

ZSH – Writing own completion functions

_source: https://askql.wordpress.com/2011/01/11/zsh-writing-own-completion/ __

By Alp1/11/2011

To be honest it wasn’t easy for me to get from the ZSH man pages how to make own completion functions. Sharing my modest achievement in that area here.

The main source of info is man zshcompsys.

@rsperl
rsperl / add_column_of_numbers.sh
Last active July 25, 2022 14:17
use #lang-awk to add numbers in a column #nosnippet
#!/bin/sh
cat count.txt | awk '{ sum+=$1} END {print sum}'