1651761800

# Optimus-go: ID Hashing and Obfuscation using Knuth's Algorithm

ID Obfuscation/Hashing Transformer for Go

There are many times when you want to generate obfuscated ids. This package utilizes Knuth's Hashing Algorithm to transform your internal ids into another number to hide it from the general public.

An example may be your database table. You may have a primary key that points to a particular customer. For security reasons you don't want to expose that id to the outside world. That is exactly where this package becomes handy.

Optimus encodes your internal id to a number that is safe to expose. Finally it can decode that number back so you know which internal id it refers to.

β­ the project to show your appreciation.

## Installation

go get -u github.com/pjebs/optimus-go


## Usage

### Step 1

• Find or Calculate a PRIME number from somewhere. It must be smaller than 2147483647 (MAXID)
• Calculate the Mod Inverse of the Prime number such that (PRIME * INVERSE) & MAXID == 1
• Generate a Pure Random Integer less than 2147483647 (MAXID).

You can use the built-in generator.GenerateSeed() function to generate all 3 required parameters if you want.

### Step 2


package hello

import (
"fmt"
"github.com/pjebs/optimus-go"
)

o := optimus.New(1580030173, 59260789, 1163945558) // Prime Number: 1580030173, Mod Inverse: 59260789, Pure Random Number: 1163945558

new_id := o.Encode(15) // internal id of 15 being transformed to 1103647397

orig_id := o.Decode(1103647397) // Returns 15 back



Please note that in order for Optimus to transform the id back to the original, all 3 numbers of the constructor must be consistent. You will need to store it somewhere after generation and usage.

## Methods

type Optimus struct {
prime      uint64
modInverse uint64
random     uint64
}

func New(prime uint64, modInverse uint64, random uint64) Optimus


New returns an Optimus struct that can be used to encode and decode integers. A common use case is for obfuscating internal ids of database primary keys. It is imperative that you keep a record of prime, modInverse and random so that you can decode an encoded integer correctly. random must be an integer less than MAX_INT.

WARNING: The function panics if prime is not a valid prime. It does a probability-based prime test using the MILLER-RABIN algorithm.

CAUTION: DO NOT DIVULGE prime, modInverse and random!

func NewCalculated(prime uint64, random uint64) Optimus


NewCalculated returns an Optimus struct that can be used to encode and decode integers. random must be an integer less than MAX_INT. It automatically calculates prime's mod inverse and then calls New.

func (o Optimus) Encode(n uint64) uint64


Encode is used to encode n using Knuth's hashing algorithm.

func (o Optimus) Decode(n uint64) uint64


Decode is used to decode n back to the original. It will only decode correctly if the Optimus struct is consistent with what was used to encode n.

func (o Optimus) Prime() uint64


Prime returns the associated prime.

CAUTION: DO NOT DIVULGE THIS NUMBER!

func (o Optimus) ModInverse() uint64


ModInverse returns the associated mod inverse.

CAUTION: DO NOT DIVULGE THIS NUMBER!

func (o Optimus) Random() uint64


Random returns the associated random integer.

CAUTION: DO NOT DIVULGE THIS NUMBER!

func ModInverse(n int64) uint64


ModInverse returns the modular inverse of a given prime number. The modular inverse is defined such that (PRIME * MODULAR_INVERSE) & (MAX_INT_VALUE) = 1.

NOTE: prime is assumed to be a valid prime. If prime is outside the bounds of an int64, then the function panics as it can not calculate the mod inverse.

func generator.GenerateSeed() (Optimus, error)


GenerateSeed will generate a valid optimus object which can be used for encoding and decoding values.

See http://godoc.org/github.com/pjebs/optimus-go/generator#GenerateSeed for details on how to use it.

## Alternatives

There is the hashids package which is very popular. Out of the box, it produces obfuscated ids that can contain any number of characters.

However:

• Knuth's algorithm is 127 times faster in benchmarks
• Hashids produce strings that contain characters other than just numbers.
• If you were to modify the code (since the default minimum alphabet size is 16 characters) to allow only characters (0-9), it removes the first and last numbers to use as separators.
• If the character '0' by coincidence comes out at the front of the obfuscated id, then you can't convert it to an integer when you store it. An integer will remove the leading zero but you need it to decode the number back to the original id (since hashid deals with strings and not numbers).

## Inspiration

This package is based on the PHP library by jenssegers.

## Other useful packages

• dataframe-go - Statistics and data manipulation
• dbq - Zero boilerplate database operations for Go
• electron-alert - SweetAlert2 for Electron Applications
• igo - A Go transpiler with cool new syntax such as fordefer (defer for for-loops)
• mysql-go - Properly cancel slow MySQL queries
• react - Build front end applications using Go
• remember-go - Cache slow database queries

## Final Notes

Feel free to fork and/or provide pull requests. Any bug reports will be warmly received.

Β© 2014-20 PJ Engineering and Business Solutions Pty. Ltd.

Author: Pjebs
Source Code: https://github.com/pjebs/optimus-go

#go #golang #id

1667425440

## pdf2gerb

Perl script converts PDF files to Gerber format

Pdf2Gerb generates Gerber 274X photoplotting and Excellon drill files from PDFs of a PCB. Up to three PDFs are used: the top copper layer, the bottom copper layer (for 2-sided PCBs), and an optional silk screen layer. The PDFs can be created directly from any PDF drawing software, or a PDF print driver can be used to capture the Print output if the drawing software does not directly support output to PDF.

The general workflow is as follows:

1. Design the PCB using your favorite CAD or drawing software.
2. Print the top and bottom copper and top silk screen layers to a PDF file.
3. Run Pdf2Gerb on the PDFs to create Gerber and Excellon files.
4. Use a Gerber viewer to double-check the output against the original PCB design.
5. Make adjustments as needed.
6. Submit the files to a PCB manufacturer.

Please note that Pdf2Gerb does NOT perform DRC (Design Rule Checks), as these will vary according to individual PCB manufacturer conventions and capabilities. Also note that Pdf2Gerb is not perfect, so the output files must always be checked before submitting them. As of version 1.6, Pdf2Gerb supports most PCB elements, such as round and square pads, round holes, traces, SMD pads, ground planes, no-fill areas, and panelization. However, because it interprets the graphical output of a Print function, there are limitations in what it can recognize (or there may be bugs).

See docs/Pdf2Gerb.pdf for install/setup, config, usage, and other info.

## pdf2gerb_cfg.pm

#Pdf2Gerb config settings:
#Put this file in same folder/directory as pdf2gerb.pl itself (global settings),
#or copy to another folder/directory with PDFs if you want PCB-specific settings.
#There is only one user of this file, so we don't need a custom package or namespace.
#NOTE: all constants defined in here will be added to main namespace.
#package pdf2gerb_cfg;

use strict; #trap undef vars (easier debug)
use warnings; #other useful info (easier debug)

##############################################################################################
#configurable settings:
#change values here instead of in main pfg2gerb.pl file

use constant WANT_COLORS => ($^O !~ m/Win/); #ANSI colors no worky on Windows? this must be set < first DebugPrint() call #just a little warning; set realistic expectations: #DebugPrint("${$$CYAN)}Pdf2Gerb.pl {\(VERSION)}, ^O O/S\n{\(YELLOW)}{\(BOLD)}{\(ITALIC)}This is EXPERIMENTAL software. \nGerber files MAY CONTAIN ERRORS. Please CHECK them before fabrication!{\(RESET)}", 0); #if WANT_DEBUG use constant METRIC => FALSE; #set to TRUE for metric units (only affect final numbers in output files, not internal arithmetic) use constant APERTURE_LIMIT => 0; #34; #max #apertures to use; generate warnings if too many apertures are used (0 to not check) use constant DRILL_FMT => '2.4'; #'2.3'; #'2.4' is the default for PCB fab; change to '2.3' for CNC use constant WANT_DEBUG => 0; #10; #level of debug wanted; higher == more, lower == less, 0 == none use constant GERBER_DEBUG => 0; #level of debug to include in Gerber file; DON'T USE FOR FABRICATION use constant WANT_STREAMS => FALSE; #TRUE; #save decompressed streams to files (for debug) use constant WANT_ALLINPUT => FALSE; #TRUE; #save entire input stream (for debug ONLY) #DebugPrint(sprintf("{\(CYAN)}DEBUG: stdout %d, gerber %d, want streams? %d, all input? %d, O/S: ^O, Perl: ]{\(RESET)}\n", WANT_DEBUG, GERBER_DEBUG, WANT_STREAMS, WANT_ALLINPUT), 1); #DebugPrint(sprintf("max int = %d, min int = %d\n", MAXINT, MININT), 1); #define standard trace and pad sizes to reduce scaling or PDF rendering errors: #This avoids weird aperture settings and replaces them with more standardized values. #(I'm not sure how photoplotters handle strange sizes). #Fewer choices here gives more accurate mapping in the final Gerber files. #units are in inches use constant TOOL_SIZES => #add more as desired ( #round or square pads (> 0) and drills (< 0): .010, -.001, #tiny pads for SMD; dummy drill size (too small for practical use, but needed so StandardTool will use this entry) .031, -.014, #used for vias .041, -.020, #smallest non-filled plated hole .051, -.025, .056, -.029, #useful for IC pins .070, -.033, .075, -.040, #heavier leads # .090, -.043, #NOTE: 600 dpi is not high enough resolution to reliably distinguish between .043" and .046", so choose 1 of the 2 here .100, -.046, .115, -.052, .130, -.061, .140, -.067, .150, -.079, .175, -.088, .190, -.093, .200, -.100, .220, -.110, .160, -.125, #useful for mounting holes #some additional pad sizes without holes (repeat a previous hole size if you just want the pad size): .090, -.040, #want a .090 pad option, but use dummy hole size .065, -.040, #.065 x .065 rect pad .035, -.040, #.035 x .065 rect pad #traces: .001, #too thin for real traces; use only for board outlines .006, #minimum real trace width; mainly used for text .008, #mainly used for mid-sized text, not traces .010, #minimum recommended trace width for low-current signals .012, .015, #moderate low-voltage current .020, #heavier trace for power, ground (even if a lighter one is adequate) .025, .030, #heavy-current traces; be careful with these ones! .040, .050, .060, .080, .100, .120, ); #Areas larger than the values below will be filled with parallel lines: #This cuts down on the number of aperture sizes used. #Set to 0 to always use an aperture or drill, regardless of size. use constant { MAX_APERTURE => max((TOOL_SIZES)) + .004, MAX_DRILL => -min((TOOL_SIZES)) + .004 }; #max aperture and drill sizes (plus a little tolerance) #DebugPrint(sprintf("using %d standard tool sizes: %s, max aper %.3f, max drill %.3f\n", scalar((TOOL_SIZES)), join(", ", (TOOL_SIZES)), MAX_APERTURE, MAX_DRILL), 1); #NOTE: Compare the PDF to the original CAD file to check the accuracy of the PDF rendering and parsing! #for example, the CAD software I used generated the following circles for holes: #CAD hole size: parsed PDF diameter: error: # .014 .016 +.002 # .020 .02267 +.00267 # .025 .026 +.001 # .029 .03167 +.00267 # .033 .036 +.003 # .040 .04267 +.00267 #This was usually ~ .002" - .003" too big compared to the hole as displayed in the CAD software. #To compensate for PDF rendering errors (either during CAD Print function or PDF parsing logic), adjust the values below as needed. #units are pixels; for example, a value of 2.4 at 600 dpi = .0004 inch, 2 at 600 dpi = .0033" use constant { HOLE_ADJUST => -0.004 * 600, #-2.6, #holes seemed to be slightly oversized (by .002" - .004"), so shrink them a little RNDPAD_ADJUST => -0.003 * 600, #-2, #-2.4, #round pads seemed to be slightly oversized, so shrink them a little SQRPAD_ADJUST => +0.001 * 600, #+.5, #square pads are sometimes too small by .00067, so bump them up a little RECTPAD_ADJUST => 0, #(pixels) rectangular pads seem to be okay? (not tested much) TRACE_ADJUST => 0, #(pixels) traces seemed to be okay? REDUCE_TOLERANCE => .001, #(inches) allow this much variation when reducing circles and rects }; #Also, my CAD's Print function or the PDF print driver I used was a little off for circles, so define some additional adjustment values here: #Values are added to X/Y coordinates; units are pixels; for example, a value of 1 at 600 dpi would be ~= .002 inch use constant { CIRCLE_ADJUST_MINX => 0, CIRCLE_ADJUST_MINY => -0.001 * 600, #-1, #circles were a little too high, so nudge them a little lower CIRCLE_ADJUST_MAXX => +0.001 * 600, #+1, #circles were a little too far to the left, so nudge them a little to the right CIRCLE_ADJUST_MAXY => 0, SUBST_CIRCLE_CLIPRECT => FALSE, #generate circle and substitute for clip rects (to compensate for the way some CAD software draws circles) WANT_CLIPRECT => TRUE, #FALSE, #AI doesn't need clip rect at all? should be on normally? RECT_COMPLETION => FALSE, #TRUE, #fill in 4th side of rect when 3 sides found }; #allow .012 clearance around pads for solder mask: #This value effectively adjusts pad sizes in the TOOL_SIZES list above (only for solder mask layers). use constant SOLDER_MARGIN => +.012; #units are inches #line join/cap styles: use constant { CAP_NONE => 0, #butt (none); line is exact length CAP_ROUND => 1, #round cap/join; line overhangs by a semi-circle at either end CAP_SQUARE => 2, #square cap/join; line overhangs by a half square on either end CAP_OVERRIDE => FALSE, #cap style overrides drawing logic }; #number of elements in each shape type: use constant { RECT_SHAPELEN => 6, #x0, y0, x1, y1, count, "rect" (start, end corners) LINE_SHAPELEN => 6, #x0, y0, x1, y1, count, "line" (line seg) CURVE_SHAPELEN => 10, #xstart, ystart, x0, y0, x1, y1, xend, yend, count, "curve" (bezier 2 points) CIRCLE_SHAPELEN => 5, #x, y, 5, count, "circle" (center + radius) }; #const my %SHAPELEN = #Readonly my %SHAPELEN => our %SHAPELEN = ( rect => RECT_SHAPELEN, line => LINE_SHAPELEN, curve => CURVE_SHAPELEN, circle => CIRCLE_SHAPELEN, ); #panelization: #This will repeat the entire body the number of times indicated along the X or Y axes (files grow accordingly). #Display elements that overhang PCB boundary can be squashed or left as-is (typically text or other silk screen markings). #Set "overhangs" TRUE to allow overhangs, FALSE to truncate them. #xpad and ypad allow margins to be added around outer edge of panelized PCB. use constant PANELIZE => {'x' => 1, 'y' => 1, 'xpad' => 0, 'ypad' => 0, 'overhangs' => TRUE}; #number of times to repeat in X and Y directions # Set this to 1 if you need TurboCAD support. #turboCAD = FALSE; #is this still needed as an option? #CIRCAD pad generation uses an appropriate aperture, then moves it (stroke) "a little" - we use this to find pads and distinguish them from PCB holes. use constant PAD_STROKE => 0.3; #0.0005 * 600; #units are pixels #convert very short traces to pads or holes: use constant TRACE_MINLEN => .001; #units are inches #use constant ALWAYS_XY => TRUE; #FALSE; #force XY even if X or Y doesn't change; NOTE: needs to be TRUE for all pads to show in FlatCAM and ViewPlot use constant REMOVE_POLARITY => FALSE; #TRUE; #set to remove subtractive (negative) polarity; NOTE: must be FALSE for ground planes #PDF uses "points", each point = 1/72 inch #combined with a PDF scale factor of .12, this gives 600 dpi resolution (1/72 * .12 = 600 dpi) use constant INCHES_PER_POINT => 1/72; #0.0138888889; #multiply point-size by this to get inches # The precision used when computing a bezier curve. Higher numbers are more precise but slower (and generate larger files). #bezierPrecision = 100; use constant BEZIER_PRECISION => 36; #100; #use const; reduced for faster rendering (mainly used for silk screen and thermal pads) # Ground planes and silk screen or larger copper rectangles or circles are filled line-by-line using this resolution. use constant FILL_WIDTH => .01; #fill at most 0.01 inch at a time # The max number of characters to read into memory use constant MAX_BYTES => 10 * M; #bumped up to 10 MB, use const use constant DUP_DRILL1 => TRUE; #FALSE; #kludge: ViewPlot doesn't load drill files that are too small so duplicate first tool my runtime = time(); #Time::HiRes::gettimeofday(); #measure my execution time print STDERR "Loaded config settings from '{\(__FILE__)}'.\n"; 1; #last value must be truthful to indicate successful load ############################################################################################# #junk/experiment: #use Package::Constants; #use Exporter qw(import); #https://perldoc.perl.org/Exporter.html #my caller = "pdf2gerb::"; #sub cfg #{ # my proto = shift; # my class = ref(proto) || proto; # my settings = # { # WANT_DEBUG => 990, #10; #level of debug wanted; higher == more, lower == less, 0 == none # }; # bless(settings, class); # return settings; #} #use constant HELLO => "hi there2"; #"main::HELLO" => "hi there"; #use constant GOODBYE => 14; #"main::GOODBYE" => 12; #print STDERR "read cfg file\n"; #our @EXPORT_OK = Package::Constants->list(__PACKAGE__); #https://www.perlmonks.org/?node_id=1072691; NOTE: "_OK" skips short/common names #print STDERR scalar(@EXPORT_OK) . " consts exported:\n"; #foreach(@EXPORT_OK) { print STDERR "_\n"; } #my val = main::thing("xyz"); #print STDERR "caller gave me val\n"; #foreach my arg (@ARGV) { print STDERR "arg arg\n"; } ## Download Details: Author: swannman Source Code: https://github.com/swannman/pdf2gerb License: GPL-3.0 license 1651761800 ## Optimus-go: ID Hashing and Obfuscation using Knuth's Algorithm ID Obfuscation/Hashing Transformer for Go There are many times when you want to generate obfuscated ids. This package utilizes Knuth's Hashing Algorithm to transform your internal ids into another number to hide it from the general public. An example may be your database table. You may have a primary key that points to a particular customer. For security reasons you don't want to expose that id to the outside world. That is exactly where this package becomes handy. Optimus encodes your internal id to a number that is safe to expose. Finally it can decode that number back so you know which internal id it refers to. β­ the project to show your appreciation. ## Installation go get -u github.com/pjebs/optimus-go  ## Usage ### Step 1 • Find or Calculate a PRIME number from somewhere. It must be smaller than 2147483647 (MAXID) • Calculate the Mod Inverse of the Prime number such that (PRIME * INVERSE) & MAXID == 1 • Generate a Pure Random Integer less than 2147483647 (MAXID). You can use the built-in generator.GenerateSeed() function to generate all 3 required parameters if you want. ### Step 2  package hello import ( "fmt" "github.com/pjebs/optimus-go" ) o := optimus.New(1580030173, 59260789, 1163945558) // Prime Number: 1580030173, Mod Inverse: 59260789, Pure Random Number: 1163945558 new_id := o.Encode(15) // internal id of 15 being transformed to 1103647397 orig_id := o.Decode(1103647397) // Returns 15 back  Please note that in order for Optimus to transform the id back to the original, all 3 numbers of the constructor must be consistent. You will need to store it somewhere after generation and usage. ## Methods type Optimus struct { prime uint64 modInverse uint64 random uint64 }  func New(prime uint64, modInverse uint64, random uint64) Optimus  New returns an Optimus struct that can be used to encode and decode integers. A common use case is for obfuscating internal ids of database primary keys. It is imperative that you keep a record of prime, modInverse and random so that you can decode an encoded integer correctly. random must be an integer less than MAX_INT. WARNING: The function panics if prime is not a valid prime. It does a probability-based prime test using the MILLER-RABIN algorithm. CAUTION: DO NOT DIVULGE prime, modInverse and random! func NewCalculated(prime uint64, random uint64) Optimus  NewCalculated returns an Optimus struct that can be used to encode and decode integers. random must be an integer less than MAX_INT. It automatically calculates prime's mod inverse and then calls New. func (o Optimus) Encode(n uint64) uint64  Encode is used to encode n using Knuth's hashing algorithm. func (o Optimus) Decode(n uint64) uint64  Decode is used to decode n back to the original. It will only decode correctly if the Optimus struct is consistent with what was used to encode n. func (o Optimus) Prime() uint64  Prime returns the associated prime. CAUTION: DO NOT DIVULGE THIS NUMBER! func (o Optimus) ModInverse() uint64  ModInverse returns the associated mod inverse. CAUTION: DO NOT DIVULGE THIS NUMBER! func (o Optimus) Random() uint64  Random returns the associated random integer. CAUTION: DO NOT DIVULGE THIS NUMBER! func ModInverse(n int64) uint64  ModInverse returns the modular inverse of a given prime number. The modular inverse is defined such that (PRIME * MODULAR_INVERSE) & (MAX_INT_VALUE) = 1. NOTE: prime is assumed to be a valid prime. If prime is outside the bounds of an int64, then the function panics as it can not calculate the mod inverse. func generator.GenerateSeed() (Optimus, error)  GenerateSeed will generate a valid optimus object which can be used for encoding and decoding values. See http://godoc.org/github.com/pjebs/optimus-go/generator#GenerateSeed for details on how to use it. ## Alternatives There is the hashids package which is very popular. Out of the box, it produces obfuscated ids that can contain any number of characters. However: • Knuth's algorithm is 127 times faster in benchmarks • Hashids produce strings that contain characters other than just numbers. • If you were to modify the code (since the default minimum alphabet size is 16 characters) to allow only characters (0-9), it removes the first and last numbers to use as separators. • If the character '0' by coincidence comes out at the front of the obfuscated id, then you can't convert it to an integer when you store it. An integer will remove the leading zero but you need it to decode the number back to the original id (since hashid deals with strings and not numbers). ## Inspiration This package is based on the PHP library by jenssegers. ## Other useful packages • dataframe-go - Statistics and data manipulation • dbq - Zero boilerplate database operations for Go • electron-alert - SweetAlert2 for Electron Applications • igo - A Go transpiler with cool new syntax such as fordefer (defer for for-loops) • mysql-go - Properly cancel slow MySQL queries • react - Build front end applications using Go • remember-go - Cache slow database queries ## Final Notes Feel free to fork and/or provide pull requests. Any bug reports will be warmly received. Β© 2014-20 PJ Engineering and Business Solutions Pty. Ltd. Author: Pjebs Source Code: https://github.com/pjebs/optimus-go License: MIT License #go #golang #id 1667279100 ## Jekyll-spaceship: Jekyll Plugin for Astronauts ## π Jekyll Spaceship π Jekyll plugin for Astronauts. Spaceship is a minimalistic, powerful and extremely customizable Jekyll plugin. It combines everything you may need for convenient work, without unnecessary complications, like a real spaceship. π‘ Tip: I hope you enjoy using this plugin. If you like this project, a little star for it is your way make a clear statement: My work is valued. I would appreciate your support! Thank you! ## Requirements • Ruby >= 2.3.0 ## Installation Add jekyll-spaceship plugin in your site's Gemfile, and run bundle install. # If you have any plugins, put them here! group :jekyll_plugins do gem 'jekyll-spaceship' end  Or you better like to write in one line: gem 'jekyll-spaceship', group: :jekyll_plugins  Add jekyll-spaceship to the plugins: section in your site's _config.yml. plugins: - jekyll-spaceship  π‘ Tip: Note that GitHub Pages runs in safe mode and only allows a set of whitelisted plugins. To use the gem in GitHub Pages, you need to build locally or use CI (e.g. travis, github workflow) and deploy to your gh-pages branch. ### Additions for Unlimited GitHub Pages • Here is a GitHub Action named jekyll-deploy-action for Jekyll site deployment conveniently. π • Here is a Jekyll site using Travis to build and deploy to GitHub Pages for your references. ## Configuration This plugin runs with the following configuration options by default. Alternative settings for these options can be explicitly specified in the configuration file _config.yml. # Where things are jekyll-spaceship: # default enabled processors processors: - table-processor - mathjax-processor - plantuml-processor - mermaid-processor - polyfill-processor - media-processor - emoji-processor - element-processor mathjax-processor: src: - https://polyfill.io/v3/polyfill.min.js?features=es6 - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js config: tex: inlineMath: - ['',''] - ['\(','$$']
displayMath:
- ['$$','$$']
- ['$','$']
svg:
fontCache: 'global'
optimize: # optimization on building stage to check and add mathjax scripts
enabled: true # value false for adding to all pages
include: []   # include patterns for math expressions checking (regexp)
exclude: []   # exclude patterns for math expressions checking (regexp)
plantuml-processor:
mode: default  # mode value 'pre-fetch' for fetching image at building stage
css:
class: plantuml
syntax:
code: 'plantuml!'
custom: ['@startuml', '@enduml']
src: http://www.plantuml.com/plantuml/svg/
mermaid-processor:
mode: default  # mode value 'pre-fetch' for fetching image at building stage
css:
class: mermaid
syntax:
code: 'mermaid!'
custom: ['@startmermaid', '@endmermaid']
config:
theme: default
src: https://mermaid.ink/svg/
media-processor:
default:
id: 'media-{id}'
class: 'media'
width: '100%'
height: 350
frameborder: 0
style: 'max-width: 600px; outline: none;'
allow: 'encrypted-media; picture-in-picture'
emoji-processor:
css:
class: emoji
src: https://github.githubassets.com/images/icons/emoji/


## Usage

### 1. Table Usage

For now, these extended features are provided:

• Cells spanning multiple columns
• Cells spanning multiple rows
• Cells text align separately
• Table header not required
• Grouped table header rows or data rows

Noted that GitHub filters out style property, so the example displays with the obsolete align property. But in actual this plugin outputs style property with text-align CSS attribute.

#### Rowspan and Colspan

^^ in a cell indicates it should be merged with the cell above.
This feature is contributed by pmccloghrylaing.

|              Stage | Direct Products | ATP Yields |
| -----------------: | --------------: | ---------: |
|         Glycolysis |          2 ATP              ||
| ^^                 |          2 NADH |   3--5 ATP |
| Pyruvaye oxidation |          2 NADH |      5 ATP |
|  Citric acid cycle |          2 ATP              ||
| ^^                 |          6 NADH |     15 ATP |
| ^^                 |          2 FADH |      3 ATP |
|                               30--32 ATP        |||


Code above would be parsed as:

#### Multiline

A backslash at end to join cell contents with the following lines.
This feature is contributed by Lucas-C.

| :    Easy Multiline   : |||
| :----- | :----- | :------ |
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange
| Apple  | Banana | Orange  \
| Apple  | Banana | Orange  |
| Apple  | Banana | Orange  |


Code above would be parsed as:

Table header can be eliminated.

|--|--|--|--|--|--|--|--|
|β| |β|β|β|β|β|β|
| |β|β|β| |β|β|β|
|β| |β| | | | | |
| |β| | |β| | | |
| | | | |β| | | |
| | | | | |β| | |
|β|β|β|β| |β|β|β|
|β|β|β|β|β| | |β|


Code above would be parsed as:

#### Cell Alignment

Markdown table syntax use colons ":" for forcing column alignment.
Therefore, here we also use it for forcing cell alignment.

Table cell can be set alignment separately.

| :        Fruits \|\| Food       : |||
| :--------- | :-------- | :--------  |
| Apple      | : Apple : | Apple      \
| Banana     |   Banana  | Banana     \
| Orange     |   Orange  | Orange     |
| :   Rowspan is 4    : || How's it?  |
|^^    A. Peach         ||   1. Fine :|
|^^    B. Orange        ||^^ 2. Bad   |
|^^    C. Banana        ||  It's OK!  |


Code above would be parsed as:

#### Cell Markdown

Sometimes we may need some abundant content (e.g., mathjax, image, video) in Markdown table
Therefore, here we also make markown syntax possible inside a cell.

| :                   MathJax \|\| Image                 : |||
| :------------ | :-------- | :----------------------------- |
| Apple         | : Apple : | Apple                          \
| Banana        | Banana    | Banana                         \
| Orange        | Orange    | Orange                         |
| :     Rowspan is 4     : || :        How's it?           : |
| ^^     A. Peach          ||    1. ![example][cell-image]   |
| ^^     B. Orange         || ^^ 2. $I = \int \rho R^{2} dV$ |
| ^^     C. Banana         || **It's OK!**                   |

[cell-image]: https://jekyllrb.com/img/octojekyll.png "An exemplary image"


Code above would be parsed as:

#### Cell Inline Attributes

This feature is very useful for custom cell such as using inline style. (e.g., background, color, font)
The idea and syntax comes from the Maruku package.

Following are some examples of attributes definitions (ALDs) and afterwards comes the syntax explanation:

{:ref-name: #id .cls1 .cls2}
{:second: ref-name #id-of-other title="hallo you"}
{:other: ref-name second}


An ALD line has the following structure:

• a left brace, optionally preceded by up to three spaces,
• followed by a colon, the id and another colon,
• followed by attribute definitions (allowed characters are backslash-escaped closing braces or any character except a not escaped closing brace),
• followed by a closing brace and optional spaces until the end of the line.

If there is more than one ALD with the same reference name, the attribute definitions of all the ALDs are processed like they are defined in one ALD.

An inline attribute list (IAL) is used to attach attributes to another element.
Here are some examples for span IALs:

{: #id .cls1 .cls2} <!-- #id <=> id="id", .cls1 .cls2 <=> class="cls1 cls2" -->
{: ref-name title="hallo you"}
{: ref-name class='.cls3' .cls4}


Here is an example for custom table cell with IAL:

{:color-style: style="background: black;"}
{:color-style: style="color: white;"}
{:text-style: style="font-weight: 800; text-decoration: underline;"}

|:             Here's an Inline Attribute Lists example                :||||
| ------- | ------------------ | -------------------- | ------------------ |
|:       :|:  <div style="color: red;"> &lt; Normal HTML Block > </div> :|||
| ^^      |   Red    {: .cls style="background: orange" }                |||
| ^^ IALs |   Green  {: #id style="background: green; color: white" }    |||
| ^^      |   Blue   {: style="background: blue; color: white" }         |||
| ^^      |   Black  {: color-style text-style }                         |||


Code above would be parsed as:

### 2. MathJax Usage

MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.

Some of the main features of MathJax include:

• High-quality display of LaTeX, MathML, and AsciiMath notation in HTML pages
• Supported in most browsers with no plug-ins, extra fonts, or special setup for the reader
• Easy for authors, flexible for publishers, extensible for developers
• Supports math accessibility, cut-and-paste interoperability, and other advanced functionality
• Powerful API for integration with other web applications

#### 2.1 Performance optimization

At building stage, the MathJax engine script will be added by automatically checking whether there is a math expression in the page, this feature can help you improve the page performance on loading speed.

#### 2.2 How to use?

Put your math expression within $...$

$a * b = c ^ b$

$2^{\frac{n-1}{3}}$

$\int\_a^b f(x)\,dx.$


Code above would be parsed as:

### 3. PlantUML Usage

PlantUML is a component that allows to quickly write:

• sequence diagram,
• use case diagram,
• class diagram,
• activity diagram,
• component diagram,
• state diagram,
• object diagram

There are two ways to create a diagram in your Jekyll blog page:

plantuml!
Bob -> Alice : hello world



or

@startuml
Bob -> Alice : hello
@enduml


Code above would be parsed as:

### 4. Mermaid Usage

Mermaid is a Javascript based diagramming and charting tool. It generates diagrams flowcharts and more, using markdown-inspired text for ease and speed.

It allows to quickly write:

• flow chart,
• pie chart,
• sequence diagram,
• class diagram,
• state diagram,
• entity relationship diagram,
• user journey,
• gantt

There are two ways to create a diagram in your Jekyll blog page:

mermaid!
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 35



or

@startmermaid
pie title Pets adopted by volunteers
"Dogs" : 386
"Cats" : 85
"Rats" : 35
@endmermaid


Code above would be parsed as:

### 5. Media Usage

How often did you find yourself googling "How to embed a video/audio in markdown?"

While its not possible to embed a video/audio in markdown, the best and easiest way is to extract a frame from the video/audio. To add videos/audios to your markdown files easier I developped this tool for you, and it will parse the video/audio link inside the image block automatically.

For now, these media links parsing are provided:

• Vimeo
• DailyMotion
• Spotify
• SoundCloud
• General Video ( mp4 | avi | ogg | ogv | webm | 3gp | flv | mov ... )
• General Audio ( mp3 | wav | ogg | mid | midi | aac | wma ... )

There are two ways to embed a video/audio in your Jekyll blog page:

Inline-style:

![]({media-link})


Reference-style:

![][{reference}]



For configuring media attributes (e.g, width, height), just adding query string to the link as below:

![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY?width=800&height=500)

![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)


![](https://www.youtube.com/watch?v=Ptk_1Dc2iPY)



#### Vimeo Usage

![](https://vimeo.com/263856289)

![](https://vimeo.com/263856289?width=500&height=320)


#### DailyMotion Usage

![](https://www.dailymotion.com/video/x7tfyq3)

![](https://dai.ly/x7tgcev?width=100%&height=400)


#### Spotify Usage

![](http://open.spotify.com/track/4Dg5moVCTqxAb7Wr8Dq2T5)


#### Spotify Podcast Usage

![](https://open.spotify.com/episode/31AxcwYdjsFtStds5JVWbT)


#### SoundCloud Usage

![](https://soundcloud.com/aviciiofficial/preview-avicii-vs-lenny)


#### General Video Usage

![](//www.html5rocks.com/en/tutorials/video/basics/devstories.webm)

![](//techslides.com/demos/sample-videos/small.ogv?allow=autoplay)

![](//techslides.com/demos/sample-videos/small.mp4?width=400)


#### General Audio Usage

![](//www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3)

![](//www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3?autoplay=1&loop=1)


### 6. Hybrid HTML with Markdown

As markdown is not only a lightweight markup language with plain-text-formatting syntax, but also an easy-to-read and easy-to-write plain text format, so writing a hybrid HTML with markdown is an awesome choice.

It's easy to write markdown inside HTML:

<script type="text/markdown">
# Hybrid HTML with Markdown is a not bad choice ^\_^

## Table Usage

| :        Fruits \|\| Food       : |||
| :--------- | :-------- | :--------  |
| Apple      | : Apple : | Apple      \
| Banana     |   Banana  | Banana     \
| Orange     |   Orange  | Orange     |
| :   Rowspan is 4    : || How's it?  |
|^^    A. Peach         ||   1. Fine :|
|^^    B. Orange        ||^^ 2. Bad   |
|^^    C. Banana        ||  It's OK!  |

## PlantUML Usage

@startuml
Bob -> Alice : hello
@enduml

## Video Usage

</script>


### 7. Markdown Polyfill

It allows us to polyfill features for extending markdown syntax.

For now, these polyfill features are provided:

• Escape ordered list

#### 7.1 Escape Ordered List

A backslash at begin to escape the ordered list.

Normal:

1. List item Apple.
3. List item Banana.
10. List item Cafe.

Escaped:

\1. List item Apple.
\3. List item Banana.
\10. List item Cafe.


Code above would be parsed as:

Normal:

1. List item Apple.
2. List item Banana.
3. List item Cafe.

Escaped:

1. List item Apple.
3. List item Banana.
10. List item Cafe.


### 8. Emoji Usage

GitHub-flavored emoji images and names would allow emojifying content such as: it's raining :cat:s and :dog:s!

Noted that emoji images are served from the GitHub.com CDN, with a base URL of https://github.githubassets.com, which results in emoji image URLs like https://github.githubassets.com/images/icons/emoji/unicode/1f604.png.

In any page or post, use emoji as you would normally, e.g.

I give this plugin two :+1:!


Code above would be parsed as:

I give this plugin two :+1:!

#### 8.1 Emoji Customizing

If you'd like to serve emoji images locally, or use a custom emoji source, you can specify so in your _config.yml file:

jekyll-spaceship:
emoji-processor:
src: "/assets/images/emoji"


See the Gemoji documentation for generating image files.

### 9. Modifying Element Usage

It allows us to modify elements via CSS3 selectors. Through it you can easily modify the attributes of an element tag, replace the children nodes and so on, it's very flexible, but here is example usage for modifying a document:

# Here is a comprehensive example
jekyll-spaceship:
element-processor:
css:
- a: '<h1>Test</h1>'                     # Replace all a tags (String Style)
- ['a.link1', 'a.link2']:                # Replace all a.link1, a.link2 tags (Hash Style)
name: img                            # Replace element tag name
props:                               # Replace element properties
title: Good image                  # Add a title attribute
src: ['(^.*$)', '\0?a=123'] # Add query string to src attribute by regex pattern style: # Add style attribute (Hash Style) color: red font-size: '1.2em' children: # Add children to the element - # First empty for adding after the last child node - "<span>Google</span>" # First child node (String Style) - # Middle empty for wrapping the children nodes - name: span # Second child node (Hash Style) props: prop1: "1" # Custom property1 prop2: "2" # Custom property2 prop3: "3" # Custom property3 children: # Add nested chidren nodes - "<span>Jekyll</span>" # First child node (String Style) - name: span # Second child node (Hash Style) props: # Add attributes to child node (Hash Style) prop1: "a" prop2: "b" prop3: "c" children: "<b>Yap!</b>" # Add children nodes (String Style) - # Last empty for adding before the first child node - a.link: '<a href="//t.com">Link</a>' # Replace all a.link tags (String Style) - 'h1#title': # Replace h1#title tags (Hash Style) children: I'm a title! # Replace inner html to new text  #### Example 1 Automatically adds a target="_blank" rel="noopener noreferrer" attribute to all external links in Jekyll's content. jekyll-spaceship: element-processor: css: - a: # Replace all a tags props: class: ['(^.*$)', '\0 ext-link']   # Add ext-link to class by regex pattern
target: _blank                     # Replace target value to _blank
rel: noopener noreferrer           # Replace rel value to noopener noreferrer


#### Example 2

Automatically adds loading="lazy" to img and iframe tags to natively load lazily. Browser support is growing. If a browser does not support the loading attribute, it will load the resource just like it would normally.

jekyll-spaceship:
element-processor:
css:
- a:                                     # Replace all a tags
props:                               #
loading: lazy                      # Replace loading value to lazy


In case you want to prevent loading some images/iframes lazily, add loading="eager" to their tags. This might be useful to prevent flickering of images during navigation (e.g. the site's logo).

See the following examples to prevent lazy loading.

jekyll-spaceship:
element-processor:
css:
- a:                                     # Replace all a tags
props:                               #
loading: eager                     # Replace loading value to eager


There are three options when using this method to lazy load images. Here are the supported values for the loading attribute:

• auto: Default lazy-loading behavior of the browser, which is the same as not including the attribute.
• lazy: Defer loading of the resource until it reaches a calculated distance from the viewport.
• eager: Load the resource immediately, regardless of where itβs located on the page.

## Credits

• Jekyll - A blog-aware static site generator in Ruby.
• MultiMarkdown - Lightweight markup processor to produce HTML, LaTeX, and more.
• markdown-it-multimd-table - Multimarkdown table syntax plugin for markdown-it markdown parser.
• jmoji - GitHub-flavored emoji plugin for Jekyll.
• jekyll-target-blank - Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
• mermaid - Generation of diagram and flowchart from text in a similar manner as markdown.

## Contributing

Issues and Pull Requests are greatly appreciated. If you've never contributed to an open source project before I'm more than happy to walk you through how to create a pull request.

You can start by opening an issue describing the problem that you're looking to resolve and we'll go from there.

Author: jeffreytse
Source Code: https://github.com/jeffreytse/jekyll-spaceship

1599854400

## What's new in the go 1.15

Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.

As Go promise for maintaining backward compatibility. After upgrading to the latest Go 1.15 version, almost all existing Golang applications or programs continue to compile and run as older Golang version.

#go #golang #go 1.15 #go features #go improvement #go package #go new features

1620729846

## Why Use WordPress? What Can You Do With WordPress?

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.
What Is The Use Of WordPress?

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is β everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Letβs start knowing them:

1. Multiple Websites Under A Single Installation
WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.
It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

2. WordPress Social Network
WordPress can be used for high-end projects such as Social Media Network. If you donβt have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.
To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.
If BuddyPress doesnβt meet all your needs, donβt give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

3. Create A Forum For Your Brandβs Community
Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page β the good old WordPress is still the best.
It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesnβt hamper the experience of the website.
Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

4. Shortcodes
Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.
There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

5. Build Online Stores
If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.
WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you donβt have to pay for the license.
Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

6. Security Features
WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.
By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.