投稿時間:2021-08-22 08:12:08 RSSフィード2021-08-22 08:00 分まとめ(14件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Engadget Japanese 「バックグランドサウンド」のちょうどい雑音で作業が捗る!:iPhone Tips【iOS 15パブリックベータ】 https://japanese.engadget.com/i-phone-tips-ios-15-accessibility-sounds-221047569.html iphonetips 2021-08-21 22:10:47
TECH Techable(テッカブル) 熱中症予兆と転倒を検知! ユビテック、「Work Mate」の実証実験を実施 https://techable.jp/archives/160206 workmate 2021-08-21 22:00:34
AWS lambdaタグが付けられた新着投稿 - Qiita 内部ALBに静的IPアドレスを設定する https://qiita.com/okubot55/items/bc2053853c582560f35d 内部ALBに静的IPアドレスを設定するはじめに本記事では、不定期にIPアドレスが変わる内部ALBに、内部NLBとLambdaを使用して静的IPアドレスを設定する方法について紹介しています。 2021-08-22 07:10:07
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) リポジトリをcloneした人を特定する https://teratail.com/questions/355497?rss=all clone 2021-08-22 07:58:58
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) パッケージマネージャーのデータはどこに格納されるのでしょうか? https://teratail.com/questions/355496?rss=all 2021-08-22 07:40:16
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 存在しているはずのクラスからNULLが帰ってくる https://teratail.com/questions/355495?rss=all 存在しているはずのクラスからNULLが帰ってくる別のインスペクタにあるオーディオソースを用いて音を鳴らすというスクリプトを組みましたしかしこの状態で実行するとPARENTクラスのSTARTが通った時点でNullReferenceExceptionが発生してしまいます存在しているはずのクラスにアクセスしなぜNULLという結果が帰ってきてしまったのでしょうかよろしくお願いいたします。 2021-08-22 07:38:05
AWS AWSタグが付けられた新着投稿 - Qiita 内部ALBに静的IPアドレスを設定する https://qiita.com/okubot55/items/bc2053853c582560f35d 内部ALBに静的IPアドレスを設定するはじめに本記事では、不定期にIPアドレスが変わる内部ALBに、内部NLBとLambdaを使用して静的IPアドレスを設定する方法について紹介しています。 2021-08-22 07:10:07
海外TECH DEV Community Gradle plugins and extensions: A primer for the bemused https://dev.to/autonomousapps/gradle-plugins-and-extensions-a-primer-for-the-bemused-51lp Gradle plugins and extensions A primer for the bemusedAll the code for this project is on Github Github drop ICE It s recently occurred to me that not everyone has spent their time as poorly as I have and therefore may not know how to created custom nested DSLs in Gradle plugins While surprisingly useful this is more importantly very aesthetic app build gradletheState theDeepState theDeepestState undermine the will of the people Proof that the IDE kinda almost provides type hints even for good ol Groovy DSL more on that in a bit Proof that the IDE understands Kotlin DSL better than the Groovy versionSoon after I took those screencaps I upgraded this project s version of Gradle from to and my IDE IntelliJ IDEA Ultimate got confused and no longer gives me DSL hints for Groovy scripts ¯ ツ ¯Leaving aside why we d want to undermine the will of the people I mean isn t it obvious how do we do this Who this is forThis is for anyone looking for non trivial examples for one of the fundamental building blocks of Gradle plugin design I wouldn t go so far as to say they re production ready sure as hell I m not going to be writing any tests but I am currently using techniques like these for building a million LOC application so… A domain specific language for the secret government bureaucracy controlling our livesWe ll start by looking at the extension itself then work backwards to how it is configured and used and finally how to declare and build it TheStateExtension ktpackage mutual aid gradleimport org gradle api Actionimport org gradle api Projectimport org gradle api model ObjectFactoryimport javax inject Injectopen class TheStateExtension Inject constructor objects ObjectFactory Configure the inner DSL object TheDeepStateHandler val theDeepState TheDeepStateHandler objects newInstance TheDeepStateHandler class java Configure the inner DSL object TheDeepStateHandler fun theDeepState action Action lt TheDeepStateHandler gt action execute theDeepState companion object fun Project theState TheStateExtension return extensions create theState TheStateExtension class java An inner DSL object open class TheDeepStateHandler Inject constructor objects ObjectFactory Configure the innermost DSL object TheDeepestStateHandler val theDeepestState TheDeepestStateHandler objects newInstance TheDeepestStateHandler class java Configure the innermost DSL object TheDeepestStateHandler fun theDeepestState action Action lt TheDeepestStateHandler gt action execute theDeepestState An even more inner er DSL object open class TheDeepestStateHandler private val whoToUndermine mutableListOf lt String gt internal val victims List lt String gt get whoToUndermine toList Tells the app who or which groups it should undermine fun undermine who String whoToUndermine add who Some of the salient points I like to name the outermost extension class FooExtension and the inner DSL objects BarHandler Having a convention like that makes it easier to navigate in a large code base You can inject all of these types with a variety of services like ObjectFactory as well as completely arbitrary objects you supply Just remember to Inject that constructor For something this deep into Gradle territory let the Gradle APIs do the work for you Don t try to get creative with Groovy closures or Kotlin lambdas with receivers ーjust use the ObjectFactory and the Action lt T gt interface I ll elaborate more on this in a moment You can expose the handlers directly as I have in the example as well as exposing them via a function and this lets your users use both dot notation and DSL like syntax with curly braces Instantiating the extensionNow we know how to create simple inner DSL objects How do we create and configure the outer most extension ThePluginOfOppression ktpackage mutual aid gradleimport mutual aid gradle TheStateExtension Companion theStateimport org gradle api Pluginimport org gradle api Projectimport org gradle api tasks JavaExecclass ThePluginOfOppression Plugin lt Project gt override fun apply project Project Unit project run val theState theState Recall that TheStateExtension theState is a companion function that is simply project extensions create theState TheStateExtension class java I like keeping that function with the class itself for encapsulation as a factory method It s also important to note that even though I m not using the theState instance I create I still need to create it here so that it can be accessed in a build script when this plugin is applied Let s go ahead and see how that works before circling back to actually using the potential user provided config Applying the plugin and configuring the extension in a build script app build gradleplugins id mutual aid oppression plugin DSL liketheState theDeepState theDeepestState undermine the will of the people With dot notation for the laconictheState theDeepState theDeepestState undermine the will of the people Mix and matchtheState theDeepState theDeepestState undermine the will of the people Easy peasy Apply the plugin and configure the extension Now s a good time to talk about those Action lt T gt functions that enable the DSL syntax As a reminder here s what one looks like import org gradle api Actionfun theDeepState action Action lt TheDeepStateHandler gt action execute theDeepState I keep including the import statements in these code snippets because it s important to note the precise API we re using here ーthe org gradle api API Gradle has special handling for these types At build runtime Gradle rewrites your build code on the fly with ASM such that the method signature theDeepState action Action lt T gt becomes effectively theDeepState action T gt Unit Actually it is more accurate to say you get both In my Groovy DSL script I could also use it liberally if I preferred I don t Now we know why the IDE struggles with this with its type hints it sees the source code which specifies a standard SAM interface it doesn t see the lambda with receiver that is provided on the fly It s unclear why it looks better with the Kotlin DSL If you explore the generated type safe accessors they also use Action lt T gt I guess we ll never know Making use of user provided configuration who should we oppress today Let s go back to our plugin definition which has now been expanded to use the information provided by our user in our custom DSL class ThePluginOfOppression Plugin lt Project gt override fun apply project Project Unit project run Apply additional plugins pluginManager apply org jetbrains kotlin jvm pluginManager apply application Create our extension val theState theState Wait for the DSL to be evaluated and use the information provided afterEvaluate tasks named run JavaExec class java it args theState theDeepState theDeepestState victims Apply additional plugins It isn t strictly necessary to apply these other plugins by our plugin but it showcases the versatility of convention plugins and also helps keep our example more encapsulatd Create our extension Same as before Make use of user provided data Sometimes it is not possible to use the Provider API and it s necessary to wait for user data ーthis is what afterEvaluate was made for In our case we re pushing the data ーwhich victims to oppress ーinto a standard JavaExec task Let s run the program and see what happens gradlew q app runNow undermining the will of the peopleOppression achieved Domain object containersIf you re an Android developer you ll be familiar with this bit of Gradle configuration android buildTypes release debug myCustomBuildType Where do those build types come from We now know how to generate and use nested DSL objects but these values are user provided The situation becomes slightly more clear when one looks at the Kotlin DSL version of the above android buildTypes getByName release getByName debug create myCustomBuildType buildTypes is a function that provides a NamedDomainObjectContainer lt BuildType gt Groovy flavored Gradle has syntactic sugar that converts debug into getByName debug OR create debug if that named type has not yet been created In Kotlin you have to be explicit This is also btw how I learned that there s no default instance named release for signingConfig We now know in rough terms what a NamedDomainObjectContainer is How do we create one How do we get new instances from one How do we use it How do our users use it Using domain object containersFor this next and final example let s switch it up Oppression is boring how can we help instead Let s start with a new extension ThePeopleExtension package mutual aid gradle peopleimport org gradle api Actionimport org gradle api Namedimport org gradle api NamedDomainObjectContainerimport org gradle api Projectimport org gradle api model ObjectFactoryimport org gradle api provider Propertyimport javax inject Injectopen class ThePeopleExtension Inject constructor objects ObjectFactory val problems objects domainObjectContainer ProblemHandler class java fun problems action Action lt NamedDomainObjectContainer lt ProblemHandler gt gt action execute problems companion object internal fun Project thePeople ThePeopleExtension extensions create thePeople ThePeopleExtension class java open class ProblemHandler Inject constructor private val name String objects ObjectFactory Named override fun getName String name internal val description Property lt String gt objects property String class java val solutions objects domainObjectContainer SolutionHandler class java fun solutions action Action lt NamedDomainObjectContainer lt SolutionHandler gt gt action execute solutions fun description description String this description set description this description disallowChanges open class SolutionHandler Inject constructor private val name String objects ObjectFactory Named override fun getName String name internal val action Property lt String gt objects property String class java internal val description Property lt String gt objects property String class java internal val rank Property lt Int gt objects property Int class java fun action action String this action set action this action disallowChanges fun description description String this description set description this description disallowChanges fun rank rank Int this rank set rank this rank disallowChanges Let s talk about a few of the patterns here before we continue First note that the types that are meant to be in a NamedDomainObjectContainer all implement the Named interface This isn t strictly necessary but it is necessary that the types have a getName String function or they can t go into a named domain object container Second we create such a container with the method ObjectFactory domainObjectContainer Class lt T gt The final interesting pattern in the above is this fun description description String this description set action this description disallowChanges As description is a Property lt String gt I prefer to keep those values internal and expose them via a function Users then have a nice DSL like description my description in Groovy or description my description in Kotlin Encapsulating those fields also lets me to do extra stuff like call disallowChanges which I think is important to prevent violating the principle of least astonishment Without that users could call the description method repeatedly from multiple locations and it would be hard to tell where the data were really coming from When we do this and someone attempts to call the method more than once the build will fail Let s continue How does this DSL look in action app build gradlethePeople problems climateChange description There is no question of cost because the cost of doing nothing is everything solutions cleanEnergy description We cannot burn any more fossil energy action Replace all fossil sources with clean solutions like wind solar and geothermal rank massTransit description Single occupant vehicles are a major source of carbon pollution action Increase density in urban environments and build free public transit for all rank stopEatingAnimals description Animal agriculture is one of the top contributors to carbon pollution action Most people can thrive on a plant based diet and do not need animal protein and could make such a choice with immediate effect rank antiRacism description People of Western European descent white people have been the primary beneficiaries of burning fossil carbon action White people should should bear the responsibility of paying for climate change mitigation rank seizeGlobalCapital description The costs of climate change are inequitably distributed action The costs of climate change mitigation should be born primarily by the wealthiest rank lastResort description If the rich and the powerful refuse to get out of the way of legislative reforms of the system killing us all there is unfortunately always a last resort action It starts with g and rhymes with poutine rank I think that s fairly readable given the complexity of the domain we re trying to model But now how do we react to that in our plugin As always I think learning is best done by example so let s tie it all together by looking at how a new plugin ThePluginOfThePeople configures tasks based on this user provided data class ThePluginOfThePeople Plugin lt Project gt override fun apply project Project Unit project run val thePeople thePeople thePeople problems all problem gt tasks register listSolutionsFor problem name capitalize ListSolutionsTask class java it problem set problem abstract class ListSolutionsTask DefaultTask init group People description Prints list of solutions for a given problem get Input abstract val problem Property lt ProblemsHandler gt TaskAction fun action val problem problem get val msg buildString appendLine problem name capitalize appendLine problem description get appendLine appendLine Solutions problem solutions sortedBy it rank get forEachIndexed i sol gt appendLine i sol name appendLine sol description get appendLine sol action get logger quiet msg We can see all the tasks that our new plugin registered quite easily gradlew app tasks group people q Tasks runnable from project app People tasks listSolutionsForClimateChange Prints list of solutions for a given problemIn our plugin we use thePeople problems all Action lt T gt to react to user provided configuration all Action lt T gt executes the provided action against all elements of the given collection as well as all future elements that may be added in this sense it is lazy For us it is useful because the plugin s apply method runs immediately when the plugin is applied in the plugins block which means that the user data is not yet available to react on all elegantly solves this problem without recourse to say afterEvaluate Within our problems all block we register a single task ーone task per problem ーand configure that task by setting its one input as the given ProblemHandler on a Provider lt ProblemHandler gt This is fully serializable and so is a valid Input property as well as being compatible with the experimental configuration cache Our task definition is straightforward It s an abstract class letting us used managed types our Input abstract val problem and has a simple action The biggest footgun here is remembering to call get on the various Provider lt String gt instances else we ll get funny output like property description fancy plugin Finally let s run one of the generated tasks like so gradlew app listSolutionsForClimateChangeConfiguration cache is an incubating feature Calculating task graph as configuration cache cannot be reused because file app build gradle has changed gt Task app listSolutionsForclimateChangeClimateChangeThere is no question of cost because the cost of doing nothing is everything Solutions cleanEnergy We cannot burn any more fossil energy Replace all fossil sources with clean solutions like wind solar and geothermal massTransit Single occupant vehicles are a major source of carbon pollution Increase density in urban environments and build free public transit for all stopEatingAnimals Animal agriculture is one of the top contributors to carbon pollution Most people can thrive on a plant based diet and do not need animal protein and could make such a choice with immediate effect antiRacism People of Western European descent white people have been the primary beneficiaries of burning fossil carbon White people should should bear the responsibility of paying for climate change mitigation seizeGlobalCapital The costs of climate change are inequitably distributed The costs of climate change mitigation should be born primarily by the wealthiest lastResort If the rich and the powerful refuse to get out of the way of legislative reforms of the system killing us all there is unfortunately always a last resort It starts with g and rhymes with poutine Wrapping upIn this post we learned how to use Gradle to model a complex domain with a nested domain specific language or DSL and how to accommodate custom user data in such a DSL using the NamedDomainObjectContainer I encourage you to explore the complete sample on Github which includes build scripts and project layout decisions that were left out of this post for simplicity autonomousapps gradle nested dsl Endnotes Watch this space for me lamenting being fired for my terrible technique up I highly recommend exploring these packages in depth up Jetbrains is the creator of the Kotlin language up 2021-08-21 22:28:04
Apple AppleInsider - Frontpage News Clubhouse hides account bios, images to protect Afghan users https://appleinsider.com/articles/21/08/21/clubhouse-hides-account-bios-images-to-protect-afghan-users?utm_medium=rss Clubhouse hides account bios images to protect Afghan usersAudio chat iOS app Clubhouse is attempting to protect its users in Afghanistan by wiping the biographies and images from thousands of accounts based in the country to keep them safer from harm Following the take over of Afghanistan by the Taliban social media platforms are taking steps to try and protect their users For social audio app Clubhouse it is doing so by making it as difficult as possible for bad actors to keep track of individual users Clubhouse has reset the details on accounts of thousands of Afghan users wiping bios and photographs in the process reports The Verge The change applies to accounts that haven t been active for a period of time while also making the account harder to find in searches Read more 2021-08-21 22:52:01
ニュース BBC News - Home Newspaper headlines: Blair's attack on US exit, and UN aid warning https://www.bbc.co.uk/news/blogs-the-papers-58295370 front 2021-08-21 22:21:40
ニュース BBC News - Home 10.54 - Thompson-Herah runs second-fastest women's 100m of all time https://www.bbc.co.uk/sport/athletics/58295310 Thompson Herah runs second fastest women x s m of all timeOlympic champion Elaine Thompson Herah runs the second fastest time in women s m history as she clocks seconds in Eugene 2021-08-21 22:22:20
ニュース BBC News - Home Match of the Day analysis: How Danny Ings scored his 'fabulous' bicycle kick for Aston Villa https://www.bbc.co.uk/sport/av/football/58295691 Match of the Day analysis How Danny Ings scored his x fabulous x bicycle kick for Aston VillaMatch of the Day s Gary Lineker Jermaine Jenas and Danny Murphy analyse Danny Ings fabulous bicycle kick for Aston Villa in their win over Newcastle United 2021-08-21 22:49:28
ビジネス ダイヤモンド・オンライン - 新着記事 日経平均株価の「2022年7月」までの値動きを予測! 一時2万7000円を割れた日経平均株価だが、2021年 の年末に3万円を回復、2022年7月に3万3000円も! - 最新記事 https://diamond.jp/articles/-/279927 日経平均株価の「年月」までの値動きを予測一時万円を割れた日経平均株価だが、年の年末に万円を回復、年月に万円も最新記事年月までの日経平均株価の値動きを予想月日には一時万円を割れたが、年末には万円を回復し、年月には万円も発売中のダイヤモンド・ザイ月号の大特集は「最強日本株【年・夏】」この特集では「万円株」「高配当株」「株主優待株」「脱コロナ株」「安定大型株」「大出世株」というつのジャンル別に、アナリストが選んだ最強の日本株を紹介また、ストラテジストによる「年月年月までの日経平均株価の予測」や「今後の日本株市場で勝つための投資戦略」も取り上げているので、投資の参考になるだろう。 2021-08-22 08:00:00
北海道 北海道新聞 ガザ、デモで衝突41人負傷 イスラエル側1人重体 https://www.hokkaido-np.co.jp/article/580713/ 重体 2021-08-22 07:03:25

コメント

このブログの人気の投稿

投稿時間: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件)