IT |
気になる、記になる… |
新型「Mac Pro」、RAMとGPUはユーザーによるアップグレードは不可能な模様 |
https://taisy0.com/2023/01/26/167635.html
|
apple |
2023-01-26 10:52:05 |
IT |
気になる、記になる… |
楽天モバイル、5G対応のホームルーター専用料金プラン「Rakuten Turbo」と対応製品「Rakuten Turbo 5G」を順次提供開始 |
https://taisy0.com/2023/01/26/167631.html
|
rakuten |
2023-01-26 10:35:21 |
IT |
気になる、記になる… |
エム・エス・シー、iPhone・AirPods・Apple Watchを同時充電可能なワイヤレス充電スタンド「Freedy マグネット 3-in-1 ワイヤレスチャージャースタンド」を発表 |
https://taisy0.com/2023/01/26/167607.html
|
|
2023-01-26 10:21:40 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 寒波襲来、普通のエアコンが動く最低気温は〇度 |
https://www.itmedia.co.jp/news/articles/2301/26/news187.html
|
itmedia |
2023-01-26 19:45:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 楽天モバイル、工事不要でネットが使える「5Gホームルーター」投入 データ無制限で月額3685円 |
https://www.itmedia.co.jp/news/articles/2301/26/news186.html
|
itmedia |
2023-01-26 19:30:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
ゴッホとカンディンスキーを判別する絵画分類器を作成してみた |
https://qiita.com/kazutomoishi/items/d37044a08aea86a8c95f
|
作りました |
2023-01-26 19:32:53 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
POST送信(通常/javascriptで制御/動的にフォームを作って送信) |
https://qiita.com/ryusuke_jazz/items/cb9ce85e3a1b37511929
|
ltinputty |
2023-01-26 19:39:11 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
wordpress関数をjsファイルで扱えるようにする |
https://qiita.com/yuta-10112022/items/ccb1e6a99313813e89e7
|
nctioncustomenqueuetmppa |
2023-01-26 19:27:56 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
AWS ECS上でRails上で動作するバッチをスケジューリングする |
https://qiita.com/TakenoriHirao/items/bb6ba4baf8ee9de869dc
|
awsecs |
2023-01-26 19:07:01 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【SAA資格勉強】Direct Connectについて |
https://qiita.com/kkk5713/items/dd76dde2ea9772dd823c
|
awsvpn |
2023-01-26 19:06:50 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
App Service 証明書を Azure Key Vault にいれたまま Application Gatewayで利用する |
https://qiita.com/georgeOsdDev@github/items/497d9da5f536b01be914
|
application |
2023-01-26 19:04:05 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
ActiveSupport::Duration で経過した月数を計算する |
https://qiita.com/murata0705/items/363ff2cb1cad1d206e67
|
thujanjstprymaingtpasttim |
2023-01-26 19:09:33 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
AWS ECS上でRails上で動作するバッチをスケジューリングする |
https://qiita.com/TakenoriHirao/items/bb6ba4baf8ee9de869dc
|
awsecs |
2023-01-26 19:07:01 |
技術ブログ |
Developers.IO |
AWS GlueでS3に保存したJSONをRDSへ保存してみた |
https://dev.classmethod.jp/articles/load-json-saved-in-s3-to-rds-with-aws-glue/
|
awsglue |
2023-01-26 10:03:13 |
海外TECH |
DEV Community |
Reflection on Visitor Pattern in Typescript |
https://dev.to/zenstack/reflection-on-visitor-pattern-in-typescript-4gjd
|
Reflection on Visitor Pattern in Typescript Visitor PatternVisitor pattern is one of the twenty three well known Gang of Four design patterns Represent ing an operation to be performed on elements of an object structure Visitor lets you define a new operation without changing the classes of the elements on which it operates The Visitor pattern is a natural fit for working with AST Abstract Syntax Tree data structures For instance if you ve ever used Babel you probably know that the babel traverse library utilizes a visitor pattern to enable you to traverse various nodes generated by babel parser quickly The pattern is typically built on the principle of double dispatch for OOP languages like Java or C Although Typescript is attempting to bring OOP to the Javascript world it s still constrained by the characteristics of Javascript This makes the visitor pattern less elegant to some extent But don t worry I ll show you how to overcome these limitations and harness the true potential of the visitor pattern in Typescript Real World ExampleLet s assume we were back at the time when HTML had just been released and we were building a browser for it ASTLet s say we only have tags supported at the beginning so that the AST would look like the below interface HTMLElement tagName string class PElement implements HTMLElement tagName string p class AElement implements HTMLElement tagName string a class BodyElement implements HTMLElement tagName string body children HTMLElement Visitor InterfaceThe below interfaces are the core part of the visitor pattern interface IVisitable accept visitor Visitor void interface IVisitor visit element PElement void visit element AElement void visit element BodyElement void And we need to make sure all the HTMLElement implement IVisitable so let s make some changes to our AST abstract class AbstractHtmlElement implements HTMLElement IVisitable public abstract tagName string double dispatch pattern public accept visitor IVisitor void visitor visit this class PElement extends AbstractHtmlElement tagName string p class AElement extends AbstractHtmlElement tagName string a class BodyElement extends AbstractHtmlElement tagName string body children AbstractHtmlElement Concrete VisitorSo a real render implementation would be like the below class Render implements IVisitor visit element PElement console log Render P visit element AElement console log Render A visit element BodyElement console log Render Body element children forEach child gt child accept this and the client that actually runs it would be simple Create a visitor const visitor IVisitor new Render Create an AST const body new BodyElement body children push new AElement body children push new PElement Visit the node body accept visitor ExtensibilityOne of the great things about using Visitor pattern is how easy to add a new visitable element Let s say the new tag Table was added to the HTML let s see what we need to do to support it Of course the first thing to do is to define it in AST like below class TableElement extends AbstractHtmlElement tagName string table The next thing is to add the visit interface and implementation for the new element interface IVisitor visit element TableElement void class Render implements IVisitor visit element TableElement console log Render Table That s all See the beauty here is that we only added the code exactly for the new element without touching the existing code at all ProblemIt looks perfect except it works for Java or C but not for Typescript Why because the Render code won t compile class Render implements IVisitor visit element PElement console log Render P visit element AElement console log Render A You will get the error below Duplicate function implementation ts That s the limitation caused by the dynamic type system of Javascript so the function name has to be unique regardless of the parameters There is an interesting part here that in interface IVisitor it doesn t have this restriction I will leave it to you to think about why is that So to make it work we have to make the visit function name unique for individual element types interface IVisitor visitP element PElement void visitA element AElement void visitBody element BodyElement void visitTable element TableElement void Because of this the accept function can t be implemented in the base class anymore Instead it has to be implemented in every type of HtmlElement like below abstract class AbstractHtmlElement implements HTMLElement IVisitable public abstract tagName string public abstract accept visitor IVisitor void class PElement extends AbstractHtmlElement public accept visitor IVisitor visitor visitP this tagName string p class AElement extends AbstractHtmlElement public accept visitor IVisitor visitor visitA this tagName string a class BodyElement extends AbstractHtmlElement public accept visitor IVisitor visitor visitBody this tagName string body children AbstractHtmlElement There are three disadvantages then For every new tag added like the Table it has to be aware of the visitor pattern and implement the accept method for it The accept method always has exactly the same implementation as public accept visitor IVisitor visitor visitA this Because Typescript is structural Typing so you might accidentally write the below wrong code and pass the type checking if the two HTMLElement types are structurally equal class PElement extends AbstractHtmlElement public accept visitor IVisitor Bug it should call visitP instead visitor visitA this tagName string p So is there a way that we don t need to care about accept function Reflection Reflection of JavascriptSince the unique function name is a hard restriction from language there seems no way to let the compiler dispatch to the correct function for us so we have to do that on our own So simply put we need to call the correct function based on the type of the input parameter Sounds doable in Javascript right Since we can get the class name of the parameter using constructor property it s easy to implement the logic in the Visit function below class Render implements IVisitor visit element AbstractHtmlElement const typeName element constructor name const methodName visit typeName ts ignore this methodName call this element visitPElement element PElement console log Render P visitAElement element AElement console log Render A visitBodyElement element BodyElement console log Render Body element children forEach child gt this visit child If you re familiar with the Javascript world this type of work may seem intuitive to you In the realm of static type languages like Java or C it s known as Reflection Then we could get rid of accept totally and always go with the new visit function like below const visitor new Render const body new BodyElement body children push new AElement body children push new PElement Visit the nodevisitor visit body PitfallAlthough it looks like the original goal has been achieved there is a big pitfall Have you noticed the ts ignore in the implementation that s it Now we have an implied limitation that the name of the function has to be visit typeName It means that if you accidentally write a different name like with an extra s at the end visitPElements element PElement console log Render P you will end up getting the error at runtime TypeError Cannot read properties of undefined reading call We went back to the unsafe Javascript world as we actively turned off the safety guard the TS compiler gives So is there any way to achieve that in the Typescript world Reflection of TypescriptAlthough the type is fully erased after being compiled into Javascript TypeScript includes experimental support for emitting certain types of metadata for declarations that have decorators And we can use the reflection API provided by reflect metadata library to retrieve the metadata at runtime Enable Metadata ReflectionTo use it we need first to install this library via npm npm i reflect metadata saveThen set the compiler option in tsconfig json as below compilerOptions target ES experimentalDecorators true emitDecoratorMetadata true Dispatcher DecoratorLet s first define the Dispatcher map the key is the type of HTMLElement and the value is the corresponding visitor function const renderDispatcherMap new Map lt any element HTMLElement gt void You can see that as long as the map is filled with the correct value we can use it to replace the unsafe function call like below visit element HTMLElement const method renderDispatcherMap get element constructor if method method call this element else throw new Error No method found for element constructor name Next we need to do is to fill the map programmatically That can be done by using the method decorator defined below function HtmlElementDispatcher return function target any propertyKey string descriptor PropertyDescriptor const htmlElementType Reflect getMetadata design paramtypes target propertyKey const originalMethod descriptor value if renderDispatcherMap has htmlElementType renderDispatcherMap set htmlElementType originalMethod return descriptor The last thing we need to do is to make sure to put the HtmlElementDispatcher decorator on every visit function and no need to worry about the function name any more HtmlElementDispatcher visitPElement element PElement console log Render P HtmlElementDispatcher visitAElement element AElement console log Render A HtmlElementDispatcher visitBodyElement element BodyElement console log Render Body element children forEach child gt this visit child ConclusionEverything comes with a price The benefit of decoupling the visitor and element in this manner is that we don t have to worry about the accept method anymore However there is a downside to this approach as well The visitor might not be updated when a new type of element is added to the object structure or if the HtmlElementDispatcher is carelessly overlooked So do you think it s worthwhile |
2023-01-26 10:34:51 |
海外TECH |
DEV Community |
A step-by-step roadmap to mastering Javascript 🔥 |
https://dev.to/rammcodes/a-step-by-step-roadmap-to-mastering-javascript-3mcf
|
A step by step roadmap to mastering Javascript A step by step roadmap to mastering Javascript ️⃣Start by learning the basics of JavaScript such as variables data types control structures and functions ️⃣Practice writing code and experimenting with different concepts to solidify your understanding ️⃣Learn about JavaScript s core objects such as arrays strings and numbers ️⃣Learn about the Document Object Model DOM and how to manipulate HTML and CSS with JavaScript ️⃣Learn about event handling and how to create interactive web pages ️⃣Learn about JavaScript s built in objects such as Date Math and RegExp ️⃣Learn about Asynchronous JavaScript and concepts like promises async await and fetch API ️⃣Learn about JavaScript libraries and frameworks such as jQuery React Angular and Vue js ️⃣Practice building real world projects such as a simple game a calculator or a weather app Keep yourself up to date with new features and best practices by regularly reading documentation and articles about JavaScript Hope this helps Do Like ️ amp Save 𝗙𝗼𝗹𝗹𝗼𝘄me on Linkedin for more Tips Guides Resources related to programming and Web Development Do Follow me here on dev to |
2023-01-26 10:09:59 |
医療系 |
医療介護 CBnews |
新規陽性の高齢者数減少も「未だ高い水準で推移」-東京都コロナモニタリング会議専門家意見 |
https://www.cbnews.jp/news/entry/20230126194132
|
新型コロナウイルス |
2023-01-26 19:50:00 |
医療系 |
医療介護 CBnews |
入院患者減少傾向も「依然として高い水準で推移」-東京都がコロナモニタリング会議の専門家意見公表 |
https://www.cbnews.jp/news/entry/20230126190915
|
減少傾向 |
2023-01-26 19:15:00 |
金融 |
金融庁ホームページ |
入札公告等を更新しました。 |
https://www.fsa.go.jp/choutatu/choutatu_j/nyusatu_menu.html
|
公告 |
2023-01-26 11:30:00 |
ニュース |
BBC News - Home |
UK car production collapses to lowest for 66 years |
https://www.bbc.co.uk/news/business-64399748?at_medium=RSS&at_campaign=KARANGA
|
collapses |
2023-01-26 10:48:00 |
ニュース |
BBC News - Home |
Matt Hancock: Man charged with assaulting former health secretary |
https://www.bbc.co.uk/news/uk-64410489?at_medium=RSS&at_campaign=KARANGA
|
london |
2023-01-26 10:50:33 |
ニュース |
BBC News - Home |
Three warnings before US boy, 6, shot teacher - lawyer |
https://www.bbc.co.uk/news/world-us-canada-64406295?at_medium=RSS&at_campaign=KARANGA
|
district |
2023-01-26 10:32:18 |
ニュース |
BBC News - Home |
Stop using hotels to house migrant children, say charities |
https://www.bbc.co.uk/news/uk-64407850?at_medium=RSS&at_campaign=KARANGA
|
asylum |
2023-01-26 10:28:15 |
ニュース |
BBC News - Home |
Video shows moment of cliff collapse on Dorset's Jurassic Coast |
https://www.bbc.co.uk/news/uk-england-dorset-64409758?at_medium=RSS&at_campaign=KARANGA
|
crumbles |
2023-01-26 10:00:41 |
ニュース |
BBC News - Home |
Australian Open 2023 results: Elena Rybakina beats Victoria Azarenka to reach final |
https://www.bbc.co.uk/sport/tennis/64400521?at_medium=RSS&at_campaign=KARANGA
|
Australian Open results Elena Rybakina beats Victoria Azarenka to reach finalWimbledon champion Elena Rybakina reaches another major final as she beats two time winner Victoria Azarenka in the Australian Open semi finals |
2023-01-26 10:38:15 |
ニュース |
Newsweek |
「ミシェル・オバマは男」に半数が同意! バカげた陰謀論が未だに力をもつ理由 |
https://www.newsweekjapan.jp/stories/world/2023/01/post-100708.php
|
なぜその噂が消えないと思うそれに、妊娠したときの写真が枚もないのはなぜかな」と書いた上で、フォロワーに「この噂を信じるかどうか」をイエス・ノーで答えさせた。 |
2023-01-26 19:12:30 |
IT |
週刊アスキー |
『機動戦士ガンダムUCE』で「ジオング」が登場する「超限定ガシャ」を開催中! |
https://weekly.ascii.jp/elem/000/004/122/4122271/
|
ucengage |
2023-01-26 19:45:00 |
IT |
週刊アスキー |
日本各地から選りすぐりの特産品が勢揃い 福岡空港にて「福岡空港JALマルシェ」2月4日・5日開催 |
https://weekly.ascii.jp/elem/000/004/121/4121192/
|
日本航空 |
2023-01-26 19:30:00 |
IT |
週刊アスキー |
アイリスオーヤマ、カーボンヒーターを採用した「スチームカーボントースター」を発売 |
https://weekly.ascii.jp/elem/000/004/122/4122211/
|
採用 |
2023-01-26 19:30:00 |
IT |
週刊アスキー |
『モンハンサンブレイク』無料アップデート第4弾の情報をバハリがお届け! |
https://weekly.ascii.jp/elem/000/004/122/4122270/
|
最新情報 |
2023-01-26 19:20:00 |
IT |
週刊アスキー |
中高生向けモバイルSuica/PASMO通学定期がスタート 3月18日から |
https://weekly.ascii.jp/elem/000/004/122/4122262/
|
pasmo |
2023-01-26 19:15:00 |
海外TECH |
reddit |
How best to deal with a threat from a fellow expat. |
https://www.reddit.com/r/japanlife/comments/10loijc/how_best_to_deal_with_a_threat_from_a_fellow_expat/
|
How best to deal with a threat from a fellow expat Some context I m a member of a Japan gardening group on Facebook People sharing photos of their plants and giving advice sort of thing This guy joins and makes a post about some pies he cooked It s not gardening so a mod removes it He flips out making a rant post about censorship and such nonsense I get to the party quite late A mod has already clarified his post was off topic and some others are defending the mods Anyway He s still ranting and threatening to leave in the comments so I post the emoji He replies to tell me i m supporting censorship and some other stuff long comment I didn t read it all so I reply to his reply with again He screenshots it and posts our conversation if you can call it that and says I m a terrible person He does the same for a couple of other members that didn t defend him I reacted to it with the heart reaction Alright I baited it a little I didn t have to but the guy was been an arsehole The whole post was later removed by a mod after he left was kicked out I forgot all about this until today when I notice I had a pending message request So he makes this threat It was made days ago and I m leaning towards the belief that he s all talk I doubt he could find me based only on that information alone but I m still wondering if I should at least report this to the police especially since he could or maybe already did try to mess with my workplace So my question is what is the best way forward here Should I report it If I do what should I prepare before I go to the police station I already know quite a lot of information about him from his profile Facebook name age nationality car license plate and a facial photo which should be enough to identify him even if the name isn t real submitted by u SuperSan to r japanlife link comments |
2023-01-26 10:06:26 |
コメント
コメントを投稿