IT |
気になる、記になる… |
Anker、「楽天お買い物マラソン」で対象製品を最大40%オフで販売するセールを開催中(4月16日まで) |
https://taisy0.com/2022/04/09/155586.html
|
anker |
2022-04-09 14:52:04 |
IT |
気になる、記になる… |
楽天市場、ポイントが最大42倍になる「お買い物マラソン」のキャンペーンを開催中(4月16日まで) |
https://taisy0.com/2022/04/09/155583.html
|
期間限定 |
2022-04-09 14:48:13 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Pythonで変数名を文字列として扱う方法 |
https://qiita.com/YukiYamamoto/items/3197b73e5396a473c62e
|
頻繁 |
2022-04-09 23:25:54 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
JupyterLabでPlotlyを使うとグラフが表示されない件 |
https://qiita.com/UdonGyoza/items/0c57eece2d4b2c1c3142
|
jupyterlab |
2022-04-09 23:22:01 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
expectation構文 |
https://qiita.com/Q-junior/items/3566f8b3b7e4407be7c4
|
expect |
2022-04-09 23:48:40 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
Azure Bastion を Terraform で構築 |
https://qiita.com/suzuyui/items/05baae1cb7b25f29957a
|
azure |
2022-04-09 23:47:09 |
技術ブログ |
Developers.IO |
AWS CDK v2 + GitHub ActionsでReactアプリをデプロイしてみた |
https://dev.classmethod.jp/articles/deploying-a-react-app-with-aws-cdk-v2-github-actions/
|
awscdkvgithubactio |
2022-04-09 14:54:26 |
海外TECH |
MakeUseOf |
How to Create an Animated Text Mask in Canva |
https://www.makeuseof.com/create-animated-text-mask-canva-how-to/
|
canva |
2022-04-09 14:30:13 |
海外TECH |
MakeUseOf |
7 Ways to Fix the Windows Local Group Policy Editor When It’s Unresponsive |
https://www.makeuseof.com/windows-local-group-policy-unresponsive/
|
doesn |
2022-04-09 14:15:13 |
海外TECH |
DEV Community |
Staged Event Driven Architecture for highly concurrent systems |
https://dev.to/dogealgo/staged-event-driven-architecture-for-highly-concurrent-systems-3b99
|
Staged Event Driven Architecture for highly concurrent systems Brief Anything connected to internet has the probability of accessing its resources from anywhere at any given time from any number of users As the any number of users translates to the number of users can be from to billion at any given time Arises the question of how we are going to allocate resources accessible by the users of any number Lets break things up So any number of user can be accessing resources at any time says clearly the need arises dynamically So lets say we can dynamically increase our resources at any time A fictious controller that is responsible for increasing the resource pool as per the load The Staged Event driven system Consider every call towards the system as Event Each Event can be processed by Network of Stages Why Events should be processed by Network of Stages Lets take HTTP request as an example A Socket connection Event is established with the server and request is read from SocketThe HTTP request packet is parsed in HTTP parser If the requested data by the HTTP request Event is available in Cache then Cache hit and proceeds to send response by writing the data to the Socket If the requested data by the HTTP request is not available in Cache then Cache miss now handle Cache miss by doing an I O Event to the Database to fetch the Cache missed Data back to system now system sends data by writing the data to the SocketThe above steps are general which is why Events are processed in stages A Staged event driven HTTP server will look as follows Figure Staged event driven HTTP server Each stage from above exampleSocket INData Parser Cache Database File I O Socket OUTas each stage handles their very own Events each stages will have a Event Queue Event Handler and Resource Pool ControllerEvent Queue holds eventsEvent Handler manages the events by doing enqueue and dequeue operations on the Event QueueResource Pool Controller will allocate the resources like CPU Network I O Memory required by Each Stage Figure SEDA Stage The Resource Pool Controller can be classified in to two typesThread pool controllerBatching controllerAs the name suggest the Thread pool controller controls the amount of threads running in the pool While the Batch controller controls the number of events processed by Event handlers on their each iterationsFigure Thread pool controller and Batching controller Reference |
2022-04-09 14:42:13 |
海外TECH |
DEV Community |
The Defensive Code Reviews |
https://dev.to/rfornal/the-defensive-code-reviews-1c10
|
The Defensive Code ReviewsI refer to the code I write as MY CODE In reality it s my client s code the majority of the time The ProblemIn the past this caused issues when I would push up a Pull Request and ask for a Code Review The reviews would come in I read them I got angry How dare anyone question MY CODE I got defensive and struggled to see the need for someone to look over the great code I was writing The IssueThe issue was that it wasn t my code The issue was that it wasn t always great code The SituationThe code I wrote was for the client The Code Reviews were made to improve the code I wrote The only difference here was my perspective The reviews hadn t changed The reviews were never an attack on my code any by extension me They were only meant to help me improve my code see other perspectives and grow as a developer The Code ReviewConsidering the subject of code review itself the code there are two conceptual levels at play A code review has important human ramifications People learn and share knowledge through the review process And they use it to prevent the kind of defects that result in frustration for the team Developers get emotionally invested in their creations we own the code we write A good code review process helps with code quality and helps developers learn It is the most effective defect prevention method This put a good code review ahead of even automated unit tests ConclusionI find that maintaining this balance of code ownership to be a challenge that comes back to visit me now and then When I first started and had my first code reviews it was much more challenging I often find myself working with other developers to ensure that they understand my intent to help them learn and grow throughout this process |
2022-04-09 14:27:34 |
海外TECH |
DEV Community |
Python 101 - what happens when you instantiate a class? |
https://dev.to/timtsoitt/python-101-what-happens-when-you-instantiate-a-class-55ba
|
Python what happens when you instantiate a class IntroductionPython is a simple language Many people pick Python as their first language to learn While you are coding in Python happily have you ever curious about how a class is instantiated TL DR Learn how Python instantiate a class from concept level to reading source code Starting PointLet take a look of this code snippet We define a method that return an integer And then we call the method to get the value def my method return a my method Then we take a look of this code snippet We define a class and then we instantiate the class class MyClass def init self passmyclass MyClass Inside the method we need to use return to get the value But for the class there is no return statement Why we can get the instance of the class There must be something hidden The hidden base classPython is a OOP language i e we can use inheritance In Python we implement inheritance like this which the derived class MyClass is inherited from the base class SuperClass class SuperClass passclass MyClass SuperClass passNow I want you to know every class has a default base class in Python which is called object If you have been using Python for a while you might have an idea seeing people define a class in this way This is because Python does not auto apply class object as the base class class MyClass object passWe can use dir method to verify it The dir method returns all attributes and methods of the specified object without the values gt gt gt dir object class delattr dir doc eq format ge getattribute gt hash init init subclass le lt ne new reduce reduce ex repr setattr sizeof str subclasshook gt gt gt dir MyClass class delattr dict dir doc eq format ge getattribute gt hash init init subclass le lt module ne new reduce reduce ex repr setattr sizeof str subclasshook weakref We can confirm that the class MyClass inherits all the things from class object You can also use issubclass MyClass object to verify it From the result of dir method there is one method we need to be aware of which is new new method is responsible to create instance from the class by allocating memory and initialising necessary fields Now we know the hidden return statement is inside new method Conceptual representation class object def new cls instance create and initialise cls return instanceOk You should spot out two points I will answer these points one by one Where is the cls init method called What you mean by conceptual Introduction of metaclassI mentioned every class has a hidden base class Object Now I also want you to know every class has a hidden metaclass which is called type Generally speaking metaclass is a class of the class that defines the behaviour of its class instances When you create an instance from a class Python needs to create the class itself first as a form of instances of the metaclass Inside the metaclass it defines how the class creates instances of itself in the call method which triggers new method and then init method from the class Conceptual representation class type def call cls args kwargs instance cls new cls cls init cls args kwargs return instanceNow we have the full picture of how init method is triggered Deep dive into Python implementation source codeWe know Python is an interpreted programming language it needs an interpreter to translate your Python code to bytecode and get it running Interpreter is a program So we need to ask how Python interpreter is developed The answer is CPython CPython is the official implementation of the interpreter As the name implies it is written in C language When you download Python in the official page you are using CPython based interpreter There are other Python implementations such as Jython Java based implementation PyPy Python based implementation How CPython is related to our topic CPython does not only translate your Python source code it also included Python standard libraries Let say when you use print command in Python do you notice that you never need to import any library while in C you need to import standard library This is because Python interpreter CPython help you to do so The implementation of class object and class type are part of the CPython It is not written in Python directly which is why I mention it as conceptual implementation in pythonic way Here is the most exciting part we are going to look into the CPython source code The CPython implementation of new methodLet us visit CPython Github repository At the time I write this article it is Python version alpha The first file we need to look for is include object h file It defines a struct called object Every instance of class is object in C implementation struct object PyObject HEAD EXTRA Py ssize t ob refcnt PyTypeObject ob type There are three fields PyObject HEAD EXTRAIt is for debug usage We can skip it Py ssize t ob refcntStoring reference counter for garbage collection management PyTypeObject ob typeThe type of the object i e the class of the object In include pytypedefs h file We can see it defines an alias name PyObject to struct object All other CPython source code always references PyObject instead of object typedef struct object PyObject In Objects object c file we can find the actual implementation of the new method It returns a PyObject such as instance of class PyObject PyObject New PyTypeObject tp PyObject op PyObject PyObject Malloc PyObject SIZE tp if op NULL return PyErr NoMemory PyObject Init op tp return op In Objects call c file we can find the actual implementation of the call method PyObject PyObject Call PyThreadState tstate PyObject callable PyObject args PyObject kwargs ternaryfunc call PyObject result PyObject Call must not be called with an exception set because it can clear it directly or indirectly and so the caller loses its exception assert PyErr Occurred tstate assert PyTuple Check args assert kwargs NULL PyDict Check kwargs vectorcallfunc vector func PyVectorcall Function callable if vector func NULL return PyVectorcall Call tstate vector func callable args kwargs else call Py TYPE callable gt tp call if call NULL PyErr Format tstate PyExc TypeError s object is not callable Py TYPE callable gt tp name return NULL if Py EnterRecursiveCall tstate while calling a Python object return NULL result call callable args kwargs Py LeaveRecursiveCall tstate return Py CheckFunctionResult tstate callable result NULL The line result call callable args kwargs is actually calling another function called type call which is defined in Objects typeobject c file static PyObject type call PyTypeObject type PyObject args PyObject kwds PyObject obj PyThreadState tstate PyThreadState GET ifdef Py DEBUG type call must not be called with an exception set because it can clear it directly or indirectly and so the caller loses its exception assert PyErr Occurred tstate endif Special case type x should return Py TYPE x We only want type itself to accept the one argument form if type amp PyType Type assert args NULL amp amp PyTuple Check args assert kwds NULL PyDict Check kwds Py ssize t nargs PyTuple GET SIZE args if nargs amp amp kwds NULL PyDict GET SIZE kwds obj PyObject Py TYPE PyTuple GET ITEM args Py INCREF obj return obj SF bug if that didn t trigger we need arguments But PyArg ParseTuple in type new may give a msg saying type needs exactly if nargs PyErr SetString PyExc TypeError type takes or arguments return NULL if type gt tp new NULL PyErr Format tstate PyExc TypeError cannot create s instances type gt tp name return NULL obj type gt tp new type args kwds obj Py CheckFunctionResult tstate PyObject type obj NULL if obj NULL return NULL If the returned object is not an instance of type it won t be initialized if PyObject TypeCheck obj type return obj type Py TYPE obj if type gt tp init NULL int res type gt tp init obj args kwds if res lt assert PyErr Occurred tstate Py DECREF obj obj NULL else assert PyErr Occurred tstate return obj Let translate this function in pythonic style Trigger new method to get instance of the class Check the returned instance is an instance of the class If no return the instance immediately If yes call init method and then return the instance SummaryReading CPython source code is not a trivial task There are lots of details I do not cover Anyway I hope you can learn more about Python after reading my article If you like my article please give me some reactions as an encouragement Thank you ReferenceCPython source code guidePython object creation sequence |
2022-04-09 14:18:52 |
海外TECH |
DEV Community |
Easily enforce git branch naming conventions |
https://dev.to/mdailey77/easily-enforce-git-branch-naming-conventions-583o
|
Easily enforce git branch naming conventionsIn many software development projects there is often some kind of branch naming conventions the developers follow What if not all developers follow the naming rules This has been a recurring problem at my work I came up with a solution that was the easiest to implement I created a githooks script that will run right before the git push command For the script to automatically run a new githooks folder needs to be created in the Git repository s root folder Git needs to know it exists so run git config core hooksPath githooks while in the repository root folder The script needs to be named pre push with no file extension My githooks script is set up so if the git branch being pushed doesn t start with certain words and contains more than characters an error message is thrown and the push doesn t occur Here is the script and GitHub Gist link usr bin env bashLC ALL Clocal branch git rev parse abbrev ref HEAD valid branch regex task master develop qa tb bug story a z message This branch violates the branch naming rules Please rename your branch if local branch valid branch regex then echo message exit fiexit |
2022-04-09 14:03:45 |
海外TECH |
DEV Community |
Day 5: Underestimated SASS |
https://dev.to/kemystra/day-5-underestimated-sass-5dlj
|
|
2022-04-09 14:02:03 |
海外TECH |
DEV Community |
Dynamic Components in React |
https://dev.to/ayo_tech/how-to-use-components-dynamically-in-react-2gmk
|
Dynamic Components in React IntroductionHi there if you have worked with Vue you would realise you are able to use components dynamically through the component tag as shown below lt script gt import CustomComponent from path to custom component import AnotherComponent from path to another component export default components CustomComponent AnotherComponent data return activeComponent CustomComponent lt script gt lt template gt lt div gt lt component is activeComponent gt lt div gt lt template gt In this article I would be demonstrating a way how you can use components dynamically in React lets start codingI m going to assume you already have a react project set up so I m going to jump right into it First create a components folder in the root directory if you do not have one yet Inside the components folder create a new file named DynamicComponent js and add the following code import React from react desc the dynamic component is used to render various component dynamically params props useDefaultPath this indicates that the component to be used is in the components folder if set to true else you would have to pass in a different component is if useDefaultPath is true you pass in the name of the component file or the path to the component in the component folder eg NewComponent or BaseUI NewComponent rest the props to be passed into the new component const DynamicComponent is useDefaultPath true rest gt return React createElement useDefaultPath require is js default is rest export default DynamicComponent We can now use this component in other files to dynamically render different components based on conditions we have set Example would be this code belowimport App css import DynamicComponent from components DynamicComponent import useState from react function App const activeComponent setActiveComponent useState SayHello return lt div className App gt lt header className App header gt lt DynamicComponent is activeComponent name Sholademi Ayomikun gt lt button onClick gt Note that SayHello and SayGoodbye have been defined in the components folder setActiveComponent activeComponent SayHello SayGoodbye SayHello gt Toggle Component lt button gt lt header gt lt div gt export default App ConclusionThe article shows how you can use React createElement to dynamically render components The code for this can be found here Use cases would be to dynamically change app layout or have multiple tabs with different view Please note that there are several approaches to doing this in React Follow me on twitter and githubAlso subscribe to my youtube channel I m trying to get up to subscribers to start dishing out content there |
2022-04-09 14:00:54 |
Apple |
AppleInsider - Frontpage News |
Dual USB-C Power Adapter soon to enter mass production |
https://appleinsider.com/articles/22/04/09/dual-usb-c-power-adapter-soon-to-enter-mass-production?utm_medium=rss
|
Dual USB C Power Adapter soon to enter mass productionApple s leaked dual port USB C wall charger may see a release in the near future as an analyst claims it will soon be entering mass production On Friday a support document briefly posted then removed from Apple s website described the unreleased Apple W Dual USB C Port Power Adapter While the leak didn t indicate when it will launch it seems that it could be a matter of a few months before it sees the light of day In a Saturday tweet TF Securities analyst Ming Chi Kuo picked up on the leak by claiming components for the item are nearing mass production While an item entering production is a positive sign for a product there s no definitive timeframe for its release but it could easily surface within a few months Read more |
2022-04-09 14:46:51 |
海外TECH |
CodeProject Latest Articles |
Cinchoo ETL - CSV Reader |
https://www.codeproject.com/Articles/1145337/Cinchoo-ETL-CSV-Reader
|
cinchoo |
2022-04-09 14:06:00 |
海外TECH |
CodeProject Latest Articles |
Using GFX in PlatformIO |
https://www.codeproject.com/Articles/5327404/Using-GFX-in-PlatformIO
|
platformio |
2022-04-09 14:01:00 |
海外科学 |
NYT > Science |
Russian Blunders in Chernobyl: ‘They Came and Did Whatever They Wanted’ |
https://www.nytimes.com/2022/04/08/world/europe/ukraine-chernobyl.html
|
Russian Blunders in Chernobyl They Came and Did Whatever They Wanted Tank treads ripped up the toxic soil bulldozers carved trenches and bunkers and soldiers spent a month camped in ーand dug into ーa radioactive forest |
2022-04-09 14:43:01 |
海外科学 |
NYT > Science |
I Reported on Covid for Two Years. Then I Got It. |
https://www.nytimes.com/2022/04/09/insider/i-reported-on-covid-for-two-years-then-i-got-it.html
|
I Reported on Covid for Two Years Then I Got It Apoorva Mandavilli has covered the coronavirus since the pandemic started But contracting the virus herself taught her something no research paper could |
2022-04-09 14:10:00 |
ニュース |
BBC News - Home |
Johnson travels to Kyiv for Zelensky talks |
https://www.bbc.co.uk/news/uk-61052643?at_medium=RSS&at_campaign=KARANGA
|
downing |
2022-04-09 14:45:36 |
ニュース |
BBC News - Home |
France election: Voters prepare to cast ballot in presidential poll |
https://www.bbc.co.uk/news/world-europe-61051217?at_medium=RSS&at_campaign=KARANGA
|
ballot |
2022-04-09 14:17:00 |
ニュース |
BBC News - Home |
We The Curious in Bristol evacuated due to fire |
https://www.bbc.co.uk/news/uk-england-bristol-61051868?at_medium=RSS&at_campaign=KARANGA
|
battle |
2022-04-09 14:39:29 |
海外TECH |
reddit |
Boris Johnson is in Kyiv right now. News sites aren't aware of it yet. |
https://www.reddit.com/r/interestingasfuck/comments/tzu2io/boris_johnson_is_in_kyiv_right_now_news_sites/
|
Boris Johnson is in Kyiv right now News sites aren x t aware of it yet submitted by u pleasureboat to r interestingasfuck link comments |
2022-04-09 14:15:33 |
コメント
コメントを投稿