Skip to content

Instantly share code, notes, and snippets.

View olastor's full-sized avatar

Sebastian olastor

  • Germany
View GitHub Profile
#/bin/bash
# comment
SAVE_DIR="$HOME/.cat-logs-once-store"
mkdir -p "${SAVE_DIR}"
target_file=$1
session_prefix=$2
@olastor
olastor / check-certs.sh
Created August 6, 2020 18:25 — forked from cgmartin/check-certs.sh
Bash SSL Certificate Expiration Check
#!/bin/bash
TARGET="mysite.example.net";
RECIPIENT="hostmaster@mysite.example.net";
DAYS=7;
echo "checking if $TARGET expires in less than $DAYS days";
expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \
| openssl x509 -text \
| grep 'Not After' \
|awk '{print $4,$5,$7}')" '+%s');
in7days=$(($(date +%s) + (86400*$DAYS)));
@olastor
olastor / prepareHtml.js
Last active November 24, 2018 20:14
SuttaCentral: Merge html files from `de/pli/sutta/sn` into one big that can be converted to pdf or latex using pandoc
// This script was placed in /sc-data/html_text/de/pli/sutta/sn (needs requirements `yarn add natural-sort glob ...`)
// Outputs book.html, a file of all merged text - (hopefully) correctly ordered.
// Minimal example for creating PDF: pandoc -o book.pdf --pdf-engine=xelatex --toc book.html
const nsort = require('natural-sort');
const glob = require('glob');
const fs = require('fs');
const cheerio = require('cheerio');
glob("**/*.html", (er, files) => {
@olastor
olastor / dmes_diff.sh
Created March 20, 2018 07:32
Allows to see info from dmesg command for device only by removing or adding it while running this script
#!/bin/bash
A=$(dmesg)
echo "Remove or add your device now."
sleep 5
B=$(dmesg)
diff <(echo "$A") <(echo "$B")
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
int main() {
pid_t pid;
int fd[2];
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
pid_t pid;
switch ((pid = fork())) {
case -1:
// error occurred
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(int argc, char *argv[]) {
int c;
while((c = getopt(argc, argv, "ab:c:")) != -1) {
switch(c) {
case 'a':
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main() {
pid_t pid;
if ((pid = fork()) < 0) {
// error occurred
printf("Error using fork()");
#include <stdio.h>
int main() {
printf("Hello World!");
return 0;
}
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main() {
// salt rnd
srand(time(NULL));
printf("%d\n", rand());
printf("%d\n", rand());