teleren/devto huggingface dataset:
Cookie Expiry Pitfalls
Tags: webdev, todayisearched, beginners, security
Published: 2019-07-24 14:05:39


I just stumbled upon some browser behavior regarding cookies that seemed very strange to me but turned out to be actually pretty obvious and well documented.
I thought I'd share what I've learned just in case some of you might not have come across this either.


## Session Cookie Expiry

This one should be pretty straight forward, right? Omitting the `Expires` property will result in a cookie that is deleted when a user ends the session, i.e. closes the browser. 
Except, as [MDN will inform you](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie), if the user has set their browser to restore the previous session when closing.

![A screenshot of the Firefox settings startpage showing the checked option 'Restore previous session'](https://thepracticaldev.s3.amazonaws.com/i/4xxeayfb9s1gcce6dqu7.png)

If you are like me and carry around 100+ open tabs at all times, chances are you'll have this setting activated. 

Chrome also has this feature of course. 

While this is nothing new, it had never manifested itself as a problem for me until now...and it's easy to forget about when conceptualizing cookie use. So be warned.

## 👻 Timezones 👻

So you set an expiry date on your cookie, hm? Would be a shame if you didn't think about the possible discrepancies between your server's timezone and the browser using your site 😈
Again, as [MDN explains](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie):
> When an expiry date is set, the time and date set is relative to the client the cookie is being set on, not the server.

This is fairly obvious when you think about it but something that is easily missed when thinking about setting cookies.

-----

So there you have it. Two small details about setting cookies on server responses that could easily be missed and could lead to data being stored on a client for much longer than you intended.  

Additionally this can become a fun source of obscure bugs that will manifest themselves with some classic "works on my machine 🤷" behavior in the future.


Happy coding! :)
To do or not to do, whats more good of a practice.
Tags: discuss, php, laravel, mysql
Published: 2019-07-24 14:02:52

---
title: To do or not to do, whats more good of a practice.
published: true
description: What's more good of a practice.
tags: discuss, php, laravel, mysql
---

Considering a hypothetical situation, in which a user makes a request to admin for a change in his profile which only admin can edit.

After processing the request, in either case, acceptance as well as denial. what's more good of a practice. To keep it in DB with a status tag, that says whats happened to the request. Or informing the user about is through mail or something and delete the request.

exp. developers of the community please share your wisdom to this young apprentice.
Startup Bus 2019 starting off!
Tags: hackathon, startup, javascript, kotlin
Published: 2019-07-24 13:54:48

---
title: Startup Bus 2019 starting off!
published: true
description: Wale Ogundipe is about to jump on the Startup Bus to New Orleans. He muses about 1) where his bus will be stopping along the way and 2) which technologies to use to make hackathon prototypes rapidly.
tags: hackathon, startup, javascript, kotlin
---

### On your marks!

In under 2 minutes, I'll be joining folks from all around North America on the [Startup Bus](https://startupbus.com/2019), a competition where teams assemble to create businesses on a bus over the course of 3 days en route to New Orleans. It'll be rigorous. I suppose calling it *_the_* Startup Bus is a bit of a misnomer: 7 buses from all across North America are converging on New Orleans. In any case, that's a nitpick not worth delving into.

Indeed, the buses are heading to New Orleans, but how are they getting there? There are 6 different origin sites: 
1. San Mateo, CA 
2. Mexico City, MX, 
3. Akron, OH 
4. Tampa, FL 
5. Washington, DC
6. New York, NY (2 buses from here)

I'll be coming from DC, so my bus ride will probably entail a tour of the South!

What might that look like? Glad that you asked! To prepare for the competition, I've put in some research. Based on my prep, here are the most likely itineraries for my bus:
- DC-Richmond-Raleigh/Durham-Charlotte-Atlanta-Chattanooga-New Orleans
- DC-Richmond-Raleigh/Durham-Charlotte-Atlanta-Chattanooga-Nashville-Birmingham-Biloxi-New Orleans
- DC-Pittsburgh-Cincinnati-Louisville-Nashville-Memphis-Jackson-New Orleans
- DC-Pittsburgh-Cincinnati-Louisville-Nashville-Huntsville-Birmingham-Biloxi-New Orleans
- DC-Pittsburgh-Cincinnati-Louisville-St. Louis-Memphis-Jackson-New Orleans
- DC-Louisville-Nashville-Chattanooga-Atlanta-Birmingham-Biloxi-New Orleans
- DC-Richmond-Raleigh/Durham-Charlotte-Jacksonville-Biloxi-New Orleans
- DC-Pittsburgh-Charlotte-Atlanta-Mobile-Biloxi-New Orleans
- DC-Akron-Charlotte-Atlanta-Mobile-Biloxi-New Orleans
- DC-Pittsburgh-Louisville-St. Louis-Memphis-Jackson-New Orleans

Do you have a guess? Put it in the comments section of this post!

### Get Set!

Even aside from guessing itineraries, preparation is the name of the game. The bus might not have the the most reliable wifi, so I had to download pertinent software libraries to my computer. Here are a few of the libraries, frameworks, tools, and documentation that I downloaded:
- [Android Studio](https://developer.android.com/studio) - for creating mobile interactions in Kotlin (Java too, but I'm teaching myself Kotlin now)
- [React Native](http://reactnative.com) - for creating more mobile interactions, but in Javascript, my strongest programming language
- [Hackathon Starter Kit](https://github.com/sahat/hackathon-starter) - the most reliable template library for node.js-based hackathoning
- [Framer.js](https://github.com/koenbok/Framer) (the open source part of Framer X) - great for simulating mobile interactions

### Go!

And we're off to the race! I'll post intermittently to let you know how things are progressing. :-)
Fetch Api: Ajax sem jQuery
Tags: javascript, ajax, jquery, fetch
Published: 2019-07-24 13:38:48

Você conhece a **FETCH API**? Você sabia que dá pra fazer requisições AJAX de uma forma simples sem usar bibliotecas externas? Você sabia que não precisa mais escrever aquele XMLHttpRequest? 
Você vai aprender a usar a FETCH API nesse Video! 

[https://www.youtube.com/watch?v=v9JVA6tVmcg](https://www.youtube.com/watch?v=v9JVA6tVmcg)
Dev Setups: I'll show you mine if you show me yours!
Tags: webdev, setups, software, apps
Published: 2019-07-24 13:28:40

---
title: Dev Setups: I'll show you mine if you show me yours!
published: true
description: Article about developer setups/software/apps
tags: Web development, setups, software, apps
---

This is my very first post here on Dev.to. Since I am a newbie-ish developer, I'm always interested in what other developers' setups/tools are and the workflows they use. I am currently enrolled in a full stack development bootcamp, [DigitalCrafts](https://www.digitalcrafts.com), so I quite often find useful new tools and apps by looking at what other developers are using. With that being said, I'm sharing my list! Of note, I use a Mac, and almost all of my apps were installed via Homebrew. If the apps weren't available via Homebrew, I used the standard Mac installation method. Please feel free to share your setups in the comments.

####Development tools:

- [Visual Studio Code](https://code.visualstudio.com)
- [iTerm 2](https://www.iterm2.com)
- [zsh](http://zsh.sourceforge.net/)
- [Homebrew](https://brew.sh/)
- [Oh My Zsh!](https://ohmyz.sh/)
- [Git](https://git-scm.com/)
- [Nodejs](https://nodejs.org/en/about/)
- [Postman](https://www.getpostman.com/)
- [Chrome](https://www.google.com/chrome/) for DevTools
- I also use Safari and Firefox for testing
- [Sequel Pro](https://www.sequelpro.com/)
- [Cyberduck](https://cyberduck.io/)

####Administrative tools:

- [Fantastical 2](https://flexibits.com/fantastical)
- [Spark](https://sparkmailapp.com/)
- [Spectacle](https://www.spectacleapp.com/)
- [Alfred](https://www.alfredapp.com/) with Powerpack
- [CopyClip](https://fiplab.com/apps/copyclip-for-mac)
- [Amphetamine](https://apps.apple.com/us/app/amphetamine/id937984704?mt=12)
- [AppCleaner](https://freemacsoft.net/appcleaner/)
- [KeyboardCleanTool](https://folivora.ai/keyboardcleantool)
- [Cheatsheet](https://www.mediaatelier.com/CheatSheet/)
- [Vanilla](https://matthewpalmer.net/vanilla/) for menubar maintenance
- [Rocket](https://matthewpalmer.net/rocket/) for emojis
- [LastPass](https://www.lastpass.com/hp)
- [Google Drive Backup & Sync](https://www.google.com/drive/download/backup-and-sync/)

####Miscellaneous tools:

- [Slack](https://slack.com/)
- [Microsoft OneNote](https://www.onenote.com/download)
- [Notion](https://notion.so)
- [Spotify](https://spotify.com)
- [PDF Expert](https://pdfexpert.com/)

And that's the end of it! I hope to be learning MongoDB in the very near future, so I will be adding that to my toolbox soon. I have installed 'Fira Code' fonts for both Visual Studio Code and iTerm, and I also use various themes for both apps as well. Right now, my VS Code theme is Cameo One Dark, but I change themes often depending on my mood.

So, now that I've shown you mine, you have to show me yours!
How do you do API versioning?
Tags: healthydebate, discuss
Published: 2019-07-24 13:19:08

Recently been thinking how to do API versionings, and realised there's multiple ways of doing things. I do not think there's only *one right way* , but I am really curious to hear what you people have to add!

There's mainly a couple of questions I'm wondering (I wish dev.to has the polls features out already!)

- Do you prefix the version to the resource, or suffix it to the resource? e.g: `/v1/users/` or `/users/v1/`?
- When you have a breaking change for a specific action (`POST /users` now take different params), do you bump the whole `/users` version, or do you bump that specific `POST /users` action?
- Where do you keep the serializers? in the same folder, or different?
- APIs are usually backed up by business logics, in some cases being called Service Objects in Rubyland — do you guys also bump your Services when your API is updated?

For more concrete example, let's say you have an API to reset password for user, eg: `/v1/users/:id/reset_password`, then for some reason you have a breaking change for `/reset_password`. What do you do now?

- Bump the entire resource to `v2` (e.g: `/v2/users`, `/v2/users/:id`,
  `/v2/users/:id/reset_password`)
- Bump only specific action (e.g: `/v1/users, /v1/users/:id, /v2/users/:id/reset_password`)
- Rethink versioning to scope by action instead (e.g: `/users/v2/:id/reset_password`)

In my opinion, this makes sense to me:

```
api/
 |> users/
     |> v1/
        |> api.rb
        |> serializer.rb
```

Couple of things I'm doing here:

- I suffix the version to resource, not prefix (breaks REST)
- I place serializers and endpoint in the same file

So whenever there's a breaking change in API (e.g: parameter changes), I think it logically makes more sense to bump the whole resource even if it's just one action, reason being as follow:

- **Deprecation** is easier - if you know that `/v1` endpoint is not being used anymore (through your APM), then just delete off the whole folder itself without worrying it'll impact other part of the app. No need to ask questions like: "v1 is still in use *except* for this specific action, for that it'll be in v2"
- **Locality** - I think that inherently serializers are just a way to serialize your data into JSON, and so it should be versioned the same way as your API. By putting them in the same folder, it ensures that you're **more likely to update both of them at the same time**, and it also makes it **much easier for developers to see which API is using which serializer**.



So, what do you guys think/do currently?
Production-friendly Configuration Files in PHP
Tags: php
Published: 2019-07-24 12:58:49

When developing a PHP apps, we often need to keep some configurations saved in constants. In that way, we can access it anywhere in our application.

But, the problem is that we need to have different configurations for development and production (+ may be testing). Here's a simple trick that you can use to do it effectively.

You will need 3 files (Normally I save include files in the `/inc` directory).

* `inc/config.php` - This is the file you are going to include
* `inc/config.server.php` - Production configurations
* `inc/config.dev.php` - Development configurations
* `inc/config.default.php` (Optional) - Default configurations (Common for both production and development)

In `config.php`, first we include the correct config file according to the server name. Make sure you replace the domains with your production and development domains in the following code. Then, we can include the default configurations file.

**config.php**

```php
<?php
if ($_SERVER['SERVER_NAME'] === 'production.com') {
    include_once 'config.server.php';
} else if ($_SERVER['SERVER_NAME'] === 'localdomain.com') {
    include_once 'config.dev.php';
}

include_once 'config.default.php';
```

Each config file can contain code as following.

```php
// database config
define('DB_HOST', 'localhost');
define('DB_USERNAME', 'root'); 
// ...

// domain config
define('PROTOCOL', 'https://');
// ...

// and any thing
```

The default config file can contain configurations which are common to both production and development.

```php
define('MAX_USERNAME_LENGTH', 15);

// etc.
```

Now, in any other PHP file where you need configurations to be included, you can just include the `config.php` file.

```php
<?php
include_once '/path/to/config.php';
```

You are done!

You may already have used this technique previously. But, if you haven't I'm happy you learned something new. I think this is the best way to save configs as there's no need to rename files in production server each time you upload, which makes no sense. (I have seen some people do that)

:)
Weekly Picks #85 — Development Posts
Tags: webdev, javascript, angular, react
Published: 2019-07-24 12:57:46

* [43 most popular GitHub JS repositories in July 2019](https://app.dailynow.co/r/7af20d887e2f8b6044deb978a2acfdc3)
* [⚡Announcing “Quark” — A Software sketchbook for your node projects ?](https://app.dailynow.co/r/00ac323f6f21250f05f1f043f85ee34f)
* [Let's loop - for...in vs for...of](https://app.dailynow.co/r/ffeddd8bc0aece027cda036a24bf3829)
* [Introduction to Service Workers in JavaScript](https://app.dailynow.co/r/0167e0b251d859017182cb37c6d8a291)
* [Using global reducer in React](https://app.dailynow.co/r/46b31daf83ef487554fa98363393f8b7)
* [A Github Engineers Explains How to Drop IE Support — Gracefully](https://app.dailynow.co/r/011bb2132d7b460ac15e51ecbdd2da4d)
* [A killer Storybook Webpack config](https://app.dailynow.co/r/f8da556dc6fbfd480353e5b3115b65a8)
* [JavaScript Sets are Excellent!](https://app.dailynow.co/r/bcb1cdfa38a856d43e6586ca18cdd9a5)
* [10 Best JavaScript Media Scripts and Plugins of 2019](https://app.dailynow.co/r/2b759e3a3156e08a730a7e4fd2c5a383)
* [Angular Platforms in depth. Part 3. Rendering Angular applications in Terminal](https://app.dailynow.co/r/6db2900eedadcc7e8f18b55a811f6785)

* * *

[_Thanks to Daily_](https://www.dailynow.co/) _developers can focus on code instead of searching for news. Get immediate access to all these posts and much more just by opening a new tab._

[![Daily promotion cover](https://cdn-images-1.medium.com/max/1024/1*7bwIhcH467BKX5Ni8XWpQg.jpeg)](https://www.dailynow.co/)
Running expo and raw react-native together
Tags: reactnative, react, redux, javascript
Published: 2019-07-24 12:57:02

Hello Glad to answer this question, about ejecting your expo app. Well, you might have been asked by your senior developer, or boss or you might have just heard it from someone but don’t exactly have a good acquaintance with it. In this article we’ll try to answer these questions, all of you might be dead curious to know this in the simplest way –

Why do we need to eject an expo app, although it gives us a tonne of features?
Can we use some modules which have native code with expo like pusher, react-native-modal, etc?
how to make expo and react native work together?
Let’s add a secret ingredient called expo-starter-kit to make all of this happen with a breeze.

Read this link: -https://codersera.com/blog/running-expo-react-native-together/
Introducing taskz
Tags: node, programming, javascript, webdev
Published: 2019-07-24 12:48:52

---
title: Introducing taskz
published: true
description: Node.js: Simple sequential and parallel task list runner for terminal library.
tags: Node.js,programming,javascript,webdev
---

[Taskz](https://github.com/rap2hpoutre/taskz) is a library for Node.js, a simple sequential and parallel task list runner for terminal.

![](https://thepracticaldev.s3.amazonaws.com/i/8b97q7yyfd7bpoftf0oi.gif)


## Getting started

Install it via `npm i taskz`. Create your task sequence in any script file then run it.

```js
const taskz = require("taskz");

taskz([
  {
    text: "first task - sleeps for 200ms",
    task: async () => await new Promise(resolve => setTimeout(resolve, 200));
  },
  {
    text: "this task will fail",
    task: async () => {
      throw new Error("this task failed");
    }
  }
]).run();
```

So in other word, you have to create a array of tasks:


```js
const myTasks = [
  { text: "task 1", task: () => { /* ... */ } },
  { text: "task 2", task: () => { /* ... */ } }
];
```

Then pass it to the `taskz` function and call `run` to start the process:

```js
taskz(myTasks).run();
```

You can also run task in parallel:

```js
taskz(myTasks, { parallel: true }).run();
```

Other features: [subtasks](https://github.com/rap2hpoutre/taskz/blob/master/README.md#subtasks), [stop on fail](https://github.com/rap2hpoutre/taskz/blob/master/README.md#fail), [pass context from task to task](https://github.com/rap2hpoutre/taskz/blob/master/README.md#use-context), 
 [change text within a task during execution](https://github.com/rap2hpoutre/taskz/blob/master/README.md#change-text-within-a-task-during-execution). 

Have fun with it: [link to github repository](https://github.com/rap2hpoutre/taskz)
Why they still don't use SVG for landing pages in 2019?
Tags: svg, html, css, design
Published: 2019-07-24 11:45:33


I work at a company with a large web development division. As many other companies in this field, our company has html/css coders to create landing pages by designer's specification.
 
Recently, I had a need to create a home page for my own project. I asked a designer to draw something simple in vector format. When I've got the result, I was surprised that **I don't need to code anything** to publish the home page to the web. All work I've done is copy-paste SVG code to the HTML body, and **it worked**. It worked on any browser I tested it with. The only problem I found so far is that my landing page doesn't have a mobile version. But it is fixable - i just need to add a css media breakpoint for a mobile SVG.

I have to confess I don't have as much experience in web design as in JS development. But I have to raise some questions:

1. Why not simplify production process for simple static sites and leave this work entirely to Designers? 
2. Are there reasons for people to use html/css in favor of SVG in 2019?


Example on GitHub:
[The "code"](https://github.com/nesterow/frontless-landing)
[The home page itself](https://frontless.js.org/)
Practical Rust Web Development - CI Travis
Tags: rust, travis, ci
Published: 2019-07-24 11:28:42

Tools like Travis can be really helpful to figure it out the stability of our software, specially when we have a huge codebase that requires a lot of time to compile and test.

In this post I'll show how to integrate the Travis CI for our project, because it's open source we can use the Travis free account.

We need to perform a couple of things, first we need to enable our project for Travis CI in the repositories [page](https://travis-ci.org/account/repositories). Then we add a `.travis.yml` file in the root with the next configuration:

`.travis.yml`

```yaml
language: rust
rust:
  - stable
  - beta
  - nightly
matrix:
  allow_failures:
    - rust: nightly
  fast_finish: true
cache: cargo
services:
  - postgresql
addons:
  postgresql: "10"
  apt:
    packages:
      - postgresql-10
      - postgresql-client-10
env:
  global:
    - PGPORT: 5433
before_script:
  - sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
  - sudo service postgresql restart
  - sleep 1
  - sudo apt-get update
  - sudo apt-get install -y postgresql-10-rum
  - psql -c 'create database mystore_test;' -U postgres
  - psql -c 'CREATE EXTENSION rum;' -d mystore_test -U postgres
script:
  - cargo install diesel_cli --quiet || true
  - cargo build --verbose --all
  - DATABASE_URL=postgres://postgres:@localhost/mystore_test diesel setup
  - cargo test --verbose --all
```

Although we are targeting stable, we might want to test it against all the compiler targets and see if our code does not break some new functionality.

We enable postgres v10 and write the scripts we're gonna need previous the test.

One last thing is add badge to the README, so people can see if our software is stable.

`README.md`:

```md
# practical-rust-web
[![Build Status](https://travis-ci.org/practical-rust-web-development/mystore.svg?branch=master)](https://travis-ci.org/practical-rust-web-development/mystore)
```

You can take a look at the source code [here](https://github.com/practical-rust-web-development/mystore/tree/v8.0)
component #9 - Radio
Tags: react
Published: 2019-07-24 11:26:44

---
title: component #9 - Radio
published: true
description: This is a part of *30 components / month* challenge.
tags: #react
---
{% codesandbox gv4xm %}

## What I have learned?

- How to make custom Radio Input :D
- Finally applied [@jer](https://dev.to/aut0poietic) advice on using a css sibling selector.

{% devcomment d662 %}. 

## What are the main challenges?

  Hmmm... :/

## Why am I doing this anyway?

- To learn.
- To have fun.
- To future Joimee (for reference).

Resources:
[How To Create a Custom Radio Button](https://www.w3schools.com/howto/howto_css_custom_checkbox.asp)



Salamat.
Change WooCommerce Dynamic Pricing Display
Tags: wordpress
Published: 2019-07-24 11:19:55


<A href="https://www.cloudways.com/blog/change-woocommerce-price-display/">WooCommerce pricing</a> display is one of the essential part of product page. There are two ways to change WooCommerce pricing display.

•	woocommerce_get_price_html: Price is shown on the product and shop pages.
•	woocommerce_cart_item_price: Product prices are shown in the cart table.

<strong>Change Price Display for All WooCommerce Products</strong>
<code>
function cw_change_product_price_display( $price ) {
    $price .= ' At Each Item Product';
    return $price;
  }
  add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
  add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
</code>

<img src="https://www.cloudways.com/blog/wp-content/uploads/01-1.jpg">

<strong>Change Price Display Based on Product Fields</strong>

If you want to change price display for some products then add a field for each product on the list and retrieve this field in the code.


<img src="https://www.cloudways.com/blog/wp-content/uploads/08-1.jpg">
What tips do you have for starting a podcast?
Tags: discuss, podcast
Published: 2019-07-24 11:15:34

---
title: What tips do you have for starting a podcast?
published: true
description: What tips do you have for someone looking to start a podcast?
tags: discuss, podcasting
---

I've decided I want to start an interview-style podcast, but I'm not sure where to go from [here](https://techless.dev/). 

What tips, tools, and general recommendations do you have for taking an idea for a podcast to production? 

Specific to interview podcasts: how do you schedule times with guests?