Skip to content

Instantly share code, notes, and snippets.

View dhilst's full-sized avatar
😻

Daniel Hilst dhilst

😻
View GitHub Profile
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
/*
* You can get the offset of a member on a struct by dereferencing that member on
* address 0 of such structure.
*/
@dhilst
dhilst / foo.go
Last active January 23, 2020 08:57
package content
import (
"fmt"
"net/http"
"github.com/ponzu-cms/ponzu/management/editor"
"github.com/ponzu-cms/ponzu/system/item"
)
@dhilst
dhilst / xcatotken
Created January 21, 2020 21:36
Get xcat token
curl -X POST 'http://localhost/xcatws/tokens?pretty=1' -H 'Content-type: application/json' --data "{ \"userName\": \"root\", \"userPW\": \"$(/opt/xcat/sbin/tabdump passwd | grep '^"system' | cut -f3 -d, | sed 's/"//g')\" }"
mkdir -p /opt/versatushpc/{etc,xcat}
mkdir -p /opt/versatushpc/xcat/post{install,scripts}
copycds CentOS-7-x86_64-DVD-1810.iso
cat <<'EOF' > /opt/versatushpc/xcat/postinstall/add-cluster-key
#!/bin/bash
pubkey=$(cat ~/.ssh/id_ed25519.pub)
authorized_keys="$IMG_ROOTIMGDIR/root/.ssh/authorized_keys"
if [ ! -f $authorized_keys ]; then
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 62: Applying options for *
debug1: Executing proxy command: exec /usr/bin/sss_ssh_knownhostsproxy -p 22 node001
debug1: key_load_private_type: No such file or directory
debug1: permanently_drop_suid: 0
debug1: key_load_private_cert: No such file or directory
debug1: key_load_private_cert: No such file or directory
debug1: key_load_private_cert: No such file or directory
[root@headnode postinstall]# ssh -v node001
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 62: Applying options for *
debug1: Executing proxy command: exec /usr/bin/sss_ssh_knownhostsproxy -p 22 node001
debug1: permanently_drop_suid: 0
debug1: key_load_private_type: No such file or directory
debug1: key_load_private_cert: No such file or directory
debug1: key_load_private_cert: No such file or directory
@dhilst
dhilst / draft.sh
Last active November 22, 2019 21:47
mkdir -p /opt/versatushpc/{etc,xcat}
mkdir -p /opt/versatushpc/xcat/post{install,scripts}
copycds CentOS-7-x86_64-DVD-1810.iso
cat <<'EOF' > /opt/versatushpc/xcat/postinstall/add-cluster-key
#!/bin/bash
pubkey=$(cat ~/.ssh/id_ed25519.pub)
authorized_keys="$IMG_ROOTIMGDIR/root/.ssh/authorized_keys"
if [ ! -f $authorized_keys ]; then
_xcat_complete() {
COMPREPLY=()
if [[ "${COMP_LINE}" =~ ^(ls|rm|ch|mk)def ]] || [[ "$COMP_LINE" =~ ^nodeset ]]; then
if [[ "${COMP_LINE}" =~ "-t network" ]]; then
local networks=$(lsdef -t network | cut -f1 -d' ' | paste -sd ' ')
COMPREPLY=( $(compgen -W "$networks" -- ${COMP_WORDS[-1]}) )
return 0
elif [[ "${COMP_LINE}" =~ "-t osimage" ]] || [[ "$COMP_LINE" =~ "osimage=" ]]; then
COMPREPLY=( $(compgen -W "$(lsdef -t osimage | cut -f1 -d' ' | paste -sd ' ')" -- ${COMP_WORDS[-1]#*=}) )
return 0
class HasIter:
def __iter__(self):
return iter(range(10))
def foo(value):
try:
for i in value:
print(i)
except TypeError:
#!/usr/bin/env python3
import sys
import re
def jobs_line(string):
return re.match(
r"^\[(?P<id>\d+)\]\s+(?P<default>\+|-)?\s+(?P<state>.*?)\s+(?P<rest>.*)", string
).groupdict()