Skip to content

Instantly share code, notes, and snippets.

@senorsmile
senorsmile / winrm_enable.ps1
Created November 26, 2024 17:37
Powershell script to enable winrm
# Enables the WinRM service and sets up the HTTP listener
Enable-PSRemoting -Force
# Opens port 5985 for all profiles
$firewallParams = @{
Action = 'Allow'
Description = 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]'
Direction = 'Inbound'
DisplayName = 'Windows Remote Management (HTTP-In)'
LocalPort = 5985
@senorsmile
senorsmile / run.sh
Created April 3, 2021 22:38
Rust cargo runner script
#!/usr/bin/env bash
set -euo pipefail
#----------
# vars
#----------
debug=1
clippy=1
@senorsmile
senorsmile / zfs_introspect_file.md
Created January 8, 2021 18:52 — forked from mbarczak/zfs_introspect_file.md
ZFS: Introspect a File (Acquiring Creation Time... etc)

Introspecting a file on ZFS

Derived from: http://www.c0t0d0s0.org/archives/7485-Find-out-in-depth-information-about-a-file-in-ZFS.html

Sometimes you need to acquire in-depth information about a file that isn't exposed by other commands like stat.

ZFS allows you to do this with zdb. However there's a confusing problem. If you're just trying to access a file on your root pool that doesn't have any nested datasets, you need use rpool/ instead of just rpool (assuming "rpool" is the name of your root pool).

Here's 3 examples of acquiring information on /filepath.

@senorsmile
senorsmile / gist:1bf4b68820460f612a2da8c345237f3b
Created October 17, 2020 13:59
vim - convert ansible one line tasks to multiline yaml
:%s/\([a-z0-9_]\+\)=\(\({{ \)\=[a-z0-9._]\+\( }}\)\=\)/\r \1: "\2"/g
---
all:
vars:
k8s_pods:
- name: kuard-5-6
#state: absent
volumes:
- name: "kuard-data"
volume_type: 'nfs'
server: "{{ hostvars['k8s-slave1']['ansible_eth1']['ipv4']['address'] }}"
---
##- Do this
- name: Install foo package
apt:
name: foo
state: present
##- not this
- name: Install foo package
apt: name=foo state=present
@senorsmile
senorsmile / rsync_backup_template.sh
Last active January 15, 2017 20:32
add message if rsync already running
#!/usr/bin/env bash
#--------
# ALL dirs must end with a backslash
#--------
now=$(date +%Y-%m-%d_%H:%M:%S_%N)
src='/home/shaun/'
dest_url='127.0.0.1'
dest_dir='/home/shaun/rsync_backups/'
@senorsmile
senorsmile / custom_type.py
Created December 28, 2016 04:27
simplified custom type in python
#!/usr/bin/env python
class MyType(object):
def __init__(self, value):
self.value = value
def __add__(self, other): #overload '+'
if not isinstance(other, MyType): #only works on MyType types
return NotImplemented
return self.__class__(self.value + other.value)
@senorsmile
senorsmile / array_slice.bash
Created December 14, 2016 06:28
array slicing in bash
#!/usr/bin/env bash
array=(zero one two three four five)
echo "${array[@]:1:3}"
## one two three
echo "${array[@]:3}"
## three four five
#!/usr/bin/env bash
perl_version='5.25.6'
perl_version='5.24.0'
verify_pkg() {
pkg="$1"
[[ $(which "${pkg}") ]] || {
echo "${pkg} not found. Exiting..."
exit 1