teleren/devto huggingface dataset:
Tracking dropped database objects in PostgreSQL
Tags: postgres, disaster, recovery
Published: 2022-05-04 18:06:00

Ever been in the situation where you need to perform a point-in-time recovery to recover a dropped database object and you need to find the exact time the object was dropped?. 
Finding the exact time is not always easy, most times it is all about guesses, we have all been there.
This is why I wrote a simple extension [pg_drop_events](https://github.com/bolajiwahab/pg_drop_events) some times back.

**pg_drop_events** is a wrapper which utilises PostgreSQL's event triggers, wraps around the dropping statement and logs the info into `pg_drop_events` table.

A sample data looks like below:
```
postgres=# SELECT pid, usename, query, xact_id, wal_position, objid, object_name, object_type, xact_time FROM pg_drop_events;
  pid  | usename   |             query              | xact_id | wal_position | objid | object_name | object_type  |             xact_time
-------+-----------+--------------------------------+---------+--------------+-------+-------------+--------------+-------------------------------
 54630 | bolaji    | DROP TABLE t.t3                |   25184 | 1/A266B090   | 51293 | t.t3        | table        | 2022-05-04 17:16:32.913969+00
 54633 | bolaji    | ALTER TABLE t.t1 DROP COLUMN a |   25185 | 1/A266BBF8   | 51287 | t.t1.a      | table column | 2022-05-04 17:16:39.033796+00
 54638 | postgres  | DROP SCHEMA t CASCADE          |   25186 | 1/A266BEC0   | 51287 | t.t1        | table        | 2022-05-04 17:16:56.094366+00
 54639 | postgres  | DROP SCHEMA t CASCADE          |   25186 | 1/A266BEC0   | 51290 | t.t2        | table        | 2022-05-04 17:16:56.094366+00

```

The info from `pg_drop_events` can be used to perform point-in-time recovery, well that is the aim of the extension, to aid point-in-time recovery. 

PostgreSQL provides various runtime config to perform point-in-time recovery. The full list can be found here [recovery target](https://www.postgresql.org/docs/14/runtime-config-wal.html#:~:text=server%20command%20line.-,20.5.5.%C2%A0Recovery%20Target,-By%20default%2C%20recovery)

Personally, I prefer using `xact_id` to perform point-in-time recovery of a dropped database object. I will talk about the reasons in the next chapter.
React Native-Theming support!
Tags: reactnative, theming, react, javascript
Published: 2022-05-04 17:39:32

Hello everyone, this is a follow up article for our new react native theming library, which now has an official YouTube video about it!

Youtube link: https://youtu.be/wW20AkwmGMk
Github link: https://github.com/KJ-GM/theme-csx


Thank you and enjoy!


## Example 

```js
// Styles
import { StyleSheet, T, appearanceHook } from 'theme-csx';

// Components
import { Text, View } from 'react-native';
import { Button } from '@components/atoms';

const DemoComponent = () => {
  // Theme switch
  const switchTheme = () => {
    appearanceHook.switch(
      appearanceHook.activeTheme === 'dark' ? 'light' : 'dark'
    );
  };

  return (
    <View style={T(styles.THEMED_CONTAINER)}>
      <Text style={styles.NORMAL_TEXT}>Hey, I am normal text</Text>

      <Text style={T(styles.THEMED_TEXT)}>Hey, I am themed text</Text>

      <Button text={'Switch theme'} onPress={switchTheme} />
    </View>
  );
};

const styles = StyleSheet.create({
  THEMED_CONTAINER: {
    flex: 1,
    backgroundColor: 'white',
    backgroundDark: 'gray', // backgroundDark prop was added to make it themeable
    alignItems: 'center',
    justifyContent: 'center',
  },
  NORMAL_TEXT: {
    fontWeight: 'bold',
    fontSize: 14,
    color: 'green',
  },
  THEMED_TEXT: {
    fontWeight: 'bold',
    fontSize: 14,
    color: 'black',
    colorDark: 'white', // colorDark prop was added to make it themeable
  },
});
```
HTML Color Codes
Published: 2022-05-04 17:31:00


**HTML color codes** may be represented in hexadecimal triplets; six-digit, three-bytes.
There is no informational difference between RGB and HEX colors.

![#ff0000](https://via.placeholder.com/15/ff0000/000000?text=+) **Red**
```diff
- #ff0000
- rgb(255, 0, 0)
```
![#00ff00](https://via.placeholder.com/15/00ff00/000000?text=+) **Green**
```diff
+ #00ff00
+ rgb(0, 255, 0)
```

![#0000ff](https://via.placeholder.com/15/0000ff/000000?text=+) **Blue**
```diff
  #0000ff
  rgb(0, 0, 255)
```

The [sRGB](https://en.wikipedia.org/wiki/SRGB "SRGB") uses 24 bits to specify a color and can produce 16,777,216 different color combinations.

![color-table-primary](https://i.imgur.com/tpBy4dD.png)
Restore lost commits - git reflog
Tags: git, webdev, reflog
Published: 2022-05-04 17:28:52

Let’s imagine you were working on your project, and you typed
```
git reset --hard HEAD~N
```
Then you tapped Enter ↩️ by mistake, maybe..

Basically this means, that you lost the last **N** commits, and right now you have a clean working tree. 

Don’t be afraid, there is a solution for this situation.

## Introducing git reflog

> The reflog is strictly local and isn’t part of the repository. It’s also not included in pushes, fetches, or clones. Git uses the git reflog tool to keep track of changes made to branch tips. It lets you go back to any commit, even if it isn’t referenced by any branch or tag

You can read more about reflogs in [Gitprotect](https://gitprotect.io/blog/how-to-use-git-reflog-reflog-vs-log/)

## So, how to restore a lost commit ?
To restore a lost commit, use
**_git reflog_** to see your local changes :
![git reflog](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ycng1ainq52cb3q7vkst.png)Here basically you can see the local logged actions by Git
Then, you can pick the SHA of the commit you want to go back to, and then run
```
git reset --hard e4dd6f6
```
or
```
git cherry-pick e4dd6f6
```
_Don’t forget that you could use `grep` with `git reflog` to search by a commit message or a branch name… 😉_
## That’s cool, but does git reflog have some drawbacks ?
Reflogs or reference logs are stored only on your machine, this means you cannot push or pull them from a remote repository.

And more importantly, they get expired after a while by **git-gc** (git garbage collector). 

The entries that have been expired are dropped, and the expiration time is taken from the configuration setting `gc.reflogExpire` (90 days by default)

You can read more about this [here](https://git-scm.com/docs/git-reflog)
## Demonstration
{% embed https://asciinema.org/a/490530 %}
Introdução ao Elixir
Tags: elixir, webdev, beginners, tutorial
Published: 2022-05-04 17:25:51

Olá, devs!
Decidi fazer esse post para compartilhar uma trilha de conhecimentos em Elixir seguindo o próprio _Getting Started_.

Caso não tenha o Elixir instalado em sua máquina, você pode dar uma olhada no post que escrevi sobre como [instalar o Erlang e o Elixir utilizando o asdf](https://dev.to/allefgomes/instalacao-do-erlang-e-elixir-com-asdf-no-ubuntu-5hnn).

Com o Elixir instalado, ganhamos três novos executáveis: `iex`, `elixir`, `elixirc`.

### IEX
Agora, abra um terminal e rode o comando `iex`. Isto irá abrir um shell interativo que poderá rodar comandos em Elixir.

![Exemplo de string em elixir](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nw3agso2kpu4xklsa2tz.png)

### ELIXIR
Também é possível rodar um script com o comando `elixir PATH_DO_ARQUIVO`. Nesse caso, a extensão do arquivo deve ser `.exs`, o que significa que esse arquivo é um script escrito em Elixir.

Para este exemplo, criaremos um simples arquivo chamado `ola_mundo.exs` e colocaremos o seguinte comando dentro do arquivo:

```elixir
IO.puts("Olá mundo!")
```

Após salvar, é só rodar o comando `elixir ola_mundo.exs` no terminal e verá um resultado igual ao abaixo:

![Rodando um script](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wer63sj6ddt7k2ox6rw.png)

### ELIXIRC
Por fim, temos o comando `elixirc` que irá compilar um arquivo `.ex` ou uma pasta que contenha arquivos `.ex` e irá gerar um `.beam` para cada módulo criado.
_Obs: Iremos entender melhor sobre módulo nos próximos posts._

Primeiro, iremos criar uma pasta chamada `primeiro_script` e dentro dela vamos criar o arquivo `ola_mundo.ex` que contém o código abaixo:
```elixir
defmodule OlaMundo do
  def run do
    "Olá Mundo"
  end
end
```
Também criaremos dentro da pasta `primeiro_script` uma pasta chamada `core` e dentro desta, criaremos o arquivo `sucesso.ex` que terá o seguinte código:
```elixir
defmodule Core.Sucesso do
  def run do
    "Sucesso!"
  end
end
```

Feito isso, teremos uma arquitetura de pastas e arquivos da seguinte forma:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vosqvf2on4mwdju3l81.png)

E dentro da pasta `primeiro_script` iremos rodar o comando que serve para compilar a pasta em que você está no terminal:
```bash
elixirc .
```
Se formos olhar agora, teremos arquivos com a extensão `.beam` que são os arquivos compilados.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ban2wdn0f3qw2tjyk4sk.png)

Para finalizarmos, podemos dar um `iex` dentro da pasta `primeiro_script` e chamar os módulos compilados e suas funções `run` para vermos o resultado.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v501mp9wy94cqy73j3ak.png)
 
Por hoje é isso, pessoal.
Te vejo no próximo post! :)
Create button to download image using HTML, CSS, and Javascript
Tags: html, css, javascript, incoder
Published: 2022-05-04 17:21:00

Hello friends, today in this blog you will learn how to create a button to download images using HTML, CSS, and Javascript. In our previous blog, we saw [how to create an input with a character limit in HTML, CSS, and Javascript](https://incoderweb.blogspot.com/2022/05/input-character-limit-with-counter.html). Now it's time to create a button for downloading the image. Earlier, I shared many projects related to [javascript](https://incoderweb.blogspot.com/search/label/Javascript), you can check if you want, and don't forget to check [HTML, CSS, and Javascript projects](https://incoderweb.blogspot.com/search/label/HTML%20CSS%20Javascript%20Mini%20Project).

You might have seen many tutorials or blogs where they say just add download Attribute to the link tag to download an image on click but it doesn't work properly, So today in this blog we will see how to create a button to download an image by using javascript.

In this design [button to download image], there are some images on the page, On the image, there is a download button as you can see in the image above. When you click on the image the image will be downloaded.

##You may like these:

- [Create a random quote generator](https://incoderweb.blogspot.com/2022/05/create-random-quote-generator.html)
- [Responsive Personal Portfolio design](https://incoderweb.blogspot.com/2022/04/responsive-personal-portfolio-design.html)
- [Create a Text to Speech Converter](https://incoderweb.blogspot.com/2022/04/text-to-speech-converter.html)
- [Create Tag Input Box](https://incoderweb.blogspot.com/2022/05/create-tag-input-box.html)

Javascript logic behind this download button, first we need to create a blob URL object of image URL. The image should be in the same directory, then create a link tag using javascript and click on the link by javascript.

Please Visit here to get [source code](https://incoderweb.blogspot.com/2022/05/create-button-to-download-image.html).
let var const - variables in js
Tags: javascript, beginners, react, es6
Published: 2022-05-04 17:03:27

## Variable

- variables are lable that references a value.
- variables are used to store information to be reference and manipulated in a computer program.
- variables holds information/data.
-  storing information.

```
let name = 'Manikandan';
    let        -> start with  //(let, var, const)
    name       -> variable identifier
    Manikandan -> information/data
    ;          -> end of the statement

```
## var
- var is function-scope.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0dypq0wmtka9st786dh.png)
-  Variables defined with 'var', redeclare and reassign is possible.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3ohzwwk9n2xclvt0fub.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/898y1vviwx2lpa2zmw6b.png)

## let
-  let is block-scope

-  Some lines of code will written in { } these parentheses, it 
-  is called block-scope.
-  block-scope Variable cannot be access outside the block.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d9rwkwnvrk9uj8ujtahy.png)

-  Variables defined with 'let', must be declare before use/assign value.
-  Once declare a Variable with 'let', after re-assign is possible but redeclare is impossible.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6xdadlpocueitzhmz7sq.png)

## const
- const is block-scope.
- variable define with 'const', cannot be redeclare and cannot be reassign.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/idvt9ac6p08m1o87gobq.png)
run python code in html files
Tags: javascript, python, webdev, html
Published: 2022-05-04 16:33:16


new framework let you run python codes in html tags
it is helpful for many usages maybe include a big python's libraries to use it in html files

---

## Use
- work with cdn link
- `<py-script> put python code in </py-script>`

<br>
<br>


---

##Example
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7tiomlkq22h5c55zyjqb.png)
<br>
<br>

https://pyscript.net
Day-80 Training At Ryaz
Tags: javascript, webdev, beginners, programming
Published: 2022-05-04 16:12:41

- Date:4/05/2022
- Day:Wednesday

Today, I started at about 11:00 am as I was in progress to complete the java script course and the project so, I started with the left over part firstly I started with the event loop JavaScript is a single-threaded synchronous programming language. It means that the main thread where JavaScript code is run, runs in one line at a time manner and there is no possibility of running code in parallel.after this I stared with promisifing and geolocation api Geolocation API is definitely one of the best known device integration APIs we have on the web, both thanks its usefulness as well as its age.Promises are  the only way APIs on the Web platform handle asynchronicity these days. after this I started with the project as there was error of not able to select the category of things we would put In the bidding so, today I was able to resolve this issue so, this way my day eneded up and I got to learn many new things.
All the things getting out of a motor
Tags: opensource, microservices, tutorial, luos
Published: 2022-05-04 16:09:00

This post is the follow-up of the Motors-in-robotics series. We will talk about rotation, speed, inertia, angular acceleration, force, heat, magnetic field, etc.

⏩ https://www.luos.io/blog/all-the-things-getting-out-of-a-motor
Some GORM Tips and Notes
Tags: go, gorm
Published: 2022-05-04 16:05:22

There are some tips and GROM's notes might prevent you debugging in front of laptop all day.

## Will not update the zero value
```go
type User struct {
  ID int
  Age int
}
// if user.Age is 6 in database originally 
user.Age = 0
db.Updates(&user)
```
You will find the age is not updated.

### How to solve

```go
db.Model(&user).Select("*").Omit("Role").Update(User{Role: "admin", Age: 0})
db.Model(&user).Update(map[string]interface{}{"role": 0})
```

### What is under the hood?

First, Most of generic in golang rely on [reflect](https://pkg.go.dev/reflect) package. Gorm use [reflect.IsZreo()](https://pkg.go.dev/reflect#Value.IsZero) to check if the field should be updated. [source code](https://github.com/go-gorm/gorm/blob/f92e6747cb12d5a5bc2bf7e0d76cb8e5f69cd637/callbacks/update.go#L165-L172)
Second, `0` is zero value to int type, not zero value to interface{} type, because interface{} underneath is like a pointer to struct which saves object's type and reference. `nil` is the zero value for interface{}.

Therefore Gorm can only use `Select(fields...)`  or `map[stirng]interface{}`  to explicitly declare fields to be updated.

## ErrNotFound
ErrNotFound will not happened in db.Find() function if not record found

## WithContext
use WithContext so if the upstream ctx timeout or be cancelled the query can be cancelled too. https://gorm.io/docs/session.html#Context
```go
timeoutCtx, _ := context.WithTimeout(context.Background(), time.Second)  

tx := db.WithContext(timeoutCtx)
tx.First(&user) // query with context timeoutCtx  
tx.Model(&user).Update("role", "admin") // update with context timeoutCtx
```
`WithContext` is a `NewSession` function type in GORM is safe to reuse in same context
https://gorm.io/docs/method_chaining.html#New-Session-Method

## Method chaining
Method chaining sometime can make code more readable and more reusable. you can use pointer value to have some optional query parameters.
```go
type Filter struct {
	IDs        []int
	Type       *OrderType
	UserID     *string
}

func (r *Repository) QueryOrders(ctx context.Context, filter Filter) (orders []repository.Order, err error) {
	db := r.db.WithContext(ctx)
	if filter.UserID != nil {
		db = db.Where("user_id = ?", filter.UserID)
	}
	if len(filter.IDs) > 0 {
		db = db.Where("id in (?)", filter.IDs)
	}
	if filter.Type != nil {
		db = db.Where("type = ?", filter.Type)
	}
	if err := db.Find(&orders).Error; err != nil {
		return nil, err
	}
}
```
but be careful `Where` is a `Chaining Method` in GORM the db returned by `Where()` is not safe to reuse.
The iOS Release You Have Been Waiting For
Tags: productivity, developertools, ios
Published: 2022-05-04 16:04:08

---
title: The iOS Release You Have Been Waiting For
published: true
description: CodeSandbox for iOS lets you take your projects and sandboxes with you wherever you go. Using an iPhone or iPad, you can now access our new cloud development platform in the comfort of a native iOS IDE.
tags: productivity, developerTools, iOS
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sd9btztpfws6s6v3b1p.jpg
---

[**CodeSandbox Projects**](https://codesandbox.io/post/announcing-codesandbox-projects) is now available on mobile. With CodeSandbox for iOS, you can take your projects with you wherever you go. Using an iPhone or iPad, you can now access our new cloud development platform in the comfort of a native iOS IDE.

When building **CodeSandbox Projects**, we set out to create a cloud development platform with the familiar speed and experience of CodeSandbox, yet also deeply integrated with your favorite tooling, and working on projects of any size. **Projects** is currently in [beta](https://projects.codesandbox.io/) and we are now ready to expand the experience to the mobile world.


## Take a look inside the iOS App

**CodeSandbox for iOS** combines the crisp and ergonomic feel of a native IDE with the power and efficiencies of cloud development.

On iOS, keep up with ongoing project work with:

**Smart Dashboards**

Our dashboards help you manage your workflow and stay connected with your entire team. In one view, you can get an overview of your project and keep track of all branches.

**IntelliSense**

Go beyond syntax highlighting and autocomplete, with smart completions based on variable types, function definitions, and imported modules.

**Live Previews**

Easily spin up a preview of your app in your browser or open tools like Swagger or Storybook to track changes as you make them. 

**Real-time Collaboration**

Enjoy both real-time and asynchronous collaboration with your team in the same file, with support for multiple clients.

**Git Workflow**

Full support for Git allows you to work on any existing project and work alongside any contributor, regardless of their developer environment.

Great ideas don’t always come to you while you are sitting at your desk. With this new mobile app, you can pick up where you left off on the web editor or on VS Code and keep the creativity flowing at your local cafe, on your commute, or while curled up on your couch with a cup of tea.

## Get started now

Right now, **CodeSandbox Projects** is in Beta. You can sign up to the waitlist [here](https://codesandbox.io/ios). You can also jump in and explore your Sandboxes [on the app](https://apps.apple.com/us/app/play-js-javascript-ide/id1423330822) in the meantime. Once you are in, you can simply import your projects or add a template project, invite your team members and get coding. 

We look forward to welcoming you to this new piece of the Projects experience and hearing where your coding adventures take you.
Talk @ Budapest ML Forum 2022 — Building NLP applications with Transformers
Tags: transformers, mlops, datascience, nlp
Published: 2022-05-24 16:03:07

---
title: Talk @ Budapest ML Forum 2022 — Building NLP applications with Transformers
published: true
date: 2022-05-04 15:58:42 UTC
tags: transformers,mlops,datascience,nlp
canonical_url: https://julsimon.medium.com/talk-budapest-ml-forum-2022-building-nlp-applications-with-transformers-15dd33095745
---

### Talk @ Budapest ML Forum 2022 — Building NLP applications with Transformers
<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FojaxE4CpIJWAV7&amp;display_name=SlideShare&amp;url=https%3A%2F%2Fwww.slideshare.net%2FJulienSIMON5%2Fbuilding-nlp-applications-with-transformers&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fbudapestmlforum2022juliensimonpublic-220504154409-thumbnail-4.jpg%3Fcb%3D1651679443&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/71700c3a3b33174a88a75ef84b5ec4db/href">https://medium.com/media/71700c3a3b33174a88a75ef84b5ec4db/href</a></iframe>

[Budapest ML Forum 2022 - Főoldal - Budapest ML Forum 2022](https://budapestml.hu/2022/en/)
Programming Tip #6: Pattern Matching
Tags: rescript, programmingtips, patternmatching
Published: 2022-05-04 15:55:27

---
title: Programming Tip #6: Pattern Matching
published: true
description: Pattern Matching. Using Variant/Union/Sum types, you can ensure ALL possibilities are handled. This solves bugs that switch statements have using defaults. For JavaScript, you can use the Folktale Union library. For Python v3.10's pattern matching, you can use Typings + mypy.
tags: rescript,programmingtips,patternmatching
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8xhu3l8wcdgijdgllvv.png
---

Programming Tip #6: Pattern Matching. Using Variant/Union/Sum types, you can ensure ALL possibilities are handled. This solves bugs that switch statements have using defaults. For JavaScript, you can use the Folktale Union library. For Python v3.10's pattern matching, you can use Typings + mypy.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8xhu3l8wcdgijdgllvv.png)

Learn More:
- https://rescript-lang.org/docs/manual/latest/pattern-matching-destructuring
- https://folktale.origamitower.com/api/v2.3.0/en/folktale.adt.union.html
- https://peps.python.org/pep-0622/
- https://github.com/tc39/proposal-pattern-matching
- https://github.com/santinic/pampy.js/blob/master/README.md
Blogs Write
Tags: blogs, write
Published: 2022-05-04 15:39:51

Various users rely on Blogswrite for real-world technology content. The technology you use every day isn’t your life, but you depend on it to function. Our goal is to maximize your technology’s potential.

Each day, we have various technology experts working together to provide you with the latest technology, bitcoin, cryptocurrency, and much more.

Over the past years, we’ve created and refined more than various pieces of content that will help you understand the latest tech trends, figure out which products you need, and then learn about us how to make it all work without pretentiousness and confusion jargon.