python |
Pythonタグが付けられた新着投稿 - Qiita |
ライフゲーム(Conway's Game of Life)の簡易実装例 |
https://qiita.com/ytaki0801/items/12707b713e6e04b874fa
|
conwaysgameoflife |
2023-02-05 22:56:44 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
poetryで利用するpythonをバージョンアップする |
https://qiita.com/watame/items/8900d4d51f97e7ad3a89
|
poetry |
2023-02-05 22:48:51 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
ChatGPT APIをPythonで使う |
https://qiita.com/Nikto/items/bebba9bd847b6ec8254d
|
discordbot |
2023-02-05 22:44:30 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
GFM(GitHub Flavored Markdown)をPDFとして出力する |
https://qiita.com/h-yon/items/fe4f7e738266bb1b77ba
|
emoji |
2023-02-05 22:12:53 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Active Storageを使った画像アップロード |
https://qiita.com/sekkey_777/items/339ac0416b1505fa0fc6
|
activestorage |
2023-02-05 22:28:12 |
GCP |
gcpタグが付けられた新着投稿 - Qiita |
[Identity-Aware Proxy] Cloud Run で公開したサービスに対して、IAM で定義したユーザのみアクセスを許可する |
https://qiita.com/Jiei-S/items/6a937856a48f0d42c620
|
awareproxycloudrun |
2023-02-05 22:40:59 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
仮想ネットワークアプライアンスを導入するときは、スループットだけではなく「ネットワークフロー数」も確認しましょう |
https://qiita.com/yukit7s/items/b03a112196bada10812c
|
azure |
2023-02-05 22:41:06 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
初学者によるubuntuでのRails + React で駅案内システム作り④~1:1、1:mで対応したモデルの登録更新、JSON出力~ |
https://qiita.com/Akane-Toribe/items/273f315f20d138b7d5e1
|
ubuntu |
2023-02-05 22:31:51 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
Active Storageを使った画像アップロード |
https://qiita.com/sekkey_777/items/339ac0416b1505fa0fc6
|
activestorage |
2023-02-05 22:28:12 |
海外TECH |
MakeUseOf |
The 6 Best Chrome Extensions to Enhance Roblox |
https://www.makeuseof.com/chrome-extensions-enhance-roblox/
|
chrome |
2023-02-05 13:30:16 |
海外TECH |
DEV Community |
Javascript if/else shorthand explained (with common uses cases) |
https://dev.to/lavary/javascript-ifelse-shorthand-explained-with-common-uses-cases-4nhh
|
Javascript if else shorthand explained with common uses cases Update This post was originally published on my blog decodingweb dev where you can read the latest version for a user experience rezaIf you re looking for the shorthand of if else in JavaScript you need to use the ternary a k a the conditional operator The ternary operator takes three operands a condition followed by a question mark and two JavaScript expressions separated by a colon The expression on the left side of the colon will be executed if the condition is truthy But if the condition is falsy the right side expression will be executed condition exprIfConditionIsTruthy exprIfConditionIsFalsyThe result of a ternary operator can be assigned to a variable and used in another expression You can also use it when returning a value in a function Let s see some use cases Initializing variables The most common use case of ternary operators is initializing variables let backgroundColor isChrismas red yellow With an if else you d achieve the same thing like so let backgroundColor if isChristmas backgroundColor red else backgroundColor yellow Not bad either Ternary operator in functions You can use the ternary operator to return a value from a function The following function determines whether a number is even or not function isEven value return value true false Ternary operator in strings You can also use the ternary operator when generating strings let greeting Welcome dear user user name user In the above example if the user is authenticated we ll greet them by name otherwise Welcome dear user would be displayed Ternary operators can be nestedThe ternary operator is right associative meaning it can be nested just like having consequent if else statements On the other hand exprIfConditionIsTruthy and exprIfConditionIsFalsy operands can be a ternary operator let someVariable condition value condition value condition value value Readability of shorthand if else in JavaScriptEven though the ternary operator is short and sweet it doesn t make if else statements a bad choice Sometimes an if else statement is more readable than a ternary operator regardless of the number of lines Which one would you choose for nested conditions ❋The ternary apporachfunction someFunction return condition value condition value value ❋The if else approach function someFunction if condition return value else if condition return value If none of the above are truthy return value Although the if else approach needs a few more lines it s closer to human language As a rule of thumb the ternary operator is handy for one liners For other flow control scenarios use if else Alright I think that does it for today I hope you found this quick guide helpful Thanks for reading ️You might like JavaScript double exclamation mark explained with examples How to check if an element exists in JavaScript with examples JavaScript isset Equivalent methods |
2023-02-05 13:45:43 |
海外TECH |
DEV Community |
Liskov's Substitution Principle (Python Design Patterns) |
https://dev.to/cleancodestudio/liskovs-substitution-principle-python-design-patterns-31c2
|
Liskov x s Substitution Principle Python Design Patterns The Liskov Substitution Principle LSP states that objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program This means that a subclass should be a subtype of its superclass and the behavior of the program should remain the same whether we use the superclass or a subclass Here s an example in Python In this example the Rectangle class defines the behavior for rectangles and the Square class inherits from it and represents squares The use it function uses a rectangle like object such as a Rectangle or a Square to calculate its area The function calls the set height method and then asserts that the area is correct When we pass a Rectangle object to use it it works as expected and the assertion is true When we pass a Square object to use it it also works and the assertion is true even though the Square class overrides the behavior of the set width and set height methods This means that the Square class is a subtype of the Rectangle class and objects of the Square class can be used wherever objects of the Rectangle class are expected without affecting the correctness of the program This adheres to the Liskov Substitution Principle PythonDesign PatternsClean Code StudioPython Design PatternsPython Liskov s Substitution Principle Design PatternLiskov Substitution Design Pattern |
2023-02-05 13:40:17 |
海外TECH |
DEV Community |
Python Open Closed Design Pattern (Python SOLID Principles) |
https://dev.to/cleancodestudio/python-open-closed-design-pattern-python-solid-principles-1b5i
|
Python Open Closed Design Pattern Python SOLID Principles The Open Closed Principle states that a module such as a class function etc should be open for extension but closed for modification In other words a module should be designed in such a way that it can be easily extended without changing its existing code Here s an example in Python In this example the Shape class is an abstract base class that defines the interface for all shapes and the Circle and Rectangle classes inherit from it and provide concrete implementations of the area method The calculate area function takes a list of shapes and calculates the total area by calling the area method on each shape By using inheritance and an abstract base class the existing code can be extended to support new shapes without having to modify the existing code For example if we wanted to add a square shape we could simply create a Square class that inherits from Shapeand provide an implementation of the area method This adheres to the Open Closed Principle as the existing code remains closed for modification while new functionality can be added through extension PythonDesign PatternsClean Code StudioPython Design PatternsPython Open Closed Principle Design PatternOpen Closed Principle OCP |
2023-02-05 13:25:42 |
海外TECH |
DEV Community |
About "Cannot use import statement outside a module" in JavaScript |
https://dev.to/lavary/about-cannot-use-import-statement-outside-a-module-in-javascript-2enh
|
About quot Cannot use import statement outside a module quot in JavaScriptUpdate This post was originally published on my blog decodingweb dev where you can read the latest version for a user experience rezaThe error “cannot use import statement outside a module occurs when you use the import statement outside an ES ECMAScript module If you re using Node js you need to set Node s module system to ES modules by adding type module to your package json file However if you re getting this error in your web browser add type module to your lt script gt tag Here s what the error looks like in the Node js environment node Warning To load an ES module set type module in the package json or use the mjs extension Use to show where the warning was created var www node test app js import isOdd from utils js SyntaxError Cannot use import statement outside a moduleAnd in the browser How to fix cannot use import statement outside a module errorAs mentioned earlier this error can happen in two environments Node jsWeb browserLet s see how we can fix the issue on either of these environments Node js Node js supports two module systems for loading modules The CommonJs Modules the default module system ES ModulesIf you re getting the error in Node js the reason is probably Node js isn t configured to use the ESM module system Node s default module system is CommonJS where you export modules with module exports and load them via require Set Node s module system to ES modules by adding type module to your package json file name test version description main app js type module scripts test echo Error no test specified amp amp exit author license ISC If you don t have a package json file yet you can create one by running npm init in your project s directory npm initNpm will ask you to provide information about your package such as name version description author etc This information is optional though The above should fix the issue in your Node js app If you re getting the error in the browser Most browsers have native support for ECMAScript Modules However if you get this error in your browser you need to add type module to your lt script gt tag lt script src main js type module gt And in case you want to write your code directly in the HTML document lt script type module gt Your JavaScript code here lt script gt Alright I think that does it I hope this quick guide could solve your problem Thanks for reading ️You might like I got TypeError getElementById is not a function in JavaScript Resolved I ran into dirname is not defined in ES module scope Fixed Cannot find module error in Node js Fixed SyntaxError Unexpected end of JSON input in JavaScript Fixed How to fix ReferenceError document is not defined in JavaScript |
2023-02-05 13:24:08 |
海外TECH |
DEV Community |
Python Single Responsibility Design Pattern (Code Example) |
https://dev.to/cleancodestudio/python-single-responsibility-design-pattern-code-example-1e1k
|
Python Single Responsibility Design Pattern Code Example Python Single Responsibility Design Pattern Every module class or function should have only one reason to change Example of the Single Responsibility Principle design pattern implemented in Python code In this example the Journal class has a single responsibility which is to store and manage journal entries The PersistenceManager class on the other hand has a single responsibility which is to persist the Journal to different storage mediums file web etc This separation of responsibilities makes the code more maintainable and easier to understand as changes to one class won t affect the other PythonDesign PatternsClean Code StudioPython Design PatternsSingle Responsibility Principle SRP |
2023-02-05 13:14:00 |
Apple |
AppleInsider - Frontpage News |
Daily Deals Feb. 5: $150 off M2 Pro 14-inch MacBook Pro, 91% off Microsoft Office for Mac, 13% off Bose Noise Cancelling Headphones 700 |
https://appleinsider.com/articles/23/02/05/daily-deals-feb-5-150-off-m2-pro-14-inch-macbook-pro-91-off-microsoft-office-for-mac-13-off-bose-noise-cancelling-headphones-700?utm_medium=rss
|
Daily Deals Feb off M Pro inch MacBook Pro off Microsoft Office for Mac off Bose Noise Cancelling Headphones The best deals we found today include off an Nvidia Shield Gen AirPods Pro off a Anker Power Bank and more Save on Bose headphones inch MacBook Pro and Microsoft Home Business for Mac The AppleInsider team searches for can t miss bargains at online retails to compile a list of unbeatable deals on top tech products including discounts on Apple products TVs accessories and other gadgets We publish the best in our Daily Deals column to help you save money on your purchases Read more |
2023-02-05 13:16:42 |
ニュース |
BBC News - Home |
Vile theories hurt missing mum's family, says friend |
https://www.bbc.co.uk/news/uk-england-lancashire-64529251?at_medium=RSS&at_campaign=KARANGA
|
abuse |
2023-02-05 13:08:44 |
ニュース |
BBC News - Home |
Truss's tax cuts clearly wrong approach, says Shapps |
https://www.bbc.co.uk/news/uk-64530150?at_medium=RSS&at_campaign=KARANGA
|
cabinet |
2023-02-05 13:48:20 |
コメント
コメントを投稿