Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【rails】chartkick導入ガイド |
https://qiita.com/Yu_unI1/items/42ee303173739c26cf60
|
chartkick |
2022-04-25 02:11:03 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【rails】chartkick導入ガイド |
https://qiita.com/Yu_unI1/items/42ee303173739c26cf60
|
chartkick |
2022-04-25 02:11:03 |
海外TECH |
MakeUseOf |
How to Post on Instagram From a PC or Mac |
https://www.makeuseof.com/tag/how-to-post-on-instagram-from-pc-mac/
|
chromebook |
2022-04-24 17:45:13 |
海外TECH |
DEV Community |
Setup Micro Frontend Application with React Js |
https://dev.to/shivampawar/setup-micro-frontend-application-with-react-js-m87
|
Setup Micro Frontend Application with React JsIn this article we are going to setup a micro frontend application with well known CLI tool call create mf app which is a bootstrap tool to setup Module Federation What is Micro Frontend Micro frontend designs break down a front end application into little semi independent microapps that work together loosely This can aid in the management of complex projects Setting up projectNow we are going to setup a project which contains two micro frontends and one container app which will hold the all micro frontend apps In this article we are focusing on only setting up project in React js only but we can have multiple framework Open a cmd terminal where you are going to setup project and enter below command npx create mf appIf create mf app is already installed then it will directly prompt for application name and if not then it will ask to install it just simply enter y and it will install it for you Once create mf app is installed it will ask for the following info I created a Shell app and given port to run the application Lets create another micro app with name common components lib We will follow same step as above but just different port and name I created a Shell app and given port to run the application Now you need to move inside of each app and enter below command to build and run the app npm install amp amp npm startI recommend to open these apps in two different cmd terminal I created a common components lib app and given port to run the application Our basic idea behind creating these app is that Shell will be our container for all the micro apps and common components lib will contains common components like Header Footer etc We will now open Folder in a Code editor Mine Favorite editor is Visual Studio Codebut you can use code editor of your choice After opening it your folder structure will look like this Note make sure both apps are up and running on different ports Creating Components inside micro appNow lets add one Header and Footer Component inside the common components lib app Create a Header Component and paste below code import React from react import header css function Header return lt div class header gt lt a href default class logo gt Header Component lt a gt lt div class header right gt lt a class active href home gt Home lt a gt lt a href contact gt Contact lt a gt lt a href about gt About lt a gt lt div gt lt div gt export default Header Also add one header css file for styling the component header overflow hidden background color fff padding px px header a float left color black text align center padding px text decoration none font size px line height px border radius px header a logo font size px font weight bold header a hover background color ddd color black header a active background color dodgerblue color white header right float right media screen and max width px header a float none display block text align left header right float none Add Footer Component and header cssimport React from react import footer css function Footer return lt div class footer gt lt p gt Footer Component lt p gt lt div gt export default Footer add footer css footer position fixed left bottom width background color fff color black text align center Import Header and Footer Component in App Component import React from react import ReactDOM from react dom import Footer from Footer import Header from Header import index css const App gt lt gt lt Header gt lt Footer gt lt gt ReactDOM render lt App gt document getElementById app Our app will look like this after adding Header and Footer Exposing Components to remotesNow lets expose these two components so that we can use it in Shell app Open webpack config js of common components lib and update code inside plugin like this new ModuleFederationPlugin name common components lib filename remoteEntry js remotes exposes Header src Header jsx Footer src Footer jsx shared deps react singleton true requiredVersion deps react react dom singleton true requiredVersion deps react dom Note We updated only exposes Consume components in Shell app Now open webpack config js of Shell app and update code inside plugin const HtmlWebPackPlugin require html webpack plugin const ModuleFederationPlugin require webpack lib container ModuleFederationPlugin const deps require package json dependencies module exports output publicPath http localhost resolve extensions tsx ts jsx js json devServer port historyApiFallback true module rules test m js type javascript auto resolve fullySpecified false test css s ac ss i use style loader css loader postcss loader test ts tsx js jsx exclude node modules use loader babel loader plugins new ModuleFederationPlugin name shell filename remoteEntry js remotes common components lib common components lib http localhost remoteEntry js exposes shared deps react singleton true requiredVersion deps react react dom singleton true requiredVersion deps react dom new HtmlWebPackPlugin template src index html Note We updated only remote Make sure you use same name as the app name inside the plugin In our case app name is common components lib and shell Render remote Components from micro apps in Shell AppNow its time to test our application by actually importing remote components in Shell application Inside App jsx import our Header and Footer components from common components lib app import React Suspense from react import ReactDOM from react dom const Header React lazy gt import common components lib Header const Footer React lazy gt import common components lib Footer import index css const App gt lt gt lt Suspense fallback lt gt Loading lt gt gt lt Header gt lt Footer gt lt Suspense gt lt gt ReactDOM render lt App gt document getElementById app Note We used Lazy Loading to import the remote components To know more about the lazy loading read the official documentation from here Time to run the Shell App Restart both the application as we made changes in webpack config js Once both apps restarted check if Header and Footer is visible on Shell app Yeah there are ConclusionThis article is focused on the setup of the micro frontend application and we successfully configured it Please do share your feedback and experiences with Micro Frontend in the comments section below I d love to see what you come up with If you found this article useful please share it with your friends and colleagues ️Read more articles on Dev To ️Shivam PawarFollow me on ️LinkedInGithub |
2022-04-24 17:41:59 |
海外TECH |
DEV Community |
Elixir: Dockerizando Aplicações Phoenix 🐳 |
https://dev.to/maiquitome/elixir-dockerizando-aplicacoes-phoenix-19gg
|
Elixir Dockerizando Aplicações Phoenix Neste post vamos aprender a colocar nossas aplicações Phoenix em contêineres e a gerenciar vários deles utilizando Docker Compose Para começar vamos criar uma aplicação sem banco de dados para entender bem como funciona e depois sim vamos criar uma aplicação com banco de dados e usando docker compose ️Criando o Projeto sem EctoCriando a Imagem Docker sem Ecto️Criando o Projeto com EctoCriando a Imagem Docker com EctoCriando o arquivo docker composeCriando o arquivo SHConfigurando o banco de dados no docker compose ️Criando o Projeto sem Ecto sem Banco de Dados Versões usadas neste projeto elixir otp erlang Crie uma aplicação Phoenix com o comando mix phx new dockerizando sem ecto app blog no ectolink do projeto no github Criando a Imagem Docker sem Ecto Vamos configurar o contêiner da nossa aplicação Phoenix criando um arquivo com o nome Dockerfile na raiz do projeto com o seguinte conteúdo imagem base Alpine éuma imagem mínima do Docker baseada no Alpine Linux com um índice de pacotes completo e apenas MB de tamanho FROM elixir alpine instalando o gerenciar de pacotes do elixirRUN mix local hex force amp amp mix local rebar force também funciona essa sintaxe RUN mix do local hex force local rebar force copiar tudo da raiz do projeto para o contêiner dockerCOPY instalar as dependenciasRUN mix do deps get deps compile executar o servidorCMD mix phx server dockerignoreAgora podemos criar um arquivo também na raiz do projeto chamado dockerignore para colocarmos os arquivos que devem ser ignorados pelo Docker ou seja não vão ir para dentro do contêiner Vamos colocar alguns arquivos que podemos querer ignorar mesmo que alguns deles não estejam no nosso projeto vamos colocar para exemplo pois algum dia vocêpode querer colocar um arquivo semelhante build deps elixir ls git github gitignore editorconfig circlecihelm terragrunt hclREADME mddocker compose Construindo a Imagem docker build t app blog Executando o comando docker images no terminal podemos constatar que a nossa imagem foi criada docker images REPOSITORY TAG IMAGE ID CREATED SIZEapp blog latest eaeacdd minutes ago MBou no Docker Desktop Criando um Contêiner docker run app blogExecutando o comando docker container ls ou o comando antigo docker ps no terminal podemos constatar que o nosso contêiner foi criado No Docker Desktop Após podemos constatar que a aplicação estárodando na porta Então vamos tentar acessar a aplicação E recebemos a mensagem que este site não pode ser acessado Isso acontece pois a nossa aplicação estána porta dentro do contêiner Para acessar precisamos executar o comando abaixo passando uma porta neste caso a porta docker run p app blog E agora conseguimos acessar a nossa aplicação dentro do contêiner Caso vocêreceba a mensagem This page ins t working Altere o arquivo config dev exs trocando para Adicionando um diretório de trabalho WORKDIR Se executarmos o comando docker run it app blog sh e depois um ls podemos notar que os arquivos do contêiner estão misturados com os arquivos da aplicação Vamos adicionar no aquivo Dockerfile o comando WORKDIR FROM elixir alpineWORKDIR app Vamos verificar que agora ficou mais organizado ️Criando o Projeto com Ecto com Banco de Dados Agora vamos criar uma aplicação Phoenix com banco de dados mix phx new dockerizando com ecto app blogLink do projeto no github Criando a Imagem Docker com Ecto Vamos usar o mesmo Dockerfile do projeto anterior criar a nossa imagem e subir um contêiner da nossa aplicação Após isso recebemos um erro informando que a conexão com o banco de dados falhou Para resolvermos isso vamos aprender a usar o docker compose Criando o Arquivo docker compose O Docker Compose serve para iniciar vários conteiners Crie um arquivo na raiz do projeto chamado docker compose yml version versão do docker composeservices serviços que precisamos colocar em conteiner e um desses serviços éa nossa aplicação app nome da nossa aplicação pode ser qualquer nome nesse caso vamos dar o nome de app build context context éo diretório onde a gente está ports pra executar o docker run precisamos passar a porta o no yml significa que éum arrayEste código do arquivo docker compose yml iráexecutar o Dockerfile e para isso vamos executar no terminal o comando docker compose up docker compose up Mesmo com o erro do banco de dados acesse a porta No momento o docker compose estáservindo apenas para fazer o build da imagem do nosso projeto Criando o arquivo SH Remova o comando CMD mix phx server do arquivo Dockerfile Crie um arquivo na raiz do projeto chamado docker dev start sh mix ecto drop destrói o banco de dadosmix ecto setup cria o banco de dados e executa o arquivo seedsexec mix phx server sobe o servidorAgora vamos fazer executar este script dentro do docker compose yml Como estamos em uma máquina Alpine adicione o seguinte comando command bin sh docker dev start sh Se a máquina fosse um Windows por exemplo o comando seria diferente version versão do docker composeservices serviços que precisamos colocar em conteiner e um desses serviços éa nossa aplicação app nome da nossa aplicação pode ser qualquer nome nesse caso vamos dar o nome de app build context context éo diretório onde a gente está command bin sh docker dev start sh executa o script do arquivo docker dev start sh ports pra executar o docker run precisamos passar a porta o no yml significa que éum arrayAo executarmos docker compose up recebemos um erro Para funcionar precisamos construir novamente a imagem e para isso pode usar o comando docker compose up build Configurando o banco de dados no docker compose Mas ainda temos o erro de conexão com o banco de dados por isso precisamos incluir o contêiner do postgres e configurar ele version services app build context command bin sh docker dev start sh ports adicione a configuração abaixo db image postgres environment POSTGRES PASSWORD postgres POSTGRES USER postgres ports Altere de localhost para db no arquivo config dev exs E como alteramos os arquivos precisamos fazer o build novamente docker compose up buildAgora funciona mas ainda temos um problema Precisamos fazer com o db execute totalmente primeiro e pra isso vamos colocar uns comandos version services app build context command bin sh docker dev start sh ports adicione o depends on e o links depends on db nosso app depende do db para funcionar links db db image postgres environment POSTGRES PASSWORD postgres POSTGRES USER postgres ports E como alteramos os arquivos precisamos fazer o build novamente docker compose up buildE agora sim o db executou primeiro DICA Podemos executar também em background usando o comando docker compose up d |
2022-04-24 17:33:14 |
海外TECH |
DEV Community |
Last Write Wins - A Conflict resolution strategy |
https://dev.to/dogealgo/last-write-wins-a-conflict-resolution-strategy-2al6
|
Last Write Wins A Conflict resolution strategyImagine a file or database is written concurrently by processes Eventhough from the user point of view where all the file write processeses happen at the same time but that doesn t mean all three can co exist in the same file or database field right It will break consistency So we need to make sure only the last written data as the final data for the file in a given time How do we consider which data is the last data Timestamp of course Timestamp is used for each write operation to identify which write is the final write MongoDB and Cassandra are examples of having Last Write Wins Strategy More importantly in Cassandra if we are quering an update each column has its own timestamp value Hope you guys find usefull Support us by Buying us some Cookies Visit our site Doge Algo |
2022-04-24 17:16:59 |
海外TECH |
DEV Community |
Introduction to Regex |
https://dev.to/yohanesss/introduction-to-regex-1lej
|
Introduction to RegexHave you ever created a password and there we were asked to use capital letters numbers and symbols And if so how could we do it Are we gonna split the input string and then check for each character if all the criteria is matched Let s see the implementation below for validating password function validatePassword input list of special character let specialChars amp lt gt const validLength input length gt true false let validCapital false let validNumber false let validSpecialChar false const isSpecialCharacter char gt specialChars includes char const isCapitalcase char gt char toUpperCase char const isNumber char gt includes parseInt char const input input split input forEach input gt if isNumber input validNumber true if isSpecialCharacter input validSpecialChar true if isNumber input amp amp isSpecialCharacter input amp amp isCapitalcase input validCapital true if validLength amp amp validCapital amp amp validNumber amp amp validSpecialChar return true else console log error creating password return false It s complex right Lo and behold the power of regexfunction validatePasswordRegex input return d a z A Z test input Our code will become so much clearer in an instant and in so mysterious way Worry not I will give you an introduction about regex in this article Regex stands for Regular Expression and it is basically an easy way to define a pattern of text Regex is often used for input validation or text identification At first glance Regex is like a gibberish text However for those who know how to use it it will be one of powerful tools in their disposal I have listed some commonly used tokens in Regex to help us TokensRepresent dAny Digit DAny Non digit character Any Character Period abc Only a b or c abc Not a b nor c a z Characters a to z Numbers to wAny Alphanumeric character WAny Non alphanumeric character m m Repetitions m n m to n Repetitions Zero or more repetitions One or more repetitions Optional character sAny Whitespace SAny Non whitespace character … Starts and ends … Capture Group a bc Capture Sub group Capture all abc def Matches abc or defFirst thing to note when we are using regex everything is a character and we are writing patterns to match a specific sequence pattern alphabet abc abc test abcd match abc test abc match abc test abcde match Look at the example above abc is our pattern we are done our first regex It s as simple as the common letters on each line number test bgh match test const number match test match We can see which is number is also treated as character in regex dot test asd a match test skip test s match dot operator in regex is also known as a wildcard because it can match any character However in the example above we can use to actually specify the dot to be in our pattern brackets asdf FfR oot test Foot match FfR oot test Root match FfR oot test foot match FfR oot test Moot skip While the metacharacter is pretty powerful to match all the character we need to somehow add a boundary to match to specific characters We could do that by using brackets notation In our example we use FfR as our pattern therefore only F f or R letter will be match and nothing else inverse within brackets FfR oot test Moot match FfR oot test Boot match FfR oot test Foot skip We also could use an inverse within brackets to excluding specific characters if there is any character in our test that are same as the characters inside our brackets it will be not match Character ranges A D c h b e test Ade match A D c h b e test Dfd match A D c h b e test Erd skip We can specify a range of sequential characters by using the dash within brackets to indicate a character range We could specify a digit or even with inverse notation a f Notice that a z lowercase and A Z uppercase are different so make sure we put it both if we want all the alphabets to be match A Za z this pattern is equivalent for w which stands for match for any alphanumeric characters And W can be used to specify non alphanumeric characters Curly brace repetitions hel o test helllo match hel o test hello skip hel o test hellllllo match hel o test hello skip We can speficy a number of repetitions for a character we want to match by using a b where a is a minimal number of repetitions and b is maximum number of repetitions If b is not specified then the repetitions must be exactly same as a In our example we specify hel o which means l character must be repeated times to be match otherwise it will be not match hel o means l character must be repeated between until to be match Plus and star quantifier o l m test ooolllmm match o l m test ooomm match o l m test mmm skip o l m test mmm match How can we match the character to be at least or more character that it follows Meet the plus quantifier There are also star quantifier which can be used to represents either or more of the character that it follows Question Mark optional d files is found test file is found match d files is found test files is found match d files is found test No files is found skip In the example above we could give our pattern more flexibility by specify an optional character using question mark into our patterns In our example we using to specifying wheter our statement is singular or plural file found singular and files is found plural and both is matching Whitespaces white s space test white space match white s space test white space match white s space test whitespace skip white S space test whites space skip white S space test whites space match Do you know that space tab newline carriage return form feed and vertical tab characters are called whitespace characters We could use s to specify a whitespace in our pattern There are also S with capital S to specify non whitespace character e g alphanumeric and special characters Hat and dollar sign Start End Start your day with orange test Start your day with an orange match Start your day with test Start your day with an apple match with orange test Finish your day with an orange match Start your day with test Start your day with an orange skip Start your day with orange test Start your day with an orange skip So far we are matching the text regardless the position of the character whether it is on start middle or near the end of the text How could we make a boundaries to search the text that must be start in and end with In that case we use hat and to match a pattern In our example above Start your day with orange we see that the pattern that didn t start with is can be match regardless of whitespace or even incorrect sentence it is also same with the pattern that didn t end with One last note inversion is different than start with Matching Group js basic txt match js txt capture js basic js intermediate txt match js txt capture js intermediate js xls match js txt capture null python txt match js txt capture null Is it possible to extract data from our matching text so we can use that ️Yes it is We can do that by defining groups of characters and capturing them using the parantheses In our example above we write a simple pattern that captures everything from the start of js until the extension txt Matching Nested Group BaldwinAve match d w capture BaldwinAve and BaldwinAve FairwayDr match d w capture FairwayDr and FairwayDr We also could do a match a nested group by using inside another In our example above we are do a match for a street number the outer group is able to capture full address And the inner group we are able to capture the street name Using quantifier inside our group match x match d x d capture and x match d x d capture and In the example above using regex we can get the value of width and height of screen resolution Note that we are using two group match in our pattern d is used to catch all the number Conditional using pipe Apple Orange Pineapple is my favorite fruit test Appleis my favorite fruit match Apple Orange Pineapple is my favorite fruit test Pineappleis my favorite fruit match Apple Orange Pineapple is my favorite fruit test Strawberryis my favorite fruit skip We also can specify a conditioning in our regex pattern by using pipe In this example we try to match whether our favorite fruit is either Apple Orange or Pineapple Other than that will be no match Congrats for making this far You are now know the basic of regex Let s see our first regex in this article for validating password Let s glance it once more function validatePasswordRegex input return d a z A Z test input Are you able to know what this regex do now If you are able to read it congrats Let s walkthrough together Our validatePasswordRegex has condition for validating a password d is used to match whether there is a number in our input a z is used to match if there is a lowercase character in our input A Z is used to match if there is an uppercase character in our input it used to make sure if there are minimal character in our input I hope this article could help you in your journey of learning regex You could try regexr if you want messing around with it Thank you for reading and good luck |
2022-04-24 17:02:14 |
Apple |
AppleInsider - Frontpage News |
Satechi Magnetic Wireless Car Charger review: A reliable MagSafe-compatible charger |
https://appleinsider.com/articles/22/04/24/satechi-magnetic-wireless-car-charger-review-a-reliable-magsafe-compatible-charger?utm_medium=rss
|
Satechi Magnetic Wireless Car Charger review A reliable MagSafe compatible chargerSatechi s Magnetic Wireless Car Charger is a great piece of kit to add to your ride and is a perfect iPhone companion when paired with wireless CarPlay Satechi Magnetic Wireless Car ChargerMagSafe is one of the more notable user facing features that debuted with iPhone before making its way to the iPhone line It s great for connecting batteries wallet and various other accessories and in the car it also makes a great wireless charger Read more |
2022-04-24 17:07:32 |
海外TECH |
Engadget |
Halo Infinite’s co-op campaign is now scheduled to arrive in August |
https://www.engadget.com/halo-infinite-co-op-campaign-august-target-171430143.html?src=rss
|
Halo Infinite s co op campaign is now scheduled to arrive in AugustFollowing multiple delays Industries hopes to deliver Halo Infinite s co op campaign sometime in August the studio said in a roadmap update released Friday Campaign co op was one of the features that didn t makeInfinite sDecember th release date IndustriesAt the time said it planned to roll out the mode alongside the game s season two update approximately three months after launch However first delayed the debut of season two to May rd and later said campaign co op wouldn t be available when the season kicked off The studio now says it s targeting an August release date for network co op with split screen co op coming even later That means you ll have to wait to invite a friend over to play the game on a single TV According to the roadmap shared couch co op won t be available until sometime during season three which won t begin until November th What s more that s a tentative plan with a note on the roadmap indicating the exact release date of the feature is “TBD If there s a silver lining to the news it s that is also targeting an August release date for a feature that allows you to replay campaign missions Additionally the studio expects to launch the Forge mode open beta sometime in September The delays are likely to irritate Infinite s already frustrated playerbase further but Joseph Staten the game s head of creative stressed is doing its best to deliver new features quickly while protecting the health of its team quot We know we need to deliver more content and more features more quickly quot Staten said quot Staying true to priority zero means that sometimes we need to slow down in order to stay healthy and move faster later But we re also aggressively looking at ways to accelerate |
2022-04-24 17:14:30 |
ニュース |
BBC News - Home |
Luke Symons: Cardiff man freed after five years in Yemen detention |
https://www.bbc.co.uk/news/uk-wales-61209721?at_medium=RSS&at_campaign=KARANGA
|
country |
2022-04-24 17:20:17 |
ニュース |
BBC News - Home |
Liverpool 2-0 Everton: Reds win derby to leave Toffees in bottom three |
https://www.bbc.co.uk/sport/football/61131364?at_medium=RSS&at_campaign=KARANGA
|
Liverpool Everton Reds win derby to leave Toffees in bottom threeLiverpool keep pace with Manchester City at the top of the Premier League as two second half goals give them a victory that deepens Merseyside rivals Everton s relegation worries |
2022-04-24 17:52:06 |
ニュース |
BBC News - Home |
Breydon Water: Norfolk lifeboat crews rescue 17 people and three pets |
https://www.bbc.co.uk/news/uk-england-norfolk-61208092?at_medium=RSS&at_campaign=KARANGA
|
dramatic |
2022-04-24 17:08:29 |
ニュース |
BBC News - Home |
Labour: Difficult to see Jeremy Corbyn return after Nato remarks - Starmer |
https://www.bbc.co.uk/news/uk-politics-61210585?at_medium=RSS&at_campaign=KARANGA
|
current |
2022-04-24 17:27:01 |
ニュース |
BBC News - Home |
Widows in call to jail police killers for life in Scotland |
https://www.bbc.co.uk/news/uk-scotland-61208595?at_medium=RSS&at_campaign=KARANGA
|
scotland |
2022-04-24 17:09:16 |
ニュース |
BBC News - Home |
World Snooker Championship 2022: Neil Robertson trails, Judd Trump leads |
https://www.bbc.co.uk/sport/snooker/61210545?at_medium=RSS&at_campaign=KARANGA
|
World Snooker Championship Neil Robertson trails Judd Trump leadsTournament favourite Neil Robertson is in trouble in the second round of the World Championship trailing Jack Lisowski after the second session |
2022-04-24 17:10:34 |
ビジネス |
不景気.com |
ジャパンフーズの22年3月期は3億円の営業赤字へ、コロナ影響 - 不景気com |
https://www.fukeiki.com/2022/04/japan-foods-2022-loss.html
|
飲料メーカー |
2022-04-24 17:24:00 |
コメント
コメントを投稿