投稿時間:2022-04-30 05:19:47 RSSフィード2022-04-30 05:00 分まとめ(24件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
GCP gcpタグが付けられた新着投稿 - Qiita 【GCP】Java版MinecraftサーバーをGCEで建てる【Java版Minecraft】 https://qiita.com/Hikoly/items/f10fb18892b4ac6ed7b2 minecra 2022-04-30 04:03:19
技術ブログ Developers.IO [アップデート]EC2のキーペアに新しい管理機能が追加されました。 https://dev.classmethod.jp/articles/update-ec2-keypair-20220429/ becominn 2022-04-29 19:29:57
海外TECH MakeUseOf How to Create Custom Style Templates in LibreOffice Writer https://www.makeuseof.com/create-custom-style-templates-libreoffice-writer/ How to Create Custom Style Templates in LibreOffice WriterLibreOffice Writer has custom style templates that help you create professional documents in line with your formatting preferences Here s how 2022-04-29 19:30:13
海外TECH DEV Community Check if an Object Contains all Keys in Array in Javascript https://dev.to/smpnjn/check-if-an-object-contains-all-keys-in-array-in-javascript-3b0k Check if an Object Contains all Keys in Array in JavascriptSometimes in Javascript we have an object which we need to conform to a specific set of keys This is possible through type enforcement in TypeScript but if we want to do certain things if the keys don t exist then we have to take a different approach For example suppose we are receiving the following object from an array where firstName lastName and age are all needed for an operation we want to complete For examplelet obj firstName Jack lastName Doe age console log obj firstName obj lastName is obj age If we are receiving our data in obj from an array we could trust that those properties will be provided but if the API ever changes we may face issues The developers of the API may decide to remove age or any other property or maybe rename firstName to first name In the best scenario this will lead to keys becoming undefined In the worst it may result in an error and crash our application To avoid this we can check the object has the keys we require How to Check if Object Contains all Keys in ArrayThe solution to this problem uses every every is an array method which checks every element in an array and performs a logical check on them If all return true then the every method returns true To check if an object contains all keys in an array we just use every on an array of all the keys we want to check That way we can logically check each element exists and then do something else if it s false preventing us from encountering any errors let requiredKeys firstName lastName age let obj firstName Jack lastName Doe age let checkAllKeys requiredKeys every i gt obj hasOwnProperty i if checkAllKeys console log obj firstName obj lastName is obj age else console log The API does not have all the keys required Please check API and configuration Here we create an array of our required keys firstName lastName and age We then use every to go through each item in that array In every we run a function here i is the the current item being looped through If obj has the property i then every will return true for that specific item If every item returns true then every returns true overall Otherwise it will return false As such if checkAllKeys is true we can be sure it has all the keys we need Otherwise we can do something else like console log an error 2022-04-29 19:21:53
海外TECH DEV Community Hotwired Modals https://dev.to/thegnarco/hotwired-modals-196a Hotwired ModalsWe can use Hotwire specifically Stimulus and Turbo to create some modals that present a nice dynamic user experience And they can do this while staying in a mutli page app structure that Rails is so good at First off we need to know that with Turbo you can load a page with a turbo frame element and Turbo will take the element from the newly loaded page and inject its contents into the current page It works just like frames and iframes work but way better So what we re talking about here is an index page and an edit page oh and a small Stimulus controller to pop up the modal The index page lists out your Resources and has an empty modal section The edit page looks exactly like the index page but has an edit form in the modal section For the purpose of this example let s call the Resource a Gadget just so it doesn t have a name that s already a core Rails concept On the index page you have your Gadgets and you want to list your Gadgets in a cool table for however cool a table can be but I digress You ll likely have something like this in your app views gadgets index html erb lt table id gadgets table gt lt gadgets each do gadget gt lt tr gt lt td gt lt gadget name gt lt td gt lt td gt lt link to Edit edit gadget path gadget data turbo frame modal content gt lt td gt lt tr gt lt end gt lt table gt lt div id modal data controller modal gt lt turbo frame id modal content gt lt turbo frame gt lt div gt Ok there we go Now we have an index that displays our Gadgets and a link that will load the edit page and replace the content of the modal via Turbo Plus also a nice container for the modal itself Gotta have that Similarly we need the edit page That will look very similar but with an important difference lt table id gadgets table gt lt gadgets each do gadget gt lt tr gt lt td gt lt gadget name gt lt td gt lt td gt lt link to Edit edit gadget path gadget data turbo frame modal content gt lt td gt lt tr gt lt end gt lt table gt lt div id modal data controller modal gt lt turbo frame id modal content gt lt form with model gadget do form gt lt form text field name gt lt form submit Save gt lt end gt lt turbo frame gt lt div gt The difference as you probably noticed is that the modal has a form in it set to edit the specified Gadget Importantly the data turbo frame attributes on the links let Turbo know to load the page and swap out the modal content frame targeting So when the user clicks on the link in the table the edit form s contents will just pop into that turbo frame You can see this if you did it right now because we don t have any CSS to make this look like a modal or to hide the modal Oh right CSS Ok let s get on that Put this inside app assets stylesheets modal css or wherever you re putting your CSS modal background rgba display none position fixed top left bottom right modal visible display flex align items center justify content center modal content width background fff Now the modal will look and act like a modal This is the last part I mentioned at the start The small Stimulus controller that watches for changes Here s where we add the ModalController that the data controller modal attribute on the modal container alluded to This will go in app javascript controllers modal controller jsimport Controller from hotwired stimulus export default class extends Controller static targets open openTargetConnected this open openTargetDisconnected this close open this element classList add visible close this element classList remove visible This works because Stimulus controllers have a number of lifecycle callbacks In this case we want the callbacks that activate when a target is connected and disconnected that is added to or removed from the children of the controller element A target is marked with an attribute data lt controller name gt target lt target name gt We have the ModalController above and it has an open target so the attribute would be data modal target open When a DOM node is either added that already has this attribute or the attribute is added to an existing element the openTargetConnected method on the ModalController is called This means that when Turbo loads the edit page and swaps in the modal the ModalController will see the open target and give the whole thing the visible class Cool so now what happens when we submit Well turbo frames are limited to one interaction per page load basically And since what we want to do is close the modal and update the contents of the index we ll need something a little more flexible Turbo StreamsTurbo Streams let you batch up multiple changes into one response And despite their name you don t have to use them in a streaming context You can return them from an action same as anything else In our GadgetsController s update action we need to save the Gadget we just changed in the browser Then instead of rendering we redirect to the index The index s turbo stream response will do what we need it to it will replace the modal with an empty modal and it will replace the table with a table that contains the new Gadget s information This change to the index action is pretty small It s using already existing functionality respond to do format format html format turbo streamendIf you are using the turbo rails gem this format will be created for you This then should be what app views gadgets index turbo stream erb looks like and you can of course extract whatever you want into partials lt turbo stream action replace target modal content gt lt template gt lt turbo frame id modal content gt lt turbo frame gt lt template gt lt turbo stream gt lt turbo stream action replace target gadgets table gt lt template gt lt table id gadgets table gt lt gadgets each do gadget gt lt tr gt lt td gt lt gadget name gt lt td gt lt td gt lt link to Edit edit gadget path gadget data turbo frame modal content gt lt td gt lt tr gt lt end gt lt table gt lt template gt lt turbo stream gt Now when the user submits the form and it saves successfully the update action will redirect to index and index will render the above turbo stream Turbo will replace the modal content which will make Stimulus close the modal and it will update the table to reflect the new value of the Gadget The best part of all of this is that this is just using existing web paradigms And if the user for whatever reason doesn t have javascript enabled this will Just Work in exactly the same manner albeit a little slower because of the progressive enhancement on top of the multi request cycle And with Javascript it never reloads the page 2022-04-29 19:19:52
海外TECH DEV Community Stop using meaningless test values! https://dev.to/simeg/stop-using-meaningless-test-values-2gg4 Stop using meaningless test values Did you ever find a test where the mock data was a bunch of meaningless test strings and integer values Yeah me too ーand it sucks Meaningless Test Values Consider this JavaScript test test should return children of parent gt mock some data const mockedParent name test age interests test test const mockedChildren name test parentName test name test parentName test run the code const actual getChildrenForParent mockedParent mockedChildren const expected name test name test assert the results expect actual toBe expected This is a a standard unit test that consists of setup execution and assertion It looks fine why are you saying it sucks If I found this test in a codebase I would not understand what data is relevant for the test to pass If I change name of the parent from test to some name would the test still pass I don t know The name of the test might help but as with other documentation it will eventually change and be out of sync with the code Meaningful Test Values What if we use meaningful test data how would our test look then test should return children of parent gt mock some data const irrelevantAge const mockedParent name specific parent name age irrelevantAge interests irrelevant irrelevant const mockedChildren name child name parentName specific parent name name child name parentName specific parent name run the code const actual getChildrenForParent mockedParent mockedChildren const expected name child name name child name assert the results expect actual toBe expected By reading this test I can see that specific parent name is found both in the parent and in the children and has the prefix specific which tells me that this value is important for the test to pass Irrelevant values on the other hand has the value irrelevant which tells me I can safely ignore these in this test For numbers and booleans you can extract the value to a constant and give the constant a meaningful name ️Disclaimer ️Using strings as IDs is bad practice ーuse integers instead I used strings to have a clear example ConclusionUsing test and other meaningless values in your tests is bad practice because it does not convey any meaning This makes the test take a longer time to understand and will slow down your development time e g when you need to refactor or extend your codeInstead use meaningful values E g specific something and irrelevant Extract number and boolean values to constants with a meaningful nameDo you agree or disagree Let s discuss in the comments Originally published at 2022-04-29 19:17:57
Apple AppleInsider - Frontpage News Examining Apple's solid $97.28B Q2 2022 by the numbers https://appleinsider.com/articles/22/04/29/examining-apples-solid-9728b-q2-2022-by-the-numbers?utm_medium=rss Examining Apple x s solid B Q by the numbersApple has reported record breaking results for the March quarter Here s how the company s Q stacks up versus the company s previous quarters and years Tim Cook financialsThe iPhone maker s performance during the March quarter marked its best Q yet Apple CEO Tim Cook said that the period serves as a testament to Apple s relentless focus on innovation and our ability to create the best products and services in the world Read more 2022-04-29 19:04:13
海外TECH Engadget Former Apple worker says Epic refused to hire her over labor advocacy https://www.engadget.com/cher-scarlett-nlrb-labor-complaint-epic-games-190953630.html?src=rss Former Apple worker says Epic refused to hire her over labor advocacyThe worker who founded the AppleToo movement has accused Epic Games of taking a similarly anti labor stance The Washington Postreports former Apple employee Cher Scarlett has filed a National Labor Relations Board complaint alleging Epic refused to hire her because she backed a labor organization is cooperating with the NLRB and is otherwise fighting unfair working conditions She claims Epic balked two days after she shared details of her advocacy work and federal testimony with recruiters for a senior web developer position Epic spokesperson Elka Looks denied any wrongdoing in a statement to The Post She said Scarlett s labor rights efforts didn t factor into the hiring decision and that the company had already settled on someone else before Scarlett shared details of her activities The winning candidate simply quot scored higher quot Looks stated Whether or not the assertions hold up it s no secret that Scarlett is known for challenging allegedly abusive and unfair workplaces She helped draw attention to misconduct at Activision Blizzard by describing sexual harassment between and Scarlett also has three ongoing cases against Apple including an NLRB complaint about a hostile work environment Another NLRB complaint from February says Mozilla discriminated against her job application at that firm The complaint against Epic also comes as tensions have risen between tech companies and staffers demanding better labor practices Amazon Apple and other companies have been fighting unionization attempts and there have long been concerns these brands might be firing outspoken employees Even if Scarlett doesn t succeed she ll highlight problematic behavior across the industry 2022-04-29 19:09:53
海外科学 NYT > Science Started Out as a Fish. How Did It End Up Like This? https://www.nytimes.com/2022/04/29/science/tiktaalik-fish-fossil-meme.html fossil 2022-04-29 19:55:09
海外科学 NYT > Science Why Americans Became More Vulnerable to Oil Price Spikes https://www.nytimes.com/2022/04/29/climate/gas-prices-america.html Why Americans Became More Vulnerable to Oil Price SpikesWhen prices soared years ago Americans launched broad efforts to wean the nation off oil and gas to protect households from price swings But then supply rose and plans fizzled 2022-04-29 19:21:18
ビジネス ダイヤモンド・オンライン - 新着記事 子どもの将来を決める、学歴より大切な「たった一つのスキル」とは? - 才能が伸びる!本当の子育て https://diamond.jp/articles/-/302084 子どもたち 2022-04-30 05:00:00
ビジネス ダイヤモンド・オンライン - 新着記事 セブン&アイがそごう・西武売却へ、教科書的な“選択と集中”に潜む「2つの死角」 - 事例で身に付く 超・経営思考 https://diamond.jp/articles/-/302508 セブンアイがそごう・西武売却へ、教科書的な“選択と集中に潜む「つの死角」事例で身に付く超・経営思考流通大手のセブンアイ・ホールディングスが、傘下の百貨店「そごう・西武」の売却に動き出しました。 2022-04-30 04:55:00
ビジネス ダイヤモンド・オンライン - 新着記事 松下幸之助が、“怖い人”なのに部下から慕われた「2つの理由」とは - 小宮一慶の週末経営塾 https://diamond.jp/articles/-/302572 小宮一慶 2022-04-30 04:50:00
ビジネス ダイヤモンド・オンライン - 新着記事 50代から輝く人は何が違う?「会社に囚われない生き方」を目指すには - 及川卓也のプロダクト視点 https://diamond.jp/articles/-/302525 及川卓也 2022-04-30 04:45:00
ビジネス ダイヤモンド・オンライン - 新着記事 「CIAに狙われている」探偵の心を5日で折った電波系依頼人の調査内容 - オオカミ少年片岡の「あなたの隣に詐欺師がいます。」 https://diamond.jp/articles/-/302527 2022-04-30 04:40:00
ビジネス ダイヤモンド・オンライン - 新着記事 「星のカービィ」30周年フィーバー、親子でハマる任天堂のにくい仕掛け - 井の中の宴 武藤弘樹 https://diamond.jp/articles/-/302571 星のカービィ 2022-04-30 04:35:00
ビジネス ダイヤモンド・オンライン - 新着記事 真田幸村の秘められた物語、家康や信長の家からは感じられない真田家の「家族っぽさ」 - from AERAdot. https://diamond.jp/articles/-/302393 戦国時代最後の戦い、「大坂の陣」を舞台に、真田一族、徳川家康、毛利勝永ら戦国武将たち、それぞれの思惑を描く。 2022-04-30 04:30:00
ビジネス ダイヤモンド・オンライン - 新着記事 東京で「イタリア&スペイン観光」気分を味わえる新・人気スポットとは!? - 地球の歩き方ニュース&レポート https://diamond.jp/articles/-/302372 aruco 2022-04-30 04:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 自慢話、高圧的、ネガティブ…タイプ別「面倒な人」への対処法 - 「超」戦略的に聴く技術 https://diamond.jp/articles/-/301741 食べるラー油 2022-04-30 04:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 ゴルフ場で「上品な紳士」に見える、コーデの簡単テクニックとは - 男のオフビジネス https://diamond.jp/articles/-/302502 着こなし 2022-04-30 04:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 【現役僧侶が教える】絶対に関わってはいけない「4種類の人」の特徴とは? - 苦しみの手放し方 https://diamond.jp/articles/-/302150 重要 2022-04-30 04:10:00
ビジネス ダイヤモンド・オンライン - 新着記事 ひろゆきが教える「毎日の生きがいを簡単に見つける方法」ベスト1 - 1%の努力 https://diamond.jp/articles/-/302069 youtube 2022-04-30 04:05:00
ビジネス 東洋経済オンライン ランドセル選び「GWがピーク」親もヘトヘトの実態 年々早まり「年中さん」から検討する人もいる | 子育て | 東洋経済オンライン https://toyokeizai.net/articles/-/585046?utm_source=rss&utm_medium=http&utm_campaign=link_back 子どもたち 2022-04-30 04:50:00
ビジネス 東洋経済オンライン 「あるものでパパッと」料理が作れる超簡単な方法 レシピ本に頼らず、ずらりと食卓に並べるコツ | 買わない生活 | 東洋経済オンライン https://toyokeizai.net/articles/-/585556?utm_source=rss&utm_medium=http&utm_campaign=link_back 東洋経済オンライン 2022-04-30 04:30:00

コメント

このブログの人気の投稿

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

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

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)