Skip to content

Instantly share code, notes, and snippets.

View svelleweetakealot's full-sized avatar

Stephan van Ellewee svelleweetakealot

View GitHub Profile
ifconfig eth0 192.168.0.253 up
# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable
# history
0 ls
1 ifconfig -a
2 ifconfig eth0 10.0.0.254 up
3 ifconfig eth0 10.0.0.253 up
4 ping 10.0.0.254
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@svelleweetakealot
svelleweetakealot / notes.md
Created March 18, 2019 20:05
Notes on UML basics.
@svelleweetakealot
svelleweetakealot / extract_image.sh
Created October 11, 2018 11:33 — forked from orodley/extract_image.sh
Extract base64-encoded images from an HTML file.
for image in `grep --color=never -Po 'data:image/[^;]*;base64,\K[a-zA-Z0-9+/]*' foo.html`; do echo -n "$image" | base64 -di > `mktemp image_XXXX`; done
@svelleweetakealot
svelleweetakealot / sieve.rs
Created January 17, 2018 20:49
Sieve of Eratosthenes
//
// Let A be an array of Boolean values, indexed by integers 2 to n,
// initially all set to true.
//
// for i = 2, 3, 4, ..., not exceeding √n:
// if A[i] is true:
// for j = i**2, i**2+i, i**2+2i, i**2+3i, ..., not exceeding n:
// A[j] := false.
//
// Output: all i such that A[i] is true.
@svelleweetakealot
svelleweetakealot / add.c
Last active November 3, 2017 11:08
C testing using CFFI, pytest
#include "add.h"
int add(int a, int b) {
return a + b;
}
@svelleweetakealot
svelleweetakealot / examples.md
Created September 6, 2017 10:44
Reasons to Python3
  • Datetime
> python3 -c 'import datetime;  print(datetime.datetime(1895, 10, 6, 16, 4, 5).strftime("%Y-%m-%d %H:%M:%S"))'
1895-10-06 16:04:05
> python2 -c 'import datetime;  print(datetime.datetime(1895, 10, 6, 16, 4, 5).strftime("%Y-%m-%d %H:%M:%S"))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: year=1895 is before 1900; the datetime strftime() methods require year >= 1900
@svelleweetakealot
svelleweetakealot / grepdates.el
Last active September 5, 2017 06:55
Kube grep dates elisp
(defun kubernetes-re-log ()
(message "test")
(set-buffer "*kubernetes logs*")
(message "buffer name %s" (buffer-name))
(goto-char (point-min))
(save-current-buffer
(set-buffer (get-buffer-create "*dump log*"))
(erase-buffer))
(while (re-search-forward "\\([0-9]+\-[0-9]+\-[0-9]+T[0-9]+:[0-9]+:[0-9]+ .*\\)" nil t)
@svelleweetakealot
svelleweetakealot / cgo-xslt.go
Created June 12, 2017 20:55
xslt lib example in go
package main
/*
#cgo pkg-config: libxslt
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/debugXML.h>
#include <libxml/HTMLtree.h>
#include <libxml/xmlIO.h>
#include <libxml/DOCBparser.h>