IT |
InfoQ |
Java News Roundup: String Templates, Quarkus, Open Liberty, PrimeFaces, JobRunr, Devnexus 2023 |
https://www.infoq.com/news/2023/04/java-news-roundup-apr03-2023/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global
|
Java News Roundup String Templates Quarkus Open Liberty PrimeFaces JobRunr Devnexus This week s Java roundup for April rd features news from OpenJDK JDK Quarkus CR and Final Open Liberty Apache Camel PrimeFaces JHipster Lite JobRunr Gradle RC and Devnexus By Michael Redlich |
2023-04-10 11:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] Mac向け老舗テキストエディタ「Jedit Ω」、ChatGPTを搭載 |
https://www.itmedia.co.jp/news/articles/2304/10/news132.html
|
artman |
2023-04-10 20:20:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
自然言語処理を用いたAmazonレビューの分類(BERT編) |
https://qiita.com/hokkey621/items/8d8c0e0fe072a6b40fed
|
naivebayes |
2023-04-10 20:50:35 |
golang |
Goタグが付けられた新着投稿 - Qiita |
Go言語でContextを活用する3つのパターン |
https://qiita.com/atsutama/items/566c38b4a5f3f0d26e44
|
context |
2023-04-10 20:28:53 |
海外TECH |
MakeUseOf |
How to Use Bing AI Chat on Your Android Phone’s Keyboard |
https://www.makeuseof.com/bing-ai-chat-android-keyboard/
|
android |
2023-04-10 11:15:16 |
海外TECH |
DEV Community |
Building Pagination in React with React Paginate |
https://dev.to/documatic/building-pagination-in-react-with-react-paginate-4nol
|
Building Pagination in React with React Paginate IntroductionPagination is a crucial component in any web application as it allows for the efficient and seamless navigation of large amounts of data In React implementing pagination can be a challenge for developers especially for those who are new to the framework However with the right understanding of React components and hooks building pagination in React can be a straightforward process In this article we will explore the steps involved in building a pagination system in React from setting up the component structure to integrating it with your application s data This guide will provide a comprehensive overview of the process and provide you with the knowledge and skills you need to build an effective and user friendly pagination system We are going to look into the following topics in the article Installing ComponentUnderstanding the react paginate library with propsData filtering for different pagePaginationConclusionNow let s get started Installing LibraryWe are going to use the react paginate library to build our pagination features You can install the library with the below command npm i react paginateAlong with that we will need some icons For icons I am using the react icons library Install it with the below command npm install react icons save App jsWe are building an application that is going to have data in an array We need to display only data on each page We can change as per requirement Let s start building them one by one ImportsHere are the imports that we will require for the component import ReactPaginate from react paginate for paginationimport AiFillLeftCircle AiFillRightCircle from react icons ai icons form react iconsimport IconContext from react icons for customizing iconsimport useEffect useState from react useState for storing data and useEffect for changing data on click import styles css stylesheetYou can look for the comments for each import DataThe data is simple it s the letter of the alphabet in an array const data A B C D E F G H I J K L M N O P Q R S T U V W X Y Z useEffect and useStateHere are the states of our application const page setPage useState const filterData setFilterData useState const n page It is for storing the current page number for the pagination componentfilterData It is the data that will be shown after filtering data for each page n It is the maximum number of items to show on a page Here is the code for the useEffect hook that we are using to filter data The data will filter when the user change to a different page On each page there will be filtered data for displaying useEffect gt setFilterData data filter item index gt return index gt page n amp index lt page n page The return formula will return the item from the data array in an array with an index in the multiple of ReturnIn the return statement at the top we are displaying the filterData lt ul gt filterData amp amp filterData map item index gt lt li gt Item item lt li gt lt ul gt Now let s look into the ReactPaginate component First let s look at the code then I will explain each prop lt ReactPaginate containerClassName pagination pageClassName page item activeClassName active onPageChange event gt setPage event selected pageCount Math ceil data length n breakLabel previousLabel lt IconContext Provider value color BCCC size px gt lt AiFillLeftCircle gt lt IconContext Provider gt nextLabel lt IconContext Provider value color BCCC size px gt lt AiFillRightCircle gt lt IconContext Provider gt gt PropsDescriptioncontainerClassNameYou can provide a class name for the container of the pagination component pageClassNameIt is for the class name for each page number activeClassNameClassname of the active page onPageChangeIt is the function that will be triggered on changing page In this we are storing the page number in the page state Also it starts with and the number in the component starts with pageCountIt is a required prop As the name suggests it will display the number of pages I have divided the length of the data by the number of each item on a page breakLabelThe component will be displayed when there will be a break between pages It is to show that there is more page in between previousLabelThe icon component is used here for displaying the previous button nextLableHere it is for the next button CSSHere is the CSS of each component used in the code App display flex font family sans serif margin auto align items center justify content center flex direction column pagination list style none height px width px display flex justify content center align items center margin top px cursor pointer active background color eff border radius page item list style none padding px px height px width px display flex justify content center align items center margin top px CodeSandboxYou can look into the complete code and the output of the project in the below codesandbox ConclusionBuilding pagination in React is an important aspect of web development and can greatly enhance the user experience in navigating large amounts of data By following the steps outlined in this article you can easily implement pagination in your React application and provide your users with a smooth and efficient way to access the data they need I hope the articles have helped you in understanding the process of creating a pagination component in React Thanks for reading the article |
2023-04-10 11:30:00 |
海外TECH |
DEV Community |
Full-Text Search: Implementando com Postgres e Django |
https://dev.to/eduardojm/full-text-search-implementando-com-postgres-e-django-kmf
|
Full Text Search Implementando com Postgres e DjangoAlgum tempo atrás vi o texto A powerful full text search in PostgreSQL in less than lines do Leandro Proença e quis implementar algo assim pra projetos que não demandam o poder de um Apache Lucene ou de um Elastic Search O django jápossui em seu core uma aplicação com métodos que são utilizados apenas com o Postgres e para a minha surpresa todos os conceitos de full text search jáestavam disponíveis nesse app Restou nesse caso tentar reproduzir por assim dizer a query do texto original utilizando o ORM do django e os métodos do full text search Esse texto tem por objetivo trazer explicações sobre como essa implementação foi feita Fundamentalmente esse texto seráuma versão explicada dessa thread no twitter Mostre me o códigoTodo o código fonte do projeto estádisponível no GitHub nesse repositório Adicionando configurações necessáriasDentro do settings py do projeto precisamos adicionar a aplicação django contrib postgres dentro da variável de INSTALLED APPS para que possamos utilizar as ferramentas do django próprias para o Postgres INSTALLED APPS django contrib admin django contrib auth django contrib contenttypes django contrib sessions django contrib messages django contrib staticfiles django contrib postgres Criando o modelPrecisamos criar um model para poder utilizar os conceitos da busca dentro dele Para simplificar esse caso utilizamos um model com um único campo de texto para as buscas class Singer models Model name models CharField Cantor max length def str self return self name class Meta verbose name Cantor verbose name plural Cantores Criando uma viewPara testar os conceitos de full text search podemos criar uma view Antes énecessário dizer que nesse texto estou usando views padrão do django com templates em HTML para não adicionar mais complexidade lidando com o Rest Framework Podemos criar uma view que recebe uma query string para fazer a busca from django shortcuts import renderfrom models import Singerdef search singer request term request GET get q if term TODO fazer busca aqui else singers Singer objects order by id all context singers singers term term return render request cantor html context O template cantor html que estou utilizando ébem simples apenas para permitir testes de forma mais fácil lt DOCTYPE html gt lt html lang en gt lt head gt lt meta charset UTF gt lt meta http equiv X UA Compatible content IE edge gt lt meta name viewport content width device width initial scale gt lt title gt Buscando Cantores lt title gt lt head gt lt body gt lt div gt lt form action gt lt input type search name q if term value term endif gt lt button type submit gt Pesquisar lt button gt lt form gt lt div gt if singers lt main gt for item in singers lt div gt lt h gt item name lt h gt if item rank or item similarity lt div gt Rank item rank Similaridade item similarity lt div gt endif lt div gt endfor lt main gt endif lt body gt lt html gt Full Text SearchPrecisamos primeiro criar um SearchVector ts vector e um SearchQuery tsquery Assim from django contrib postgres search import SearchVector SearchQuery vector SearchVector name config portuguese query SearchQuery term config portuguese O vector éfeito assim pra utilizar a coluna name do model Singer A query éfeita para processar a variável term recebida no código da view acima O próximo ponto écriar annotations para fazer o select de campos como o to tsvector e o ts rank o método annotate do Django ORM faz o select de outros campos e agrega eles a entidade from django contrib postgres search import SearchVector SearchQuery SearchRank vector SearchVector name config portuguese query SearchQuery term config portuguese singers Singer objects annotate search vector rank SearchRank vector query filter search query order by rank all Adicionando o código dentro da view passamos a ter from django shortcuts import renderfrom django contrib postgres search import SearchVector SearchQuery SearchRankfrom models import Singerdef search singer request term request GET get q if term vector SearchVector name config portuguese query SearchQuery term config portuguese singers Singer objects annotate search vector rank SearchRank vector query filter search query order by rank all else singers Singer objects order by id all context singers singers term term return render request cantor html context Utilizando um pequeno grupo de dados para teste Podeos testar e verificar que passamos a ter uma busca funcional Porém ainda temos alguns problemas pois por exemplo na busca por palavras incompletas perdemos o ranqueamento Nesse ponto entra a busca por similaridade que combinada com o Full Text Search nos permitiráfazer uma busca mais funcional Busca por SimilaridadePrecisamos primeiro adicionar a extensão pg trgm no banco de dados Podemos fazer isso manualmente ou podemos criar uma migration vazia e adicionar essa extensão na migration Vou seguir pela segunda opção Para a primeira basta executar o comando no banco de dados CREATE EXTENSION pg trgmPara a segunda abordagem podemos executar o comando python manage py makemigrations nome do app empty e ele criaráuma migration vazia A partir da migration vazia podemos adicionar o import ao CreateExtension e adicionar dentro de operations from django db import migrationsfrom django contrib postgres operations import CreateExtensionclass Migration migrations Migration dependencies texto alter feat music operations CreateExtension pg trgm Basta agora executar python manage py migrate e teremos a extensão criada no banco de dados Agora dentro da nossa busca podemos fazer o uso do TrigramSimilarity para melhorar nossos resultados Primeiro vamos adicionar dentro do annotate from django contrib postgres search import SearchVector SearchQuery SearchRank TrigramSimilarity singers Singer objects annotate search vector rank SearchRank vector query similarity TrigramSimilarity name term Precisamos também alterar o filter para utilizar de um operador lógico OU Para isso precisamos fazer uso do Q condição Q condição do django from django contrib postgres search import SearchVector SearchQuery SearchRank TrigramSimilarityfrom django db models import Q singers Singer objects annotate search vector rank SearchRank vector query similarity TrigramSimilarity name term filter Q search query Q similarity gt order by rank similarity all Aqui o que fazemos éadicionar o campo de similarity na nossa query e filtrar pra o full text search encontrou ou a similaridade émaior que zero A partir desse momento fazendo a mesma busca de um dos prints acima Por fim nossa view passa a ter o código from django shortcuts import renderfrom django db models import Qfrom django contrib postgres search import SearchQuery SearchRank SearchVector TrigramSimilarity from models import Singerdef search singer request term request GET get q if term vector SearchVector name config portuguese query SearchQuery term config portuguese singers Singer objects annotate search vector rank SearchRank vector query similarity TrigramSimilarity name term filter Q search query Q similarity gt order by rank similarity all else singers Singer objects order by id all context singers singers term term return render request cantor html context Épossível utilizar tanto o rank ou o similarity para cortar valores conforme exemplos da documentação Por último podemos adicionar um índice dentro do nosso model para lidar com performance das queries from django db import modelsfrom django contrib postgres indexes import GinIndexfrom django contrib postgres search import SearchVectorclass Singer models Model name models CharField Cantor max length def str self return self name class Meta verbose name Cantor verbose name plural Cantores indexes GinIndex SearchVector name config portuguese name singer search vector idx Todo o código fonte do projeto estádisponível no GitHub nesse repositório Referências A powerful full text search in PostgreSQL in less than lines Full text search Django DocumentationFoto de capa por Mick Haupt no Unsplash |
2023-04-10 11:29:58 |
Apple |
AppleInsider - Frontpage News |
Apple will not buy Disney, no matter how often it hears that it will |
https://appleinsider.com/articles/22/11/23/apple-will-not-buy-disney-no-matter-how-often-it-hears-that-it-will?utm_medium=rss
|
Apple will not buy Disney no matter how often it hears that it willThe rumor that Apple will buy Disney is old enough to buy an overpriced beer at EPCOT And six months after we last talked about it it s back yet again with talking heads inspired this time by Apple getting serious about streaming Are you ready to see an Apple logo on the front of Cinderella s Castle The rumor that Apple will buy Disney is as old as the iPod And you d think that analysts would have figured out by now that it isn t going to happen Read more |
2023-04-10 11:56:37 |
Apple |
AppleInsider - Frontpage News |
Apple is best positioned to benefit as China's premium smartphone market swells |
https://appleinsider.com/articles/23/04/10/apple-is-best-positioned-to-benefit-as-chinas-premium-smartphone-market-swells?utm_medium=rss
|
Apple is best positioned to benefit as China x s premium smartphone market swellsThe premium smartphone is expected to see the most growth of China of any market segment and Apple is the best positioned to take advantage of this expansion iPhones are a key part of China s premium smartphone market In February analysts said the iPhone helped recover China s smartphone market with it outpacing local brands in November and December Now it seems that Apple could end up benefiting more as the market is forecast to improve in its favor Read more |
2023-04-10 11:31:12 |
Apple |
AppleInsider - Frontpage News |
DreameBot L10s Ultra review: Too-noisy automated cleaning |
https://appleinsider.com/articles/23/04/10/dreamebot-l10s-ultra-review-too-noisy-automated-cleaning?utm_medium=rss
|
DreameBot Ls Ultra review Too noisy automated cleaningThe DreameBot Ls Ultra doesn t do much to stand out from other robot vacuum and mop combos but the lower price might be a worthwhile trade for its noisy performance DreameBot Ls UltraRobotic cleaning products are becoming more commonplace and that means a wide variety to choose from As a result the days of Roomba owning the sector are over and that s great for companies like Dreame Read more |
2023-04-10 11:22:10 |
医療系 |
医療介護 CBnews |
電子処方箋発行率6%、調剤率は2%-3月初旬時点、モデル事業中間報告 |
https://www.cbnews.jp/news/entry/20230410195943
|
中間報告 |
2023-04-10 20:30:00 |
金融 |
日本銀行:RSS |
総裁・副総裁就任記者会見(4月10日)動画の配信 |
http://www.boj.or.jp/about/release/shunindouga.htm
|
記者会見 |
2023-04-10 20:35:00 |
海外ニュース |
Japan Times latest articles |
China ends military drills after practicing blockade of Taiwan |
https://www.japantimes.co.jp/news/2023/04/10/asia-pacific/china-taiwan-military-exercises-day-three/
|
China ends military drills after practicing blockade of TaiwanThe three days of exercises saw Chinese forces conduct training involving an aircraft carrier and simulated strikes by warplanes carrying live ammunition under actual combat |
2023-04-10 20:35:32 |
ニュース |
BBC News - Home |
Junior doctors' strike: NHS chief calls for ACAS help with talks |
https://www.bbc.co.uk/news/uk-65230594?at_medium=RSS&at_campaign=KARANGA
|
confederation |
2023-04-10 11:56:47 |
ニュース |
BBC News - Home |
Vodafone broadband down for customers across UK |
https://www.bbc.co.uk/news/technology-65230801?at_medium=RSS&at_campaign=KARANGA
|
internet |
2023-04-10 11:10:56 |
ニュース |
BBC News - Home |
China-Taiwan: Aircraft carrier 'seals off' island on third day of drills |
https://www.bbc.co.uk/news/world-asia-65229003?at_medium=RSS&at_campaign=KARANGA
|
mccarthy |
2023-04-10 11:36:55 |
ニュース |
BBC News - Home |
Assistant ref stood down as 'elbow' on Liverpool star investigated |
https://www.bbc.co.uk/sport/football/65232115?at_medium=RSS&at_campaign=KARANGA
|
Assistant ref stood down as x elbow x on Liverpool star investigatedConstantine Hatzidakis will not be involved in any matches while the FA investigates an incident in which he appeared to elbow Liverpool s Andy Robertson |
2023-04-10 11:20:41 |
ニュース |
Newsweek |
イスラエル警察のモスク襲撃に始まった暴力がシリアに拡大、ネタニヤフの狙いは |
https://www.newsweekjapan.jp/stories/world/2023/04/post-101361.php
|
|
2023-04-10 20:28:04 |
IT |
週刊アスキー |
質問「ツナ缶」の使い方で一番しっくりくるのは? |
https://weekly.ascii.jp/elem/000/004/132/4132265/
|
質問 |
2023-04-10 20:30:00 |
コメント
コメントを投稿