IT |
ITmedia 総合記事一覧 |
[ITmedia News] バイデン大統領、中絶と患者のプライバシーに関する大統領令に署名 |
https://www.itmedia.co.jp/news/articles/2207/11/news059.html
|
itmedia |
2022-07-11 07:47:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia エグゼクティブ] ブランドとは何か? 時代の変化から見るブランド戦略の転換期 |
https://mag.executive.itmedia.co.jp/executive/articles/2207/11/news004.html
|
itmedia |
2022-07-11 07:09:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【Python】ブラウザが送信しているHTTP POSTを再現する |
https://qiita.com/super-pylori/items/c52a1520970cd18e7d56
|
httppost |
2022-07-11 07:23:45 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Windowsにゼロから WSL2 + Docker CE + React環境を構築する全手順 |
https://qiita.com/yamazombie/items/4071dfb28e2465da7e3b
|
react |
2022-07-11 07:32:52 |
海外TECH |
DEV Community |
How to create Google Maps clone with Next.js, Prisma, and Postgres. |
https://dev.to/isaacdyor/how-to-create-google-maps-clone-with-nextjs-prisma-and-postgres-305h
|
How to create Google Maps clone with Next js Prisma and Postgres This article is a documentation of my process of implementing a map on my website that displays markers at certain points stored in a Postgres database through Next js and Prisma To start this project I created a Next js project with the command npx create next app latestNext I created a Postgres database hosted on Heroku following these steps Then I needed to connect my Next project to my Postgres database through Prisma The first step was to install Prisma with the following command npm install prisma save devThen I initialized the Prisma project by runningnpx prisma initThis adds a prisma schema file which is where you define your schema It also creates a env file where you can define your environment variables In my env file I defined my database link You can find this by following step of the link to setup a postgres database DATABASE URL postgresql blahblahblah Then I created my schema in the prisma schema file Make sure to include an address field in the schema because that is how our program will know where to place the markers I also included other information I wanted to provide the user in the info window prisma schemadatasource db provider postgresql url env DATABASE URL generator client provider prisma client js model Location id String default cuid id title String address String website String phone String Push the schema to your databasenpx prisma db pushInstall prisma clientnpm install prisma clientUpdata your prisma clientnpx prisma generateCreate a new directory called lib and a prisma js file in it In the prisma js file you have to create an instance of the Prisma client Then you can import your instance of the Prisma client into any file you need prisma jsconst PrismaClient require prisma client const prisma new PrismaClient export default prismaRun npx prisma studio to open the Prisma studio I added a few entries to play around with Now that I have my project connected with my database I can start building the webpage I created a new file in the pages directory called maps js First I imported all of the packages that we need to use We need useState and useRef from React to manage the state We also need to import a few things from the react google maps api package which is a package designed to connect the google maps api to our react application We also need a few things from the react places autocomplete package which makes it easy for us to implement a google places api searchbar into our application I also imported my prisma instance from my prisma js file and the script package from next script import React useState useRef from react import GoogleMap useLoadScript Marker InfoWindow from react google maps api import PlacesAutocomplete geocodeByAddress getLatLng from react places autocomplete import Script from next script import prisma from lib prisma const libraries places After we have all of this imported then we can query our database for our data export const getServerSideProps async gt const locations await prisma location findMany return props locations Then we can create a new functional component with our quereyed data as a prop const App locations gt Then we are going to create some state I created a lot of state and this can probably done in a more efficient way but it works so I will go with it const App locations gt const center setCenter useState lat lng const address setAddress useState const coords setCoords useState const mapRef setMapRef useState null const selected setSelected useState null const mapRef useRef const options disableDefaultUI true zoomControl true The mapRef is pretty stupid but who cares Next we need to connect to the google maps api We do this through the useLoadScript function we imported earlier The first step is to get a google maps api key The instructions to do so can be found here The second step is to create a env local file in the root directory You might be able to use the env file that Prisma created but this is the way that I did it In the env local file add the following line and insert your API Key NEXT PUBLIC MAPS API KEY your api keyYou can then use this api key in your component with the following function const isLoaded useLoadScript googleMapsApiKey process env NEXT PUBLIC MAPS API KEY libraries The libraries line at the end importants the places library Now we need to define a few functions that will be called later on in our code The first function takes the address that the user selects from the places autocomplete dropdown and it converts the address to latitude and longitude It also sets the center to the new latitude and longitude const handleSelect async value gt const results await geocodeByAddress value const latLng await getLatLng results setAddress value setCenter latLng The next function is the convertAddress function which is called onMapLoad and converts all of the addresses stored in the database to latitude and longitude points so that we can use those coordinates to display markers later on const convertAddress async value gt const results await geocodeByAddress value address const latLng await getLatLng results const locationData title value title address value address website value website phone value phone lat latLng lat lng latLng lng setCoords coords gt coords locationData The next function is called when someone clicks on a marker What this function does is set the center of the map to whatever the current center is It gets the current center through calling getCenter on the mapRef const onCenterChanged gt if mapRef const newCenter mapRef getCenter console log newCenter setCenter lat mapRef getCenter lat lng mapRef getCenter lng The next function is called when the map loads and it initializes the map as well as converts all of our addresses into latitude and longitude as mentioned earlier const onCenterChanged gt if mapRef const newCenter mapRef getCenter console log newCenter setCenter lat mapRef getCenter lat lng mapRef getCenter lng The final function just pans the map to a certain lat and long const panTo React useCallback lat lng gt mapRef current panTo lat lng Overall our component looks like this right now const App locations gt const center setCenter useState lat lng const address setAddress useState const coords setCoords useState const mapRef setMapRef useState null const selected setSelected useState null const mapRef useRef const options disableDefaultUI true zoomControl true const isLoaded useLoadScript googleMapsApiKey process env NEXT PUBLIC MAPS API KEY libraries const handleSelect async value gt const results await geocodeByAddress value const latLng await getLatLng results setAddress value setCenter latLng const convertAddress async value gt const results await geocodeByAddress value address const latLng await getLatLng results const locationData title value title address value address website value website phone value phone lat latLng lat lng latLng lng setCoords coords gt coords locationData const onCenterChanged gt if mapRef const newCenter mapRef getCenter console log newCenter setCenter lat mapRef getCenter lat lng mapRef getCenter lng const onMapLoad map gt mapRef current map setMapRef map locations map location gt convertAddress location const panTo React useCallback lat lng gt mapRef current panTo lat lng The first thing I did was create a button that got the coordinates of the user and panned the map to those coordinates lt button className locate onClick gt setAddress navigator geolocation getCurrentPosition position gt panTo lat position coords latitude lng position coords longitude setCenter lat position coords latitude lng position coords longitude gt null gt Locate lt button gt Then I created the map itself Inside the map I mapped through the different coordinates that had been converted from our database and I displayed a marker at each place I also included an info window that displays the information of each place lt GoogleMap zoom center lat center lat lng center lng mapContainerClassName map container options options onLoad onMapLoad onBoundsChanged onCenterChanged gt coords map coord gt return lt Marker key coord lat position lat parseFloat coord lat lng parseFloat coord lng onClick gt onCenterChanged setSelected coord gt selected lt InfoWindow position lat selected lat lng selected lng onCloseClick gt setSelected null gt lt div gt lt h gt selected title lt h gt lt p gt selected address lt p gt lt div gt lt InfoWindow gt null lt GoogleMap gt Finally I added the places autocomplete searchbox I also loaded the google maps places api through the script tag lt PlacesAutocomplete value address onChange setAddress onSelect handleSelect gt getInputProps suggestions getSuggestionItemProps gt lt div gt lt input getInputProps placeholder Type address gt lt div gt suggestions map suggestion gt const style backgroundColor suggestion active be fff return lt div getSuggestionItemProps suggestion style gt suggestion description lt div gt lt div gt lt div gt lt PlacesAutocomplete gt lt Script src libraries places strategy beforeInteractive gt lt Script gt That is pretty much it Keep in mind that this code is far from perfect Also this code has literally zero styling so it is very ugly It works though which is pretty cool All in all this is the final code maps jsimport React useState useRef from react import GoogleMap useLoadScript Marker InfoWindow from react google maps api import PlacesAutocomplete geocodeByAddress getLatLng from react places autocomplete import Script from next script import prisma from lib prisma const libraries places export const getServerSideProps async gt const locations await prisma location findMany return props locations const App locations gt const center setCenter useState lat lng const address setAddress useState const coords setCoords useState const mapRef setMapRef useState null const selected setSelected useState null const mapRef useRef const options disableDefaultUI true zoomControl true const isLoaded useLoadScript googleMapsApiKey process env NEXT PUBLIC MAPS API KEY libraries const handleSelect async value gt const results await geocodeByAddress value const latLng await getLatLng results setAddress value setCenter latLng const convertAddress async value gt const results await geocodeByAddress value address const latLng await getLatLng results const locationData title value title address value address website value website phone value phone lat latLng lat lng latLng lng setCoords coords gt coords locationData const onCenterChanged gt if mapRef const newCenter mapRef getCenter console log newCenter setCenter lat mapRef getCenter lat lng mapRef getCenter lng const onMapLoad map gt mapRef current map setMapRef map locations map location gt convertAddress location const panTo React useCallback lat lng gt mapRef current panTo lat lng if isLoaded return lt div gt lt p gt Loading lt p gt lt div gt if isLoaded return lt div gt lt button className locate onClick gt setAddress navigator geolocation getCurrentPosition position gt panTo lat position coords latitude lng position coords longitude setCenter lat position coords latitude lng position coords longitude gt null gt Locate lt button gt lt GoogleMap zoom center lat center lat lng center lng mapContainerClassName map container options options onLoad onMapLoad onBoundsChanged onCenterChanged gt coords map coord gt return lt Marker key coord lat position lat parseFloat coord lat lng parseFloat coord lng onClick gt onCenterChanged setSelected coord gt selected lt InfoWindow position lat selected lat lng selected lng onCloseClick gt setSelected null gt lt div gt lt h gt selected title lt h gt lt p gt selected address lt p gt lt div gt lt InfoWindow gt null lt GoogleMap gt lt PlacesAutocomplete value address onChange setAddress onSelect handleSelect gt getInputProps suggestions getSuggestionItemProps gt lt div gt lt input getInputProps placeholder Type address gt lt div gt suggestions map suggestion gt const style backgroundColor suggestion active be fff return lt div getSuggestionItemProps suggestion style gt suggestion description lt div gt lt div gt lt div gt lt PlacesAutocomplete gt lt Script src libraries places strategy beforeInteractive gt lt Script gt lt div gt export default App Also there is an error on line because I didn t include a key It is not breaking but you can just add a key to solve it Booh yah |
2022-07-10 22:25:38 |
海外TECH |
DEV Community |
Quickly create K3s cluster and add K3s nodes with GUI Tool using AutoK3s (Installation guide in WSL) |
https://dev.to/msh2050/quickly-create-k3s-cluster-and-add-k3s-nodes-with-gui-tool-using-autok3s-installation-guide-in-wsl-3e5d
|
Quickly create Ks cluster and add Ks nodes with GUI Tool using AutoKs Installation guide in WSL AutoKs is a new tool that will make it easy to install and manage Kubernetes clusters in many platforms In this tutorial we will install Kubernetes in windows WSL with the use of Ubuntu WSL distrowhat is amazing in this distro is that they have built in systemctl If you chose another distro you should use other methods to make docker and other services start Docker for Linux without docker desktop as you may know docker desktop is not free anymore and I found it use more resources from the pc KSKs is a highly available certified Kubernetes distribution designed for production workloads The most important it is Lightweight Kubernetes KD kd is a lightweight wrapper to run ks in docker AutoKsAutoKs is a lightweight tool for simplifying Ks cluster management Install a Linux distroit is recommended to use Ubuntu in this tutorial You can download it from Microsoft store It is advisable to upgrade sudo apt update amp amp sudo apt upgrade Enable systemctlin your WSL edit etc wsl confsudo nano etc wsl confadd the following line boot command usr libexec wsl systemd then close the terminal and restart WSL with the following command in your PowerShell wsl shutdownthen you can start new WSL shell and check that systemctl is working ps auxnot that first line PID is systemctl then check systemctl status systemctl statusfor me I got failed services ssh servicesystemd remount fs servicesystemd sysusers serviceto solve ssh service apt get install openssh server openssh client dpkg reconfigure openssh serverfor the rest comment out the line in the etc fstab LABEL cloudimg rootfs ext discard errors remount ro open usr lib systemd system systemd sysusers service and delete all lines then add Unit Description Create System UsersDocumentation man sysusers d man systemd sysusers service DefaultDependencies noConflicts shutdown targetAfter systemd remount fs serviceBefore sysinit target shutdown target systemd update done serviceConditionNeedsUpdate etc Service Type oneshotRemainAfterExit yesExecStart systemd sysusersTimeoutSec Service LoadCredential Finally restart and check the services again Install Dockerthe instructions for installing Docker in details from this tutorial we can skip Sharing dockerd and adding script because we use systemctl in short this can be done with the following Install dependenciessudo apt install no install recommends apt transport https ca certificates curl gnupgSwitch to legacy iptablesupdate alternatives config iptablesselect iptables legacypackage repository configurationFirst temporarily set some OS specific variables etc os releaseThen make sure that apt will trust the repo curl fsSL ID gpg sudo tee etc apt trusted gpg d docker ascThen add and update the repo information so that apt will use it in the future echo deb arch amd ID VERSION CODENAME stable sudo tee etc apt sources list d docker listsudo apt updateInstall Dockersudo apt install docker ce docker ce cli containerd ioAdd user to Docker groupsudo usermod aG docker USERFinally close that WSL window and launch WSL again And check if docker is working docker run rm hello world Install KD and AutoKsInstall KDcurl s bashInstall AutoKsDownload the binary from the release page curl create dirs o bin autoksMake it executablechmod bin autoksthen add to pathecho export PATH HOME bin PATH gt gt bashrcinstall kube explorer optional curl create dirs o bin kube explorerchmod HOME bin kube explorer start autoks to deploy Kubernetes clusterautoks serveOpen on your browser to start create delete modify Kubernetes clusters Select kd as provide and give name to the cluster and specify how many mater worker nodes you want This is a sample option I used to build a cluster with one master node and one worker node and limit their ram usage to GBYou can add the explorer to the cluster |
2022-07-10 22:12:30 |
Apple |
AppleInsider - Frontpage News |
Early Prime Day deal: Apple Watch Series 7 dips to $284, lowest price ever |
https://appleinsider.com/articles/22/07/09/early-prime-day-deal-apple-watch-series-7-dips-to-284-lowest-price-ever?utm_medium=rss
|
Early Prime Day deal Apple Watch Series dips to lowest price everAmazon is home to some of the best Apple Watch deals available ahead of Prime Day with the Series now off Amazon has slashed the Apple Watch Series to lowest price ever ahead of Prime Day Pre Prime Day Apple Watch discounts Read more |
2022-07-10 22:22:35 |
海外TECH |
Engadget |
Uber co-founder Travis Kalanick reportedly saw violence against drivers as a tool for growth |
https://www.engadget.com/uber-files-leak-221118281.html?src=rss
|
Uber co founder Travis Kalanick reportedly saw violence against drivers as a tool for growthA new trove of leaked documents has shed an unfavorable light on the early days of Uber Dubbed the Uber Files the leak consists of approximately internal company documents including more than emails and text messages exchanged between former CEO Travis Kalanick and other executives that date to a period between and The latter marks the year Kalanick stepped down as CEO of Uber amid mounting controversy Working with the International Consortium of Investigative Journalists ICIJ The Guardian shared the trove with journalists at outlets across countries The documents show a company willing to do things many of its own executives thought were “fucking illegal nbsp In for instance Kalanick reportedly ordered French employees to encourage local Uber drivers to counter protest the taxi strikes that were underway in Paris at the time When one executive warned Kalanick that “extreme right thugs were part of the protest the former CEO pushed back “I think it s worth it he said “Violence guarantee s success And these guys must be resisted no One former senior executive told The Guardian that nbsp Kalanick s response was consistent with a strategy of “weaponizing drivers and a playbook the company returned to in other countries Another selection of documents details the lengths the company went to escape regulatory scrutiny In at least instances Uber ordered staff at local offices in six countries including France the Netherlands and India to employ the “kill switch an internal tool the company developed to protect its data “Please hit the kill switch ASAP Kalanick wrote in one email shared by The Washington Post quot Access must be shut down in AMS he added referring to the company s Amsterdam office In two cases involving Uber s Montreal office authorities entered the building only to see all the computers and tablets before them resetting at the same time The company told The Post “such software should never have been used to thwart legitimate regulatory actions and that it stopped using the system in “We have not and will not make excuses for past behavior that is clearly not in line with our present values said Jill Hazelbaker Uber s senior vice president of marketing and public affairs in a statement the company issued after The Guardian published its findings on the Uber Files “Instead we ask the public to judge us by what we ve done over the last five years and what we will do in the years to come In a statement published by the ICIJ Travis Kalanick s spokesperson said any suggestion the former executive “directed engaged in or was involved in “illegal or improper conduct quot is “completely false quot quot The reality was that Uber s expansion initiatives were led by over a hundred leaders in dozens of countries around the world and at all times under the direct oversight and with the full approval of Uber s robust legal policy and compliance groups quot they added |
2022-07-10 22:11:18 |
金融 |
ニュース - 保険市場TIMES |
明治安田生命、メタバース上に「明治安田生命バーチャルスタジアム」を展開 |
https://www.hokende.com/news/blog/entry/2022/07/11/080000
|
明治安田生命、メタバース上に「明治安田生命バーチャルスタジアム」を展開仮想空間でのイベントも明治安田生命保険相互会社は月日、メタバース上に「明治安田生命バーチャルスタジアム」を展開すると発表した。 |
2022-07-11 08:00:00 |
ニュース |
BBC News - Home |
Man dies after fall from bonfire |
https://www.bbc.co.uk/news/uk-northern-ireland-62111760?at_medium=RSS&at_campaign=KARANGA
|
antiville |
2022-07-10 22:07:46 |
ニュース |
BBC News - Home |
The Papers: 'Tory rivals scramble' amid 'toxic smears' |
https://www.bbc.co.uk/news/blogs-the-papers-62117007?at_medium=RSS&at_campaign=KARANGA
|
front |
2022-07-10 22:36:15 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
トランプ氏元側近バノン氏、議会襲撃で証言の意向=特別委 - WSJ発 |
https://diamond.jp/articles/-/306252
|
議会 |
2022-07-11 07:22:00 |
北海道 |
北海道新聞 |
大谷、球宴に投手でも選出 DHと2年連続で二刀流 |
https://www.hokkaido-np.co.jp/article/704135/
|
大リーグ |
2022-07-11 07:34:29 |
北海道 |
北海道新聞 |
猪瀬直樹氏「改革伝わった」 公示前にセクハラ行為で批判 |
https://www.hokkaido-np.co.jp/article/704133/
|
日本維新の会 |
2022-07-11 07:17:03 |
北海道 |
北海道新聞 |
今井絵理子氏「スピード感ない」 投票翌日の当選、笑顔見せ |
https://www.hokkaido-np.co.jp/article/704130/
|
speed |
2022-07-11 07:09:14 |
コメント
コメントを投稿