Skip to content

Instantly share code, notes, and snippets.

@steveswing
steveswing / cryptography-file-formats.md
Created May 7, 2023 03:02 — forked from tuansoibk/cryptography-file-formats.md
Cryptography material conversion and verification commands
  1. Introduction
  2. Standards
  3. Common combinations
  4. Conversion
  5. Verification/Inspection
  6. Tips for recognising

Introduction

It happens that there are many standards for storing cryptography materials (key, certificate, ...) and it isn't always obvious to know which standard is used by just looking at file name extension or file content. There are bunch of questions on stackoverflow asking about how to convert from PEM to PKCS#8 or PKCS#12, while many tried to answer the questions, those answers may not help because the correct answer depends on the content inside the PEM file. That is, a PEM file can contain many different things, such as an X509 certificate, a PKCS#1 or PKCS#8 private key. The worst-case scenario is that someone just store a non-PEM content in "something.pem" file.

@steveswing
steveswing / noip2.service
Created April 24, 2023 00:03 — forked from NathanGiesbrecht/noip2.service
Systemd Service file for no-ip.com dynamic ip updater
# Simple No-ip.com Dynamic DNS Updater
#
# By Nathan Giesbrecht (http://nathangiesbrecht.com)
#
# 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin)
# 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file
# 3) Copy this file noip2.service to /etc/systemd/system/
# 4) Execute `sudo systemctl daemon-reload`
# 5) Execute `sudo systemctl enable noip2`
# 6) Execute `sudo systemctl start noip2`
# Bash best practices and style-guide
Just simple methods to keep the code clean.
Inspired by [progrium/bashstyle](https://github.com/progrium/bashstyle) and [Kfir Lavi post](http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/).
## Quick big rules
* All code goes in a function
* Always double quote variables
@steveswing
steveswing / version-rules.xml
Created November 26, 2020 03:12
version-rules.xml
<ruleset comparisonMethod="maven"
xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 http://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
<ignoreVersions>
<ignoreVersion type="regex">.*[Aa]lpha.*</ignoreVersion>
<ignoreVersion type="regex">.*[Bb]eta.*</ignoreVersion>
<ignoreVersion type="regex">.*M\d+$</ignoreVersion>
<ignoreVersion type="regex">.*-rc-\d+$</ignoreVersion>
<ignoreVersion type="regex">.*-b\d+$</ignoreVersion>
<ignoreVersion type="regex">.*\.pr\d+$</ignoreVersion>
@steveswing
steveswing / brew.install.quicklook.sh
Created December 13, 2019 18:50 — forked from N4M3Z/brew.install.quicklook.sh
Install Quick Look Plugins (OS X Caskroom)
#!/bin/sh
##
# Quick Look Plugins
# @url http://caskroom.io
# @brief Quick Look Plugins installed via Homebrew Cask
#
# For a comprehensive overview of Quick Look plugins look here: https://github.com/sindresorhus/quick-look-plugins
#
brew cask install qlcolorcode # Preview source code files with syntax highlighting
brew cask install qlstephen # Preview plain text files without a file extension. Example: README, CHANGELOG, etc.
@steveswing
steveswing / disable mcafee endpoint protection.md
Created November 28, 2019 00:35 — forked from tegansnyder/disable mcafee endpoint protection.md
Disable McAffee Endpoint Protection OSX

method 1

sudo /usr/local/McAfee/AntiMalware/VSControl stopoas

alternatively

sudo defaults write /Library/Preferences/com.mcafee.ssm.antimalware.plist OAS_Enable -bool False
sudo /usr/local/McAfee/AntiMalware/VSControl stop
sudo /usr/local/McAfee/AntiMalware/VSControl reload
@steveswing
steveswing / mac-bootstrap.sh
Created November 5, 2019 00:50 — forked from knoopx/mac-bootstrap.sh
mac bootstrap osx
# change modifier keys
# install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install mas
mas upgrade
# core utils
brew install findutils ssh-copy-id unrar wget git hub gnutls gnu-tar trash fzf
#!/bin/bash
# checkip.sh
# Detect when public IP address changes
# Add the following to the crontab (i.e. crontab -e)
# */30 * * * * ~/checkip.sh
# To successfully start SubstratumNode in privileged mode this script has to run as root or as a sudoer.
# When run by cron sudo can't prompt for a password. See creating /etc/sudoers.d/<username> and adding an entry like the following:
# %<your-user-here> ALL=(ALL) NOPASSWD:SETENV: /your/path/to/build/directory/node_ui/static/binaries/SubstratumNode
# Change paths ./recorded-ipv4 and SubstratumNode as needed for your system
@steveswing
steveswing / server.scala
Created December 12, 2017 04:45 — forked from huntc/server.scala
A complete server using Akka streams that reads some source, batches its data and then publishes. If the data cannot be published then it backs off with a best-effort of sending that data again.
val (recycleQueue, recycleSource) =
Source
.queue[SoilStateReading](100, OverflowStrategy.dropTail)
.prefixAndTail(0)
.map(_._2)
.toMat(Sink.head)(Keep.both)
.run()
StreamConverters.fromInputStream(() => this.getClass.getClassLoader.getResourceAsStream("sensors.log"))
.via(SoilStateReading.csvParser)
.merge(Source.fromFutureSource(recycleSource))
[
{"location": "Dublin", "datetime": "20171109T220000Z", "temp": 35},
{"location": "Los Angeles", "datetime": "20171111T110000Z", "temp": 59 },
{"location": "Los Angeles", "datetime": "20171111T070000Z", "temp": 59 },
{"location": "Dublin", "datetime": "20171110T000000Z", "temp": 31},
{"location": "Dublin", "datetime": "20171110T100000Z", "temp": 27},
{"location": "Columbus", "datetime": "20171111T030000Z", "temp": 21 },
{"location": "Dublin", "datetime": "20171110T190000Z", "temp": 27},
{"location": "Los Angeles", "datetime": "20171109T220000Z", "temp": 62 },
{"location": "Dublin", "datetime": "20171109T230000Z", "temp": 33},