Skip to content

Instantly share code, notes, and snippets.

View murphybytes's full-sized avatar

John Murphy murphybytes

View GitHub Profile
@murphybytes
murphybytes / dump-yaml.sh
Created November 11, 2024 18:16
Dumps yaml from connected cluster
#!/usr/bin/env bash
#####################################################################
# This script dumps all resources in a cluster to yaml files
# Usage: ./dump-cluster-as-yaml.sh KUBE-CONTEXT
# Example: ./dump-cluster-as-yaml.sh $(kubectl config current-context)
#####################################################################
set -e
CONTEXT="$1"
@murphybytes
murphybytes / shell.md
Created July 23, 2024 16:46
favorites
package main
import (
"bufio"
"fmt"
"log"
"net"
"strings"
"time"
)
apiVersion: troubleshoot.sh/v1beta3
kind: HostPreflight
metadata:
name: kurl-builtin
spec:
collectors:
- cpu: {}
- memory: {}
- tcpPortStatus:
collectorName: "Kubernetes API TCP Port Status"
@murphybytes
murphybytes / profile.sh
Created June 4, 2018 01:24
git coloring for terminal
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local DEFAULT="\[\033[0m\]"
PS1="\h:\W \u$LIGHT_GREEN\$(parse_git_branch) $DEFAULT\$ "
}
@murphybytes
murphybytes / factory.go
Last active July 15, 2017 23:54
Go Factory
package main
import (
"crypto"
"crypto/rsa"
"crypto/ecdsa"
"crypto/sha256"
"crypto/x509"
"encoding/pem"
"math/big"
@murphybytes
murphybytes / inquery.go
Created November 12, 2016 06:23
Bug in sqlx.In
func (d *Datastore) searchLabelsWithOmits(query string, omit ...uint) ([]kolide.Label, error) {
sqlStatement := `
SELECT *
FROM labels
WHERE MATCH(name)
AGAINST(? IN BOOLEAN MODE)
AND NOT deleted
AND id NOT IN (?)
LIMIT 10
`
@murphybytes
murphybytes / traits.go
Created November 8, 2016 16:26
Impelment db traits
package kolide
import (
"time"
"github.com/WatchBeam/clock"
)
type Createable interface {
MarkCreated(clock.Clock)
@murphybytes
murphybytes / main.go
Last active November 6, 2016 02:16
Synchronized access to a data using a closure over a channel
package main
import (
"errors"
"fmt"
"sync"
)
type counters struct {
sum int
@murphybytes
murphybytes / pam.c
Last active March 20, 2022 06:53
pam
#include <sys/types.h>
#include <security/pam_appl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int conv_func(int msgs, const struct pam_message **msg, struct pam_response **resp, void *p ){
struct pam_response *aresp;