AWS |
AWS Machine Learning Blog |
Build taxonomy-based contextual targeting using AWS Media Intelligence and Hugging Face BERT |
https://aws.amazon.com/blogs/machine-learning/build-taxonomy-based-contextual-targeting-using-aws-media-intelligence-and-hugging-face-bert/
|
Build taxonomy based contextual targeting using AWS Media Intelligence and Hugging Face BERTAs new data privacy regulations like GDPR General Data Protection Regulation have come into effect customers are under increased pressure to monetize media assets while abiding by the new rules Monetizing media while respecting privacy regulations requires the ability to automatically extract granular metadata from assets like text images video and audio files at … |
2022-07-20 16:29:48 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
DjangoでGraphQLを触ってみるPart.3 (データ操作編) |
https://qiita.com/abemaru/items/6f396991a0de716d1684
|
django |
2022-07-21 01:03:11 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Rails6.1で追加されたmissingがとてもエレガント |
https://qiita.com/YoshitakeHiroki/items/eb92d9471c57e49cfe45
|
leftjoinsdataswheredatas |
2022-07-21 01:47:59 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
form_withの引数について |
https://qiita.com/izsm/items/4b067d58791eb8e4781a
|
formwith |
2022-07-21 01:12:39 |
海外TECH |
MakeUseOf |
10 Basic DIY Projects to Improve Your Home’s Security |
https://www.makeuseof.com/basic-diy-projects-improve-home-security/
|
security |
2022-07-20 16:30:14 |
海外TECH |
MakeUseOf |
9 Ways to Fix a Bluetooth Audio Delay in Windows 11 |
https://www.makeuseof.com/windows-11-bluetooth-delay-fix/
|
windows |
2022-07-20 16:15:14 |
海外TECH |
DEV Community |
Create Simultaneous Allowlists with Signature Drop and Next.js |
https://dev.to/thirdweb/create-simultaneous-allowlists-with-signature-drop-and-nextjs-3aco
|
Create Simultaneous Allowlists with Signature Drop and Next jsLearn how to create simultaneous allowlists where different users can buy NFTs from the drop at a different price based on which allowlist they are in What is thirdweb thirdweb is a platform that lets you deploy smart contracts without having to know Solidity you can do it by using TypeScript Python or Go or even without writing any code IntroductionIn this guide we are going to create a Signature drop where userswill be able to connect their wallets to the website and claim an NFT from the drop Once the user clicks Mint we will make anAPI request that checks if the user is in one of our allowlists Based on the check we will generate a signature with a different price for each allowlist Let s get started SetupI am going to use the Next typescript starter template for this guide If you are following along with the guide you can create a project with theNext TypeScript template using the thirdweb CLI npx thirdweb create next tsIf you already have a Next js app you can simply follow these steps to get started Install thirdweb dev react and thirdweb dev sdk and ethersAdd MetaMask authentication to the site You can follow this guide to do this By default the network in app tsx is Mainnet we need to change it to Mumbaiimport type AppProps from next app import ChainId ThirdwebProvider from thirdweb dev react This is the chainId your dApp will work on const activeChainId ChainId Mumbai function MyApp Component pageProps AppProps return lt ThirdwebProvider desiredChainId activeChainId gt lt Component pageProps gt lt ThirdwebProvider gt export default MyApp Creating a Signature Drop and batch Uploading NFTsWe also need to create a Signature Drop and upload a bunch of NFTs that users can claim So go to the thirdweb dashboard and create a signature drop Fill out the details and deploy the contract Now let s batch upload some NFTs for the users to mint I am going to use the Pokemon batch upload example Click on batch upload and upload the images and the CSV JSON file Once they are uploaded you will be able to see the NFTs To learn more about batch upload check out this guide Making the website Creating an API for generating a signatureWe are going to use the signature minting on our backend to check the price at which this user will mint the NFT Create a new folder api in the pages folder and generate mint sig ts inside it We will now build a basic API that will output gm wagmi import type NextApiRequest NextApiResponse from next const generateMintSignature async req NextApiRequest res NextApiResponse gt res send gm wagmi export default generateMintSignature This creates a basic API for us if you now go to the api generate mint sigendpoint you will get a response of Gm wagmi Let s now initialize the thirdweb SDK const sdk ThirdwebSDK fromPrivateKey process env PRIVATE KEY as string mumbai As you can see we are using an environment variable to initialize the sdk The variable is called PRIVATE KEY which is the private key of the wallet Create a new file env local and add your private key PRIVATE KEY lt private key gt How to export your private keyLearn how to export your private key from your wallet To do this create a file called env local at the root of your project and add the following to it PRIVATE KEY your private key hereEnsure you store and access your private key securely Never commit any file that may contain your private key to your source control We also need to import the ThirdwebSDK import ThirdwebSDK from thirdweb dev sdk Determining the price of the NFTI am creating hardcoded arrays in this example but you can get them from a JSON file from a database or anything you like So add these arrays and a function to determine the price const teamMembers xAbfAfbadeCFBEcDBd const allowList xbFEaeBCcf const determinePrice address string gt if teamMembers includes address return if allowList includes address return return So if the person is in the allowlist they will mint the NFT for MATIC if they are a team member they will mint the NFT for MATIC and if they are not in an allowlist they will mint the NFT for MATIC Generating the signatureFinally we are going to access the Signature Drop using the sdk and generate a signature from it const address req body const drop sdk getSignatureDrop xcBeEFaCeeDeFAdAF try const signedPayload await drop signature generate to address price determinePrice address return res status json signedPayload signedPayload catch error console log error return res status json error Calling the API from the frontendIn index tsx update the address ternary and add the Mint button lt div gt address lt button onClick mint gt Mint lt button gt lt button onClick connectWithMetamask gt Connect with Metamask lt button gt lt div gt Now we will create the mint function that makes an api call to the backend and mints the NFT const drop useSignatureDrop xcBeEFaCeeDeFAdAF const mint async gt const signedPayloadReq await fetch api generate mint sig method POST body JSON stringify address const signedPayload await signedPayloadReq json try const nft await drop signature mint signedPayload signedPayload return nft catch err console error err return null If we now try minting the NFT we will be able to mint the NFT successfully at different prices ConclusionThis was a lot now pat yourself on the back and share your amazing apps with us If you want to have a look at the code check out the GitHub Repository |
2022-07-20 16:47:43 |
海外TECH |
DEV Community |
React Query v4 + SSR in Next JS |
https://dev.to/arianhamdi/react-query-v4-ssr-in-next-js-2ojj
|
React Query v SSR in Next JSSSR data fetching caching mechanism is a bit tricky in next js In this article we will learn how to improve initial load time via SSR and have a high speed client side navigation with the help of CSR and React Query We will create a blog app using the JSON Placeholder API We are going to see just important sections here To see the full source code checkout the github repo You can also check the Live demo to get a better sight The React Query devtools is available in this demo so you can check the cache flow Table of contents Create a new project Setup Hydration Prefetching and dehydrate data Shallow Routing with CSR HOC handle status code Conclusion Refrences Create a new project First create a nextjs project yarn create next app blog appornpx create next app blog appLet s install React Query and Axios yarn add tanstack react query axiosornpm install tanstack react query axios Setup Hydration Due to the react query documents we set up hydration in app js pages app jsimport useState from react import Hydrate QueryClient QueryClientProvider from tanstack react query import config from lib react query config function MyApp Component pageProps This ensures that data is not shared between different users and requests const queryClient useState gt new QueryClient config return lt QueryClientProvider client queryClient gt Hydrate query cache lt Hydrate state pageProps dehydratedState gt lt Component pageProps gt lt Hydrate gt lt QueryClientProvider gt export default MyApp Prefetching and dehydrate data Before we continue note that In v React Query would cache query results for a default of minutes then manually garbage collect that data This default was applied to server side React Query as well This lead to high memory consumption and hanging processes waiting for this manual garbage collection to complete In v by default the server side cacheTime is now set to Infinity effectively disabling manual garbage collection the NodeJS process will clear everything once a request is complete Now we need to prefetch data and dehydrate queryClient in getServerSideProps method pages posts id jsimport getPost from api posts import dehydrate QueryClient from tanstack react query export const getServerSideProps async ctx gt const id ctx params const queryClient new QueryClient prefetch data on the server await queryClient prefetchQuery post id gt getPost id return props dehydrate query cache dehydratedState dehydrate queryClient From now on we can easily use this prefetched data in our page without passing any data by props Just to be clear lets take a look at the implementation of getPost method and usePost hook api posts jsimport axios from lib axios export const getPost async id gt const data await axios get posts id return data hooks api posts jsimport useQuery from tanstack react query import as api from api posts export const usePost id gt return useQuery post id gt api getPost id Now we can use this usePost hook to get post data pages posts id jsimport useRouter from next router import usePost from hooks api posts import Loader from components Loader import Post from components Post import Pagination from components Pagination const PostPage gt const query id useRouter const data isLoading usePost id if isLoading return lt Loader gt return lt gt lt Post id data id title data title body data body gt lt Pagination id id gt lt gt getServerSideProps implementation We talked about it in section Shallow Routing We want to manage our data fetching and caching mechanism just in the client so we need to use shallow true prop in the Link component for navigating between post pages to prevent calling getServerSideProps each time This means that getServerSideProps method will only call when the users directly hit the URL of the post and not in the client side navigation within the app We have a Pagination component to navigate between pages so we use shallow true here components Pagination jsximport Link from next link function PaginationItem index return lt Link className itemClassName href posts index shallow true gt index lt Link gt export default PaginationItem P S We used the new link component in nextjs v so we didn t need to use lt a gt tag here with CSR HOC At this time nextjs v shallow routing only works for URL changes in the current page nextjs shallow routing caveatsthis means if you navigate from posts to posts with shallow true the getServerSideProps won t call but if you navigate from home to posts the getServerSideProps is called even you use shallow routing and this will fetch unnecessary data even if it s available in the cache I found a work around that checks if this request to getServerSideProps is a client side navigation request or not If it was then returns an empty object for props and prevents fetching data on the server we can t prevent calling getServerSidePropswhen navigating between different pages but we can prevent fetching unnecessary data in the getServerSideProps Here is withCSR HOC implementation HOC with CSR jsexport const withCSR next gt async ctx gt check is it a client side navigation const isCSR ctx req url startsWith next if isCSR return props return next ctx Now we should wrap our getServerSideProps with this HOC pages posts id jsimport getPost from api posts import dehydrate QueryClient from tanstack react query import withCSR from HOC with CSR export const getServerSideProps withCSR async ctx gt const id ctx params const queryClient new QueryClient await queryClient prefetchQuery post id gt getPost id return props dehydratedState dehydrate queryClient If we navigate from different pages to post pages getServerSideProps won t fetch any data and it just returns an empty object for props Handle status code While Next js renders an error page if a post is not available it doesn t actually respond with an error status code This means that while you can be viewing a error the page is actually responding with a code To search engines this essentially translates to Everything went fine and we found the page Rather than actually responding with a which tells search engines that page doesn t exist To resolve this issue let s take a look at getServerSideProps again const Page isError gt show custom error component if there is an error if isError return lt Error gt return lt PostPage gt export const getServerSideProps withCSR async ctx gt const id ctx params const queryClient new QueryClient config await queryClient prefetchQuery post id gt getPost id get post state const state queryClient getQueryState post id const isError state error if there is an error we will change response status code if isError ctx res statusCode state error response status return props also passing down isError state to show a custom error component isError dehydratedState dehydrate queryClient export default Page Conclusion We setup a caching mechanism with the ability to prefetch data on the server in SSR context We also learned how to use shallow routing for faster client side navigation Here is the live demo of our implementation and the github repository for source code As well I had been added React Query devtools into production for you to understand thoroughly what is going under the hood I would like to extend my sincere thanks to alyn Refrences JSON Placeholder APIReact Query setup hydrationReact Query no manual garbage collection server sidenextjs shallow routing caveatsPrevent data fetching in getServerSideProps on client side navigationrespond with a error in Next jsProject source codeLive demo |
2022-07-20 16:17:58 |
Apple |
AppleInsider - Frontpage News |
Apple releases iOS 15.6 & iPadOS 15.6 with bug fixes |
https://appleinsider.com/articles/22/07/20/apple-releases-ios-156-ipados-156-with-bug-fixes?utm_medium=rss
|
Apple releases iOS amp iPadOS with bug fixesThe iOS and iPadOS release is now available to download but with iOS expected to launch in September it is just a simple bug fix update Apple releases iOS and iPadOS with bug fixesThe updates will install automatically for most users but anyone who wants to push the update right away can do so from the Settings app Just select General then Software Update to check if the new updates are available Read more |
2022-07-20 16:57:52 |
Apple |
AppleInsider - Frontpage News |
3D printer basics: The best 3D printers for Mac and iOS users |
https://appleinsider.com/articles/22/07/20/3d-printer-basics-the-best-3d-printers-for-mac-and-ios-users?utm_medium=rss
|
D printer basics The best D printers for Mac and iOS usersIf you want to delve into the emerging ecosystem of D printing and own a Mac iPhone or iPad here s what you need to know before you take your first foray and print your first test boat Image via Pexels A natural progression of the maker movement D printing has risen in popularity over the years and has become a way for people to turn D models into real physical items Read more |
2022-07-20 16:47:53 |
Apple |
AppleInsider - Frontpage News |
Limited edition Beats Studio Buds coming, in partnership with Nickmercs |
https://appleinsider.com/articles/22/07/20/limited-edition-beats-studio-buds-coming-in-partnership-with-nickmercs?utm_medium=rss
|
Limited edition Beats Studio Buds coming in partnership with NickmercsApple s Beats by Dre brand is releasing a new limited edition version of the Beats Studio Buds in partnership with gaming streamer Nickmercs Nickmercs Beats Studio BudsNick Nickmercs Kolcheff is a Twitch streamer and co owner of esports organization Faze Clan The new limited edition Beats are meant to pay homage to the professional Twitch streamers loyal community the company wrote in a press release Read more |
2022-07-20 16:36:50 |
Apple |
AppleInsider - Frontpage News |
AirPods given USB-C & more repairable design by engineer |
https://appleinsider.com/articles/22/07/20/airpods-given-usb-c-more-repairable-design-by-engineer?utm_medium=rss
|
AirPods given USB C amp more repairable design by engineerThe engineer who placed a USB C port in a custom AirPods charging case has provided an in depth video for his methodology and explains how others can try it at home USB C in a custom AirPods case Image source Ken PillonelYouTuber and engineer Ken Pillonel isn t happy about Apple s port situation so he s been finding ways to rectify it himself After putting USB C in an iPhone he built an AirPods charging case with USB C using a combination of custom components and Apple s own internals Read more |
2022-07-20 16:28:15 |
Apple |
AppleInsider - Frontpage News |
Hands on: Whill model F motorized wheelchair with iPhone connectivity |
https://appleinsider.com/articles/22/07/20/hands-on-whill-model-f-motorized-wheelchair-with-iphone-connectivity?utm_medium=rss
|
Hands on Whill model F motorized wheelchair with iPhone connectivityWhile we wish the need for a motorized wheelchair on nobody chairs like Whill s Model F integrate well with Apple technologies and are mobility preserving for the folks that do need them Here s what it s like to use one Whill Model FI am not the one who needs this chair so a little bit of a preamble is in order If you followed me to AppleInsider from a prior publication that has since succumbed to bit rot you may have a dim recollection of reading about my spouse having a stroke in the summer of Read more |
2022-07-20 16:29:49 |
海外科学 |
NYT > Science |
Heat Wave Complicates Global Energy Crisis and Climate Fight |
https://www.nytimes.com/2022/07/20/climate/global-energy-crisis-climate-war.html
|
Heat Wave Complicates Global Energy Crisis and Climate FightFirst Russia upended the world energy market then searing temperatures drove up demand for energy forcing some of the world s largest economies to scramble to secure power for their citizens |
2022-07-20 16:25:20 |
金融 |
金融庁ホームページ |
金融庁職員の新型コロナウイルス感染について公表しました。 |
https://www.fsa.go.jp/news/r4/sonota/20220720.html
|
新型コロナウイルス |
2022-07-20 17:15:00 |
ニュース |
BBC News - Home |
New nuclear power plant gets go-ahead |
https://www.bbc.co.uk/news/uk-england-suffolk-62235221?at_medium=RSS&at_campaign=KARANGA
|
nuclear |
2022-07-20 16:12:37 |
ニュース |
BBC News - Home |
David Venables jailed for wife's septic tank murder |
https://www.bbc.co.uk/news/uk-england-hereford-worcester-62235752?at_medium=RSS&at_campaign=KARANGA
|
brenda |
2022-07-20 16:38:56 |
ニュース |
BBC News - Home |
Prince Charles: No inquiry into £2.5m cash donation to his charity |
https://www.bbc.co.uk/news/uk-62011791?at_medium=RSS&at_campaign=KARANGA
|
charity |
2022-07-20 16:08:45 |
ニュース |
BBC News - Home |
Check your postcode: Is your area vulnerable to extreme heat? |
https://www.bbc.co.uk/news/uk-62243280?at_medium=RSS&at_campaign=KARANGA
|
experiences |
2022-07-20 16:49:23 |
ニュース |
BBC News - Home |
Euro 2022: England boss Sarina Wiegman to return for quarter-final against Spain |
https://www.bbc.co.uk/sport/football/62241258?at_medium=RSS&at_campaign=KARANGA
|
Euro England boss Sarina Wiegman to return for quarter final against SpainEngland manager Sarina Wiegman is to return for Wednesday s Euro quarter final against Spain after recovering from a bout of Covid |
2022-07-20 16:15:47 |
ニュース |
BBC News - Home |
Tour de France: Tadej Pogacar wins stage 17 but Jonas Vingegaard retains overall lead |
https://www.bbc.co.uk/sport/cycling/62241055?at_medium=RSS&at_campaign=KARANGA
|
Tour de France Tadej Pogacar wins stage but Jonas Vingegaard retains overall leadTadej Pogacar edges out Jonas Vingegaard to win stage of the Tour de France but the Dane retains a handsome overall lead |
2022-07-20 16:17:00 |
北海道 |
北海道新聞 |
イラク北部攻撃、9人死亡 トルコ、観光客に被害 |
https://www.hokkaido-np.co.jp/article/708198/
|
観光客 |
2022-07-21 01:32:00 |
北海道 |
北海道新聞 |
胆振65人感染 日高は22人 新型コロナ |
https://www.hokkaido-np.co.jp/article/708197/
|
新型コロナウイルス |
2022-07-21 01:18:00 |
北海道 |
北海道新聞 |
三ツ山病院「コロナに負けない」 医療機関で唯一「潮ねりこみ」参加 |
https://www.hokkaido-np.co.jp/article/708122/
|
医療機関 |
2022-07-21 01:02:03 |
コメント
コメントを投稿