teleren/devto huggingface dataset:
PizzaTimer: Starting the project
Tags: devjournal, pizzatimer, reactnative
Published: 2019-10-23 08:09:32

---
title: PizzaTimer: Starting the project
published: true
description: I started a new project to learn to build a mobile app with React Native.
tags: [devjournal, pizzatimer, React native]
---

I wanted to learn to write mobile applications and decided to look into React Native. I also think that I eat pizza too often and decided to write an app that tells me how long it has been since I ate pizza. Or rather, when I can eat pizza again. (I'm thinking of trying to limit it once a week.) 

Getting first React native project created was easy following the instructions, but then I run into a snag. I like TDD and wanted to setup
mocha for unit tests. Unfortunately there has been recent changes in both [mocha](https://github.com/mochajs/mocha/wiki/compilers-deprecation) and [babel](https://babeljs.io/docs/en/env/). None of the instructions seemed to work. Finally, I decided that I don't know enough modern JS development with ES2015 style imports and transpilers and gave up. I was going to look into Flutter next but never got around to it.

That is the problem with instructions that just explain what you should do without telling why. If things don't work you have no idea what you did wrong or how to start debugging your configuration.

Yesterday I looked at my code again and found the babel link above. I replaced 'babel-preset-es2015' with 'babel-preset-env' and run mocha with '--require @babel/register' and things worked! 

Code is available at [GitHub](https://github.com/jautero/react-apps). (I  would use Liquid tag, but it doesn't support repositories that don't have ReadMe.)
No experience, no job!
Tags: job, opensource, beginners, career
Published: 2019-10-23 07:52:47

In job applications the applicants are often asked about their work-experience. But how do you gain work-experience in the first place? In a many professions you need somebody to employ you WITHOUT any experience so that you can gain some. Trying to get this first chance might be really tiring and frustrating.

But the good news is: if you want to become a programmer its much easier, you can gain experience even BEFORE you get your first job!

There are thousands of open source projects around you can engage with. Simply choose one that is written in the programming language that you want to learn or know and participate in open source development.

Here are just a few examples:

- ownCloud - cloud storage (written in PHP / JS) https://owncloud.org/community/

- Joomla - CMS (written in PHP / JS) https://developer.joomla.org/

- GIMP image editor (Written in C, GTK+) https://www.gimp.org/develop/

- LibreOffice Office Suite (Written in C++, Java, and Python) https://www.libreoffice.org/community/get-involved/

- etc.

Just pick your favoured project and get involved! As an easy starting point you can:

- look through the documentation and improve it

- translate the project into your language

- test new versions and file bug reports

- work on easy-to-fix issues e.g. LibreOffice "Easy Hacks": https://wiki.documentfoundation.org/Development/EasyHacks

- ownCloud "junior jobs": https://github.com/owncloud/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22junior+job%22

Here a good practical article how to start contributing: [Demystifying Open Source Contributions](https://dev.to/wassimchegham/demystifying-open-source-contributions-1moi)

So get started! Make mistakes, get corrected and gain some real world work-experience! And make sure to list your activities for the next job application.

BTW. by writing open source software you will also do a great service to society.
Uncovering tiny little magic in Rails
Tags: ruby, rails, activerecord
Published: 2019-10-23 07:42:14

---
title: Uncovering tiny little magic in Rails
published: true
description: 
tags: ruby, ruby on rails, activerecord
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bzl8cye01xs9x29rg4s3.jpeg
---

Recently I got really curious with one of the magical things in Ruby on Rails framework. Let's take a look at the following code:

```ruby
class User < ActiveRecord::Base
  validates_presence_of :name
end
```

As a Rails developer, we understand that `validates_presence_of :name` helps us to easily perform a modal validation to ensure that the name attribute must be present. BUT wait a minute.. where does this come from? 

The beauty of Rails is that the framework provides a bunch of methods we could conveniently use out-of-the-box to perform difficult things easily. Back to our example, we can find this magical method `validates_presence_of` being defined inside the `rails` [sourcecode](https://github.com/rails/rails/blob/d87a0c6a206cecefac25c96e707e8cd1ad97cd5d/activemodel/lib/active_model/validations/presence.rb#L34). This magic is just another class method. 

You may be curious on how did I manage to find the method in the source code. A good starting point to look at the rails sourcecode would be under activerecord since our model inherits from `ActiveRecord::Base`.     

This is quite a common pattern in the Rails world. Some other examples would be `has_many`, [acts-as-taggable](https://github.com/mbleigh/acts-as-taggable-on), [has_paper_trail](https://github.com/paper-trail-gem/paper_trail) and etc.

You can easily implement this pattern in your project. All you have to do is to define a class method in your parent class. You sub class will be able to use the method right away. Below is a simple code sample to demonstrate on how you can write it yourself.

```ruby
class Employee
  def self.onboarding_pack(department)
    # Insert any complex logic here. For simplicity, this sample only prints a sentence. 
    puts "Onboarding pack for #{department} employees"
  end
end

class Developer < Employee
  onboarding_pack "Developer"
end

class Clerk < Employee
  onboarding_pack "General"
end

puts Developer.new # Onboarding pack for Developer employees
puts Clerk.new # Onboarding pack for General employees

```

## Takeaway

Alot of convenient things (methods, generators and etc) provided by Rails will seem like magic on the surface. If we stay curious and take a dive into the rails sourcecode, you will be able to uncover its magic.
Paket wisata jogja
Tags: wisata, travel
Published: 2019-10-23 07:33:00

Anda dapat menghindari kerumunan besar turis dengan mengunjungi Yunani pada bulan Mei. Habiskan hari-hari Anda di pulau dengan naik perahu kecil, atau berjemur di bawah sinar matahari dan budaya setempat di Mykonos. Either way, Anda dapat mengandalkan suhu tinggi dan kemungkinan hujan rendah di Yunani sepanjang tahun ini. https://www.kartanesia.com/
Scarica suonerie per telefoni cellulari gratis | SuonerieTelefono.com
Published: 2019-10-23 07:14:57

Fornisce le suonerie più recenti relative a  iphone, whatsapp, samsung, huawei,  Marimba Remix, Suono, SMS, Animali, Sveglia 

Qui:https://suonerietelefono.com/

#suonerie #suonerie_telefono #suonerie_gratis #rintone
About privileges, genders and races
Tags: discuss, gender, privilege, race
Published: 2019-10-23 07:13:56

---
title: About privileges, genders and races
published: true
description: Where to start if I want to educate myself?
tags: discuss, gender, privilege, race
cover_image: https://thepracticaldev.s3.amazonaws.com/i/5bi0ywsbi8bs90boudmw.jpeg
---

## Eye opening

When I started my career in programming 3 years ago, I *felt* like I was honest enough to realize I had a lot of privileges. It felt pretty clear to me that some people coming from different backgrounds, genders, socio-economics classes and/or religions would have less opportunities and less chances than me.

That was before I started to gravitate around the programming world. Even if I felt aware of the situations, I was never in direct contact with people's experiences. Reading about it quickly made me realize I actually didn't really understand all those things. Some of the comments people gave to those experiences, things I could have said honestly, were finally completely detached from those people's reality, and only reflecting their realities, which where close to mine as a white man.

So, I started to follow more people with that kind of experiences. I'm trying to read more content from people that had a different background. Whenever I respond to anyone, I check if my answer is appropriate. It takes time, and sometimes you take some slaps in the face, but I feel like it's a necessary work to do. It goes beyond the realm of programming. 

So, I wish to continue this path of learning. Could you recommend any material that would be a good start? Material that would educate me on the realities of privileges in our world? And how myself, a white dude, might help out in some situations (if any)?


I'm more into books, but if you have some recommendations on people to follow or blogs to read or anything else, I'll happily take it.

Thank you. :heart:
🔑 Self-signed SSL certificate in Tomcat
Tags: devops, opensource
Published: 2019-10-23 06:31:06

Self-signed SSL certificate and add into Java truststore.

**Step 1:**

*Generate the SSL certificate by running the following command*

`$ keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks -validity 365 -keysize 2048`

- The number of days that indicates 365 is for which the certificate will be valid.
- The selfsigned.jks is the key store file.
- The aforementioned command exports the certificate that alias is tomcat.

**By default, the key store password is set to changeit; you can use the keytool utility -storepasswd option to change it to something more secure.**

**Step 2:**

*The aforementioned command has some default sets, and also prompts the developer to enter additional information as shown below:*

```bash
What is your first and last name?
  [Unknown]:  localhost
What is the name of your organizational unit?
  [Unknown]:  Open DevOps
What is the name of your organization?
  [Unknown]:  opendevops.dev
What is the name of your City or Locality?
  [Unknown]:  Athens
What is the name of your State or Province?
  [Unknown]:  Attiki
What is the two-letter country code for this unit?
  [Unknown]:  GR
Is CN=localhost, OU=Profile Software, O=profilesw.com, L=Athens, ST=Greece, C=GR correct?
  [no]:  yes
```

**Step 4:**

*Verify the contents of keystore by running the given command*

`$ keytool -list -v -keystore selfsigned.jks`

- The keytool utility -list option lists the contents of a specified key store file.
- The -v option tells the keytool utility to display certificate fingerprints in human-readable form.

**Step 5:**

*Import the certificate into your application’s trust store. The keytool utility -import option installs a certificate from a certificate file in a specified trust store.*

`$ keytool -import -noprompt -trustcacerts -alias tomcat -file selfsigned.cer -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit`

**Step 6:**

*The certificate is already completed and can be used by Apache Tomcat server container by using the following configuration*

```xml
<Connector port="8080" protocol="HTTP/1.1"
           redirectPort="443"
           disableUploadTimeout="false"/>
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           keystoreFile="selfsigned.jks" keystorePass="<password>"
           clientAuth="false" acceptCount="100"/>
```

**Step 7:**

SSL port of the current instance is already for connection in `https://localhost:443/`.

https://www.opendevops.dev/self-signed-ssl-certificate-in-tomcat/
🔨Setup Maven on Windows
Tags: devops
Published: 2019-10-23 06:29:41

The developer always wants to install Maven on Windows as first step in order to make a Maven project on the preferred IDE such as IntelliJ IDEA, Eclipse or NetBeans IDE. The following steps are described below:

**Step 1:**

*Setup JDK and JAVA_HOME*

Make sure **JDK** is installed properly in the operating system and **JAVA_HOME** variable is added as Windows environment variable.

**Step 2:**

*Download Apache Maven*

Go to official website: **https://maven.apache.org/download.cgi**

Download *Binary zip archive* from the aforementioned website and ensure that system requirements are properly configured such as JDK, free disk space and operating system.

Unzip the folder to `C:\Program Files\Apache\maven`

**Step 3:**

*Setup M2_HOME and MAVEN_HOME*

Add both `M2_HOME` and `MAVEN_HOME` variables in the Windows environment and point it to the maven directory.

*Note: M2_HOME or MAVEN_HOME. Maven document said add M2_HOME only, but some programs still reference Maven folder with MAVEN_HOME, so it's safer to add both.* 

**Step 4:**

*Add to PATH*

Update `PATH` variable, append Maven bin folder `%M2_HOME%\bin`, so that you can run the Maven command everywhere.

**Step 5:**

*Verification*

To verify maven if it works properly, try and run `mvn -version` command in the CMD of Windows.
🛠 Stop WildFly Application Server
Tags: devops
Published: 2019-10-23 06:28:21

DevOps engineers usually want to stop the WildFly application server if the process is running in the background. To keep it simple on Windows, here are two steps to do it.

Step 1: Find address and process

Enter the following command to find the process that is listening and running to port number 8080.

```
netstat -a -n -o | findstr :8080
```

The command line argument prints an open connection that is listening on the console as show below.

```
TCP   127.0.0.1:8080   0.0.0.0:0   LISTENING   9332
```

Step 2: Kill the process

Kill the process ID by using the following command.

```
taskkill.exe /F /pid 9332
```
🛠 Increase heap memory on WildFly
Tags: devops, wildfly
Published: 2019-10-23 06:22:33

WildFly application servers gives us the opportunity to increase heap memory for faster results on our web applications that we are running locally on development environment. There is only one step as shown below:

**Step 1:**

*In the WildFly installation home directory, we can find the standalone.conf (for Unix based systems) or standalone.conf.bat (for Windows systems) file in the bin folder.*

1.  We can simply open it and update the -Xmx option in the following line (change the number as per the requirement):

```xml
JAVA_OPTS="-Xms64m -Xmx512m ..."
```

**Step 2:**

1.  This will set the heap memory while starting up the server. (We need to restart the server)
🛠 Binding WildFly 18 on all interfaces
Tags: opensource, wildfly, devops
Published: 2019-10-23 06:21:10

When DevOps engineers need to deploy web applications on WildFly 18 run command to binding on all interfaces that is the following command:

```
standalone.bat -b 0.0.0.0
```

The equivalent command line argument to binding **WildFly 18** on all interfaces is described in the following section how to configure it.

Navigate to the following path and go to standalone.xml file:

```
C:\Servers\wildfly-18.0.0.Final\standalone\configuration\standalone.xml
```

In the end of the XML file, you can find the following code snippet:

```xml
<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
    </interface>
    <interface name="public">
        <inet-address value="${jboss.bind.address:127.0.0.1}"/>
    </interface>
</interfaces>
```

Find and replace the public interface with IP address **127.0.0.1** with the following code snippet:

```xml
<interface name="public">  
    <any-address/>
</interface>  
```

Make sure to save the changes and restart WildFly 18 server!
Should you write acceptance tests for bugs?
Tags: softwaretesting, qa, tdd, bdd
Published: 2019-10-23 06:00:42

As a developer or as a QA-engineer you found a bug in a piece of code, and you cannot fix it straight away (maybe its not an urgent one, or you do not have the knowledge or time to fix it), so what do you do? You file an issue-report and hope it will be fixed in a future sprint by someone. So far, so normal, but should you also write a test for it? I would argue yes, you should! Why?

- to make sure the behaviour does not get worse
- to make sure you notice when the bug is fixed accidentally as a side-effect of some other change
- to force the developer who fixes the bug, to look at the tests
- to have an easy and automated way of reproducing the bug
- to be agile and do test-driven-development. Isn’t that what you want? So better start by writing tests!

You can reach this goal by writing a specific type of bug-demonstrating acceptance test. Ideally this test should to be written in a way that they pass now and will fail when the bug is fixed. So we

1. create a (acceptance) test that demonstrates the current behaviour (meaning the behaviour of the bug)
2. also write test-steps that show the expected correct behaviour, but comment them out, so they do not run
3. tag the test with the corresponding issue-number

So when the bug is fixed, the developer is forced to look at the tests, because they fail. Reading through the test-steps she can decide if the commented-out steps are what should happen and what she has implemented.

If everything is fine she will activate the correct steps, delete the bug-demonstrating-steps and un-tag the test. Ideally more tests will be added also.

On the other hand, whoever works on the bug and is aware of the tests can do the test-editing process before starting to fix the bug. So without any extra work the developer has a way to reproduce the bug over and over again just by running the tests. She can proceed with normal TDD, modifying code to make the test pass.

BTW: all the credit for coming up with that system to [Phil Davis](https://www.linkedin.com/in/phillip-davis-53972131)

At [ownCloud](https://owncloud.org/) that process works pretty well. See the [developer manual](https://doc.owncloud.com/server/developer_manual/testing/acceptance-tests.html#writing-scenarios-for-bugs).
What is the rxjs tap function used for?
Tags: rxjs, angular
Published: 2019-10-23 05:59:52

Official documentation state that the tap operator will:
_Perform a side effect for every emission on the source Observable, but return an Observable that is identical to the source._

Lets unpack that statement:  

*__"Perform a side effect for every emission"__*  
This means that everytime your observable delivers a package, your tap will fire.  We kind of expected that.  

*__"return an Observable that is identical to the source"__*  
Now that's interesting.  What this means is no matter what you do in the tap operation, it won't effect the value that gets passed to a subsequent operation.  This is actually quite powerful since we can call methods outside of our ngrx flow.  But in my opinion this could cause more confusion that it's worth.  If I were looking at somebody elses code, I would never expect a tap to perform critical tasks.  What tap is excellent for is debugging.  We can console.log to see how our rxjs function stack is manipulating the data.

For example...
```javascript
this.thingService
      .getThing().pipe(
        tap(object => console.log(object)),
        map(object => object.name),
        tap(name => console.log(name))
      )
      .subscribe(result => {
        ///whatever
      });
```
When getThing() completes and the subscription fires, we will see a console.log of our raw value object.  The map operator then changes the value to pass only the name property.  And the second tap call just outputs the name.  This is very useful when we have more complex rxjs pipelines and we want to see how our values change as they flow through.  Really, really useful when doing switchMaps.

I'm of the opinion that using the tap operator to execute side effects is an anti-pattern.  Happy to hear the opposing view.
Re-export Context Provider
Tags: react
Published: 2019-10-23 03:43:44

Recently I realize I like this pattern a lot, much enough that I'll write a short note on this.

## Problem

When we use React's Context​, we need to first create the context:

```jsx
export const ContextA = React.createContext(null);
```

Then `<Context.Provider />` is normally called elsewhere. We'd probably import the context, grab the named Provider​ inside, and mount that `<Provider />`​ with a value​ that we as a user needs to know. And likely higher in our component tree we have many of these:

```jsx
const App = () => (
  <PlaylistContext.Provider value={mySpotifyPlaylist}>
    <CoffeeContext.Provider value={!!morning ? 'americano' : 'flatwhite'}>
      <WorkspaceContext.Provider value={code}>
        ...now i can start working
      </WorkspaceContext.Provider>
    </CoffeeContext.Provider>
  </PlaylistContext.Provider>
);
```

## Approach

What makes more sense to me is that the developer who works on the Context probably knows all the things about it. Here is something I learned from [Jamie's hook-based Unstated library](https://github.com/jamiebuilds/unstated-next). Instead of exporting the bare bone Context​, we can wrap and re-export the context provider. This allows the author of the context to keep all the logic along the same conceptual object in one place.

```jsx
export const PlaylistContext = React.createContext(null);

export const PlaylistProvider = ({ children }) => {
  // potentially code to create "value"
  const playlist = ['Bach Cello Suite No.1 in G Major, BWV1007'];
  return (
    <PlaylistContext.Provider value={playlist}>
      {children}
    </PlaylistContext.Provider>
  );
};
```

Now in our app root, or anywhere we need to use the context, we no longer need to generate and supply that value elsewhere. We can write very terse context providers like this:

```jsx
const App = () => (
  <PlaylistProvider>
    <CoffeeProvider>
      <WorkspaceProvider>...my day of work</WorkspaceProvider>
    </CoffeeProvider>
  </PlaylistProvider>
);
```

If you are with TypeScript and have complaints around annotating the context value with a potential `null` when creating the context, check out [this solution in React TypeScript Cheatsheet](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet#context).

## Relevant links

- [Jamie's hook-based Unstated library](https://github.com/jamiebuilds/unstated-next)
- [make a `createCtx` and make TypeScript happy with no `defaultValue`](https://github.com/typescript-cheatsheets/react-typescript-cheatsheet#context)