From 438c4f2c3340811fac757e62967c4834a8dcd7fa Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 2 Feb 2021 20:13:47 -0300 Subject: [PATCH] Init --- gmi-files/blog/how-to-remain-online.gmi | 149 +++++++++++++++++++++++ gmi-files/blog/index.gmi | 9 ++ gmi-files/blog/jest-vuejs-laravel.gmi | 107 ++++++++++++++++ gmi-files/blog/linux-shell-shortcuts.gmi | 89 ++++++++++++++ gmi-files/blog/partitions-systemd.gmi | 85 +++++++++++++ gmi-files/index.gmi | 27 ++++ md2gemini.sh | 1 + 7 files changed, 467 insertions(+) create mode 100644 gmi-files/blog/how-to-remain-online.gmi create mode 100644 gmi-files/blog/index.gmi create mode 100644 gmi-files/blog/jest-vuejs-laravel.gmi create mode 100644 gmi-files/blog/linux-shell-shortcuts.gmi create mode 100644 gmi-files/blog/partitions-systemd.gmi create mode 100644 gmi-files/index.gmi create mode 100644 md2gemini.sh diff --git a/gmi-files/blog/how-to-remain-online.gmi b/gmi-files/blog/how-to-remain-online.gmi new file mode 100644 index 0000000..f214fe5 --- /dev/null +++ b/gmi-files/blog/how-to-remain-online.gmi @@ -0,0 +1,149 @@ +# How to remain online when the big services crash + +Every now and then a big service as Google, Facebook or Twitter stops working. That is usually a non-productive day. People usually spend the day not being able to work, complaining, checking if the service is already back and trying to find a way to get around it. But it is always a stressful lost day. + +The problem here is the centralization. These services usually work fine, are free and nice/easy to use, so we get used to them up to the point we need them for everything. The client files, your communication with your family, friends, boss, clients, everything depends on them. The problem starts when they are not available for some reason. Maybe the servers had crashed, or your account was banned for any reason. At this time, you notice everything you use/have is not available anymore. To avoid this dependency, we need to decentralize. + +Think about a webpage or an email provider: even if Gmail were down, other providers as Yahoo Mail or Outlook will still be up and running. Even better, if you use a local client as Mozilla Thunderbird or Microsoft Office Outlook you will still be able to access the downloaded emails, even while the webmail is down. The same happens with websites: when one is down, just that one is not working but you still can open other pages. + +When we talk about quick message services, as WhatsApp, Telegram or Signal, things are even worse as once it is down you have no other way to access them. So, how to decentralize? + +### Level 0 - very easy to follow + +* Use Google in a Private tab of your browser: this is not about centralization, but big services usually personalize your search results/suggestions, what directs you into thinking way far in a single direction (maybe even a wrong one!). This can lead to polarization, addiction and/or extremism. + + +* For a general advice, I would suggest DO NOT keep all your eggs in the same basket. While using Google, Gmail, Google Sheets, Google Keep, Google Drive, Hangouts and Google Chrome appears to be easy and simple, if your account were lost, so all your data will be as well. A single block from Google and it is done. No one to complain (have you tried to contact someone there?), no more files, emails, notes, spreadsheets or contacts. You could even lose your bookmarks. But if you use different providers, only a few resources will be lost. + + +* Use an e-mail application. You do not need to move all your emails to it (POP3), instead, you can set it up as a sync (IMAP), so if you mark an email an unread on the program, it will be changed to unread in your webmail as well. + + + +### Level 1 - not that easy, but better + +* Start using another search engine as Qwant, Bing, StartPage, Yahoo, DuckDuckGo interchangeably. You will be used to them and barely notice when one is down. + + +* You probably already use Facebook to contact people, so avoid using a second app of them (yes, I am talking about WhatsApp) and install another option. Now, Signal will do the trick, but there are better options... + + +* If you use Google Chrome, you can give a try in another browser. Vivaldi, Brave, Opera and a lot of others use the same engine from Chrome, so all the pages will load the same way, but you will have a different server to sync your information. + +> If you find that accessing Google Services are slower or Recapcha is asking you more confirmations, try to install an extension that changes your User-Agent (how the browser identifies itself to websites) to Chrome. Tests shows that Google slow things down on purpose to keep you from changing browser, but that will do the trick. +* Have at least one physical backup of everything. Worst case scenario, you can just plug a external storage to your computer and have your data back + + +* Use Jitsi Meet instead of Hangouts or Microsoft Teams + + + +### Level 2 - I don't want to rely on big companies + +Maybe you don't like to be tracked, is afraid of losing all your data or of a crazy government that could gather information about you. Or yet you just enjoy using FOSS (Free and Open-Source Software) programs. So that section is for you: + +* Get rid of Google Search. DuckDuckGo will probably be your first replacement for it, but I also recommend Qwant and SearX (you will need to find someone that hosts it, as https://stuxos.com/meow/). + +=> https://stuxos.com/meow/ https://stuxos.com/meow/ + + +* User a browser that DOES NOT use Chrome engine. Firefox will be probably your first choice, but there are a lot of others as well. You might find something interesting on https://en.wikipedia.org/wiki/Comparison_of_web_browsers. + +=> https://en.wikipedia.org/wiki/Comparison_of_web_browsers https://en.wikipedia.org/wiki/Comparison_of_web_browsers + + +* Use a decentralized/federated messaging program. E-mail is a decentralized service (multiples servers that exchange messages between them), while WhatsApp or Signal are not (you can only send messages to your contacts using their app/servers). There are a few options here as well, but the most used are *XMPP* (ugly clients but easy on resources) or *Matrix* (more beautiful clients but is way heavier). They both has encrypted messages, closed or opened groups (yes, groups that anyone can find/join), amazing audio and video calls etc. The same way as an email service, you will need a host/server (the service itself) and a program to run it on your device. I will write another post about that later. + + +* If you have an Android phone, you will not want to rely on Google Play as they forbid apps that are not interesting for them. Instead, install F-Droid to have access to a long list of FOSS apps that might replace your proprietary ones. + + +* Twitter is not as good as it was before? You prefer to not have an algo and keep the messages in chronological order? Create an account right now on Mastodon. Better yet, it is federated, so you can choose your server based on your preferences. + + +* The harder one to get rid of is YouTube. Google has money enough to keep big servers necessary for that, to pay the content creators and they demand the videos to be exclusive for their platform. But that does not mean you don't have alternatives. Take the chance to know the federated video platform called PeerTube. + + + +### Level 3 - I don't trust anyone + +This is the easier part. Basically, follow every step before but hosting yourself the service. If you don't have a lot of technical knowledge, YunoHost can be a really great friend! + +You can host yourself: + +* Email server (check iRedMail) +* XMPP server (Ejabberd) +* Matrix server +* Video conference (Jitsi Meet) +* Cloud service (NextCloud) +* File transfer (Jirafeau) +* Search engine (Searx) +* Read it later service (Wallabag) +* Mastodon +* PeerTube + +### Important note + +Don't get me wrong, there are way more apps and services than the ones I listed here. I just focused on the ones I've know the best, but with a little search you can find much more. + +## Links + +### Search engines + +* DuckDuckGo: https://duckduckgo.com +* Qwant: https://www.qwant.com +* Searx: https://searx.me +* StartPage: https://www.startpage.com + +### Chat / Videoconference + +* Jitsi Meet: https://meet.jit.si +* Matrix: https://matrix.org +* Signal: https://signal.org +* XMPP: https://xmpp.org + +### Browsers + +* Brave: https://brave.com +* Firefox: https://firefox.com +* Opera: https://www.opera.com +* Vivaldi: https://vivaldi.com + +### Others + +* F-Droid: https://f-droid.org +* Jirefeau: http://www.jirafeau.net +* Mastodon: https://joinmastodon.org +* PeerTube: https://joinpeertube.org +* Thunderbird: https://www.thunderbird.net + +### Servers + +* iRedMail: https://www.iredmail.org +* NextCloud: https://nextcloud.com +* Wallabag: https://www.wallabag.it +* YunoHost: https://yunohost.org + +Photo by Sigmund on Unsplash + +=> https://duckduckgo.com https://duckduckgo.com +=> https://www.qwant.com https://www.qwant.com +=> https://searx.me https://searx.me +=> https://www.startpage.com https://www.startpage.com +=> https://meet.jit.si https://meet.jit.si +=> https://matrix.org https://matrix.org +=> https://signal.org https://signal.org +=> https://xmpp.org https://xmpp.org +=> https://brave.com https://brave.com +=> https://firefox.com https://firefox.com +=> https://www.opera.com https://www.opera.com +=> https://vivaldi.com https://vivaldi.com +=> https://f-droid.org https://f-droid.org +=> http://www.jirafeau.net http://www.jirafeau.net +=> https://joinmastodon.org https://joinmastodon.org +=> https://joinpeertube.org https://joinpeertube.org +=> https://www.thunderbird.net https://www.thunderbird.net +=> https://www.iredmail.org https://www.iredmail.org +=> https://nextcloud.com https://nextcloud.com +=> https://www.wallabag.it https://www.wallabag.it +=> https://yunohost.org https://yunohost.org diff --git a/gmi-files/blog/index.gmi b/gmi-files/blog/index.gmi new file mode 100644 index 0000000..79a7a24 --- /dev/null +++ b/gmi-files/blog/index.gmi @@ -0,0 +1,9 @@ +# Bruno Fontes Blog + +=> how-to-remain-online.gmi How to remain online when the big services crash +=> partitions-systemd.gmi Mounting partitions with systemd +=> linux-shell-shortcuts.gmi Linux Shell Shortcuts +=> jest-vuejs-laravel.gmi Configuring Jest to test your VueJS on Laravel 5.8 + + +=> / Back diff --git a/gmi-files/blog/jest-vuejs-laravel.gmi b/gmi-files/blog/jest-vuejs-laravel.gmi new file mode 100644 index 0000000..e37ae69 --- /dev/null +++ b/gmi-files/blog/jest-vuejs-laravel.gmi @@ -0,0 +1,107 @@ +# Configuring Jest to test your VueJS on Laravel 5.8 + +Jest is one of the most used tools to test JavaScript, but it requires some configuration to work with VueJS on Laravel. So here it goes a very simple and direct way to do that: + +## Configuring... + +1. Install the followgin dependencies, for dev only: @vue/test-utils, babel-core, babel-jest, babel-loader, babel-preset-env, jest and vue-jest: + +``` + $ npm i -D @vue/test-utils babel-core babel-jest babel-loader babel-preset-env jest vue-jest +``` + +> Laravel had already installed a babel version, but I had to install it again in order to keep everything working + + +2. Add the following lines in your package.json file: + + - Inside scripts node: + +``` + "scripts": { + "test": "jest", + "test-watch": "npm run test -- --watch" + } +``` + + - Create the following node: + +``` + "babel": { + "env": { + "test": { + "presets": [ + ["env", {"targets": {"node": "current"}}] + ] + } + } + } +``` + +3. Create a file named jest.config.js on your project root with the following content: + +``` +module.exports = { + verbose: true, + moduleFileExtensions: [ + "js", + "json", + "vue" + ], + transform: { + ".*\\.(vue)$": "vue-jest", + "^.+\\.js$": "/node_modules/babel-jest" + }, + collectCoverage: true, + collectCoverageFrom: [ + "src/components/*.{js,vue}", + "!**/node_modules/**" + ], + coverageReporters: [ + "html", + "text-summary" + ], +} +``` + +## Creating the test... + +Once the dependencies are already installed and configured, you just need to create the tests. Create a new file under resources/js named ExampleComponent.test.js. Let's test the Vue Example Component, that you have already: + +``` +resources/js/ExampleComponent.test.js + +import { mount } from '@vue/test-utils' +import ExampleComponent from './ExampleComponent.vue'; + +describe('ExampleComponent', () => { + test('is a Vue instance', () => { + const wrapper = mount(AttendanceAddress); + expect(wrapper.isVueInstance).toBeTruthy(); + }); +}); +``` + +## Running the test... + +Now go to the console and run: + +``` +npm test +``` + +This will test your component. If you found a lot of errors and is solving them at once, run: + +``` +npm run test-watch +``` + +This command will automatically re-run your tests when the files were changed. +For more info... + +You probably already knows how to use Jest or vue-test-utils, but if you need any help, their sites has the completly description of all asserts. + +=> https://jestjs.io/docs/en/using-matchers Jest +=> https://vue-test-utils.vuejs.org/guides/#common-tips Vue-test-utils + +=> /blog/ Back diff --git a/gmi-files/blog/linux-shell-shortcuts.gmi b/gmi-files/blog/linux-shell-shortcuts.gmi new file mode 100644 index 0000000..544d148 --- /dev/null +++ b/gmi-files/blog/linux-shell-shortcuts.gmi @@ -0,0 +1,89 @@ +# Linux Shell Shortcuts + +I am pretty sure most people who uses Linux knows these, but they are quite handy and it is not the kind of thing I usually see online, so here it goes a small list of shortcuts to be used on your favorite terminal/shell. + +Let's say you were copying a file from a virtual domain to another one, so you type: + +``` +$ cp /var/www/old-website.com/public_html/mail/index.php + /var/www/new-website.com/public_html/mail/index.php +``` + +So you remember that, actually, you want to move the file, not just copy that. On that case, you want to repeat all the parameters but the main command. So you can achieve that with... + + +## The !* shell expansion + +``` +$ mv !* +``` + +This !* will expand into all the parameters of the last command: + +``` +$ mv /var/www/old-website.com/public_html/mail/index.php + /var/www/new-website.com/public_html/mail/index.php + +mv: cannot move '/var/www/old-website.com/public_html/mail/index.php' to +'/var/www/new-website.com/public_html/mail/index.php': Permission denied +``` + +Oops, you do not have permission to that. Now you just want to repeat exactly the same command, but using sudo this time. You can make it really simple again, just using... + +## The !! shell expansion + +``` +$ sudo !! +``` + +This will expand into your last command, as follows: + +``` +$ sudo mv /var/www/old-website.com/public_html/mail/index.php + /var/www/new-website.com/public_html/mail/index.php +``` + +Yes, you finally moved the file into the right place. But it is not over yet. You still need to edit this moved file. Should you type the entire path this time? No! You can reuse just a parameter of your last commando with... + + +## The !$ expansion + +``` +$ sudo vim !$ +``` + +The !$ operator expands to the last parameter of the last command. So it will become: + +``` +$ sudo vim /var/www/new-website.com/public_html/mail/index.php +``` + +## The !: expansion + +Another option is to pick the parameter by it's number. To achieve that, you can use the !:, that will expand into the specified parameter, starting the numbering at 0. + +``` + 0 1 2 +$ sudo mv /var/www/old-website.com/public_html/mail/index.php + 3 + /var/www/new-website.com/public_html/mail/index.php +``` + +So we could have used !:3 instead of the !$ on the last command with the same result. +TL;DR and more... + +There are much more shortcut, expansions etc, but here are a few that I like to use: + +* Ctrl+A - Go to start of command line +* Ctrl+E - Go to end of command line +* Ctrl+x, Ctrl+e - Edit the command line in your text editor- !! - Last command +* !^ - First argument of last command +* !$ - Last argument of last command +* !* - All arguments of last command +* ! - last command line of that command +* !: - argument of last command +* !: - argument of the +* ^foo^bar - Repeat last command replacing foo with bar +* {1..10} - Expand to 1 2 3 4 5 6 7 8 9 10 + +=> /blog/ Back diff --git a/gmi-files/blog/partitions-systemd.gmi b/gmi-files/blog/partitions-systemd.gmi new file mode 100644 index 0000000..43df0bc --- /dev/null +++ b/gmi-files/blog/partitions-systemd.gmi @@ -0,0 +1,85 @@ +# Mounting partitions with systemd + +I had a problem: every time my Windows have a big update, it locks a specific partition that I use to share files between Windows and Linux. After the update, I wasn't able to boot Linux again, as fstab could not mount it. + +To avoid using a pen drive or booting any other way just to get my Linux working again, I removed the partition from fstab. + +It worked, but I didn't want to manually mount it on every boot. Worst than that: Dropbox app synchronize on that partition. It means that on every single boot it raised an error message that my files were moved. It was definitely not a good way to solve it. + +My new solution: create a script to mount the partition and run it at boot. Any error here would not stop my Linux from booting and I would still have it working by the time I logged in after boot. But, where is the best place to run a root script at startup? Of course, systemd! A simple service running a script should do the trick. + +Well, with a simple search I found out something even better: systemd can mount partitions using systemd.mount! + + +## How to mount a partition with systemd + +To keep it simple, I am going to explain, step by step, the basic usage of systemd.mount with only the options I used myself. + +1. Create a .mount file on /etc/systemd/system/ (I will get back at this point later, for now, just use any name for the file) + +2. Inside the file you should specify the following attributes: + +* Description= A description of your mount script +* What= The partition that will be mounted +* Where= Directory where the partition will be mounted +* Type= The partition file type (ext4, ntfs, fat32 etc) +* Options= Mount options +* WantedBy= or RequiredBy= Unit dependencies. It's used by the enable and disable commands of the systemctl + +3. Now comes the tricky part: you have to name your .mount file accordingly with your Where= statement. So to mount it on /run/media/bruno/Multimedia you have to name it run-media-bruno-Multimedia.mount + +4. It's time to test it: + +``` + $ systemctl daemon-reload + $ systemctl start run-media-bruno-Multimedia.mount +``` + + To check the unit status, you can run systemctl status run-media-bruno-Multimedia.mount + + If everything is working fine, just enable it: systemctl enable run-media-bruno-Multimedia.mount and you are good to go. + + +## My mount script + +``` +/etc/systemd/system/run-media-bruno-Multimedia.mount + + [Unit] + Description=Mount Multimedia out of fstab + + [Mount] + What=/dev/disk/by-label/Multimedia + Where=/run/media/bruno/Multimedia + Type=ntfs + Options=defaults + + [Install] + WantedBy=multi-user.target +``` + + +## Explaining the attributes + +### Description= +Just a description of you .mount script. + +### What= +The partition itself. You can specify it by name, path or UUID. + +Examples: + +* /dev/sdb2 +* /dev/disk/by-label/Multimedia +* /dev/disk/by-uuid/bcebcc2e-3a07-48d8-bd3c-e4eaf98fafc5 + +### Type= +The easiest one after description: the file type of the partition. If you are trying to mount a Windows partition, it will probably be ntfs. If it is a Linux partition, it will probably be ext4. + +### Options= +Partition options, the same used on fstab. + +### WantedBy= +I used multi-user.target to start in multi-user runlevel. + +=> /blog/ Back diff --git a/gmi-files/index.gmi b/gmi-files/index.gmi new file mode 100644 index 0000000..0b1d473 --- /dev/null +++ b/gmi-files/index.gmi @@ -0,0 +1,27 @@ +``` + + ____ _____ _ +| __ ) _ __ _ _ _ __ ___ | ___|__ _ __ | |_ ___ ___ +| _ \| '__| | | | '_ \ / _ \ | |_ / _ \| '_ \| __/ _ \/ __| +| |_) | | | |_| | | | | (_) | | _| (_) | | | | || __/\__ \ +|____/|_| \__,_|_| |_|\___/ |_| \___/|_| |_|\__\___||___/ + +-------------------------------------------------------------- + +``` + +# Welcome! + +Welcome to my small and humble gemini server. :) + +My name is Bruno F. Fontes, and I am a developer, sysadmin (of my own servers only), localization engineer and Project Manager. + +At the moment, I am using this space as a copy of my personal blog: +=> blog/index.gmi Blog + +You can also see this blog as a regular webpage, as well as my personal websites as follows: +=> https://brunofontes.net +=> https://dicionarios.cc + +Other interesting links: +=> gemini://gus.guru/ GUS - Gemini Universal Search diff --git a/md2gemini.sh b/md2gemini.sh new file mode 100644 index 0000000..926f3cf --- /dev/null +++ b/md2gemini.sh @@ -0,0 +1 @@ +md2gemini -l copy -w -p -s