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 / multiprocessing.py
Last active July 25, 2022 16:07
multiprocessing #python #snippet
from multiprocessing import Process
def method_to_call(*args, **kwargs):
# do what you do
pass
def main():
#
rows = ("job1", "job2")
procs = []
@rsperl
rsperl / queries.txt
Last active July 25, 2022 14:03
ldap query filters #snippert
# find a user
(&(objectCategory=person)(objectClass=user))
# recursive group membership using LDAP_MATCHING_RULE_IN_CHAIN
(&(objectCategory=person)(objectClass=user))(memberOf:1.2.840.113556.1.4.1941:=<groupdn>))
# find all computer objects that are not disabled
(&(objectCategory=computer)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
@rsperl
rsperl / copy_file.go
Last active July 25, 2022 16:08
copy a file #go #snippet
import (
"io"
"os"
)
func cp(dst, src string) error {
s, err := os.Open(src)
if err != nil {
return err
}
@rsperl
rsperl / download_binary_file.go
Last active July 25, 2022 16:05
download binary file #go #snippet
import (
"encoding/binary"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func download() string {
client := &http.Client{}
@rsperl
rsperl / monitor_debug.go
Last active July 25, 2022 16:06
monitor debug vars #go #snippet
package main
import (
_ "expvar"
"fmt"
"net/http"
"os"
)
// use expvarmon to monitor:
@rsperl
rsperl / run_external_command.go
Last active July 25, 2022 16:05
run external command #go #snippet
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
)
@rsperl
rsperl / singleton.go
Last active July 25, 2022 16:04
singleton #go #singleton #snippet
import "sync"
var (
r *repository
once sync.Once
)
func Repository() *repository {
if r == nil {
once.Do(func() {
@rsperl
rsperl / skip_http_cert_check.go
Last active July 25, 2022 16:03
do not validate certificates when making rest calls #go #rest #snippet
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"os"
)
@rsperl
rsperl / using_contexts.go
Last active July 25, 2022 16:03
using contexts #go #snippet
package main
import (
"context"
"fmt"
"time"
)
// Some APIs are designed with context interface, google search is an example. Use context to send cancel signal.
@rsperl
rsperl / dcalc.pl
Last active July 25, 2022 16:02
date calculations #perl #dates #snippet
#!/usr/bin/env perl
use strict;
use FindBin;
use DateTime;
use DateTime::Duration;
use Getopt::Long;
my ($days, $date);
GetOptions(