投稿時間:2023-01-11 01:22:32 RSSフィード2023-01-11 01:00 分まとめ(24件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita ABC284 A~E問題 ものすごく丁寧でわかりやすい解説 python 灰色~茶色コーダー向け #AtCoder https://qiita.com/sano192/items/fddbb5f56f7552fffe7c abcae 2023-01-11 00:12:11
Ruby Rubyタグが付けられた新着投稿 - Qiita 【Ruby】で配列に複数入ったオブジェクトを一つだけ消そうとしたら失敗した https://qiita.com/giver0720/items/c062b2ffcd7aea095663 配列 2023-01-11 00:39:27
海外TECH DEV Community 7 React Hooks for Every Project https://dev.to/webdevhero-com/7-react-hooks-for-every-project-1jdo React Hooks for Every ProjectHooks are one of the most powerful features of React They enable us to easily reuse functionality across our application s components What s best about hooks is their reusability you can reuse your hooks both across components and your projects Here are seven of the most important hooks that I reuse across every React project I create Give them a try today and see if they re as useful for you when building your own React apps Before we begin it s important to clarify that not every custom React hook needs to be written by you In fact all of the hooks that I will mention come from the library mantine hooks Mantine is great third party library that includes these hooks and many more They will add just about every significant feature to your React app that you can think of You can check out the documentation for mantine hooks at mantine dev The useIntersection HookWhen a user scrolls down the page in your application you may want to know when an element is visible to them For example you might want to start an animation only when a user sees a specific element Or you may want to show or hide an element after they ve scrolled a certain amount down the page To get information about whether an element is visible we can use the Intersection Observer API This is a JavaScript API that s built into the browser We can use the API on its own using plain JavaScript but a great way to get information about whether a particular element is being intersected within its scroll container is to use the useIntersection hook import useRef from react import useIntersection from mantine hooks function Demo const containerRef useRef const ref entry useIntersection root containerRef current threshold return lt main ref containerRef style overflowY scroll height gt lt div ref ref gt lt span gt entry isIntersecting Fully visible Obscured lt span gt lt div gt lt main gt To use it all we need to do is call the hook in our component and provide a root element Root is the scroll container and this can be provided as a ref with the useRef hook useIntersection returns a ref which we pass to the target element whose intersection in the scroll container we want to observe Once we have a reference to the element we can keep track of whether the element is intersecting or not In the example above we can see when the element is obscured or when it s fully visible based off the value of entry isIntersecting You can pass additional arguments that allow you to configure the threshold which is related to what percentage of the target is visible The useScrollLock HookAnother hook related to scrolling is the useScrollLock hook This hook is very simple it enables you to lock any scrolling on the body element I have found it to be helpful whenever you want to display an overlay or a modal over the current page and do not want to allow the user to scroll up and down on the page in the background This lets you either focus attention on the modal or allow scrolling within its own scroll container import useScrollLock from mantine hooks import Button Group from mantine core import IconLock IconLockOpen from tabler icons function Demo const scrollLocked setScrollLocked useScrollLock return lt Group position center gt lt Button onClick gt setScrollLocked c gt c variant outline leftIcon scrollLocked lt IconLock size gt lt IconLockOpen size gt gt scrollLocked Unlock scroll Lock scroll lt Button gt lt Group gt useScrollLock locks the user s scroll at their current position on the page The function returns an array which can be destructured as in the code above The second value is a function that allows us to lock the scroll The first destructured value on the other hand is a boolean that tells us whether the scroll has been locked or not This value is useful for example if you want to show certain content when the scroll is locked or to tell the user that it has been locked You can see in the example below that we are indicating within our button when the scroll has been locked or unlocked The useClipboard HookIn many cases you want to provide a button that allows the user to copy something to their clipboard which is where copied text is stored A great example of this is if you have a code snippet on your website and you want to users to easily copy it For this we can use another web API the Clipboard API mantine hooks gives us a convenient useClipboard hook which returns a couple of properties copied which is a boolean that tells us whether a value has been copied to the clipboard using the hook as well as a copy function to which we can pass whatever string value we like to it to be copied In our example we would like to copy a code snippet for our users to paste where they like as seen in the video below useClipboard demoWe call our copy function when they hit our designated copy button pass to it the code snippet and then show a little checkmark or something that indicates to them that the text has been copied What s neat is the useClipboard hook comes with a timeout value After a given timeout period which is in milliseconds the copied state will be reset showing the user that they can copy the text again The useDebouncedValue HookThe next hook useDebouncedValue is essential if you have a search input in your app Whenever a user performs a search using an input the search operation usually involves an HTTP request to an API A typical problem you will encounter especially if you want your users to receive search results as they are typing is that a query request will be performed on every keystroke Even for a simple search query there is no need to perform so many requests before a user has finished typing what they want This is a great use case for the useDebounceValue hook which applies a debounce function on the text that s has been passed to it import useState from react import useDebouncedValue from mantine hooks import getResults from api function Demo const value setValue useState const results setResults useState const debounced useDebouncedValue value wait time of ms useEffect gt if debounced handleGetResults async function handleGetResults const results await getResults debounced setResults results debounced return lt gt lt input label Enter search query value value style flex onChange event gt setValue event currentTarget value gt lt ul gt results map result gt lt li gt result lt li gt lt ul gt lt gt You store the text from your input in a piece of state with useState and pass the state variable to useDebouncedValue As the second argument to that hook you can provide a wait time which is the period of time that the value is debounced The debounce is what enables us to perform far fewer queries You can see the result in the video below where the user types something and only after milliseconds do we see the debounced value The useMediaQuery HookAnother very useful hook that I use all the time is the useMediaQuery hook Media Queries are used in plain CSS and the useMediaQuery hook allows us to subscribe to whatever media query we pass to the hook For example within our component let s say that we want to show some text or change the styles of a component based off of a certain screen width such as pixels We provide a media query just like we would in CSS and useMediaQuery returns to us a matches value which is either true or false import useMediaQuery from mantine hooks function Demo const matches useMediaQuery min width px return lt div style color matches teal red gt matches I am teal I am red lt div gt It tells us the result of that media query in JavaScript which is particularly useful when we have styles that we want to change directly within our JSX using the style prop for example In short this is an essential hook for those handful of cases in which CSS cannot be used to handle media queries The useClickOutside HookThis next hook useClickOutside might seem like a strange one but you ll see how important it is when you actually need it When you develop a dropdown or something that pops up in front of a page s content and needs to be closed afterwards such as a modal or drawer this hook is indispensable It s very easy to open one of these types of components by clicking a button Closing these components is a little harder To follow good UX practices we want anything that obstructs our user s view to be easily closable by clicking outside of the element This is specifically what the useClickOutside hook lets us do When we call useClickOutside it returns a ref that we must pass to the element outside of which we want to detect clicks Usually that element is going to be controlled by a boolean piece of state such as the one we have in our example below that is the value opened import useState from react import useClickOutside from mantine hooks function Demo const opened setOpened useState false const ref useClickOutside gt setOpened false return lt gt lt button onClick gt setOpened true gt Open dropdown lt button gt opened amp amp lt div ref ref shadow sm gt lt span gt Click outside to close lt span gt lt div gt lt gt useClickOutside accepts a callback function which controls what happens when you actually click outside that element In most cases we want to do something quite simple which is to just close it To do so you ll likely need to have a state setter like setOpened and pass it a value of false to then hide your overlayed content The useForm HookMy favorite and most helpful hook in this list is the useForm hook This hook comes specifically from Mantine and involves installing a specific package from the library mantine form It should give you everything that you need to create forms in React including the ability to validate inputs display error messages and ensure the input values are correct before the form is submitted useForm accepts some initial values which correspond to whatever inputs you have within your form import TextInput Button from mantine core import useForm from mantine form function Demo const form useForm initialValues email validate email value gt S S test value null Invalid email return lt div gt lt form onSubmit form onSubmit values gt console log values gt lt TextInput withAsterisk label Email placeholder your email com form getInputProps email gt lt Button type submit gt Submit lt Button gt lt form gt lt div gt The great benefit of useForm is its helpers such as the validate function which receives the value that s been typed in to each input then allows you to create validation rules For example if you have an email input you might have a regular expression to determine whether it is in fact a valid email as you can see in the code above If not then you can show an error message and prevent the form from being submitted How do you get the values that have been typed into the form Mantine provides a very convenient helper called getInputProps where you simply provide the name of the input you re working with like email and it automatically sets up an onChange to keep track of the values that you ve typed into your form Additionally to handle form submission and prevent submission if its values do not pass validation rules it has a special onSubmit function which you wrap around your regular onSubmit function On top of applying the validation rules it will take care of calling preventDefault on the form event so that you don t have to do it manually I am just scratching the surface with this hook but I would highly recommend you use it for your next project Forms are traditionally a pain to get working properly especially forms that require validation and visible error messages useForm makes it incredibly easy Want the All in one Way to Learn React As we ve seen in this post there are tons of powerful hooks that we can use to build our applications If you want to really learn React in depth including writing and using amazing hooks like these I have made a complete resource for you called the React Bootcamp It will teach you everything you need to be a React pro from the fundamentals of the library even if you ve never used it before to building complete fullstack applications Just click the link below to get started Enjoy Click to join the React Bootcamp 2023-01-10 15:51:23
海外TECH DEV Community Top 7 Featured DEV Posts from the Past Week https://dev.to/devteam/top-7-featured-dev-posts-from-the-past-week-4ikf Top Featured DEV Posts from the Past WeekEvery Tuesday we round up the previous week s top posts based on traffic engagement and a hint of editorial curation The typical week starts on Monday and ends on Sunday but don t worry we take into account posts that are published later in the week Understanding Git with ImagesInspired by Nico Riedmann s Learn git concepts not commands nopenoshishi put together an awesome guide on Git s system structure featuring hand drawn images Understanding Git through images kataoka nopeNoshishi・Jan ・ min read git beginners image tutorial Improve Your Chances at InterviewsLooking for work is always a tough experience Here andrewbaisden describes many actions you might take to make sure you get your foot in the door of the IT business How to increase your chances of getting interviews and job offers in tech Andrew Baisden・Jan ・ min read career watercooler codenewbie beginners Databases Databases can be a confusing and scary topic for those who haven t explored them danielhert shares their learnings letting us know what they find particularly fascinating about databases Database Data Consistency for Beginners Daniel Reis・Jan ・ min read beginners database sql architecture Reduce Docker Image SizesReducing the size of the Docker image in their pet project by kitarp uncovered some really effective methods for bringing down the size of Docker images Read on to see how they made it happen Reducing Docker Image size Pratik Singh・Jan ・ min read docker go devops kubernetes Google Logo in CSSIllustrating logos in CSS is a great way to learn the ins and outs of the language In this post ratracegrad walks us through creating the Google logo Learn CSS Create the Google Logo Jennifer Bland・Jan ・ min read css webdev tutorial A Guide to WebAssemblyWebAssembly Wasm is a low level binary format that is designed to be faster and more efficient than traditional JavaScript In this article cocoandrew explores how to use WebAssembly in a web application Revolutionizing the Web with WebAssembly A Comprehensive Guide Cocoandrew・Jan ・ min read webassembly productivity programming webdev Blogging for DevelopersThough it can be difficult to get going nasirovelchin puts forth several reasons why blogging is particularly beneficial to software developers Every Software Developer should write a blog Elchin Nasirov・Jan ・ min read blog webdev programming developer That s it for our weekly Top for this Tuesday Keep an eye on dev to this week for daily content and discussions and be sure to keep an eye on this series in the future You might just be in it 2023-01-10 15:39:46
Apple AppleInsider - Frontpage News Apple's 14-inch MacBook Pro dips to $1,599 at Amazon, plus $400 off additional models https://appleinsider.com/articles/23/01/10/apples-14-inch-macbook-pro-dips-to-1599-at-amazon-plus-400-off-additional-models?utm_medium=rss Apple x s inch MacBook Pro dips to at Amazon plus off additional modelsAmazon s top holiday MacBook Pro deals have returned for with retail inch and inch models now off Save on MacBook Pros Top MacBook Pro deals are back Read more 2023-01-10 15:54:41
Apple AppleInsider - Frontpage News Eddy Cue highlights groundbreaking year for apps, music, TV https://appleinsider.com/articles/23/01/10/eddy-cue-highlights-groundbreaking-year-for-apps-music-tv?utm_medium=rss Eddy Cue highlights groundbreaking year for apps music TVAs senior vice president of Apple Music Apple TV and more Eddy Cue is celebrating a milestone number of subscribers and what he describes as a groundbreaking year for apps music TV Cue s position overseeing all of Apple s services was finally recognized in in with a change to his job description Since then services grew to over million subscribers in October At some point over the past year you probably discovered a new app a new song a new TV show or movie or game writes Cue An experience that made you laugh taught you something new or helped you see the world in a new way ーand moved you to share it with others Read more 2023-01-10 15:37:54
Apple AppleInsider - Frontpage News Microsoft dumping ton of cash into ChatGPT Office infusion https://appleinsider.com/articles/23/01/10/microsoft-dumping-ton-of-cash-into-chatgpt-office-infusion?utm_medium=rss Microsoft dumping ton of cash into ChatGPT Office infusionFresh after rumors of using OpenAI s writing technology in its productivity apps Microsoft is now preparing to invest billion into the AI tool company OpenAITools using artificial intelligence are becoming a more important element of computing and Microsoft is seemingly backing an expansion in the field It apparently intends to do so by investing billion into OpenAI the producers of the popular text tool ChatGPT Read more 2023-01-10 15:08:01
海外TECH Engadget Coinbase is laying off another 950 workers amid a crypto market downturn https://www.engadget.com/coinbase-lay-offs-reduced-expenses-153433234.html?src=rss Coinbase is laying off another workers amid a crypto market downturnCoinbase is letting another employees go seven months after it cut jobs In a note to staff the company s CEO Brian Armstrong said that amid a downturn in the crypto market and the broader economy he s made the call to reduce operating expenses by percent quarter over quarter resulting in the layoffs Coinbase says on its website that it has more than employees so it s shedding around a fifth of its staff While acknowledging that some of the factors that resulted in the layoffs were outside of the company s control Armstrong said he took accountability He added that in hindsight Coinbase could have let more people go back in June Armstrong said the company is well capitalized and crypto isn t going anywhere and noted that recent events like FTX s collapse and clearer rules from regulators could benefit Coinbase in the long run However those changes won t happen overnight We need to make sure we have the appropriate operational efficiency to weather downturns in the crypto market and capture opportunities that may emerge Armstrong wrote In planning for Coinbase s leadership determined it was necessary to reduce expenses to increase our chances of doing well in every scenario Armstrong notes that this is the first time that both the crypto market and the broader economy have simultaneously experienced a downturn adding that planning has helped Coinbase to survive several bear markets over the last decade Due to the layoffs Coinbase is canceling some projects that had a lower likelihood of success Other teams will have to adjust for having a smaller headcount Armstrong said the employees who are being let go will be informed today Impacted workers in the US will receive a compensation package of at least weeks base pay with an extra two weeks per year of service health insurance and other benefits The company says it will offer extra transition support to those on work visas Coinbase will extend similar support to fired workers in other countries in line with local employment laws and it will help those being laid off to find their next job Coinbase has had to contend with other issues in recent times In July it was reported that the Securities and Exchange Commission was investigating the company over whether it sold unregistered securities Earlier this month Coinbase reached a million settlement with a New York financial regulator over claims that it made the platform vulnerable to serious criminal conduct in part by neglecting to carry out sufficient background checks and having a large backlog of flagged transactions to review 2023-01-10 15:34:33
海外TECH Engadget Amazon brings Prime shipping to more third-party sites on January 31st https://www.engadget.com/amazon-buy-with-prime-third-party-sites-151609757.html?src=rss Amazon brings Prime shipping to more third party sites on January stLike it or not Amazon is expanding Prime to cover more of the web The company says it s making Buy with Prime quot widely available quot to eligible third party sites in the US on January st More shops can offer free shipping a streamlined checkout and simplified returns to Prime members Before now stores had to already be using Amazon s fulfillment system and receive an invitation The company is also introducing an option that lets Buy with Prime partners feature Amazon customer ratings and reviews on their store pages A site won t have to hope that someone leaves a glowing review on its own storefron If someone shopping at Amazon likes a product it ll be visible on the third party shop The theoretical advantages are clear You get products with less hassle while stores are more likely to turn visitors into paying customers Amazon meanwhile is hoping to boost interest in Prime subscriptions and play an important role at other merchants The catch of course is that you have to pay Amazon to reap the benefits ーand not everyone may be thrilled by the prospect Amazon is already facing government scrutiny over the treatment of third party sellers on its marketplace including accusations it uses their sales data to develop rival products Buy with Prime extends Amazon s influence to yet more sellers and could invite more attention from regulators as a result 2023-01-10 15:16:09
海外科学 NYT > Science AI Is Becoming More Conversant. But Will It Get More Honest? https://www.nytimes.com/2023/01/10/science/character-ai-chatbot-intelligence.html AI Is Becoming More Conversant But Will It Get More Honest At a new website called Character AI you can chat with a reasonable facsimile of almost anyone live or dead real or especially imagined 2023-01-10 15:45:27
海外科学 BBC News - Science & Environment UK rocket failure is a setback, not roadblock https://www.bbc.co.uk/news/science-environment-64223882?at_medium=RSS&at_campaign=KARANGA failure 2023-01-10 15:33:41
金融 ◇◇ 保険デイリーニュース ◇◇(損保担当者必携!) 保険デイリーニュース(01/11) http://www.yanaharu.com/ins/?p=5119 三井住友海上 2023-01-10 15:38:23
金融 RSS FILE - 日本証券業協会 株券等貸借取引状況(週間) https://www.jsda.or.jp/shiryoshitsu/toukei/kabu-taiw/index.html 貸借 2023-01-10 15:30:00
金融 RSS FILE - 日本証券業協会 J-IRISS https://www.jsda.or.jp/anshin/j-iriss/index.html iriss 2023-01-10 15:07:00
金融 金融庁ホームページ EDINETの稼働状況に関するお知らせについて更新しました。 https://www.fsa.go.jp/search/edinet-Information/information-01.html edinet 2023-01-10 17:00:00
ニュース BBC News - Home Strikes bill: Unions criticise plans as unworkable https://www.bbc.co.uk/news/uk-64219016?at_medium=RSS&at_campaign=KARANGA public 2023-01-10 15:38:11
ニュース BBC News - Home UK rocket failure is a setback, not roadblock https://www.bbc.co.uk/news/science-environment-64223882?at_medium=RSS&at_campaign=KARANGA failure 2023-01-10 15:33:41
ニュース BBC News - Home Spare review: The weirdest book ever written by a royal https://www.bbc.co.uk/news/uk-64223264?at_medium=RSS&at_campaign=KARANGA memoir 2023-01-10 15:31:41
ニュース BBC News - Home Newcastle City Council fined after decaying tree collapsed on girl https://www.bbc.co.uk/news/uk-england-tyne-64222170?at_medium=RSS&at_campaign=KARANGA henderson 2023-01-10 15:45:43
ニュース BBC News - Home Global recession warning as World Bank cuts economic forecast https://www.bbc.co.uk/news/business-64213830?at_medium=RSS&at_campaign=KARANGA covid 2023-01-10 15:49:16
ニュース BBC News - Home Rishi Sunak's use of jet for hospital trip defended by No 10 https://www.bbc.co.uk/news/uk-politics-64225730?at_medium=RSS&at_campaign=KARANGA climate 2023-01-10 15:10:33
ニュース BBC News - Home Greek trial of 24 rescuers who saved migrants in Med begins https://www.bbc.co.uk/news/world-europe-64221696?at_medium=RSS&at_campaign=KARANGA beginsthe 2023-01-10 15:07:32
ビジネス ダイヤモンド・オンライン - 新着記事 インフレ対策で政治的反発強まる恐れも=パウエルFRB議長 - WSJ発 https://diamond.jp/articles/-/315876 議長 2023-01-11 00:08:00
GCP Cloud Blog Sparse Features Support in BigQuery https://cloud.google.com/blog/topics/developers-practitioners/sparse-features-support-in-bigquery/ Sparse Features Support in BigQueryIntroductionMost machine learning models require the input features to be in numerical format and if the features are in categorial format pre processing steps such as one hot encoding are needed to convert them into numerical format Converting a large number of categorical values may lead to creating sparse features a set of features that contains mostly zero or empty values As zero values also occupy storage space and sparse features contain mostly zeros or empty values the effective way of storing them becomes a necessity We are happy to announce a new functionality that supports sparse features in BigQuery This new feature efficiently stores and processes sparse features in BigQuery using Array Struct lt int numerical gt data type What are sparse features If you have been working with machine learning systems for a while you may come across the term sparse features As most machine learning algorithms require numerical features as input if the features are in categorical format pre processing steps such as one hot encoding are usually applied to convert them before using them as input features Applying one hot encoding to a categorical data column with a large number of categorical values creates a set of features that contains mostly zero or empty values also known as sparse features  Given two sentences “Hello World and “BigQuery supports sparse features now If we are to create a vector representation of those sentences using bag of words approach we will get a result like thisTake a look at how “Hello World is represented with There are only two instances of ones and the rest of the values in the vector are all zeros As you can imagine if we have a large corpus of text suddenly we end up with a very large NxM dimension of mostly zeros So due to its unpredictable nature sparse features may span from a few columns to tens of thousands or even more of columns Having tens of thousands of zero valued columns isn t a particularly good idea especially at scale Not only are the zeros taking up the space they are also adding additional computation for operations such as lookup Hence it is essential to store and process the sparse features efficiently when working with them  To achieve that goal we can store only the index of non zero elements in a vector since the rest of the values will be zeros anyway Once we have the indices of all the non zero elements we can reconstruct the sparse vector by knowing the highest index With this approach we can represent “Hello World with just instead of like before If you are familiar with SparseTensor from TensorFlow this new feature in BigQuery is similar to that Working with sparse features in BigQueryThis newly released feature enables efficient storage and processing of sparse features in BigQuery In this blog post we will demonstrate how to create sparse features with an example First things first let s create a dataset with the two sentences “Hello World and “BigQuery ML supports sparse features now We will also split the sentences into words using the REGEXP EXTRACT ALL function code block StructValue u code u Create a dataset if does not exist r nCREATE SCHEMA IF NOT EXISTS sparse features demo r n r n Create a table with example sentences and sentences split by a REGEX r nCREATE OR REPLACE TABLE sparse features demo sentences AS r n SELECT r n sentence r n REGEXP EXTRACT ALL LOWER sentence a z AS words r n FROM r n SELECT Hello World AS sentence r n UNION ALL r n SELECT BigQuery supports sparse features now AS sentence r n r n u language u u caption lt wagtail wagtailcore rich text RichText object at xefcecd gt The result table sentences should look like thisTo be able to represent the sentence in vector format we will create a table to store the vocabulary using all the words from the sentences It can be done by executing following commandscode block StructValue u code u Create a table with word frequency and assign their respective index r nCREATE OR REPLACE TABLE sparse features demo vocabulary AS r n SELECT r n ROW NUMBER OVER ORDER BY word AS word index r n COUNT word AS word freq r n word r n FROM r n sparse features demo sentences r n UNNEST words AS word r n GROUP BY r n word r n ORDER BY r n word index r n u language u u caption lt wagtail wagtailcore rich text RichText object at xeeffee gt The vocabulary table will be populated with these informationOnce we have the vocabulary table we can create a sparse feature using the new functionality To create a sparse feature in BigQuery we just need to define a column with Array Struct lt int numerical gt type as followscode block StructValue u code u Generate a sparse feature by aggregating word index and word freq for each sentence r nCREATE OR REPLACE TABLE sparse features demo sparse feature AS r n SELECT r n word list sentence r n ARRAY AGG STRUCT vocabulary word index vocabulary word freq AS feature r n FROM r n SELECT r n sentence r n word r n FROM r n sparse features demo sentences r n UNNEST words AS word r n AS word list r n LEFT JOIN r n sparse features demo vocabulary AS vocabulary r n ON word list word vocabulary word r n GROUP BY r n word list sentence r n u language u u caption lt wagtail wagtailcore rich text RichText object at xefc gt You should see this result And that s it We just created a sparse feature using BigQuery You can then use this feature to train models with BigQuery ML which would not have been possible without the use of sparse feature functionality 2023-01-10 16:21:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)