teleren/devto huggingface dataset:
Postgres table partitioning with Rails
Tags: help, postgres, rails, ruby
Published: 2020-01-03 19:50:21

Hi all, Our system currently uses Postgresql 9.6 with Rails but has been having table performance problems. We decided to add table partitioning and I created the triggers to do that. My problem is that `CREATE` works perfectly, but `UPDATE` gives me constraint errors. Has anyone had good luck in implementing this? I would also note that I added a `DELETE` trigger for removing the row from parent after insert, but that gives me problems in tests because it can't find the row. Any help would be greatly appreciated. Thanks

example of error
```
PG::ForeignKeyViolation: ERROR:  insert or update on table "table2" violates foreign key constraint "fk_rails_647be12f23"
         DETAIL:  Key (id)=(7867) is not present in table "table1".
```

I'm assuming I'm missing something that's right in front of my face but I can't seem to find the right posts/articles to jog that.

To answer some questions on the problem:

*have you tried testing the partitions without Rails?*

  I have through psql statements. updates don't work. I'm assuming that I would need a seperate process for moving the record, but I haven't found clear solutions to help.

*Do the various CRUD operations work?*

  Inserts do

*how are the partitions defined?*

  Through a check on an id and by month

*what are you using in Rails to support partitions?*

  Just function triggers in Postgres. no gem usage
Who is using the JAMstack?
Tags: jamstack, jamuary
Published: 2020-01-03 19:46:51

A new stack is often met with scrutiny and skepticism. It’s common for developers to question the problems a new stack addresses and to pick out its current users in an attempt to validate it. As an incredibly flexible approach to building high performance sites, the JAMstack fits the bill for tackling many modern challenges of building for the web. For one, JAMstack sites are incredibly popular among agencies because of how adaptable they are. Clients often come with different sets of challenges and have varying expectations around deliverables and tech stacks. In the case of [Nike.com’s recent Kaepernick campaign](https://www.netlify.com/customers/matter-supply-nike-site/?utm_source=devto&utm_medium=mattercasestudy-div&utm_campaign=devex), the JAMstack helped the Matter Agency and Nike team build a robust site that paired frontend components with real time databases. Moreover, it empowered them to build a robust and lightning fast site that supported real time user submissions in a matter of weeks. By encouraging a decoupled stack, the JAMstack championed a separation of concerns and enabled agency developers to focus on the core business logic and brand at hand without getting stuck on implementation details. 

This strategy to building sites can be pushed further to include enterprise use cases. In an enterprise setting, time is of the essence and a slow site can cost millions in revenue. [Loblaw Digital](https://www.netlify.com/whitepaper/?utm_source=devto&utm_medium=loblawwhitepaper-div&utm_campaign=devex), a company powering one of the largest food retailer in Canada, saw a whopping 92% performance improvement and an almost 38k in cost savings by shifting to the JAMstack. Compared to their previous workflow, the JAMstack equipped them with the confidence to compartmentalize their stack and hone in on key business goals like performance and user experience. 

If you’d like to dig into the case studies mentioned above, the [JAMstack conf 2019 wrap up](https://www.netlify.com/blog/2019/11/07/news-from-the-largest-jamstack-conference-yet/?utm_source=devto&utm_medium=jamstackconf-div&utm_campaign=devex) is a great place to start. The use cases for the JAMstack grow by the day and the future of the JAMstack looks bright. We hope you’ll join us.
Useful resources i use on day to day basis.
Tags: beginners, webdev, design
Published: 2020-01-03 19:00:27

When i work on a project i use several different resources that come in handy everyday. I picked them up from several other people who mentioned them on their resources list and just kept using the best ones. While surfing facebook i got in contact with some people who asked about some help on their design. I then proposed to them to use one of these resources that i will list here and they were totally blown away. Until now i had no idea that there were still people who had no idea that these extremely useful resources existed. That is why i decided to make a post of it. Here is the list:

# **Ui Gradients**

Whenever i am looking for a beatiful gradient to overlay on an image or to put as a background Ui gradients is a no-brainer and my usual first place to go.

![Alt text of image](https://uigradients.com/static/images/uigradients.jpg)

[Go to ui gradients](https://uigradients.com/)

# **Flaticon**

Small beatiful icons like facebook, and instagram can be found here. Why bother doing the tedious work of making an icon when you can have them easily free on flaticon? Just don't forget to reference the creator of the icon on your own website. This way both you and the creator wins!

![Alt text of image](https://media.flaticon.com/share/flaticon-generic.jpg)

[Go to ui flaticon](https://www.flaticon.com/)

# **Dribbble**

Dribble is a place where designers upload their creations and get feedback on them. It is also a place for developers and other designers to get inspiration from to create their own masterpieces!

![Alt text of image](https://cdn.dribbble.com/uploads/1615/original/f3731f44e5b7085e8dfd5272f7b4f0a8.png?1565983272)

[Go to dribbble](https://dribbble.com/)

# **Pexels**

Pexels is the go to website if you need HD images to put either as a placeholders on your new websites or as real photos as pexels has a free to use policy for their images. It has thousands of beatiful images and i use them on most of my projects.

![Alt text of image](https://www.pexels.com/assets/pexels-stock-photos-6c3d5eb0cbed47e1bdf44ff85ebd9cd4669f50b895b3c6e76a23a4fd43852099.jpg)

[Go to pexels](https://www.pexels.com/)

# **Google fonts**

Thousands of beatiful open source fonts are found here and can be used for free ! Google fonts is fast and reliable.

![Alt text of image](https://www.gstatic.com/images/icons/material/apps/fonts/1x/opengraph_color_1200dp.png)

[Go to pexels](https://fonts.google.com/)

# More resources?

If you made it down here, thank you for reading through my resource list, i hope you create something amazing with these resources. If you have any other resource that you want to share with me or others please comment it down below!
I made a browser extension to hide reactions and notifications on Dev.to 💆
Tags: productivity, mentalhealth
Published: 2020-01-03 19:36:40

This year in 2020, I want to work towards posting blogs more consistently. I can see the value it can bring in improving my writing skills, and helping me to better understand programming concepts, and so I’ve committed for the first half of the year to try and post a blog a week.

But it’s very easy to start chasing likes and followers when posting on a platform like DEV. I will admit getting more followers and reactions is cool, and it’s a good feeling when you get that validation. But on the flip side, when you post and no one looks at it, that feeling kind of sucks.

I don’t want those feelings - good or bad - to get in the way of me posting blogs, and so I made a browser extension to fix that.

Now when I look at posts on my feed I will see something like this: 

![Picture of post on feed without reaction count](https://i.ibb.co/HPRJJ9p/Screen-Shot-2020-01-04-at-6-31-38-am.png)

And my dashboard no longer shows analytics data:

![Picture of dashboard without the analytics at the top](https://i.ibb.co/jrRmPmJ/Screen-Shot-2020-01-04-at-6-22-22-am.png)

And I've done the same to my notifications page and other pages across DEV.

I’ll admit this is probably a bit extreme of me, and I’m still probably going to get the urge to check my stats once in a while, but I think this is a good compromise for now.

If you’re interested in installing it yourself, I’ve put up the repository [here](https://github.com/emgoto/dev-reactions-hider). There’s definitely still some bugs - it doesn’t seem to always work when navigating between pages so I would love to know if it can be improved upon.
What's happening in Tech: January 3rd
Tags: news
Published: 2020-01-03 18:19:16

---
title: What's happening in Tech: January 3rd
published: true
description: What's happening in Tech This week
tags: news
cover_image: https://thepracticaldev.s3.amazonaws.com/i/071z37q4fpci4363asuz.jpg
---
Things were a little slow because of the holidays, but there were still some things happening in tech. Here's what happened this week: 

## New Stuff

2019 was an innovative year for tech and 2020 will be even better. Here are [20 predictions about software development trends for 2020](http://bit.ly/37xJP43). Expect to see more development in cloud infrastructure, AI/ML, No code software and more. 

Forrester, an established thought leader in tech, also made some [bold predictions about no-code software](http://bit.ly/2twvFRZ) recently, and it's a topic worth discussing. 

Henry Coles, creator of Pitest writes about [saving a half a million dollars with a single character code change](http://bit.ly/2Fh2aqf), it's an interesting story with some useful code snippets in it. 

## Food for Thought

Sumit Khanna wrote an interesting article [comparing microservices architecture with biological systems](http://bit.ly/35iMVr5). It provides an interesting abstract look at microservices architecture and how it might relate to biology.

## Cloud

Cloud infrastructure is changing and 2020 is shaping up to be a year where we double down on things that worked in 2019.

Read more about [eWeek's cloud predictions for 2020](http://bit.ly/2QmiLPC). 

## DevOps

ITProPortal released [Six DevOps Predictions for 2020](http://bit.ly/36oUXAb) that's worth a read. 

## AI/ML

Want to know where AI is going in 2020? This article, in [this article](http://bit.ly/2ZLhuor) some top minds in AI talk about where things are headed with AI for 2020. A fantastic read. 

## Security / Privacy

There's a high focus on improving your SDLC these days but sometimes security can be an afterthought. Patricia Johnson writes [how to secure your SDLC](http://bit.ly/2QjjmBz) and it gives actionable advice for examining and planning your process. 

In [this article](http://bit.ly/37C1WGj) experts from Synopsys talk about their predictions for 2020, with some security-minded predictions worth reading. 

## Have a great weekend!

Let us know what you think of these updates in the comments! Check out our latest podcast, "High-Performance Teams by Richard Harpur" 

{% podcast https://dev.to/allhandsontech/009-high-performance-teams-by-richard-harpur %}
Inspirofy
Tags: webdev, javascript, css, html
Published: 2020-01-03 17:35:59

hello people,

Checkout my new [random inspirational quote generating application](pagalprogrammer.github.io/inspirofy) based on vanilla js - [Inspirofy](pagalprogrammer.github.io/inspirofy)

**Fun Part**: Everytime you refresh the page, not only a random quote is generated but a random background is also generated based on your screen resolution.

Your feedback will be much appreciated. 🙂

[Source Code](https://github.com/pagalprogrammer/inspirofy) for tinkerers.

Created that logo in [Canva](canva.com)
My love for OpenBSD.
Published: 2020-01-03 17:34:37

Finding OpenBSD was a simple mistake.  Upon returning from Burning Man one year I discovered by Windows machine had died & there were no install disks to be found.  Numerous *nix installations were laying around though.  FreeBSD, Slackware Linux, Solaris, & OpenBSD were all attempted but alas, only OpenBSD detected all the hardware in my box right off the bat.  It was the beginning of a wonderful relationship.

First off I took to setting up SSH, and allowing remote logins from outside my home's network.  This was amazing to me.  The ability to be able to use my computer from anywhere else fascinated me.  All inside an encrypted connection no less!

SFTP was next, then setting up SMTP and Apache, slowly moving around the computer learning about included networking tools.  Which leads me to my favorite part about OpenBSD...  the documentation.

Type 'help' on any Mac and you'll be giving a list of possible commands to type at the terminal.  Type 'help' on an OpenBSD machine and you're introduced to man pages, info pages, and Unix in general.  There are a seemingly endless amount of information on commands and system tools available.

Setting up new network devices were as easy as editing text files in the /etc directory.  Scripts became available as bash functions.  It felt as if I wasn't going to the internet, but the internet was coming to me.

I highly recommend OpenBSD to anyone wanting to learn the ins and outs of backend solutions or just servers in general.

http://www.openbsd.org
My best CSS 2019 performance tip: contain
Tags: css, webperf, tips
Published: 2020-01-03 17:30:16

---
title: "My best CSS 2019 performance tip: contain"
published: true
description: Isolated your DOM with this one weird property
tags: css, web performance, tips
---

The best CSS performance tip I had in 2019 was to use the [contain property](https://developer.mozilla.org/en-US/docs/Web/CSS/contain).

*contain* creates an new isolated context for the DOM element that is attached to. For most web pages the main sections of the page tend not to depend on one another's states. A footer or sidebar for a page, for example.

Where the real power comes from though are pages that have many repeating blocks. Things like search results, product cards and even table rows can all be isolated while having local state and behaviour.

Even for older code there are advantages in terms of resetting stacking and block contexts to something that is more intuitive. Even the clipping rules are probably more more what you'd expect for a block on-screen that the default page-based rules.

The final magical thing about *contain* is that you don't have to get it right. If the browser detects that it needs to repaint that section of the DOM, you pay the performance penalty and it does. The emphasis is therefore on you to make sure you don't implement changes that invalid its use. On the other hand nothing goes wrong in situations where you unexpectedly find a dependent change or there are circumstances in which the UI is not as isolated as your mental model predicted.

For a reasonable well-implemented site the performance benefit it probably going to be subtle and take some time in the dev tools to notice but it is a simple non-breaking change that allows you embed a bit of your mental model into your HTML and maybe avoid you having to use a "clearfix" class ever again.
Elixir run asynchronous function with Task.async and Task.await
Tags: elixir
Published: 2020-01-03 17:24:58

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/luzql8ltzg6srp7c3tld.jpg)

วันนี้ได้มีโอกาสไปงาน [Elixir Casually Mini-meetup](https://www.facebook.com/events/514712659136277) มา เป็นงาน meet-up เล็กๆ สำหรับกลุ่มคนใช้ Elixir ในไทย และ คนที่สนใจ

ซึ่ง session แรกได้ทางคุณ Zack Siri มาเล่าท่าต่าง ๆ ในการรัน asynchronous function ด้วย Elixir 

สำหรับท่าแรกที่ง่าย ๆ เลยที่ผมเอามาสรุปวันนี้คือใช้ฟังก์ชัน [Task.async](https://hexdocs.pm/elixir/Task.html#async/1) (สำหรับใครที่ไม่เคยใช้ Elixir เวลาเห็น Task.async นั้น async เป็นชื่อฟังก์ชัน ที่อยู่ใน module Task เวลาใช้งานต้องเอาชื่อ module ก่อนแล้วค่อย dot ตามด้วยชื่อฟังก์ชันที่เราจะเรียกใช้ที่อยู่ใน module นั้น ๆ)

ซึ่งวิธีใช้งานคือเราจะส่งฟังก์ชันไปให้ Task.async ทำงาน เสร็จแล้วเราจะได้ค่าของ Task struct กลับออกมา เมื่อถึงจุดที่เราอยากได้ผลลัพธ์การทำงาน ก็ให้เราเรียกฟังก์ชัน [Task.await](https://hexdocs.pm/elixir/Task.html#await/1) พร้อมส่งค่าของ Task struct ไปให้ ก็จะได้ผลลัพธ์ของ Task นั้นที่เราสั่งไปรันผ่าน Task.async กลับมานั่นเอง

ตัวอย่างเช่น ผมจะเรียกใช้ [:httpc.request](http://erlang.org/doc/man/httpc.html#request-1) ซึ่งเป็น function ในการสั่ง http request โดยให้ทำงานผ่าน Task.async แล้วค่อยเรียก Task.await ได้ดังนี้

```elixir
# start :inets and :ssl for using :httpc 
# These modules from Erlang for make a http request
Application.ensure_all_started(:inets) 
Application.ensure_all_started(:ssl)

task = Task.async(fn ->
    :httpc.request('https://google.com')
end)

{:ok, {_, _, body}} = Task.await(task)

IO.puts body
```

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/5a1ztumkbefxi2s28282.png)

จริงๆแล้ว Elixir/Erlang ยังมีอีกหลายท่าที่ช่วยให้เราจัดการ Asynchronous Task ได้ง่ายๆ ซึ่งทางคุณ Zack เองก็เอามาให้ดูหลายท่า เดี๋ยวผมจะสรุปอีกทีใน post ถัด ๆ ไปครับ
SQL and the Soup Kitchen
Tags: sql
Published: 2020-01-03 17:21:33

At a soup kitchen on Potrero St in San Francisco is a man named Charlie.  Charlie has been working to take care of the homeless for over thirty years.  One of the responsibilities he’s taken on is having the kitchen’s address available for those in need to use to receive their mail.  Looking through the mail that’s accumulated takes Charlie, or whoever is checking the mail for someone, can take forever.

Searching for someone's mail consists of looking one by one for the recipient's name on each envelope.  At worst finding, or not finding, a single piece of mail can take upwards of fifteen minutes.

A simple SQL solution could make life incredibly easier.  When mail arrives, why not populate a simple table in SQL consisting of a recipient & arrival date?  

For example:
```
CREATE TABLE mail (
id INTEGER PRIMARY KEY,
recipient_id INTEGER,
arrival_date TEXT
delivered BOOLEAN);

CREATE TABLE recipient (
id INTEGER PRIMARY KEY, 
name TEXT);
```

Presto!  From here we have a starting point to make simple queries to the database which would identify if someone has a letter waiting.

No longer will soup burn when you have to look for mail!
Node.js v/s Spring for startups
Published: 2020-01-03 17:07:18

Firstly, if you are like me, coming from a C, C++ background and then switched over to JavaScript for Front-end web development with very little or almost no knowledge in Java, Node.js should be your choice. But if you are well versed with Java, you may pick as you are comfortable with.

Secondly, Node.js is single threaded. If something goes wrong and Node.js crashes, then everything crashes. You don’t have the isolation that you have with a Java web application.

Thirdly, Spring Boot is fabulous: light and fast, complete and extremely configurable. Spring Boot strictly follows the MVC pattern. But in case of Express.js (minimalist framework for Node.js) it may or may not be configured like that way. So, if you mess up the codes its a problem.

Fourthly, authentication in Spring is better as compared to Passport.js used with Node.js. But Passport.js supports major functions of Spring authentication and are sometimes simpler to code and understand the logic. Hibernate is still the most complete, mature, and versatile solution, but at a very high cost! Sequelize may cover 90% of your use cases. Sequelize is easy to create queries at runtime. Try to do it while creating a JPQL query or consider how over-complicated it is to do with certain criteria. Sequelize is a better option as per me.

Lastly, as we are talking about startups, I will consider simplicity and flexibility over strict MVC and robustness of Spring. JS makes things much simpler and easy to code. Besides, the workflow in Node.js is much faster then that in Spring. Even, the learning curve is also smooth in Node.js as compared to Java. Rather then this build management is much tougher with Maven than with NPM.

BONUS : According to Stack overflow survey, Express is before Spring both in terms of most loved and most wanted web frameworks. Even with Node.js you can code JavaScript at both ends of the website. But, Spring has been in market for long and has a large ecosystem supporting it. The number of high quality third-party libraries available in Java is very high.

So at the end of the day, it is a matter of choice.

Even feel free to visit my blog : <a href ="http://learnnodeonline.blogspot.com/">LEARNNODEONLINE.BLOGSPOT.COM | A PLATFORM TO LEARN NODE.JS</a>
Get comfortable with JS arrays: exercises for beginners
Tags: javascript, beginners
Published: 2020-01-03 17:06:32

Just a few exercises that I came up with while tutoring. The goal is to wrap your head around iterating over arrays as a pre-cursor to learning the forEach() and filter() methods in functional JS.

The learner also had some confusion data types in arrays and about Parameters vs Argument so the exercises also reflect those.

###1.
```
let myAlphabet = ['A', 'B', 'C', 'D','E','F', 'G'];
```
- What is the length of the array?
- Write a function called <code>myAlphabetLength</code> which console.logs the length of the array
- Within the function also use an <code>if-conditional</code> statement that checks if the number of items within the array are less than <code>4</code>


###2.

- Declare a function <code>checkFunc</code> that takes a string and a boolean as parameters
-  Call the function using 2 arguments



###3.


- Declare and initialize an array called <code>Planets</code> with 5 string values
-  <code>console.log</code> each item in the array
- Also console.log the index in each iteration



###4.


- Declare and initialize an array called 
```
wowDatatypes
```
- The array must have 5 different data types (NOT objects)
- Iterate over the array and console.log each item in the array + it’s index and data type in the array



###5.

- <code>console.log</code> each item in this array WITHOUT using a for loop
```
   let myArr = [ 1, 2, 'One', true];
```
###6.
```
let student1Courses = ['Math', 'English', 'Programming'];
let student2Courses = ['Geography', 'Spanish', 'Programming'];
```
- Loop over the 2 arrays and if there are any common courses, if so <code>console.log</code> them

###7.

```
let food = ['Noodle', 'Pasta', 'Ice-cream'];
let food = ['Fries', 'Ice-cream', 'Pizza'];
```
- compare the 2 arrays and find common food if any


###8.

```
let values1= ['Apple', 1, false];
let values2 = ['Fries', 2 ,true];
let values3 = ['Mars', 9, 'Apple'];
```
- compare the 3 arrays and find any common elements


###9.
```
let furniture = ['Table', 'Chairs','Couch'];
```
- For each item in this  array <code>console.log</code> the letters in each item
How to use Docker for development on local machine
Tags: laravel, docker, tutorial
Published: 2020-01-03 17:03:28

I've used [Vagrant](https://www.vagrantup.com/) and [Homestead](https://laravel.com/docs/6.x/homestead) for local development for last several years, and recently switched to Docker. And I'm super-happy with my current setup, as Docker containers are much easier to setup, and they consume less resources than Vagrant.

If you're wondering how to start using Docker in local development and quickly run Laravel application in Docker container, watch my video tutorial:
{% youtube DNyQX00X_cg %}

A few notes:
- This Docker template is adopted for Laravel/PHP apps, however feel free to customize it to fit your own needs;
- This Docker template is used only for development on local machine;
- You may get Laravel Docker Template on [Github](https://github.com/maxkostinevich/Laravel-Docker-Template);
- I still use classic VPS/non-dockerized environment on production;

I hope you found this tutorial useful! Any questions or feedback is much appreciated!
Formularios de c# problem
Published: 2020-01-03 16:43:25

Necesito ayuda con un problema que tengo con los formularios quería realizar el inicio de sesion donde la cual al comienzo del programa empieza el FRMPrincipal pero todos sus botones los deshabilite el único botón habilitado es iniciar sesión y salir. Cuando apreté iniciar sesión y se valide el user y pass se cierre el FRMSesion y se habiten los demás botones. Trato de realizar eso pero no puedo hacerlo de ninguna manera ayuda porfavor