teleren/devto huggingface dataset:
Avoid Test Delays And Speed Up Your Development Cycle by Mocking Callbacks
Tags: programming, ruby, testing
Published: 2023-11-05 16:31:24

---
title: Avoid Test Delays And Speed Up Your Development Cycle by Mocking Callbacks
date: 2022-06-01 00:00:00 UTC
tags: programming,ruby,testing
canonical_url: http://calebhearth.com/mocking-callbacks
published: true
---

Mocking is one way to achieve isolation in tests. It is the practice of using a fake object in place of a collaborator object. In the simplest case, a mock will accept a method call, do nothing, and return a value (usually nil in Ruby). Mocks can also stub methods to return realistic values. They can provide static responses or use arguments to calculate a return value. It’s often as simple as specifying the expected method arguments and a response.

 

A simple stubbing might look like this:

 

```
stubs { mailer.deliver("a message") }.with { "canned response" } mailer.deliver("a message") # => "canned response" 
```

 

But stubbing methods isn’t always so straightforward. When a Ruby method takes a block to call later, it’s harder to identify whether, when, and how to call that block. It’s not as easy as the method mock above that can discard or do minimal work with arguments. Blocks often have side effects that may be important and that we need to assert against.

 

When a Ruby method takes a...

[http://calebhearth.com/a/mocking-callbacks](Read%20more)
[Discusión]¿Porqué usar un Framework de ORM?
Tags: discuss, database, programming, node
Published: 2022-06-01 00:13:59

Para adentrarnos en la discusión del porqué es que deberíamos utilizar un Framework de ORM, primeramente debemos empezar por acotar que es lo que hace dicho marco.

> Un ORM te permite convertir los datos de tus objetos en un formato correcto para poder guardar la información en una base de datos (mapeo) creándose una base de datos virtual donde los datos que se encuentran en nuestra aplicación, quedan vinculados a la base de datos (persistencia).

_Luis del Valle Hernández, ¿Qué es un ORM?, https://programarfacil.com_

Es decir, es una herramienta que ayuda a transformar la información que va de la aplicación que estamos desarrollando hacia la base de datos y viceversa.

---

### ¿Cómo me conectaba a la base de datos?

> Recuerdo esos tiempos cuando usaba PHP en los que usaba algún cliente de base de datos para hacer una conexión y en la que tenía escribir los comandos SQL directamente para llevar a cabo las operaciones que requería.

> En ese momento, recibía la información a través de un formulario de HTML y directamente con el método POST de HTTP buscaba las variables en PHP y las concatenaba al comando

> Sólo recuerdo que el temor a un SQL Injection fue lo que hizo que cambiara la forma en la que lo hacía.

---

Ahora bien, discutiendo esto en términos de rendimiento, por sí sólo usar un ORM no genera una desempeño más rápido en las operaciones de la base de datos como tal y tampoco es que simplifique el código de programación qué se debe utilizar.

Sin embargo, ayuda a plasmar el modelo que el negocio utiliza de tal suerte que se obtiene una implementación orientada a objetos y que resulta conveniente a la hora de realizar consultas en la información. Además, ayuda a simplificar el trabajo que los programadores tienen que llevar a cabo al ser una capa que genera objetos y propiedades independientemente del motor gestor de base de datos.

Incluso, hay veces en las que los ORM vienen con herramientas para dar paso a la gestión de migraciones de la base de datos y él cómo alimentarlas a través de una interfaz de línea de commandos.

En conclusión, la perspectiva de mantener una coherencia en el modelo de negocios y feliz al programador es lo que impulsa la implementación de un ORM.

Es por eso que lo recomiendo si el proyecto en el que estás trabajando es un producto de software y en el que varios integrantes trabajan o están a la espera de hacerlo.
A Blind Web Developer's Portfolio
Published: 2022-06-01 00:09:33

---
title: A Blind Web Developer's Portfolio
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

I am a blind web developer by hobby, accessibility engineer by occupation, and I just recently published the start of my portfolio. Would love to communicate with other developers and get feedback. View my project and blog at https://www.chriswestbrook.com. Leave a comment here or on my blog.
you.sh
Tags: tools, automation, scripting, shell
Published: 2022-11-09 16:04:18

---
title: you.sh
published: true
cover_image: https://jhall.io/images/bn-shell-script-name-tags.jpg
date: 2022-06-01 00:00:00 UTC
tags: tools,automation,scripting,shell
canonical_url: https://jhall.io/archive/2022/06/01/you.sh/
---

Word from a former Hulu employee is that when they would notice someone doing something tedious and manual that could be automated, they would name the automation script after them.

`corey.sh` or `valarie.sh`, etc.

I don’t suppose this is a very adviseable practice, as it’s not at all clear what `valarie.sh` does… But I think it can make for a fun game:

_What would your script do?_

Let me know. And if I get some good responses, I’ll share them in the future :)

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Database Migrations (6.2)
Tags: rails, beginners, tutorial, discuss
Published: 2022-05-31 23:32:59

Recently found out how to migrate/alter applications database.

Let's take a look at the contents of our new migration file:

```
class CreateArticles < ActiveRecord::Migration[7.0]
  def change
    create_table :articles do |t|
      t.string :title
      t.text :body

      t.timestamps
    end
  end
end
```

The call to `create_table` specifies how the `articles` table should be constructed. By default, the `create_table` method adds an `id` column as an auto-incrementing primary key. So the first record in the table will have an `id` of 1, the next record will have an `id` of 2, and so on.

Inside the block for `create_table`, two columns are defined: `title` and `body`. These were added by the generator because we included them in our generate command (`bin/rails generate model Article title:string body:text`).

On the last line of the block is a call to `t.timestamps`. This method defines two additional columns named `created_at` and `updated_at`. As we will see, Rails will manage these for us, setting the values when we create or update a model object.
Added new Frameworks/Libraries.
Tags: readme, github, markdown
Published: 2022-05-31 23:13:38

🧰 Frameworks and libraries
Arduino BlissfulJS Bootstrap Cordova Electron Express.js Flutter GitHub Actions Jest JUnit Keras Material Design Symfony NumPy Pandas PHPUnit Pytest React Symfony SonarLint Symfony SymPy TensorFlow Wordpress WPF (.Net)
Day 53: Hello, TypeScript!
Published: 2022-05-31 22:48:54

Hi!
Today I got started with typescript and I was going through the first two chapters of the TypeScript Handbook. I like the idea behind typescript and the intellisense and everything but I think the way types are implemented doesn't look that good as in languages like Java,  but I will get used to it as I plan to use it in my next project. I' m currently stuck at the concept of Typescript Enums as I found them confusing but maybe that's has to do with the fact that I'm so tired I'll take a rest and continue tomorrow.
The plan for tomorrow is To continue learning as I expect a new project coming up that will include `GraphQL` `Prisma` and so much new stuff to learn but we will see how it goes

Signing off...
WebPageTest LIVE! Special Edition at 10am PT/5pm UTC on June 1!
Tags: frontend, webdev, webperf, javascript
Published: 2022-05-31 22:03:06

Join us on WebPageTest LIVE! at 5pm UTC on June 1, 2022 (Wednesday) for a VERY exciting edition. You're not going to want to miss this one...

Set your reminder now!

📺 [Twitch](https://www.twitch.tv/webpagetest) OR [Youtube Live](https://www.youtube.com/channel/UC5CqJ9V7cQddZDf1DKXcy7Q
)

📅: June 1, 2022

🕙 10am PT/ 1pm ET/ 5pm UTC ([timezone convertor]((https://dateful.com/convert/pst-pdt-pacific-time?t=10am&tz2=UTC)))

🎤 [Tim Kadlec](https://twitter.com/tkadlec),  [Scott Jehl](https://twitter.com/scottjehl) and [Jeena James](https://www.linkedin.com/in/jeenajames/)
Week 6 - Sum Two Numbers App
Tags: react, hook, usestate, events
Published: 2022-05-31 21:22:06

---
title: Week 6 - Sum Two Numbers App
published: true
description: creating small UI component to build large scale projects
tags: reactjs, hook, useState, events
cover_image: https://i.imgur.com/4iE3ydT.jpg
key: 1
series: React Curve
---

## Welcome to Week 6 of React Curve

Hello developer!, glad to see you again.

This is a react-curve, open source project where I can share and start creating small UI components in the way I understood the concepts to build large scale projects .

----------------

## Sum Two Numbers App

![Sum Two Numbers app](https://i.imgur.com/rWOzyea.gif)
This week we created a Sum Two Numbers app. The user enter two numbers in a form and result of the summation is shown in react.

To create a SumTwoNum component; We have to :

* Create two states that hold the value of each number.
* Create a state that holds the summation value with an initial value equal to zero.
* Create a calculate function that calculates and updates the summation.
* Create two inputs and handle events for each number.
* onClick submit button, calculate method is fired and do summation.

## Code
```react
import React, {useState} from 'react';

const SumTwoNum = () => {
    const [number1, setNumber1] = useState();
    const [number2, setNumber2] = useState();
    const [summation, setSummation] = useState(0);
  
    function calculate() {
        setSummation(number1 + number2);
    }

    return (

       <div>
            <h2>Sum Two Numbers</h2>
            <input
                placeholder="First Number"
                type="number"
                value={number1}
                onChange={(ev) => setNumber1(+ev.target.value)}
            />
            <input
                placeholder="Second Number"
                type="number"
                value={number2}
                onChange={(ev) => setNumber2(+ev.target.value)}
            />
            <br />
            <button onClick={calculate}>Sum Two Numbers</button>
            <p>Summation  : {summation || "0"}</p> 
        </div>
    );
}

export default SumTwoNum;

```
### Conclusion
Thank you for reading and any contribution is more than welcome in the threads below!

[Live Preview](https://this-react-curve.vercel.app/summation)
[Source Code](https://github.com/this-mkhy/react-curve)
[Solved] Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch
Published: 2022-05-31 21:04:35


### Problem:

Running into the following error when trying to use the `akhileshns/heroku-deploy` GitHub Action in a GitHub Actions workflow:

```
error: failed to push some refs to 'https://git.heroku.com/nextjs-github-actions-heroku.git'

    Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch.
    (If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml.
    Specifically, the error was: Error: Command failed: git push heroku HEAD:refs/heads/master

```

### Solution:

I was able to solve this issue by changing the version of the `akhileshns/heroku-deploy` GitHub Action from `3.12.12` to `3.7.8`. Also, you might have to remove the `12.x` and `16.x` node versions from the `node-version` array if those versions are failing when the GitHub Actions workflow completes. Here is the full workflow yaml file that resolved this issue:

```
name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v3
    - name: Deploy to Heroku
      uses: akhileshns/heroku-deploy@v3.7.8
      with:
        args: deploy --dir=build --prod
        heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
        heroku_app_name: 'nextjs-github-actions-heroku'
        heroku_email: '<enter_your_email>@gmail.com'
```

## Conclusion

Thanks for reading this blog post!

If you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.

If you found this article helpful please share it and make sure to follow me on [Twitter ](https://twitter.com/Shehan_Atuk)and [GitHub](https://github.com/ShehanAT), connect with me on [LinkedIn](https://www.linkedin.com/in/shehan-atukorala-8631491a5/) and subscribe to my [YouTube channel](https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ).
Why you should consider JavaScript as a general scripting language?
Tags: javascript, devops, programming, ops
Published: 2022-05-31 20:51:27

Although the name may be confusing, JavaScript is not the scripting language of Java. Often considered as a tool to build applications in your web browser, JavaScript is a versatile language offering many possibilities: frontend, backend, and many others… Often neglected for this aspect, we will make you discover why JavaScript can also be considered as a language of choice to design your maintenance and server administration scripts, making it a general purpose scripting language.

## Reason #1: Because you already know this language
Unlike other dedicated scripting languages such as Ruby, or Bash, most developers have at least minimal knowledge of JavaScript. In fact, anyone who has dabbled in web programming has already used this language. If you write your maintenance scripts in JavaScript, you will have no trouble sharing them with your colleagues.

## Reason #2: Because it runs everywhere
Moreover, it is a language that works on most platforms: personal computers as well as servers, Windows, Mac as well as Linux. With JavaScript, there is no need to write a different version of your code on your workstation.

## Reason #3: It is supported by all text editors and IDEs
Even if your main programming language is not JavaScript, most code editors and IDEs offer syntax highlighting and autocompletion of JavaScript code. Adding JavaScript code to the side of your main code will probably not be a problem for you, either in terms of implementation or management.

## Reason #4: It’s an efficient language
Although it has often had a bad reputation because of its lack of optimization in some implementations, today’s JavaScript is fast, with top-level concurrency support. If you need to manipulate large amounts of data or make many network calls in parallel, JavaScript will be able to provide you with an efficient and elegant solution, without wasting time, especially thanks to the use of promises.

## Reason #5: It’s a popular language
In addition to being known by a large number of users, it is also a popular language with an active community on the web. Thus, you will have much less trouble looking for help on code written in JavaScript, than in a dedicated scripting language for your server.

## Reason #6: It has a large ecosystem
Unlike other languages, such as Bash, JavaScript has a fairly large ecosystem of packages and libraries. If you need to perform a particular calculation or processing, it is very likely that someone has done it before you, and you can find a code library online that you can simply add to your script to get the desired result.
Framer | Made with React JS
Published: 2022-05-31 20:45:19

![Framer | Made with Javascript | React JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1653489383/large_framer_made_with_react_js_bc076f4e29.png "Framer | Made with Javascript | React JS")


### Design beautiful websites in minutes

> Design and publish websites faster than ever before. Meet the new Framer, featuring breakpoints, effects, CMS, styles, and so much more.
> 
> You’ve never made a website this fast before. Really.
> 
> No more complicated workflows. Just design and publish. That’s it.
> 
> Design. Publish. Done.
> Stop rebuilding your designs from scratch. In Framer, everything you put on the canvas is ready to be published on the web.
> 
> Simplify your stack.
> No dependencies on front-end services. No more tickets to get engineers involved. No more waiting on your builds to finish. Hit publish and you’re live in just seconds.
> 
> Easy documentation.
> With your components in Framer it’s easy to build rich docs around it. Save time and money on integrating an extra service or app.
> 
> Already got designs in Figma? Copy, paste, and publish with Framer.
> 
> Blazing fast. Incredible output. Tons of integrations.

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [Framer on Twitter](https://twitter.com/withjavascript/status/1531736255117021185?s=20&t=v-CjIlLuJxavnEVkiNpx5Q)
 |
| Medium | [Framer on Medium](https://medium.com/@madewithjavascript/framer-made-with-react-js-2544be8a7dd4)
 |
| Facebook | [Framer on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid0KVBQNVhVhvacQjKKRhrHXbSRPX8sYHp3FZXdrEY313uVRoXmqsfrGuQ5MzDodbWml)
 |
| Tumblr | [Framer on Tumblr](https://madewithjavascript.tumblr.com/post/685799935919243268/framer-made-with-react-js-design-beautiful)
 |
| LinkedIn | [Framer on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6937502098607542272)
 |
| Pinterest | [Framer on Pinterest](https://pin.it/1Wag19l)
 |


Filled Under:

 - [Made with Javascript](https://madewithjavascript.club)    
 - [Made with React JS](https://madewithjavascript.club/categories/react-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Arrays are major key
Tags: javascript, beginners, programming, discuss
Published: 2022-05-31 20:27:32

You can read the title and can walk away with that. However that would be an injustice to just how great and pivotal arrays are. It’s Emmanuel here, currently going to Flatiron School NYC. I have learned to appreciate arrays and how essential they are to a JavaScript and other languages.

Why would arrays be major key? It’s all about the functionality. Arrays are essentially lists that can hold anything. You can have string, numbers, Boolean, other arrays, objects, and/or variables in a array. What you can do with your list of things is what brings it all together. There are functionality call forEach()or map() which will go through each item in your array and you can do what ever you want to do. You can filter or find specific items in your Array which can help with huge databases. Imagine getting a huge list of names and you want to know all the names that start with J. Filter would be your best friend. And with using that you can then make a new list or delete it from the original list. There is so much to do. When you add objects, another topic for another day, you have everything. 

I am just really impressed and intrigued to what possibilities to what a generate from just know how to use array and its related functions. Check back with me in July because that is when I’ll be finished.
pyenv no module named '_sqlite3'
Tags: python
Published: 2022-05-31 19:58:53

---
canonical_url: https://waylonwalker.com/til/pyenv-no-sqlite3/
published: true
tags:
- python
title: pyenv no module named '_sqlite3'
---

I've been trying to adopt pyenv for a few months, but have been completely blocked by this issue on one of the main machines I use.  Whenever I start up ipython I get the following error.

```
ImportError: No module named '_sqlite3
```

I talked about why and how to use pyenv along with my first impressions in [this post](/til/pyenv-first-impressions)

## pyenv/issues/678

According to [#678](https://github.com/pyenv/pyenv/issues/678) I need to install `libsqlite3-dev` on ubuntu to resolve this issue.

## install libsqlite3-dev

`libsqlite3-dev` can be installed using apt

```bash
sudo apt install libsqlite3-dev
```

## But wait....

When I make a fresh env and install ipython I still get the same error and I am still not able to use ipython with pyenv.

```python
ImportError: No module named '_sqlite3
```

## re-install python

After having this issue for awhile an coming back to [#678](https://github.com/pyenv/pyenv/issues/678) several times I realized that
`libsqlite3-dev` needs to be installed while during install.

```bash
pyenv install 3.8.13
```

I think I had tried this several times, but was missing the `-y` option each time.  You gotta read errors like this, I am really good at glossing over them.

![pyenv-install-exists](https://screenshots.waylonwalker.com/pyenv-install-exists.webp)

## Let's never have this issue again.

When you spend months living with little errors like this and finally fix it, its good to make sure that it never happens again.  Whenever I start a new ubuntu machine I run an ansible playbook that does all the setup for me.  I added `libsqlite3-dev` to my core install in [64c85ca](https://github.com/WaylonWalker/devtainer/commit/64c85ca1b38eefe95dfc8723c1e83e8e334cf4dc) now it will be on all of my machines and not break again.
Query All Features from a Feature Service
Tags: arcgis, javascript, geodev
Published: 2022-05-31 19:34:18

---
title: Query All Features from a Feature Service
published: true
description: When querying an ArcGIS Feature Service, there is typically a maximum number of features (records) that will be returned from any query -- usually set to 1000. Normally, if you wanted to query for all the features in the service, you would need to make multiple REST calls to get them all. Learn how to use the package query-all-features to do this with only one REST call.
tags: arcgis,javascript,geodev
canonical_url: https://gavinr.com/query-all-features-from-feature-service/
---

When querying an ArcGIS Feature Service, there is typically a maximum number of features (records) that will be returned from any query – usually set to 1000. If you want to query for **all** the features in the service, ArcGIS REST JS does not currently do this (see [this discussion](https://github.com/Esri/arcgis-rest-js/issues/690)) - you’ll need to make multiple REST calls to get them all. Use the package [query-all-features](https://www.npmjs.com/package/query-all-features) to do this.

First install the package:

```bash
npm install query-all-features
```

Then use it in your code. It takes as input the same object as the [queryFeatures endpoint of ArcGIS REST JS](https://developers.arcgis.com/arcgis-rest-js/api-reference/arcgis-rest-feature-service/queryFeatures).

```js
import { queryAllFeatures } from "query-all-features";

queryAllFeatures({
    url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"
}).then((results) => {
    console.log('results', results);
}, (err) => {
    console.error('err', err);
});
```

You can also use it in [NodeJS](https://github.com/gavinr/query-all-features#node-js), in the [browser via ES Modules (via CDN)](https://github.com/gavinr/query-all-features#browser---es-modules-via-cdn), and in the [browser via a script tag](https://github.com/gavinr/query-all-features#browser---script-tag-via-umd-cdn). Here's a full code sample in action:

https://codepen.io/gavinr/pen/ExQYegd