teleren/devto huggingface dataset:
Hot reloaded Apollo server: Introduction
Tags: docker, graphql, node
Published: 2020-02-24 17:58:05

*Photo by Dan Wayman on Unsplash*

This is my first post on dev.to. For some time I wanted to build Apollo server with hot reload. Many attempts failed, but I recently found webpack plugin that helped me. In this short series, I will demonstrate that.


# Init and clear package.json

`npm init`

After that, I cleaned up package.json and added .gitignore.

# Install dependencies and create demo app

`npm i apollo-server graphql`

src/resolvers/index.js
```js
export default {
  Query: {
    testMessage() {
      return "Hello World!";
    }
  }
};
```

src/typeDefs/index.js
```js
import { gql } from "apollo-server";

export default gql`
  type Query {
    testMessage: String!
  }
`;
```

src/index.js
```js
import { ApolloServer } from "apollo-server";

import resolvers from "./resolvers";
import typeDefs from "./typeDefs";

const server = new ApolloServer({ resolvers, typeDefs });

server.listen(process.env.GRAPHQL_PORT || 8080).then(({ url }) => {
  console.log(`Server ready at ${url}`);
});

if (module.hot) {
  module.hot.accept();
  module.hot.dispose(() => {
    console.log("Module disposed");
  });
}
```

# Production webpack config

Install dev dependencies:
`npm i -D npm i -D webpack webpack-cli clean-webpack-plugin webpack-merge webpack-node-externals`

webpack.common.js
```js
const path = require("path");

module.exports = {
  output: {
    filename: "server.js",
    path: path.resolve(__dirname, "dist")
  },
  resolve: {
    extensions: [".js"]
  },
  target: "node"
};
```

webpack.production.js
```js
const path = require("path");

const cleanWebpackPlugin = require("clean-webpack-plugin");
const merge = require("webpack-merge");
const nodeExternals = require("webpack-node-externals");

const common = require("./webpack.common");

module.exports = merge.smart(common, {
  devtool: "source-map",
  entry: [path.join(__dirname, "src/index.js")],
  externals: [nodeExternals({})],
  mode: "production",
  plugins: [new cleanWebpackPlugin.CleanWebpackPlugin()]
});
```

And finally add this script to package.json
```
"build": "webpack --config webpack.production.js",
"start": "node dist/server.js"
```

# Test run

Next step is build app:
`npm run build`
and test run:
`npm start`

After that, you can open your browser at http://localhost:8080/ and try out this query:
```graphql
query {
  testMessage
}
```

# Next part

In the next part, I will dockerize app.


{% github VojtechP/apollo-server-hot-reload-example %}
A good day
Tags: devjournal, webdev
Published: 2020-02-24 17:49:31

You know when you fix something but your are not entirely sure how. At this stage in my new job I am now taking the initiative to plagiarise and bastardise other team developers code like I'm cramming the last bin bag in the bin and it doesn't look like it will fit. It's a joyful experience when it actually works and so far this total disregard for code quality is working fine.

Today I had to refactor my trail of destruction and honestly it wasn't that bad with my beautiful new editor Webstorm. It's also not that bad because by some miracle I was heading in the right direction with my solution. The concept I understand but the execution was a bit off. It's taken 10x as long (makes me a 10x developer) but I can see the way to not make the same mistakes and maybe just maybe deliver my 1 story before the sprint is out.

Fun times thanks for reading.
Unexpected result while solving given type of expression
Published: 2020-02-24 17:39:44

Hello friends,

getting zero in the code written below during compilation but the correct answer is 30.
 
int main()
{
    int a=(30/100)*100;
    printf("%d",a);
}


here the problem is all the expression is written with int datatype only no float value is here so **0.3** is considered as **0** according to integer and the whole expression is **zero**.
To correct this we have to provide either upper value as float or denominator as float 

and the code is look like this with the correct output.

int main()
{
    int a=(30/100.0)*100;
    printf("%d",a);
}
Python segfault one-liner
Tags: python
Published: 2020-02-24 17:32:57

Today I found a way to segfault Python, and after some investigation made a minimal working example:
```python
from threading import Thread
from itertools import count

Thread(target = lambda: [print('', end = '') for x in count()]).start()
```
The program runs infinitely, so you have to press `^C` to stop it, and it raises:
```
Exception ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
    t.join()
  File "/usr/lib/python3.6/threading.py", line 1056, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
KeyboardInterrupt
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads

Thread 0x00007f07e3866700 (most recent call first):
  File "segfault.py", line 4 in <listcomp>
  File "segfault.py", line 4 in <lambda>
  File "/usr/lib/python3.6/threading.py", line 864 in run
  File "/usr/lib/python3.6/threading.py", line 916 in _bootstrap_inner
  File "/usr/lib/python3.6/threading.py", line 884 in _bootstrap

Current thread 0x00007f07e53a0740 (most recent call first):
Aborted (core dumped)
```
It seems Python wants to print a nice traceback message for KeyboardInterrupt, but the spawned thread constantly steals the lock for stdout, so Python just breaks.
RPN calculator in lua
Tags: lua
Published: 2020-02-24 17:20:38

---
title: RPN calculator in lua
published: true
description: RPN calculator lua
tags: lua
---

Even though I am old and well into my career I still love to learn. A problem that I saw today is a great learning problem.

There is a lot to gather from writing a small RPN calculator. RPN stands for reverse polish notation. See here if you have no clue what that is.
https://en.wikipedia.org/wiki/Reverse_Polish_notation

My code is below. I used lua but the ideas are universal really and can be implemented in any language.


```lua
--[[
super simple stack, uses table functions built into lua
see here: https://www.lua.org/pil/19.2.html
]]--
local stack = {}
function stack_push(s,val)
        table.insert(s,val)
end
function stack_pop(s)
        return table.remove(s)
end

--[[
take value/operation from input
use the stack to perform the operation
]]--
function take(input,stack)
        -- get a value from input
        local op_or_value = table.remove(input,1)
        -- check if this is a number or not
        if tonumber(op_or_value) ~= nil then
                print("pushing number: " .. op_or_value)
                stack_push(stack,tonumber(op_or_value))
        elseif op_or_value == "+" then -- handle the plus operation
                local v1 = stack_pop(stack)
                local v2 = stack_pop(stack)
                print("v1 and v2: " .. v1 .. " "  .. v2)
                local res = v1 + v2
                stack_push(stack,res) -- put the value back on the stack
        end
end

local input = { "9", "10", "+" }

take(input,stack)
take(input,stack)
take(input,stack)

for i,v in ipairs(stack) do
        print(v)
end
```

The way I am solving the problem in the larger picture is I am taking input from an array and using a stack. You read the next item from the input and do something with it.

If the item is a number you need to store it somewhere and I am using a stack for this.
If the item is an operation (plus,minus,times,etc...) then you need to perform that operation. Since all of the operations I mentioned have two arguments, you pull those two values from the stack and perform the operation.

The final step is you push the result back on the stack. You do this step so that the next operation could use the result as a value.

I only implemented the "+" operation but the other operations would be similar.

Keep learning!
Open source project
Tags: github, code, opensource, severless
Published: 2020-02-24 17:11:32

So here is the big news! Three projects from Formula coming open source today based on my work with Formula - Universal Code Editor! 



Postagem do blog [em português]:

https://vtnorton.com/2020/02/24/3-projetos-serveless-agora-com-codigo-aberto/



The blog post [in english]:

https://vtnorton.com/en/2020/02/24/3-new-opensource-projects/



Check it out:

https://github.com/vtnorton/Formula.Newsfeed

https://github.com/vtnorton/Formula.Releases

https://github.com/vtnorton/Formula.Feedback
Struct Instruct
Tags: structures, methods, functions, swift
Published: 2020-02-24 17:09:59

One way to create a new type in Swift is by defining a structure, which is often called a struct. A struct is a way of grouping values of other types together. A struct is a better way to define data rather than declaring a series of variables because doing the latter would result in one having to access different arrays possibly with the same index. A struct is a new type, therefore it should begin with a capital letter. Properties should begin with lowercase letters to distinguish values from types, facilitating the reading of the code. I was listening to Coding with Chris on YouTube the other day and he mentioned that a method is the old way of referring to a function. Basically, they are the same… when you think method, think function.
How could I make a secure site?
Tags: beginners, php, security, career
Published: 2020-02-24 17:02:35

Hi guys, I want to create a site, my first one. I already have some experience with this, but I've never had a public one. I want a basic site, with a login/up system and some basic lessons from some school subjects. I want to know how can I can make it safe to use, keep your data in and make some payments. I basically want an example of this kind of stuff, where can I find a tutorial or some simple examples that will make me develop it in a safe way. Thanks :D!
AutoTranslation from Python to Javascript in Jupyter
Tags: jupyter, beakerx, python, javascript
Published: 2020-02-24 16:15:31

Today, we are going to think about how to bridge the data to different kernel. BeakerX project is quite useful as an extension of Jupyter notebook in order to use various kinds different languages which are based on Java. Therefore, when I have some chances to learn other languages, I can easily learn it from Jupyter notebook. It supports Clojure, Groovy, Java, Kotlin, R, SQL, Scala:

![BeakerX](https://dev-to-uploads.s3.amazonaws.com/i/0kotz4qbjhcnwmt6ep4y.png)

This extension also gives a way to bridge between different kernels for exchange of the data, called AutoTranslation (refer: https://github.com/twosigma/beakerx).

Firstly, I generate random histogram data in Python. Then, we use beakerx data holder to save them. Secondly, we are going to use them for showing in amCharts.

Here are whole source code which you can copy & paste. However, you should install BeakerX for your Jupyter. Please, read the instruction in https://github.com/twosigma/beakerx for more information.

{% gist https://gist.github.com/hkmoon/8bbb650103eb3c7cd7a09fbecd27cd62 %} 

Happy coding!
Undefined Behavior of Terminal
Published: 2020-02-24 17:02:27

Hi guys,
During writing code, we got irritated when we stuck at some problem and try to find the solution on the internet but can't find it.I am here with a problem faced by my friend.

the problem is during running code in a terminal the terminal gets crashed just after running it without entering any input and shows an extension after compilation is **EXE.APC.VIR** in **vs code**.

This is due to the terminal is set by default in command prompt.
step 1:- go to the terminal window and click the window navigator where **"code"** is written in the top right of the terminal and click "select default shell"
step 2:- select **Powershell** as default in the next window or popup.
and then run your program you are now getting **.exe** file and code works fine.
Agente do GitHub Actions 
Tags: github, actions, mvpbr, mvpbuzz
Published: 2020-02-24 16:59:15

Já faz algum tempo que a Microsoft comprou o GitHub, e ao contrário do que muitos pensavam, muitas melhorias surgiram. Entre elas, a principal acho que é o GitHub Actions.

# Oque é
O GitHub Actions é a plataforma do GitHub para automações principalmente de CI/CD. 
A Microsoft já possui a um bom tempo uma plataforma de CI/CD, chamada Azure Pipelines, que faz parte da Stack do [Azure DevOps](https://dev.azure.com). O Actions, basicamente é um fork do Azure Pipelines, e a partir daí conta com suas particularidades. Você pode notar por exemplo, que a estrutura dos Scripts são diferentes.

# O Agente
Para a execução de seu pipeline, se faz necessária a utilização de um agente. Por padrão, o GitHub fornece para nós, agentes hosted, que podemos utilizar em nosso processo, e os agentes são disponibilizados nas seguintes plataformas:
- Windows
- Linux
- Mac

O único "*problema*" de utilizar o agente fornecido, é que se você precisar de algo muito especifico, pode ser que você não consiga utilizá-los, por exemplo, você quer compilar uma aplicação VB6, é muito pouco provável que você tenha essa opção nos agentes do GitHub. 
Por isso, você pode precisar de um agente "*auto hospedado*" ou "*self-hosted*".

# Agente Self-Hosted
Este é um modelo, onde você instala o agente no seu próprio ambiente, permitindo a execução de cenários específicos, ou mesmo a realização de deploys em ambiente On Premisses.
A configuração desses agentes, é bem simples, para isso, ao acessar o seu repositório no GitHub, deve seguir os seguintes passos:
1. Clicar em Settings
2. Clicar no menu Actions
3. Clicar em Add Runner

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

Após essas opções, será exibida uma tela, onde você recebe informações sobre qual a plataforma que deseja instalar, e como deseja fazer.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v5yziu7fgz07j990j8xm.png)

Após a instalação, será exibido o agente e o seu status na tela, e já poderá utilizar em seus pipelines.

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

Quer acompanhar essa instalação no detalhe? Assista meu vídeo sobre o tema logo abaixo
{% youtube wL0Tfa2t8To %}
I've published a collection of best practices for web application developers
Tags: codequality, reference, architecture, typescript
Published: 2020-02-24 16:42:31

---
title: I've published a collection of best practices for web application developers
published: true
description: The recommendations are based on real-life experience, enabling teams to consistently deliver high-quality products, be more productive and less frustrated. Topics range from architecture to code formatting.
tags: #codequality #reference #architecture #typescript
---

Are you looking to level-up your skills and create applications faster, with fewer bugs, in a maintainable way? I think you'd appreciate this new [best practices document](https://thekarel.gitbook.io/best-practices/) available on GitBook. It's written for small to medium-sized teams working on non-trivial, long-life enterprise applications using TypeScript or JavaScript.

> [Pragmatic recommendations based on clean coding principles for teams working on TypeScript/JavaScript web application.](https://thekarel.gitbook.io/best-practices/)

I firmly believe that successful teams have a robust, detailed set of best-practices from the very beginning. Making things up as we go is not enough. Figuring out the answers to problems as they happen is wasteful and reactive. A solid baseline, on the other hand, provides confidence and productivity to the team.

You only want to worry about problems that are truly unique to you and your product. I think one way to do that is to pick up an off the shelf reference and adapt it to your situation.

The recommendations are all based on real-life experience: these are the ones that worked well in multiple projects, with diverse teams and products. The ideas themselves [are not new](https://thekarel.gitbook.io/best-practices/resources/resources); what I've tried to do is to present them pragmatically, in the context of modern enterprise web app development.

> Topics include:
> * Principles
> * Architecture
> * Naming
> * TypeScript
> * Monorepo
> * Monolith
> * Versioning
> * Code formatting
> * Folder structure
> * Configuration
> * Logging
> * Testing: E2E, integration, unit tests
> * Using Git
>
> [and more](https://thekarel.gitbook.io/best-practices/)

Hopefully, the synergy of the ideas leads you into the "Pit of Success": to be able to consistently deliver high-quality products, be productive and less frustrated in your day to day job.

You can read the GitBook at https://thekarel.gitbook.io/best-practices/

I have been working on this collection for some time and keep it up-to-date with the latest ideas, insights and remarks from the developer community. Please reach out if you have any comments: I'd appreciate your feedback. [PRs are welcome](https://github.com/thekarel/best-practices) on GitHub!
ara issue of the week
Tags: showdev, contributorswanted, android, kotlin
Published: 2020-02-24 16:38:22

Well I am back again with more opportunity's for contribution
{% github https://github.com/FultonBrowne/Ara-android/issues/206 %}

if like my work and want to see ara grow please give ara a star, give me a follow, or [buy me a coffee](https://www.buymeacoffee.com/28EcqNL)

I also have some computers for sale to support my project

https://www.ebay.com/itm/153834406902

https://www.ebay.com/itm/153834910618
🙊Tech Girl At Work: 🤬What she says VS what she really means
Tags: tech, humor, developer, meetings
Published: 2020-02-24 16:27:06

👋Hello, I'm Eleftheria, an app developer, master student, content creator, and chocolate lover

In this video you'll watch: What tech people say VS what they really mean. Enjoy :)


😎Top 3 list:
- How to stay motivated | A developer's edition | @BatsouElef: https://youtu.be/qMvEtb5OxNo
- How to be a Better Problem Solver | Tips and solutions: https://youtu.be/dELt7yKIxIA
- Simple Tips to Build a Personal Brand as a Developer (+ personal examples): https://youtu.be/7s0o1gi0iP0

🥰If you liked this video please share

🍩Would you care about buying me a coffee? You can do it here: [paypal.me/eleftheriabatsou](paypal.me/eleftheriabatsou) but If you can't that's ok too!


**************************************

🙏It would be nice to subscribe to my [Youtube](https://www.youtube.com/c/EleftheriaBatsou) channel. It’s free and it helps to create more content.

🌈[Youtube](https://www.youtube.com/c/EleftheriaBatsou) | [Codepen](https://codepen.io/EleftheriaBatsou) | [GitHub](https://github.com/EleftheriaBatsou) | [Twitter](https://twitter.com/BatsouElef) | [Site](http://eleftheriabatsou.com/) | [Instagram](https://www.instagram.com/eleftheriabatsou/)
The Building an Indie Business Podcast- Time Spent Listening as a Metric for Your Podcast
Tags: podcast, startup
Published: 2020-02-24 16:19:28

In this episode I discuss a better metric to track for a podcast Time Spent Listening. I go over why TSL is a better metric, how to find it, what you can do with the information of TSL, how to get TSL to become a standard metric, why downloads is used, and problems with TSL

https://overcast.fm/+RG5g-ds-g

Survey for the podcast: https://alex4814.typeform.com/to/cD38zZ
[Episode Page](https://baib-podcast.com)
[Revenue Research](https://revenueresearch.co/)
Devart Introduced The New Version of Its Flagman Solution — dbForge SQL Complete v.6.4
Tags: sqlserver, sql, database, debugging
Published: 2020-02-24 16:13:48

---
title: Devart Introduced The New Version of Its Flagman Solution — dbForge SQL Complete v.6.4
published: true
description: Devart dbForge team promptly reacted to feature requests and rolled out the new version of dbForge SQL Complete v.6.4. The main improvements affected code debugging.
tags: SQLServer, SQL, database, debugging
---
*Devart dbForge team promptly reacted to feature requests and rolled out the new version of dbForge SQL Complete v.6.4. The main improvements affected code debugging.*

![dbForge SQL Complete](https://blog.devart.com/wp-content/uploads/2020/02/copy-from-grid-2.png)

Devart, a recognized vendor of professional database management software for developers and DBAs, released the new version of its flagman solution [dbForge SQL Complete for SQL Server](https://www.devart.com/dbforge/sql/sqlcomplete/). The most notable feature of the recent release is the newly introduced debugging functionality designed to take away the pain of combing through scripts to find errors and grant the possibility to debug code directly in the IDE.

The full list of dbForge SQL Complete updates includes:

**1) Code Debugger for SQL Server.** The new feature allows investigating the run-time behavior of database objects and locating logic errors. Users can also benefit from the support for step-by-step execution, call stack browsing, breakpoints, and watches. The feature will come in handy since Transact-SQL debugger was deprecated in Microsoft SQL Server Management Studio 18.0

**2) Copying results from the Aggregate Panel.** In response to many requests, the vendor has added the opportunity to copy the result values right from a grid.

**3) Modified HELP for Command-line.** Answering the user calls, Devart has modified the command-line HELP information to provide more clarity and user-friendliness.

**dbForge SQL Complete** is an advanced solution for SQL database development, management, and administration. The tool helps to write, beautify, and refactor SQL code while boosting overall productivity. 

To learn more about new SQL Debugger, please watch this video — https://youtu.be/ZXSHlnnLjEM 

**About Devart**

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.
For additional information about Devart, visit https://www.devart.com/.