teleren/devto huggingface dataset:
Querying ActiveStorage Attachments
Tags: activestorage, rails, ruby, sql
Published: 2021-06-25 02:52:18

## The problem

You want to find all the ActiveRecord models that either do / do not have a record attached to them.

## The solution

Let's say you have a `Post` class which has one image attached like so:

```rb
class Post < ApplicationRecord
  has_one_attached :image
end
```

To query for all `Posts` that do not have an image attached the syntax would look like this:

```rb
Post.left_joins(:image_attachment).where(active_storage_attachments: { id: nil })
```

This will return all posts that do not have an image. If you want to find all posts that _have_ an image attached, you would use a `#not` clause in there like so:

```rb
Post.left_joins(:image_attachment).where.not(active_storage_attachments: { id: nil })
```

## has_many_attached

This can even be extended to `has_many_attached` by using the plural form of `:image_attachment` like so:

```rb
class Post < ApplicationRecord
  has_many_attached :images
end

# Query for all without attachments
Post.left_joins(:image_attachments).where(active_storage_attachments: { id: nil })

# Query for all with attachments
Post.left_joins(:image_attachments).where.not(active_storage_attachments: { id: nil })
```

## Final Syntax

The syntax for attachments is fairly straightforward like so:

```rb
ModelName.left_joins(:<attachment_name>_attachment[s]).where(active_storage_attachments: { <column>: <value> })
```

And thats it! Good luck and enjoy your new found query power!
Sharing of how I made my own command
Tags: beginners, ubuntu
Published: 2021-06-25 02:34:54

## Weekly sharing

Hi everyone, I am Ekim, a fresh Bootcamp graduate and an IT helper (I don't dare to call myself a programmer yet). Every Friday, I will share some of the work that I've done over the last week in a bid to get feedbacks from you guys and record my journey to become a programmer. 



### Introduction

Last week was a hectic journey. I didn't have much time working on blog writing. So this blog wouldn't be as detailed as others I've written. Despite that, I would like to share with you some tips for making your own command on Ubuntu. 

### Previously
<a href="https://dev.to/ekim34351855/multi-master-vrrp-set-up-5f2g">Multi-Master VRRP set-up</a>

### How I made my own command ?

1. Writing in `~./bashrc` 

   - After writing a `.js` file or other kinds of files, you could run it with `node` or other runtime tools. 

   - In the `~./bashrc`, we could make use of `alias` to help us run those files in a much easier way

   - For example to execute `node abcd.js`, we could make it with as simple as only one word `abcd`

   - Here is how we could do it

```bash
       alias abcd="node /var/local/abcd.js"
```

   - The down side of writing `alias` in `~./bashrc` is that the script can only be used by the users whose `~./bashrc`  has those script. 

   - If there are multiple accounts in the server, you could not make sure that everyone could use that shortcut



2. Writing an executable at `/usr/local/bin`

   - An executable is a file which is set to be executed

   - In that file, you specify how the script is run

   - Using the above `abcd` as an example, what you need is the following

```bash
       cd /usr/local/bin
       touch abcd
       chmod a+x ./abcd			# enable execution for all groups
       
       # edit the executable
       vim abcd
       
       # ------- vim abcd -------
       #!bin/bash
       
       node "/var/local/abcd.js"
       # ------- vim abcd -------
```

   - By doing so, every user could use the `abcd` command

   - If the `abcd.js` accepts 3 arguments, which you include something like `let [ var1, var2, var 3] = process.argv.slice(2)` in your `.js` file to get the arguments , you could further do this

```bash
       # ------- vim abcd -------
       #!bin/bash
       
       node "/var/local/abcd.js" $1 $2 $3
       # ------- vim abcd -------
```



### Conclusion

Now, you have created a command called `abcd` in your system. Input your newly created command into your console and see if it could run as expected. If I did anything wrong, please let me know as well. That's all for today. I hope you enjoy reading.
How much time do you spend developing dashboard designs?
Tags: template, uikit, dashboard, bootstrap
Published: 2021-06-25 02:31:26

> About how I made the Dashboard Kit that saves you 10x your time.

Don’t be in a hurry to start with a blank piece of paper when designing a dashboard, as things like a holistic design system and a well-structured component base ahead can make you forget that you’re drinking too much coffee and ending the day in front of a computer.

So you’re still sitting comfortably in a chair, and I’m offering a great UI Kit that will save you a lot of time with examples that will surprise you a little.

Add new post page – Elegant Dashboard UI Kit
Elegant Dashboard UI Kit is a Dashboard design with an integrated design system, containing standard components and ready-to-use screens.

The Idea
So where did the idea come from? Why did I decide to develop a UI Kit for Dashboards? At first, I started looking for side project Dashboard designs myself, which I found but they were saturated with very expensive or useless components. I just wanted to find a compact and clean Dashboard UI Kit and finish my side project quickly.

After I finished drinking a few cups of coffee, I had this idea – what if I developed a UI Kit for Dashboards myself?

Although it seemed like a lot of fun at first, a few days later I had a strong tension in my brain because developing a UI Kit wasn’t as easy as drawing wireframes on paper while just drinking a cheeseburger and Pepsi.

I deleted all the work I had done in the first week from Figma and felt confused because I started working without much searching. ctrl + a and delete I deleted the 1-week hard-working result instantly. The reason was that the UI Kit had very few components that were semantically necessary, and I had planned to demonstrate a practice-based UI Kit for people in advance.

During the day, I reviewed many CMS systems and started drawing again. Now everything was better because every screen had a jam of useful parts.

I have finally developed my first UI Kit called Elegant Dashboard and I am sharing it with you today.

See the result of hard work: https://dashboard.elegant-goodies.com/

In addition, I have found some other good Dashboard design kits and will share them with you soon.

I apologize for my bad English under the article you have already read 🙂
Javascript Questions
Tags: javascript, beginners, interview, intermediate
Published: 2021-06-25 02:20:59

Is this a pure function?

function sum(a, b) {
  return a + b;
}

A: Yes
B: No


Answer: A

A pure function is a function that always returns the same result, if the same arguments are passed.

The sum function always returns the same result. If we pass 1 and 2, it will always return 3 without side effects. If we pass 5 and 10, it will always return 15, and so on. This is the definition of a pure function.
Convert Integer value to Hour:Minute:Seconds in dart
Tags: dart, flutter, firstpost, mobile
Published: 2021-06-25 02:14:33

As a developer, there are times that you 'll need to convert a integer values to time remaining, It could be during the course of using Stream or something else.

Below is a good approach to handle the situation

Not so fast,
![Alt text of image](https://media.giphy.com/media/QWw4hc5gTnJhY0BUI3/giphy.gif)
To understand the code below you need to understand some basic time conversion.
## 1. one(1) hour =3600 seconds
Definitely to convert let's say 2 hours to seconds we 'll have **2*3600 = 7200 seconds**
## 2. one(1) minute = 60 seconds
Definitely to convert 2minutes to seconds we 'll have
**2*60 =120 seconds**
## 3. one(1) seconds = 1 seconds



``` Dart
String intToTimeLeft(int value) {
  int h, m, s;

  h = value ~/ 3600;

  m = ((value - h * 3600)) ~/ 60;

  s = value - (h * 3600) - (m * 60);

  String result = "$h:$m:$s";

  return result;
}
```
**Output**
``` Dart

0:0:0
```

## And if you decide to go with one with more muscle
``` Dart
String intToTimeLeft(int value) {
  int h, m, s;

  h = value ~/ 3600;

  m = ((value - h * 3600)) ~/ 60;

  s = value - (h * 3600) - (m * 60);

  String hourLeft = h.toString().length < 2 ? "0" + h.toString() : h.toString();

  String minuteLeft =
      m.toString().length < 2 ? "0" + m.toString() : m.toString();

  String secondsLeft =
      s.toString().length < 2 ? "0" + s.toString() : s.toString();

  String result = "$hourLeft:$minuteLeft:$secondsLeft";

  return result;
}
```
**Output**
``` Dart

00:00:00
```
That wraps up everything ..See you in the next one
Moldy mi nuevo proyecto
Tags: opensource, spanish, go, help
Published: 2021-06-25 01:58:55

Hola soy el Creador de Moldy un proyecto Open Source que su propósito es ser la forma mas rápida, segura, moderna de iniciar y manejar tus proyectos ya tenemos la versión v0.1.0 beta sacada bueno y estoy aqui buscando gente y comunidad para que me ayude con este proyecto este momento necesitamos las siguentes habilidades si lo tienes no dudes en avisarme:

1. Diseñador de UX UI para la Web y Documentación de Moldy
2. Desarrollador Golang para trabajar el CLI 
3. Desarrollador Web para la creación del Home Page Documentación 
4. Desarrollador Backend para que ayude con la api ( Posiblemente NodeJs con TS por definir)
5. Diseñador del logo tenemos un logo muy bonito actualmente pero con el renacimiento de este proyecto pensamos renovarlo ( Se aceptan sugerencias ideas o tal vez mascotas )
6. Desarrollador que sepa Sh o Ps1 para crear los instaladores
7. Sponsors el proyecto quiere crecer y ya que es un proyecto opensource no puedo ni quiero cobrar por el entonces si quiero tener un dominio o alguna otra cosa lo será por sponsors


Les dejo a continuación las Redes Sociales de Moldy

https://twitter.com/CommunityMoldy
https://discord.com/invite/2uwzhmJdfw
https://github.com/Moldy-Community

Espero de su ayuda y colaboración si pueden compartir genial

> Pueden usar la release o dar feedback del proyecto en su discord los espero

Espero su ayuda y colaboración
Ionic dev question
Tags: ionic, develope, tutorial, errors
Published: 2021-06-25 01:54:09

https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fionic2plus%2Fposts%2F1025048078029946

I'm gonna develop above tutorial 
It is do pictures transfer to some a server 
but it have error like a above url.

Please help me and advice everyone!
Create Horrible Console Messages with CSS
Tags: css, javascript
Published: 2021-06-25 01:44:19

Are you tired of reading debug messages featuring the same Courier New 10px font over and over again? Do you want to color code your error messages or console logs by code block? Do you want to remind people inspecting your web app of the lawless days of Myspace?

Well now you can.

Most modern browsers support styling console messages with CSS. All you have to do is prefix your message with %c and pass whatever styling you want as a second argument.

```
console.log("This is a normal message.");
console.log(
  "%cThis message is big and scary!",
  "color: red; background-color: black; font-size: 16px"
);
console.log("This message is not.");
```

For example, the above code results in the following output.

![Big Scary Console Message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phqo2ypisp94cqyeqgz8.png)

You can even define styling in variables and use template literals.

```
const style = `
    color:white;
    background: linear-gradient(312deg, rgba(255,0,0,1) 0%, rgba(241,255,0,1) 15%, rgba(0,255,12,1) 30%, rgba(0,254,255,1) 43%, rgba(0,1,255,1) 59%, rgba(250,0,253,1) 88%, rgba(255,0,0,1) 100%);
    border: 1px solid white;
    padding: 5px;
    font-family: "Comic Sans MS";
    font-size: 16px;
`;

console.error(
  `%c🌈💖 An error has occurred. Everything is ruined forever. 💖🌈`,
  `${style}`
);
```
![Rainbow Colored Error Message](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4fc38d5dfbsm5i26l8tr.png)

It really helps soften the blow, don’t you think?
🎬Neumorphism Login Form | HTML & CSS✨
Tags: html, css, tutorial, neumorphism
Published: 2021-06-25 01:19:15

We will explore the new neumorphism trend and create a "Neumorphism Login Form" using that trend.
So, in this video, you will learn how to use this trend and create a “Neumorphism Login Form | HTML & CSS ”(No JavaScript).
  **We'll walk you through step-by-step** on how to create it and how to add it to your websites.

---

{% youtube QWh0S-3D7uY %}

---

🏆**Recommended Projects**🏆

🎬Login & Registration Form Using HTML & CSS & JS
➤https://youtu.be/I5_T547tHf0

🎬Neumorphism Login Form | HTML & CSS 
➤https://youtu.be/QWh0S-3D7uY

🎬Top 10 Best VS Code Extensions | 2021
➤https://youtu.be/bwPmpducPgw

🎬Amazing Social Media Buttons Hover Effects | HTML & CSS 
➤ https://youtu.be/P9pi4hq7BBA 

🎬Animated Login Form | HTML, CSS & JavaScript 
➤ Watch: https://youtu.be/ogNwc45qHKo 

🎬Slider Sign In / Sign Up Form | HTML CSS Vanilla JS 
➤ Watch: https://youtu.be/Wz5THk0-Y1s 

---

🛴 Follow me on: 
👉Facebook:https://bit.ly/3cp2S5W

---
Class properties in Svelte
Tags: svelte, react
Published: 2021-07-18 14:53:54

---
title: Class properties in Svelte
description: A handy trick to make your Svelte components feel even more like plain old HTML.
cover_image: https://navillus.dev/posts/2021-06-25-svelte-class-props.jpg
published: true
date: 2021-06-25 00:00:00 UTC
tags:
  - svelte
  - react
canonical_url: https://navillus.dev/blog/svelte-class-props/
---

I've noticed an interesting pattern when a [React](https://reactjs.org/) developer gives [Svelte](https://svelte.dev) a try - they almost immediately add a `className` property to their first Svelte component.

Don't get me wrong, the power of dynamically adding classes to a component can save your butt. The term `className` is a dodge in the JSX world though since `class` is a reserved word in JavaScript. Here's a quick trick to make your Svelte components feel even more like plain old HTML with a proper `class` property!

**tl;dr;** Check out the [REPL](https://svelte.dev/repl/ee6a1591aa214368b56804241f0f4c6d?version=3.38.3) example to see a working example.

## First, the problem

With Svelte, you may think it's as simple as

```html
<script>
  export let class = "";
</script>

<div {class}>...</div>
```

Unfortunately you run smack into the same reserved word problem - Svelte treats the `script` as regular JavaSript (or TypeScript) and won't allow a variable named `class`.

### The workaround

If you're like me you probably hit this once, banged your head against the nearest wall a couple times, then moved on to the obvious fix of renaming the prop to `class`.

```html
<script>
  export let className = "";
</script>

<div class="{className}">...</div>
```

Writing Svelte is so close to HTML that you can almost forget there's a framework at all...until you come across something like `<Button className="send-btn"/>`. Those four extra characters stand out like a sour thumb, flashing a big neon sign to remind you this isn't actually HTML.

## There's an easy fix

```html
<script>
  let className = "";
  export { className as class };
</script>

<div class="{className}">...</div>
```

That's all there is to it! Internally the property is named `className`, avoiding JavaScript's reserved word issue. Externally, though, the component has an optional property named `class`.

```html
<button class="send-btn" />
```

Doesn't that just feel right? No more JSX-like `className` property screaming "is this React!?!"

## Conclusion

React is a very powerful framework and web development wouldn't be where it is today without it. But when it comes to workarounds like renaming `class` to `className`, or camel casing CSS properties for that matter, it can feel freeing when you can move past those quirks and get back to the basics.
Taylorism is dead. Long live Taylorism!
Tags: automation, management, devops, practices
Published: 2021-06-29 08:20:31

---
title: Taylorism is dead. Long live Taylorism!
published: true
date: 2021-06-25 00:00:00 UTC
tags: automation,management,devops,practices
canonical_url: https://jhall.io/archive/2021/06/25/taylorism-is-dead.-long-live-taylorism/
---

“Taylorism” may be a new term to many of you, but I’m sure the _concept_ isn’t.

Frederick Taylor (1856-1915) is credited with the management theory of [Scientific Management](https://en.wikipedia.org/wiki/Scientific_management), also often called “Taylorism”, which basically boils down to the idea that business processes can be optimized through scientific observations, such as [time and motion study](https://en.wikipedia.org/wiki/Time_and_motion_studies), to the point that an untrained monkey can do the work with the proper guidance from the theoretically omniscient management.

In the last decades, Scientific Management/Taylorism has gotten a lot of flack, and rightly so. It views “front-line” workers as cogs in a machine, with no ability to think, reason, or imagine ways of improving their daily work. It’s seen as inhumane at worst, and ineffective at best—particularly for knowledge work.

Concepts like Agile and LEAN are largely rooted in a reaction _against_ Taylorism. Of course, Taylorism is now deeply engrained in the management culture of the western world, and it will take many more decades to eliminate it completely, if that’s ever even possible (or desirable).

But there’s one area where we all thrive with a Taylorist mindset.

When is the last time you tried to optimize a function in your program?

Or you tried to speed up a CI/CD pipeline?

If these aren’t examples of systemic improvement through [time and motion studies](https://en.wikipedia.org/wiki/Time_and_motion_study), I don’t know what is.

The important distinction from “classical” Taylorism is that the subject of our study is a computer (or network or other mechanical or electrical system), not human beings.

Taylorism is great when it’s applied to _actual_ (or proverbial) cogs in _actual_ machines.

A huge part of DevOps is applying the Taylorist approach to our computer systems.

So Taylorism is dead, as a management philosophy for humans. But long live Taylorism as an optimization philosophy for machines.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Fchg32 is the Swiss Army knife of Tuxedo FML32
Tags: oracle, tuxedo, fml32
Published: 2021-11-03 06:23:15

---
title: Fchg32 is the Swiss Army knife of Tuxedo FML32
published: true
date: 2021-06-25 00:00:00 UTC
tags: oracle,tuxedo,fml32
canonical_url: http://aivarsk.com/2021/06/25/fchg32/
---

`FML32` is Oracle Tuxedo buffer type similar to `std::multimap` in C++ or `multidict` in Python where the key might occur more than once in the container. `Fchg32` is the function for changing a value for a specific key and occurence. But carefully reading [the documentation](https://docs.oracle.com/cd/E53645_01/tuxedo/docs12cr2/rf3fml/rf3fml.html#1005951) reveals more interesting details.

First, if there are only two occurances and you try to change the value of the fifth occurance, a third and forth occurance with the default value (`0` for numeric fields) will be added:

```
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>

int main() {
  long value;
  FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);

  value = 1;
  Fchg32(fbfr, TA_MORE, 0, (char *)&value, 0);
  value = 2;
  Fchg32(fbfr, TA_MORE, 1, (char *)&value, 0);
  value = 5;
  Fchg32(fbfr, TA_MORE, 4, (char *)&value, 0);

  Fprint32(fbfr);
  return 0;
}


$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 1
TA_MORE 2
TA_MORE 0
TA_MORE 0
TA_MORE 5

```

Second, `Fchg32` will behave like `Fadd32` and add new occurances when the occurence `-1` is specified:

```
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>

int main() {
  long value;
  FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);

  value = 1;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
  value = 2;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
  value = 3;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);

  Fprint32(fbfr);
  return 0;
}


$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 1
TA_MORE 2
TA_MORE 3

```

Third, `Fchg32` will behave like `Fdel32` and delete existing fields when the value `NULL` is specified:

```
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>

int main() {
  long value;
  FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);

  value = 1;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
  value = 2;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
  value = 3;
  Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);

  Fchg32(fbfr, TA_MORE, 0, NULL, 0);
  Fchg32(fbfr, TA_MORE, 0, NULL, 0);

  Fprint32(fbfr);
  return 0;
}


$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 3

```

`Fchg32` is the Swiss Army knife of `FML32` API functions.
W3C Games CG June 2021: Godot, Coil, and Pixi
Tags: gamedev, godot, pixijs, coil
Published: 2021-06-25 15:19:53

---
title: W3C Games CG June 2021: Godot, Coil, and Pixi
published: true
date: 2021-06-25 00:00:00 UTC
tags: gamedev, godot, pixijs, coil
canonical_url: https://end3r.com/blog/w3c-games-cg-jun-2021/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j629v2ih6wwcdx4ync8x.jpg
---

This time during our bi-monthly [W3C Games Community Group](https://end3r.com/blog/tag/w-3-c-games/) meetup we had three presentations: **Godot** ’s and **Pixi** ’s history and future, and an update from [Coil](https://coil.com/?ref=end3r) about the upcoming **Web Monetization Workshop** and the **Rafiki** project.

Our meetup started with **Fabio Alessandrelli** talking about [Godot](https://godotengine.org/): the history, current state of the engine, especially around HTML5, and the plans ahead.

![End3r's Corner - W3C Games CG June 2021: Rafiki](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fzkqtxt9qgp9xrfouau.jpg)

Next was **Uchi Uchibeke** from [Coil](https://coil.com/?ref=end3r) presenting about **Web Monetization API** in general, but also [announcing the Web Monetization Workshop](https://dev.to/coil/announcing-the-web-monetization-workshop-wmw-2oid) and explaining the [Rafiki](https://write.as/coil/introducing-rafiki-an-all-in-one-solution-for-interledger-wallets) project.

![End3r's Corner - W3C Games CG June 2021: Pixi](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zw5i9efvhwwslf6b9bk7.jpg)

Third and the last one was **Mat Groves** from [Goodboy Digital](https://www.goodboydigital.com/) who went through [Pixi](https://www.pixijs.com/)’s evolution over the years, and what is yet to come in the future.

Our next event will be a second installment of the workshop (topic yet to be determined), since the first one had some good discussions going on - it will happen next month, right between the bi-monthly meetups.
Proof of Work vs. Proof of Stake: Beginner’s Guide!
Tags: cryptocurrency, blockchain, proofofstake, proofofwork
Published: 2021-06-26 02:16:35

---
title: Proof of Work vs. Proof of Stake: Beginner’s Guide!
published: true
date: 2021-06-24 23:56:39 UTC
tags: cryptocurrency,blockchain,proofofstake,proofofwork
canonical_url: https://medium.com/coinmonks/proof-of-work-vs-proof-of-stake-beginners-guide-da257533be8
---

[![](https://cdn-images-1.medium.com/max/1680/1*Te75nlZgMOB9gbtr6dRpew.jpeg)](https://medium.com/coinmonks/proof-of-work-vs-proof-of-stake-beginners-guide-da257533be8?source=rss----721b17443fd5---4)

Proof of Stake is strongly coming to unveil in a couple of months. So, which one is better, affordable, faster, decentralized, safer…

[Continue reading on Coinmonks »](https://medium.com/coinmonks/proof-of-work-vs-proof-of-stake-beginners-guide-da257533be8?source=rss----721b17443fd5---4)