Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Webアプリ】個人開発したWebアプリを公開 |
https://qiita.com/harukioo/items/d8ee0a0f325837f23fef
|
yesorno |
2022-08-10 03:55:03 |
海外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-259h
|
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 Mac Development Setup wcj documented the process and the tools apps settings used on a daily basis and used this doc to set up a recently wiped MacBook Follow along if you have a Mac you need to set up for a development environment Setting up a Mac for Development CJ R ・Aug ・ min read webdev beginners productivity node TypeScript ReactUsing TypeScript comes with a lot of benefits omerwow covers those benefits as well as how to best utilize TypeScript with React TypeScript The Best Way to Use It with React Omer Elbaz・Aug ・ min read webdev typescript react beginners Are you Agile What does it mean to be agile rcls covers Agile and Scrum in this retrospective on a conversation between Dave Farley and Allen Holub You think you re working in an agile way Probably not Ossi P ・Aug ・ min read agile devops scrum Using Job Boards Effectively wagslane compiled a few of the best places for you to look for new job openings Take a look and use the ones that are most useful to you How to Use the Best Job Boards to Find a Software Engineering Job Lane Wagner for Boot dev・Aug ・ min read job career hiring jobs Getting UnstuckDevelopers spend an enormous amount of time being stuck Here stebunovd offers some advice on how to learn to be better at getting unstuck How to get unstuck and make progress Denis Stebunov・Aug ・ min read productivity management motivation Write to Improve wesen started writing regularly a year ago and became a better developer for it Here are some tips to start this process yourself Writing made me a better engineer Manuel Odendahl・Aug ・ min read career programming writing productivity Coding as artThe community loved this artwork by asyrafhussin and it s easy to see why True artistry ーand the palette is comprised of only HTML amp CSS Pure CSS Woman with Long Hair Asyraf Hussin・Aug ・ min read codepen html css webdev 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 |
2022-08-09 18:40:35 |
海外TECH |
DEV Community |
Object Mapping advanced features & QoL with Kotlin |
https://dev.to/krud/object-mapping-advanced-features-qol-with-kotlin-5dgn
|
Object Mapping advanced features amp QoL with KotlinWhen working with multi layered applications external libraries a legacy code base or external APIs we are often required to map between different objects or data structures In this tutorial we will check out some Object Mapping libraries advanced features to simplify this task while saving development and maintenance time In our examples we will use the library ShapeShift It s a light weight object mapping library for Kotlin Java with lots of cool features Auto MappingWe will start with a bang Auto mapping can and will save you lots of time and boiler plate code Some applications require manual mapping between objects but most applications will save tons of time working on boring boiler plate by just using this one feature And it gets even better with ShapeShift s default transformers we can even use automatic mapping between different data types Simple MappingLet s start with a simple example for auto mapping We have our two objects imagine they could also have tens hundreds or even thousands for the crazy people here of fields class User var id String var name String null var email String null var phone String null class UserDTO var id String var name String null var email String null var phone String null We want to map all the field from User to UserDTO Using auto mapping we don t need to write any boiler plate code The mapper will be defined as follow val mapper mapper lt User UserDTO gt autoMap AutoMappingStrategy BY NAME AND TYPE Voila All the fields will be mapped automatically without any manual boiler plate code Advanced MappingIn this example we will use the power of default transformers to take auto mapping even further class User var id String var name String null var birthDate Date null class UserDTO var id String var fullName String null var birthDate Long null Note that the types of the birthDate field are different in the source and destination classes But using the power of default transformers we can still use auto mapping here val mapper mapper lt User UserDTO gt autoMap AutoMappingStrategy BY NAME We changed the auto mapping strategy to BY NAME so it will map fields also with different types Now we need to register a default transformer to the ShapeShift instance in order for it to know how to transform Date to Long val shapeShift ShapeShiftBuilder withTransformer DateToLongMappingTransformer true build We can also add manual mapping on top of the auto mapping in order to add change behavior The source and destination classes have different names for the name field so we will add manual mapping for it val mapper mapper lt User UserDTO gt autoMap AutoMappingStrategy BY NAME User name mappedTo UserDTO fullName Auto mapping is great for use cases that does not require specific mapping It helps reduce the amount manual boiler plate code needed to configure mapping and also helps you keep your sanity TransformersTransformers are very useful feature that allows you to transform the type value of a field to a different type value when mapping a field Some use cases we have been using widely Transform date to long and vice versa between server and client objects Transform JSON string to it s actual type and vice versa between server and client objects Transform comma separated string to list of enums Transform another object id to its object or one of its fields from the DB using Spring transformers Basic TransformersWe will start with a simple transformer example Date to Long and Long to Date transformers class DateToLongMappingTransformer MappingTransformer lt Date Long gt override fun transform context MappingTransformerContext lt out Date gt Long return context originalValue time class LongToDateMappingTransformer MappingTransformer lt Long Date gt override fun transform context MappingTransformerContext lt out Long gt Date context originalValue return null return Date context originalValue All we need to do now is to register them val shapeShift ShapeShiftBuilder withTransformer DateToLongMappingTransformer true true is optional we are registering the transformers as default transformers more on that later withTransformer LongToDateMappingTransformer true build That s it We can now use the transformers when mapping objects class User var id String var name String null var birthDate Date null class UserDTO var id String var name String null var birthDate Long null val mapper mapper lt User UserDTO gt User id mappedTo UserDTO id User name mappedTo UserDTO name User birthDate mappedTo UserDTO birthDate withTransformer DateToLongMappingTransformer class We don t have to state the transformer here because it is a default transformer Inline TransformersIn some use cases we want to transform the value but we don t need a reusable transformer and we don t want to create a class just for a one time use Inline transformers for the rescue Inline transformers allow to transform the value without the need to create and register and transformer val shapeShift ShapeShiftBuilder withMapping lt Source Target gt Map birthDate to birthYear with a transformation function Source birthDate mappedTo Target birthYear withTransformer originalValue gt originalValue year build Advanced TransformersTransformers also allow us to do transformations with the DB or other data sources In this example we will use the power of the Spring Boot integration to create transformers with DB access We have three models Job DB entity User DB entity UserDTO Client model class Job var id String var name String class User var id String var jobId String null class UserDTO var id String var jobName String null We want to convert the jobId on User to jobName on UserDTO by querying the job from the DB and setting it on the DTO In Spring s case you generally avoid interaction with the application context from static functions or functions on domain objects We will use a ShapeShift s Spring integration to create a component as a transformer to access our DAO bean Componentclass JobIdToNameTransformer private val jobDao JobDao MappingTransformer lt String String gt override fun transform context MappingTransformerContext lt out String gt String context originalValue return null val job jobDao findJobById context originalValue return job name All that s left to do is to use this transformer in our mapping val mapper mapper lt User UserDTO gt User id mappedTo UserDTO id User jobId mappedTo UserDTO jobName withTransformer JobIdToNameTransformer class Another bonus of using transformers is their reusability In some use cases We could create more generic transformers that will have application wide usage Default TransformersWhen registering transformers you can indicate wether a transformer is a default transformer A default transformer of types lt A B gt is used when you map a field of type lt A gt to field of type lt B gt without specifying a transformer to be used As we already seen default transformers are useful for recurring transformations and especially for automatic mapping Deep MappingWhat if we want to map from to fields that available inside a field which is an object We can even do that easily In order to access child classes we can use the operator Let s look at the following example class From var child Child Child class Child var value String class To var childValue String We want to map the value field in Child class inside the From class to the childValue field in the To class We will create a mapper with the operator val mapper mapper lt From To gt From child From Child value mappedTo To childValue Let s take it one step further with multi level depth class From var grandChildValue String class To var child Child Child class Child var grandChild GrandChild GrandChild class GrandChild var value String To access the grand child field we just use the operator twice val mapper mapper lt From To gt From grandChildValue mappedTo To child To Child grandChild To GrandChild value Conditional MappingConditions allow us to add a predicate to a specific field mapping to determine whether this field should be mapped Using this feature is as easy as creating a condition class NotBlankStringCondition MappingCondition lt String gt override fun isValid context MappingConditionContext lt String gt Boolean return context originalValue isNullOrBlank And adding the condition to the desired field mapping data class SimpleEntity val name String data class SimpleEntityDisplay val name String val mapper mapper lt SimpleEntity SimpleEntityDisplay gt SimpleEntity name mappedTo SimpleEntityDisplay name withCondition NotBlankStringCondition class Inline ConditionsLike transformers conditions can also be added inline using a function val mapper mapper lt SimpleEntity SimpleEntityDisplay gt SimpleEntity name mappedTo SimpleEntityDisplay name withCondition it originalValue isNullOrBlank Annotations MappingThis specific feature receives lots of hate because it breaks the separation of concerns principle Agreed this could be an issue in some applications but in some use cases where all objects are part of the same application it can also be very useful to configure the mapping logic on top of the object Check out the documentation and decide for yourself ConclusionObject mapping libraries are not the solution for every application For small simple applications using boiler plate mapping functions are more than enough But when developing larger more complex applications object mapping libraries can take your code to the next level saving you development and maintenance time All of these while reducing the amount of boiler plate code and overall improving the development experience On a personal note I used to work with manual mapping functions and was ok with it It was just some simple lines of code After upgrading our applications to use object mapping as part of our boiler plate free framework We will discuss that framework at a later time I can t go back Now we spend more time on what s important and interesting and almost no time on boring boiler plate code |
2022-08-09 18:33:31 |
Apple |
AppleInsider - Frontpage News |
How to hide photos in macOS Ventura |
https://appleinsider.com/inside/macos-ventura/tips/how-to-hide-photos-in-macos-ventura?utm_medium=rss
|
How to hide photos in macOS VenturaWhether you need to be secretive or you just like to be tidy Photos will let you hide away any image you choose in macOS Ventura Perhaps it s the introduction of iCloud Shared Photo Library to macOS Ventura and iOS which has made you think about hiding certain photos If it s that the wrong person seeing the wrong photo means your secret double existence is exposed then you possibly need to examine your life choices But for anything else it can be handy useful or just plain tactful to hide an image before you let someone sit at your Mac Now you can do exactly that with the Photos app in the shortly forthcoming macOS Ventura Read more |
2022-08-09 18:20:43 |
海外TECH |
Engadget |
People spent much less time watching gaming streams this spring, report says |
https://www.engadget.com/twitch-youtube-facebook-gaming-livestreaming-report-183021612.html?src=rss
|
People spent much less time watching gaming streams this spring report saysThe number of hours streamed and watched across Twitch YouTube Gaming and Facebook Gaming have dropped significantly over the last year according to the latest Streamlabs and Stream Hatchet report on the landscape of livestreaming Between April and June streamers on the three platforms were live for million hours That s down percent from Q and percent from the previous quarter Viewers tuned in to streams for billion hours across the three platforms last quarter That s a drop of percent year over year viewership was at billion hours in Q and percent from the previous quarter The slowdown for all three platforms could be a case of people spending more time outside than they did last year for pandemic related reasons Twitch is still by far the biggest player among the three platforms with percent of market share in terms of hours watched billion and percent of hours streamed million Those figures dropped by percent and percent from Q The number of unique channels streaming on the platform dropped by nearly million to million as well However Twitch s Just Chatting category continues to go from strength to strength Hours watched there actually grew by percent from the previous quarter giving the category its highest ever viewership The most watched categories after that were Grand Theft Auto V million hours and League of Legends million YouTube Gaming viewership actually remained steady from the previous quarter though it dropped percent from Q to billion hours The total hours streamed dropped by percent year over year to million Facebook Gaming suffered a bigger setback per the report despite Meta s efforts to court creators The number of hours watched fell by a whopping percent from a year ago to million There was an even bigger drop in terms of hours streamed from million in Q to million last quarter ーa decline of percent Perhaps we ll soon start seeing some of those numbers creep up again though With a recession looming folks may spend more time indoors again tuning back into streamers they enjoyed watching during the first months or so after COVID took hold |
2022-08-09 18:30:21 |
海外科学 |
NYT > Science |
Biden Signs Industrial Policy Bill Aimed at Bolstering Competition With China |
https://www.nytimes.com/2022/08/09/us/politics/biden-semiconductor-chips-china.html
|
Biden Signs Industrial Policy Bill Aimed at Bolstering Competition With ChinaThe legislation invests in American chip manufacturing and is part of a streak of legislative successes that President Biden is planning to highlight as the midterm elections approach |
2022-08-09 18:38:11 |
海外TECH |
WIRED |
Big Takeaways From the FBI's Mar-a-Lago Raid |
https://www.wired.com/story/trump-fbi-raid-mar-a-lago/
|
florida |
2022-08-09 18:51:41 |
ニュース |
BBC News - Home |
Ukraine war: Blasts rock Russian airbase in annexed Crimea |
https://www.bbc.co.uk/news/world-europe-62482425?at_medium=RSS&at_campaign=KARANGA
|
ukraine |
2022-08-09 18:55:42 |
ニュース |
BBC News - Home |
Boris Johnson defends leaving fuel crisis to successor |
https://www.bbc.co.uk/news/uk-politics-62477155?at_medium=RSS&at_campaign=KARANGA
|
political |
2022-08-09 18:32:09 |
ニュース |
BBC News - Home |
UK heatwave: Four-day extreme heat warning for parts of UK |
https://www.bbc.co.uk/news/uk-62472926?at_medium=RSS&at_campaign=KARANGA
|
highs |
2022-08-09 18:28:23 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
浦和レッズが声出し応援で制裁金2000万円、歴代最高額でクラブ経営に大打撃 - ニュース3面鏡 |
https://diamond.jp/articles/-/307791
|
|
2022-08-10 03:55:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
YouTube ロシアで今も視聴できる訳 - WSJ PickUp |
https://diamond.jp/articles/-/307882
|
wsjpickup |
2022-08-10 03:50:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
福沢諭吉の娘婿、相場師から実業家に転じた福沢桃介の半生(下) - The Legend Interview不朽 |
https://diamond.jp/articles/-/306414
|
thelegendinterview |
2022-08-10 03:45:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
エヌビディア、ゲームで負け予告 - WSJ PickUp |
https://diamond.jp/articles/-/307883
|
wsjpickup |
2022-08-10 03:40:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
台湾出身の半導体魔術師、中国の業界制覇の野望牽引 - WSJ PickUp |
https://diamond.jp/articles/-/307884
|
wsjpickup |
2022-08-10 03:35:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「学芸大附属国際」が実践するユニークなIB教育手法 - 中学受験のキーパーソン |
https://diamond.jp/articles/-/307083
|
中学受験 |
2022-08-10 03:30:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
ドキュメンタリー映画「失われた時の中で」が教えてくれる、明日への希望 - Oriijin(オリイジン) |
https://diamond.jp/articles/-/307336
|
ドキュメンタリー映画「失われた時の中で」が教えてくれる、明日への希望Oriijinオリイジン「SDGs」「ダイバーシティインクルージョン」という言葉がメディアをにぎわす一方で、「戦争」という言葉がいまだ過去のものにならない現代社会。 |
2022-08-10 03:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【ひろゆきが呆れる】仕事を抱え込んで人に任せられない残念な特徴・ワースト1 - 1%の努力 |
https://diamond.jp/articles/-/307275
|
著者 |
2022-08-10 03:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【本日は一粒万倍日!】 苦労せずに「1万円を1億円にできる人」に共通する、たった1つのルール - 13歳からの億万長者入門 |
https://diamond.jp/articles/-/307464
|
【本日は一粒万倍日】苦労せずに「万円を億円にできる人」に共通する、たったつのルール歳からの億万長者入門話題沸騰万部突破生涯投資家の村上世彰氏が絶賛識者からも「億万長者マインドセットが手に入る最良の書」「高校の資産形成の授業にぴったり」と評価の高い全米ロングセラー本書を翻訳し「朝日beフロントランナー」で取り上げられた関美和氏に「万円を億円にできる人」だけが知っている、たったつの思考法について聞いた。 |
2022-08-10 03:15:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
カリスマ保育士てぃ先生が解決! 今日あったことを答えない子への 「どうだった?」ではない聞き方 - カリスマ保育士てぃ先生の子育て〇×図鑑 |
https://diamond.jp/articles/-/307908
|
カリスマ保育士てぃ先生が解決今日あったことを答えない子への「どうだった」ではない聞き方カリスマ保育士てぃ先生の子育て〇×図鑑【YouTubeチャンネル登録数万人Twitterフォロワー数万人、Instagramフォロワー万人】と、今どきのママパパに圧倒的に支持されているカリスマ保育士・てぃ先生の子育てアドバイス本第弾『子どもが伸びるスゴ技大全カリスマ保育士てぃ先生の子育て×図鑑』ができました子育ての悩みは、決して親の能力や愛情の深さの問題ではなく、子ども特有の気持ちやものごとのとらえ方、体の状態を知るだけでうまくいくことが多いと、てぃ先生は教えてくれます。 |
2022-08-10 03:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【20代で1億円を貯めた元会社員が断言】 自分という商品を最大化する 会社員以外の稼ぎ方 - 投資をしながら自由に生きる |
https://diamond.jp/articles/-/307018
|
|
2022-08-10 03:05:00 |
コメント
コメントを投稿