Featured Post

Snake monochrome (JS1024)

JS1024 is an annually held code golfing competition where you're basically required to create something creative in 1024 bytes or less of raw "JavaScript/HTML/WebGL"

I participated for JS1024 2020 competition with my First entry titled "Snake monochrome" Originally inspired by the old Nokia game going by the same name "Snake" which i used to play as far back as 2007-2008

Another entry making it Second is named "Tetris monochrome" i was compiled to do this game as a dare from my Girlfriend on June 6 the "Tetris 1984" anniversary

Third one is F1-racer it's inspired by my bestfriend who wasn't impressed with how i hooked up controls on "Tetris Monochrome" so he requested "i modify controls a bit", and i improved "input/output" by adding smooth touch input to it as requested

Snake game contains two entities. The Snake and the Apple, the Snake is an Object with properties position (vector), velocit…

How to restore PostgreSQL database dump

They'res a magnitude of methods to restore PostgreSQL dumps for a typical plaintext dump "psql" can do a pretty neat Job In few words a PostgreSQL plaintext dump is nothing but a corpus embodied with SQL statements, which when executed tables are created data gets retrieved, inserted and restored.So assuming you have a backup dump saved somewhere on your system open your terminal.And type;psql -U {{username}} < {{dump.sql}}That's it you've imported a database dump

how to dump a postgresql database using from the terminal

PostgreSQL is a relational database management system and arguably the best database management around. postgreSQL comes with utilities used to manipulate databases from the terminal "psql" being the most popular utility I'm sure you've read somewhere or used "psql"dumping "backing" databases is done using PostgreSQL's pg_dump utilityIn your terminal type;
pg_dump <database name> > <output>For instance to backup a database named "books" to a file named "books.sql" do;pg_dump "books" > books.sql
HowtoexcludedatabasedatafrombackupsTo exclude database data from your output file you should include "-s" flag in your commandpg_dump -s "books" > books.sql

Introduction to webshare API (navigator.share)

navigator.share is a JavaScript API providing a sharing interface similar to native apps
webshare API is supported on most updated mobile browsers Including Google chrome for Android
Sharing is done by passing an Object with parameters "url", "text" or "title" to navigator.share function.
For a webshare request to succeed you must supply at lest one of the parameters
navigator.share returns a Promise upon being called "upon
    "url": document.location,
    "text": "I'm an example",
    "title": document.title
.then(resp =>"Successfully shared"))
.catch(errors => console.error(errors))

How to stop moz dotbot from accessing your website

DotBot is Moz's web crawler, it gathers web data for the Moz Link Index
Dotbot obeys robots.txt rules before accessing your host machine so the easiest way to stop dotbot is by adding robots.txt rules that limit dotbot activities
To forbid a directory let's say "login" add;
User-agent: dotbot
Disallow: /login/
Upon reading and parsing directives above moz dotbot won't dare access you sites login sub directory in it's craw routine
To forbid an entire website's access include directives below;
User-agent: dotbot
Disallow: /
Alternatively you can limit crawl rate by adding directives below "time is probably in seconds"
User-agent: dotbot
Crawl-delay: 10
I've attached an nginx log it's a trail left by dotbot along with it's ip and moz support e-mail address; - - [19/Mar/2020:15:16:29 +0000] "GET /index.html HTTP/1.1" 200 13433 "-" "Mozilla/5.0 (compatible; DotBot/1.1; http://www.opensiteexplorer.o…

How to set content disposition header for nginx server to force content download

Nginx (pronounced as engine x) is an HTTP server, reverse proxy server, as well as a mail proxy server
Nginx is well known for its high performance, stability, efficiency, rich feature set, simple configuration, and low resource consumption.
content disposition headers direct web browsers to save content instead of attempting to render it
To set content disposition open your desired server configuration in "/etc/nginx/sites-available/"
within your configuration add code below within your server {block}

location ~* (mp3|ogg|wav)$ {     add_header Content-Disposition "attachment"; }
mp3, ogg and wav are example file extensions matched by regular expressions rules
Test configuration by acessing mp3, ogg and wav files from your webserver
Alternatively you can force custom filenames as shown below "$1" substitutes filenames sent to clients. As an example its value corresponds to the requested file's extension
location ~* (mp3|ogg|wav)$ {     add_header C…

Reasons why you shouldn't consider hosting on github pages

Github pages is a service for deployment of static websites normally software documentation and blogs
Github pages is available on all public github repositories and on premium accounts it extends to private repositories as well.
So what's not to like about it. hmmmm think about it. that's too good to be true It's not a secret that "the only free cheese is served on a mouse trap"
1. "Downtime due to maintenance" Every now and then github pages websites undergo an annoying and imaginary maintenance that causes undesirable user experience especially for professional websites.
2. "Slow deployment"
I've been using github pages to host my static website with less than 10,000 pages deployment process knocked my entire site offline for 10 mins again that's unnecessary downtime sometimes it extended to days
3. "uninvited cloners"
So you put your site out there few days later 50 clones uninvited unwelcome and unnecessary
4. "Limi…

How to set content disposition headers for express nodejs apps

In express nodejs apps you can force the user agent "browser" to rather download content instead of displaying or attempting to render given content within the browser.

In this example assuming you're using express.static to serve content pass an Object as second argument to express.static function

An Object with configuration parameters; const config = {
setHeaders: res => res.set('Content-disposition',  'attachment')

In your code replace "path/to/media/" with the path pointing to the static content.

app.use('/media/', express.static('path/to/media/', config))
To test try accessing content at /media/*

HTML minifier module for Nodejs

HTML minification is a process involving striping off unneeded, abundant or otherwise unused HTML attributes and elements without affecting the webpage appearance.minification is useful for statically genetated 'serverless' web application webpages as it delivers easy to digest minimal webpageshtml-minifier is free and open-source npm nodejs module written in JavaScript for minifying HTML documents, as compared to similar nodejs html minification modules html-minifier proves to be pretty fast, flexible and efficienthtml-minifier module can be used to minify HTML code programmatically or alternatively you can minify HTML code using global commandline moduleNpm module InstallationTo install module in your terminal typenpm i html-minifierTo install commandline version of html-minifier in your terminal type npm i -g html-minifierusage:
html-minifier [options] [files...]options:
Strip HTML comments--remove-empty-attributes
Remove all attributes with whitespace-onl…

Open-graph meta data tags introdution

Open-graph elements are meta tags that contain extra meta data of a webpage open-graph is used by Facebook to create website cards for urls shared on it's platform  cards contain website image thumbnail and as well as title, description, type and url open-graph meta tags have a property attribute containing a property prefixed by "og:"For example;<meta property="og:image"  content="image-url">