Coder Social home page Coder Social logo

samrocketman / blog Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 0.0 2.47 MB

A personal technical blog. Full featured complete with automated peer review.

Home Page: http://sam.gleske.net/blog/

License: Other

Ruby 20.50% Makefile 7.82% HTML 40.70% CSS 16.21% Shell 8.94% Dockerfile 0.35% JavaScript 5.49%
blog blog-engine entertainment jekyll-site jekyll-blog hacktoberfest

blog's Introduction

My blog - Build Status

This is a blogging website where I post technical information for myself, Sam Gleske. If others find it useful then more power to 'em. If you'd like to learn more about me then check out my first post.

Features of my blog

  • Minimal as possible while still remaining useful.
  • Easy to copy and make your own. All author settings for customizing this blog is stored in _config.yml.
  • Write blog posts in GitHub flavored markdown.
  • Slightly reddish/pink tint which is good for readers' eyes.
  • Tags and categories.
  • Integrated with some social media:
    • Disqus (for comments)
    • GitHub (for post history)
    • Keybase.io links.
    • GPG key hosting and GPG key ID (verify GPG signed posts for author integrity)
    • Twitter (post sharing)
  • Automated peer review.
  • Three modes:
    1. development - distractions like social media buttons and comments removed.
    2. simulated production - Just like production but local. Good to check out before publishing when customizing style and layout.
    3. production - The live site.

Copy my blog and make it your own

  1. Fork or clone this blog. I recommend you clone and copy so you get stats in your GitHub profile.
  2. Remove all posts from _posts and _drafts.
  3. Customize _config.yml with your own information.
  4. Update LICENSE.txt and make it your own.
  5. Publish back to GitHub.
# Step 1
git clone https://github.com/samrocketman/blog
# Step 2
rm _posts/*.md* _drafts/*.md
# Step 3
vim _config.yml
# Step 4
vim LICENSE.txt
# Step 5
git remote add myblog [email protected]:<your_username>/<your_blog>.git
git push myblog 'refs/heads/main:refs/heads/gh-pages'

Note: gh-pages branch automatically gets published to GitHub pages. However, if you'd rather be more like this blog publishing from main, then you can customize the branch to main from the repository settings.

Legal note: the 3rd_party/ directory must remain intact in order to satisfy license requirements of both work provided by myself and authors in which I built upon. It contains all notices and licenses for using other peoples' source code.

Getting started with development

Prerequisites

  • OS: Ubuntu GNU/Linux
  • Ruby 2.4

If you're using a Mac, then building the blog won't work. It's due to differences in the BSD toolset vs the GNU toolset.

The blog requires Ruby 2.4 to be installed. It's best to use rvm for Ruby.

Set up with rvm.

rvm install 2.4
#optionally install within a "blog" gemset
rvm use 2.4@blog --create

If you encounter an error about not being in a login shell then use bash -l to create one. Now when you open a new terminal be sure to execute the following commands before modifying the blog.

rvm use 2.4@blog --create

Install dependencies.

make deps

Developing the site

There a "make" commands which make developing this blog easier and performing more complex tasks.

  • make - Starts the website removing all distractions (development mode).
  • make prod - Starts a local copy of the website like it is meant to be viewed in production (simulated production mode).
  • make test - Performs automated peer review and generates the live site in the _site/ directory (production mode).

Other make commands:

  • make history - will generate data for your site which will be used for the "last updated" links in blog posts. This automatically gets run with make test as well.
  • make sign - will GPG sign blog posts which have changed using your default GPG private key.

Automated peer review

What is it? It performs common and repeatable tasks a person would normally do when checking this blog. Rather than having to do it you're able to rely on computers to check it for you.

What sort of tasks are performed in automated peer review for this blog?

  • Grammar and spelling checking. It smartly checks posts which have changed rather than everything.
  • GPG signature checking for blog posts to ensure you didn't miss signing your content.
  • Builds the website for uploading to other sources.

Automated peer review is useful to run before you even publish the website for readers to see. I use GitHub pull requests and Travis CI for automated peer review when publishing my new blog posts.

Note: Grammar and spell checking isn't perfect due to the technical nature of my blog. I have added grammar_ignore.dict for skipping keywords and grammar_skip.sentences for skipping whole sentences when I'm writing. It doesn't always get it right but it still forces me to double check the sentences it calls out.

Tips for myself

Sign any changed blog posts:

make sign

Force re-signing all blog posts:

make sign FILES="$(echo _posts/*.md)"

Force re-signing a specific blog post:

make sign FILES="_posts/somepost.md"

Sign a commit:

git commit -S

Summary of Licenses

All source code is MIT Licensed by LICENSE.txt with exception for:

blog's People

Contributors

dependabot[bot] avatar samrocketman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

blog's Issues

Distroless busybox

A minimal distroless busybox

FROM alpine

SHELL ["/bin/sh", "-exc"]
# Prerequisites
RUN \
  # Directory structure and permissions
  mkdir -p base/bin base/tmp base/var/tmp base/etc base/home/nonroot base/sbin base/root; \
  chmod 700 /root; \
  chown root:root /root; \
  chmod 1777 base/tmp base/var/tmp; \
  chown 65532:65532 base/home/nonroot; \
  chmod 750 base/home/nonroot; \
  # UID and GID
  echo 'root:x:0:' > /base/etc/group; \
  echo 'nonroot:x:65532:' >> /base/etc/group; \
  echo 'root:x:0:0:root:/root:/sbin/nologin' > /base/etc/passwd; \
  echo 'nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin' >> /base/etc/passwd; \
  # init binary
  apk add --no-cache dumb-init; \
  cp -a /usr/bin/dumb-init base/bin/dumb-init; \
  # copy busybox and musl
  mkdir -p base/usr/bin base/lib; \
  cp /lib/ld-musl-*.so.1 base/lib; \
  cp -a /bin/busybox base/bin/; \
  # find all symlinks pointing at busybox
  for x in /bin /sbin /usr/bin /usr/sbin; do \
    mkdir -p base"$x"; \
    find "$x" -type l -exec /bin/sh -c 'e() { if [ "`readlink "$1"`" = /bin/busybox ]; then echo "$1"; fi; }; e {}' \; \
      | tr '\n' '\0' | xargs -0 -I{} cp -a {} base"$x"/; \
  done; \
  echo "distroless" > base/etc/issue

FROM scratch
COPY --from=0 /base/ /
ENTRYPOINT ["/bin/dumb-init", "--"]
USER nonroot
ENV HOME=/home/nonroot USER=nonroot PATH="/usr/sbin:/usr/bin:/sbin:/bin"
WORKDIR /home/nonroot
CMD ["/bin/sh"]

Jenkins config rescue

Back up jenkins config without build history.

find . -maxdepth 2 \( -path './config-history/*' -o -path './plugins/*' -o -path './secret*' -o -path './*.xml' -o -type f \( -name 'config.xml' -o -name 'nextBuildNumber' \) \) -exec tar -uvf /tmp/jenkins-config.tar {} +

Grammar and misc

  • Remove again from "delete Windows again".

  • Remove the bit about commented out USB code since that is not the case. It was only the case during development of the post when I was facing challenges.

  • Casing: "VirtualBox guest additions"

  • Space "#USB 3"

  • Remove "and Guest Additions" from section heading.

Linux performance and swap tips

Summary

  • Memory via free -m
  • CPU via top
  • Disk IO via iotop-c
  • Disable journald logging to syslog and disable all persistent storage so that it logs in-memory.
  • Enable swap space and change Linux kernel parameter vm.swappiness to 100 (default 60 by the kernel)

top

top -H

shortcuts zxc and then press 1 to see CPU core usage. Use < and > to navigate sorting fields.

iotop-c

iotop-c -oPa

shortcuts a (to toggle aggregate or real time stats) and p (to toggle break down by parent process or by pthreads).

ps

View process threads for thread count and more info about the threads. UID 1000

ps -T -u 1000

Disable journald logging

Edit /etc/systemd/journald.conf with

[Journal]
Storage=none
ForwardToSyslog=no

and restart

systemctl restart systemd-journald

Enable swap space and increase swappiness

50% of RAM is conservative but if you want to enable hibernation on laptops you need at least 100% of RAM available as swap.

# allocate disk
dd if=/dev/zero of=/swapfile bs=1G count=16

# prepare swap
chmod 600 /swapfile
mkswap /swapfile

# persist enabling swap on reboot
echo '/swapfile none swap sw 0 0' >> /etc/fstab

# enable swap without needing to reboot
swapon /swapfile

Change swappiness so that Linux kernel has more memory management options. For SSDs, maximum swappiness is okay because of their random access. SSD lifespan is good enough to not worry about it.

# Check swappiness is not already configured
grep vm.swappiness /usr/lib/tuned/*/tuned.conf /etc/sysctl.conf

# read current swappiness (returned 60 which is kernel default)
cat /proc/sys/vm/swappiness

# set swappiness persistent on reboot
echo 'vm.swappiness=100' >> /etc/sysctl.conf

# set swappiness in the current runtime so reboot is not needed
sysctl -w vm.swappiness=100

# verify current swappiness (returned 100)
cat /proc/sys/vm/swappiness

Background reading material

and man pages

man 8 systemd-journald.service
man 5 journald.conf

Make use of GitHub button?

At some point it might be worth making use of GitHub buttons on the blog.

<iframe src="http://ghbtns.com/github-btn.html?user=samrocketman&repo=blog&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=samrocketman&repo=blog&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.