teleren/devto huggingface dataset:
Autostart Desktop Applications
Tags: linux
Published: 2023-01-06 01:12:29

---
title: Autostart Desktop Applications
published: true
date: 2020-11-29 18:45:28 UTC
tags: Linux
canonical_url: https://brandonrozek.com/blog/autostartdesktopapps/
---

The [freedesktop specification](https://specifications.freedesktop.org/autostart-spec/0.5/ar01s02.html) describes how to identify file types, launch applications, and other useful desktop functions. A useful spec I’ve found recently is for launching desktop applications when you log into your machine.

In my Kubuntu 20.10 system, the directory `$HOME/.config/autostart` can contain [`.desktop`](/blog/linuxdesktopicons/) files that describes the applications to start on login. Drop whichever desktop file you wish to start there. In other systems it may be located under `$XDG_CONFIG_DIRS/autostart`.

If you want to start up a script instead, you can put the script under `$HOME/.config/autostart-scripts`.
Getting Started with SVN
Tags: tutorial, git, java, beginners
Published: 2020-11-29 18:42:18

SVN is an SCM(Source Code Management) tool developed by the Apache Software Foundation. It is one of the less popular but still widely used Source Code Management tool.

## Installation
To check the version of Subversion run the following command
`svn --version`

If SVN client is not installed on your machine, you will get back an error, otherwise, the command will return the version number.
```
$ svn --version
bash: svn: command not found
```
If you get back an error, SVN is not installed on your system and you need to run the following commands to install Subversion.

If you are using RPM-based GNU/Linux, the default package manager is yum package manager. So you will have to run the following command.
```
$ sudo yum install subversion
```

In the case of Debian-based GNU/Linux, the default package manager is apt package manager. So to install Subversion, run the following command
```
$ sudo apt-get install subversion
```

## Workflow
### Checking out a repository
`svn checkout <svn-repo-url> <folder-name>`

Now you can cd into the svn directory and copy your project files and folders inside the directory.

### Adding files or folders to SVN
`svn add filename`
`svn add foldername`

### Checking in code to the server
`svn commit -m "Commit Message"`

## Conclusion
Now you are ready to get started with SVN and use it as an SCM in your projects.
Use a particular column as a foreign key in rails
Tags: rails, database, beginners
Published: 2020-11-29 18:41:44

In rails, to add a foreign key, we usually do
```
rails generate migration AddReferenceToXX mm:references
```
what this does is that it adds a foreign key to the `XX` table, and uses the `mm` model's attribute `id` as the referenced column. However, this `id` is not what we'd always want to use as a foreign key, what if we want to use some other column as a foreign key, let's say the column `email`? In this article, we're going to learn exactly that thing.

Suppose we have two models named `GmailInbox` and `GmailThread`, their relationship being that `GmailInbox` has many `GmailThread`s and a `GmailThread` belongs to only one `GmailInbox`, so it's a One-to-Many relationship.

We need a way to connect the `GmailThread` to a `GmailInbox` based on the email (because a Gmail account is identified based on the email)
`GmailInbox`: id, email
where `email` attribute will have a uniqueness constraint (i.e no duplicates allowed in this column since it is going to be a referenced column for a foreign key).
`GmailThread`: id, thread_id, inbox_email
we will use `inbox_email` attribute as a foreign key to refer to the Gmail inbox it belongs to.

Firstly, we will generate a migration, using
```
rails generate migration add_foreign_key_to_gmail_threads
```
Then we need to add uniqueness constraint on the column of the referenced table, after that, we'll add the foreign key to the gmail_threads table.

our migration file will be
```ruby
def change
  add_index :gmail_inboxes, :email, unique: true
  add_foreign_key :gmail_threads, :gmail_inboxes, column: :inbox_email, primary_key: :email
end
```
the syntax explanation is
```add_index :table_name, :column_name, unique: true```
```add_foreign_key :from_table, :to_table, column: :foreign_key_column, primary_key: :referenced_column```

The last thing we need to do is to put the foreign key information in our models.
```ruby
class GmailThread < ApplicationRecord
  belongs_to :gmail_inbox, foreign_key: 'inbox_email', primary_key: 'email', optional: true
end
```
and do the same in `GmailInbox` model
```ruby
class GmailInbox < ApplicationRecord
  has_many :gmail_threads, foreign_key: 'inbox_email', primary_key: 'email'
end
```
and that's it.
Windows 10: Black & White mode
Tags: todayilearned, windows, blackandwhite
Published: 2020-11-29 18:19:04

Very recently I bought myself, a Google Pixel 4A, a stylish & sleek mobile. I have always been a fan of the Pixel series since its launch. 

A new feature which I found with Pixel 4A is, it allows you to set your sleep & wake up time. During this period, the phone turns to __Do not disturb__ mode and more brilliant, the display turns an eye soothing ___Black & White___ mode. I am in love with this.

Now, since I am a software engineer by profession and passion, I spend quite a lot of my time on my laptop. I own a Dell XPS 7390 :-)
Even though the Windows operating system has _Night Light_ mode, I don't like it much. To me, it does not help much.

So, considering the case above with my Pixel 4A, I just turned curios if Windows 10 also as any such feature. I searched on google and TADAA.. I hit the jackpot (at least for me). Windows 10 has a setting where you can turn color filter on or off.

![Turn color filter on or off](https://dev-to-uploads.s3.amazonaws.com/i/45a6gc8x03u12c4g9230.png)

Hit the _Windows_ key and type "Turn color filter on or off". This takes you to System setting page for color filter. From their, you can turn on the color filter and enable global shortcut toggle key, which is _Ctrl + Win + C_.

![Color filter](https://dev-to-uploads.s3.amazonaws.com/i/saxdjdrf9jp9shyovmvo.png)

With this, you can toggle between color or black & white display mode. __Black & White__ mode to the rescue of night owls.

> Combine this feature with _Night mode_ and the display turns even dimmer.

Thats all folks!!
Make triangles with borders in CSS
Tags: css, codenewbie, webdev, html
Published: 2020-11-29 16:00:46

At first it may seem like making triangles with CSS might be hard...
Well... 
For me it kinda was. but  when you understand how to do it right you'll see it's not hard at all.
So let's begin :
<br>

If we create an invisible square with just borders , like this :

```css
.triangle {
    width: 200px;
    height: 200px;
    border-bottom: solid 25px red;
    border-right: solid 25px green;
    border-left: solid 25px blue;
    border-top: solid 25px yellow;
}
```



The results would look like this :
<img src="https://dev-to-uploads.s3.amazonaws.com/i/i78s0dlqbq63aevfuhzr.jpg" alt="triangle">

You see how each border has a sharp point?<br><br>



Now set the height and width to zero :

```css
.triangle {
    width: 0;
    height: 0;
    border-bottom: solid 25px red;
    border-right: solid 25px green;
    border-left: solid 25px blue;
    border-top: solid 25px yellow;
}
```

<img src="https://dev-to-uploads.s3.amazonaws.com/i/es45m8l3evwdnjgbx9hp.jpg">

with setting the height and width to zero we removed the space between borders and the sharp points got sharper ,then all came close together and now it's small square with 4 triangles.  
<hr>

You may ask "okay how do I make just one triangle? I don't need four of them"!

It's easy. we'll make a triangle that its sharp point faces up :

```css 
.triangle { 
    width: 0;
    height: 0;
    border-bottom: rgb(255, 139, 251) solid 200px;
    border-left: transparent solid 200px;
    border-right: transparent solid 200px;
}
```

<img src="https://dev-to-uploads.s3.amazonaws.com/i/8vzamrzwcsdnj6vbbv6g.jpg">

So what happened here?
Since I wanted the sharp point to be at the top I had to give it border-bottom and then border-left and border-right.

<img src="https://dev-to-uploads.s3.amazonaws.com/i/zy3knkw3eiucxa2k41by.jpg">

As you can see we have 3 triangles here, in order to make it just one we have to make the left and right triangles invisible.
And the trick is we have to set them to <b>transparent</b>.

If you want the sharp point to face down you need to give it border-top and set the border-left and border-right to transparent:

```css
.triangle {
    width: 0;
    height: 0;
    border-top: 100px solid rgb(0, 162, 255);
    border-left: 100px solid transparent;
    border-right: 100px solid transparent;
}
```

<img src="https://dev-to-uploads.s3.amazonaws.com/i/4shpe0ybkr4at2z9zsa8.jpg">

<br>
We can even make triangles that face top-left, top-right, bottom-left and bottom-right
<img src="https://dev-to-uploads.s3.amazonaws.com/i/zzdn372w0fy3nc0xsfmb.png">
<br>
<img src="https://dev-to-uploads.s3.amazonaws.com/i/ve2upkatikn1ylsf8eo1.jpg">



<br>

I've prepared a CSS file and live preview. you can check it out <a href="https://github.com/NazaNEYn/Triangles"> <em>HERE</em> </a>





<br><br><br>

You can also check out <a href="https://codepen.io/chriscoyier/pen/lotjh">this cool animation </a> on codepen
Checking the Dimensions of an HTML Element in Vanilla JavaScript
Tags: javascript, html, beginners, css
Published: 2020-11-29 17:34:35


Because of the way that web technologies work, the sizes of things in your web page might not be predictable. This is especially true with modern standards of responsiveness and the multitude of screen shapes necessitating those standards. You might leave you wondering how to get the size of an HTML element using vanilla JavaScript. There are a few different ways to measure this. 

# Full Height and Width

To get the full size of the space an element takes up, we can use `HTMLElement.offsetHeight` and `HTMLElement.offsetWidth`. These properties of an element provide values that include the width of scrollbars, padding, and border.

```javascript
// Grab an element with id target
var element = document.getElementById('target');

// Check its height and width
console.log('h', element.offsetHeight);
console.log('w', element.offsetWidth);
```

Another way to achieve these same measurements is using `getBoundingClientRect()` but that function would not provide accurate readings if transforms were applied to the element in question. It's better to get in the habit of using `offsetHeight` and `offsetWidth` for this because those properties **account for transforms** applied to our element.

# Looking at the Content

Instead of getting the full size of an **element**, we might be interested in looking at the size of its **content**. Here's a method that ignores borders, margins, and scrollbars: `Element.clientHeight` and `Element.clientWidth`. These properties provide the dimensions of an element's content including padding.

```javascript
// Log the height of visible content & padding
console.log('h', element.clientHeight);
// Log the width of visible content & padding
console.log('w', element.clientWidth);
```

We can also look at the size of the content regardless of how much is currently visible onscreen. `Element.scrollHeight` and `Element.scrollWidth` provide the height and width of the content--all of the content, even if scroll bars are in use and not all the content is currently in view.

```javascript
// Log full height of content
console.log('h', element.scrollHeight);
// Log full width of content
console.log('w', element.scrollWidth);
```

# Build Something

These are just some tiny techniques that you might need down the line. Keep them on your toolbelt and use them to build something! For example, you could store an element's height and width in **data attributes** when the document loads, and write **CSS rules** that attenuate to those data attributes to change the style of elements based on size. Another example where this stuff might be useful is **finding the center of an element**; we can get the element's height and width and divide those in half. You'll find little ways to use these techniques the more you practice and learn.
data science courses
Tags: datasciencecourses
Published: 2020-11-29 17:29:55

Global Leaders In Training
ExcelR is a global leader delivering a wide gamut of management and technical training over 40 countries. We are a trusted training delivery partner of 350+ corporate clients and universities across the globe with 140,000+ professionals trained across various courses. With over 25 Franchise partners all over the world, ExcelR helps individuals and organisations by providing courses based on practical knowledge and theoretical concepts. Our industry reputation speaks for itself. We offer the best value in training services combined with the support of our creative minds to establish a solution that suits your learning needs. We help in building careers and shaping up the future leaders.
Click here to know more details about data science courses
https://www.excelr.com/data-science-course-training
PHP - Create your own dotenv to loads environment variables from .env file
Tags: php, mysql, tutorial, laravel
Published: 2020-11-29 17:29:28

# Loads environment variables from .env file to getenv(), $_ENV and $_SERVER.

**Now we create a file named .env**
```
APP_ENV=dev
DATABASE_DNS=mysql:host=localhost;dbname=test;
DATABASE_USER=root
DATABASE_PASSWORD=root
```
Let's create the class that will parse .env file.
```php
<?php

namespace DevCoder;

class DotEnv
{
    /**
     * The directory where the .env file can be located.
     *
     * @var string
     */
    protected $path;


    public function __construct(string $path)
    {
        if(!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('%s does not exist', $path));
        }
        $this->path = $path;
    }

    public function load() :void
    {
        if (!is_readable($this->path)) {
            throw new \RuntimeException(sprintf('%s file is not readable', $this->path));
        }

        $lines = file($this->path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        foreach ($lines as $line) {

            if (strpos(trim($line), '#') === 0) {
                continue;
            }

            list($name, $value) = explode('=', $line, 2);
            $name = trim($name);
            $value = trim($value);

            if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
                putenv(sprintf('%s=%s', $name, $value));
                $_ENV[$name] = $value;
                $_SERVER[$name] = $value;
            }
        }
    }
}


```
**How to use ?**
```php
<?php
use DevCoder\DotEnv;

(new DotEnv(__DIR__ . '/.env'))->load();

echo getenv('APP_ENV');
// dev
echo getenv('DATABASE_DNS')
// mysql:host=localhost;dbname=test;
```
Ideal for small project
Simple and easy!
[https://github.com/devcoder-xyz/php-dotenv](https://github.com/devcoder-xyz/php-dotenv)
let's make a Burger API -TOGETHER (video)
Published: 2020-11-29 17:13:37

Hello everyone! In this weeks video I show you how to make your own API and deploy it onto the internet in just a few easy steps.

For those of you who would like to add a burger to my api, please make a pull request here, following the same format as discussed: https://github.com/kubowania/burger-api

For those of you wishing to check out the live API, visit here: https://my-burger-api.herokuapp.com/burgers

If you did like this video, please hit the Like and Subscribe button so I know to make more!

Twitter: https://twitter.com/ania_kubow
YouTube: https://youtube.com/aniakubow
Instagram: https://instagram.com/aniakubow

{% youtube FLnxgSZ0DG4 %}
Fixing a bug in the F# compiler
Tags: fsharp, dotnet
Published: 2020-11-29 16:37:12

A couple weeks ago, a [PR of mine](https://github.com/dotnet/fsharp/pull/10510) was merged into the F# compiler repo, fixing an issue that bothered me with unused `open` statement detection. Even just a few years ago, this would have seemed like a daunting task to me, so this felt like a real achievement.

A great motivator for me was to watch this relaxed, slow-moving presentation from Don Syme (the man himself), fixing a bug in the compiler live. It is filled with useful nuggets of information about the structure of the codebase and coding conventions, and that definitely helped me get around and understand what I was looking at. {% youtube -dKf15xSWPY %}

I then read the available documentation, which is high quality: the [README](https://github.com/dotnet/fsharp/blob/main/README.md), the [DEVGUIDE](https://github.com/dotnet/fsharp/blob/main/DEVGUIDE.md), and the [Compiler Guide](https://fsharp.github.io/fsharp-compiler-docs/). I really appreciate that all this documentation is right there in the repo, it makes it easy to access, consume and update.

Having worked with Github daily for about a year, I had become familiar with the PR process. Nonetheless, one mistake I made was to clone the actual `dotnet/fsharp` repo instead of forking it and then cloning my fork; once I had the fix commited, I was unable to push it as, of course, I don't have the rights on `dotnet/fsharp`. If that happens to you, it's easy to retarget your local repo to your fork with
```git remote set-url origin https://github.com/yourusername/yourfork.git```

Now you'll be able to `git push` your changes as they'll go to your fork.

I made the mistake of trying to debug the F# tools on the currently released Visual Studio. Currently, this requires [Visual Studio Preview](https://visualstudio.microsoft.com/vs/preview/), which can be installed side-by-side.

I also got a [mysterious error trying to run the tests](https://github.com/dotnet/fsharp/pull/10510#issue-524327963) but you can always run the tests directly on the compiled dll with `dotnet test <your test dll>`. I also added `--verbosity detailed` to get the result of each test printed to the console.

Overall, I'm surprised the process was so straightforward for what is a large codebase with a long history. The F# tools definitely need some love, so I hope this helps someone out there trying to improve them.
Flash is gone! We dedicate this book
Published: 2020-11-29 15:55:33

I created so much with Flash and would like to honor its demise (December 2020) with a remake of the classic Flash Book but made with [ZIM](https://zimjs.com).  Here is an example:

https://zimjs.com/cat/book.html

The example book, while being primarily pictures, can be completely interactive inside the pages as well.  You can see some buttons in there but there could be animations, draggable objects, sliders, dials, particle emitters, etc.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oi2ome5m4p2bnt2pi8ib.jpg)

One of the buttons leads to a second book:

https://zimjs.com/darklo - on the famous VR Potter.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/whe7kos8js328gyxdq5g.jpg)

---

Check out the ZIM code - perhaps this will be what gets you started coding in ZIM!  https://zimjs.com/five/book.html We hope so.

```javascript
// The pages in the book can be fully interactive
// but here is an example of just loading images into the book
// note - import ZIM and CreateJS in a script file above
// copy the template from https://zimjs.com/code.html

var path = "covers/"; // the folder with the images
var assets = ["build.jpg", "castle.jpg", "ganymede.jpg", "lastyear.jpg", "martian.jpg"];
const frame = new Frame("fit", 1024, 768, darker, darker, assets, path);
frame.on("ready", () => {
    const stage = frame.stage;

    // get one picture to find the size of the book
    const pic = asset("build.jpg");
    new Book(pic.width*2, pic.height, assets).center();

    stage.update();
}); // end of ready
```
---

{% youtube KBpNEEKbDvY %}

---

{% youtube 8o6b4WifIQ8 %}

---

If you have not checked out the Canvas recently - you simply must!  Here is the [ZIM&nbsp;Dev&nbsp;Site](https://dev.zimjs.com) and some [In-depth&nbsp;Guides](https://drabstract.medium.com/) by Dr&nbsp;Abstract including [Your Guide to Coding Creativity on the Canvas](https://drabstract.medium.com/your-guide-to-coding-creativity-on-the-canvas-ada0996298f6).
Chroot and Virtual Filesystems
Tags: linux
Published: 2023-01-06 01:12:41

---
title: Chroot and Virtual Filesystems
published: true
date: 2020-11-29 15:52:07 UTC
tags: Linux
canonical_url: https://brandonrozek.com/blog/chrootvirtfilesystem/
---

When running applications under a [`chroot`](https://en.wikipedia.org/wiki/Chroot) environment, it can be annoying when certain [virtual filesystems](https://opensource.com/article/19/3/virtual-filesystems-linux) are unavailable. Here are the commands to mount the most common ones:

```
sudo mount -t proc /proc /mnt/root/proc
sudo mount -o bind /sys /mnt/root/sys
sudo mount -o bind /dev /mnt/root/dev

```

Source: [ArchWiki](https://wiki.archlinux.org/index.php/chroot)
Completed Hacktoberfest 2020
Tags: hacktoberfest
Published: 2020-11-29 15:41:43

Thanks to Digital Ocean and Dev community for providing the great opportunity. 

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

<!-- 
### [Intro Heading]
If you are new to the DEV community, introduce yourself and share a bit about why you joined DEV and decided to participate in Hacktoberfest this year.   
Background

 Are you brand new to open source? What about coding in general? Tell us about how you got here →-->
<!-- 
### Progress

 Share a bit about where you’re at in your Hacktoberfest journey. What stage are you at? How has the process been?  -->

<!-- 
### Contributions

 This is where you can list the contributions you made and explain why you chose the projects you did. Don’t forget to add links!  -->


<!-- ### Reflections
Overall, how has your Hacktoberfest 2020 experience been? If you’re a first-timer, will you participate again? What have you learned? Have you made any interesting connections? What is your next step in open source?  -->
Git config based on current (sub)folder
Tags: git
Published: 2021-07-29 19:49:33

---
title: Git config based on current (sub)folder
published: true
date: 2020-11-29 15:00:00 UTC
tags: git
canonical_url: https://banach.net.pl/posts/2020/git-config-based-on-current-subfolder/
---

Some time ago I’ve looked over my current company repositories. Surprisingly there was a lot of commits with emails that are not company ones. Instead of those - a lot of _gmail.com_, _outlook.com_and other free email providers!

That looks a bit unprofessional, isn’t it? Even if we do some freelance gigs - we probably want to put nicer email than private one used for social websites. And if, for some reason, we’re forced to use company email - we need to be sure that it will be used!

So, what we can do to make it better? Just configure it with couple lines of code ;-) Let’s assume that all our work-related stuff will live in `~/work` folder and all other is personal. So, let’s start with a simple `~/.gitconfig` configuration:

```
# ~/.gitconfig
[user]
name = Johny Mnemonic
email = johny@mnemonic.tld
[includeIf "gitdir:~/work/"]
path = ~/work/.gitconfig

```

Configuration in _user_ section will be default one. We will overwrite it in other configuration files, like in folders with work.

Let’s then create an additional configuration for work, just in our work folder:

```
# ~/work/.gitconfig
[user]
email = johny@memory.courier.tld

```

We want to put our name in commits, yep? So only one thing that we overwrite will be the email address. Instead of _private_ one, there will be company email.

And that’s it. Now all repositories, that didn’t have set up individual user settings, will use ones that are based on the folder, e.g.:

- `~/work/super-duper` will use work configuration,
- `~/project/my-website` will use private (default) one.

I hope that “short writeup” will help somebody in some way. :-) Also - did you have any comments? Drop me a line on [Twitter](https://twitter.com/elwin013/ "Kamil Banach on Twitter")!