投稿時間:2022-04-12 07:12:48 RSSフィード2022-04-12 07:00 分まとめ(40件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
海外TECH DEV Community RECURSIVE ALGORITHMS IN PYTHON https://dev.to/iemmanuel104/recursive-algorithms-in-python-190h RECURSIVE ALGORITHMS IN PYTHONRECURSION DEFINITIONRecursion is a computing technique where by a function calls itself during execution and add data to a stack memory till it reaches the end of the recursive loop and returns back the required output Recursive algorithms are suited for problem whose data structure can be scaled down to smaller versions and they provide and alternative to the conventional iterative methods of approaching problems A visual example of how recursive algorithms work is the Russian doll As depicted above the Russian doll has a smaller version contained in it till you get to the smallest doll so also does recursive algorithms they help solve problems that can be fragmented into smaller pieces but in this case each stage is stored in a STACK memory and can be recalled through a recursive path RECURSION VS ITERATION The major difference between a recursive and iterative algorithm falls under three major criteria for review SPACE USAGE Recursive algorithms are not space efficient when compared to iterative algorithms this is because No stack memory is required in the case of iterative algorithms TIME EFFICIENCY When it come to being time efficient iterative algorithms are more time efficient compared to recursive ones Recursive algorithms require time to pop and push elements to stack memory which is less time efficient CODE SIZE Recursion reduces the size of the code while iteration prolongs it Hence recursive algorithms are easy to code STEPS FOR WRITING RECURSION ALGORITHM Using an example of writing a recursive algorithm to determine the factorial of a number i BUILD A RECURSIVE CASE THIS DESCRIBES THE FLOW GOVERNING EQN AND LOGIC n factorial n ii SPECIFY A BASE CASE THIS IS A STOPPING CRITERION TO PREVENT AN INFINITE LOOPif n in iii IDENTIFY THE UNINTENTIONAL CASE THIS PLACES A CONSTRAINT TO THE ALGORITHMassert n gt and int n n The number must be a positive integer only The code block above returns the factorial of the parameter which is passed into the function The function calls itself each time and adds the each result variable in the stack memory till the base case ia achieved 2022-04-11 21:15:00
海外TECH DEV Community Figma: Animations https://dev.to/tmchuynh/figma-animations-47e4 Figma Animations Table of ContentsFigma AnimationsFigma PluginsStep by StepsConclusion Figma HelpFigma has a help site for animations that goes through instant dissolve smart animate move in out push and slide in out animations It goes into what these animations are has small clips on how they would look like on a mobile device and what they support ie duration easing and direction This Figma help goes into using easing curves whether they be linear ease in ease out ease in and out ease in back ease out back ease in and out back or custom easing curves Overall there are many animations and lots of motions you can add into your designs Along with plugins it can be overwhelming So it s okay to start slow Figma PluginsJitter is one of the Figma plugins that lets you animate your designs with just a few simple clicks The download page says Jitter lets you animate your Figma designs in just a few clicks to export the animation as a video or as a GIF create your motion design system or share the animation parameters with developers So it can t be wrong right Motion is another popular Figma plugin that allows you to use advanced animation techniques and wow your developer friends Let s Do This For this we re going to be using the Jitter plugin Select Jitter and the artboard you want to animate Once the board exports to Jitter in the new tab you ll want to select the element that you want to animate before clicking New Animation button This will bring up all the options for to choose from When you select an animation and it happens too quickly you can change the speed by lengthening the blue bar at the bottom of the screenNote You can stack animations together as well ConclusionAnimations are a great way to make your applications come to life Do you have a favorite plugin to use in Figma for your animations Happy coding 2022-04-11 21:11:56
海外TECH DEV Community Raspberry Pi, meet Arduino. Arduino, meet Raspberry Pi. Let’s talk Bluetooth (LE) https://dev.to/chrisdinhnz/raspberry-pi-meet-arduino-arduino-meet-raspberry-pi-lets-talk-bluetooth-le-35mi Raspberry Pi meet Arduino Arduino meet Raspberry Pi Let s talk Bluetooth LE Some months back I wrote a blog post about Arduino Nano IoT and how to interact with it s onboard Bluetooth module At that time I used Nordic Semiconductor s nRF Connect tool from the App store to interact with Arduino In this post I will build upon what I did and use a Raspberry Pi to interact with the Arduino There are quite a few good BLE helper libraries out there that can make my job easier But not all are created equal some may be perfect for building peripheral BLE applications but may not be the best for central BLE applications As I am going to make the Raspberry Pi the client Bleak is a great one to use Bleak is a GATT client software capable of connecting to BLE devices acting as GATT servers It is designed to provide a asynchronous cross platform Python API to connect and communicate with other BLE devices e g sensors The scenario is described by the sequence diagram below The above diagram consists of main elements A Raspberry PiArduino Nano IoTA SwitchThe Raspberry PiThe Raspberry Pi is a single board computer SBC with an operating system and because it is managed by an operating system we get the same benefits as we would on a PC such as multi tasking develop applications using higher languages such as Python and C hosting NET applications and the list goes on On the other hand being managed by an operating system means access to lower level services and hardware resources are not as simple The Raspberry Pi in this case is acting as a BLE client specifically searching for the Arduino device Once found it will connect to the Arduino and registered to be notified when the state of the switch changes defined by a characteristic UUID Arduino Nano IoTArduino Nano IoT board is a microcontroller has no operating system and host a single program written using a lower level language such as C C This board makes it very easy to work with other electronic devices which is why I see the Raspberry Pi and Arduino board as complementary devices rather than competing devices Which is use the Raspberry Pi as a gateway between the local network and the internet and use the Arduino board to talk to local sensors actuators The Arduino Nano IoT board in this case is acting as a BLE GATT server consisting of a characteristic describing the current state of the switch When the state of the switch changes the Arduino board will notify any registered client of the new state The SwitchThe switch is a physical device which controls a GPIO line on the Arduino When it is pressed the line will be set to high When it is depressed the line will be set to low Setting up Python environment on the Raspberry PiBleak is a Python library so let s set up a Python virtual environment on the raspberry pi and install Bleak Now install Bleak venv pi raspberrypi Workspace ble client pip install bleak Looking in indexes Collecting bleak Using cached kB Collecting dbus next Using cached kB Installing collected packages dbus next bleak Successfully installed bleak dbus next venv pi raspberrypi Workspace ble client pip list Package Version bleak dbus next pip setuptools wheel venv pi raspberrypi Workspace ble client Setting up the Arduino Nano IoT boardLoad the following Arduino sketch onto the Nano IoT board It is practically the same code as that in the Beyond The Built In LED post I talked about include lt ArduinoBLE h gt define SWITCH PIN u static bool isPressed BLEService switchService bfd e ff ad aed BLEByteCharacteristic switchServiceCharacteristic bfe e ff ad aed BLERead BLENotify void setup Serial begin pinMode LED BUILTIN OUTPUT pinMode SWITCH PIN INPUT isPressed false if BLE begin Just keep looping until BLE module is up and running while BLE module is up and running now add our service and characteristic to it BLE setLocalName My Arduino switchServiceCharacteristic writeValue isPressed switchService addCharacteristic switchServiceCharacteristic BLE addService switchService BLE setAdvertisedService switchService BLE advertise Serial println My Arduino started void loop BLE poll if digitalRead SWITCH PIN HIGH if isPressed digitalWrite LED BUILTIN HIGH isPressed true switchServiceCharacteristic writeValue isPressed Serial println Switch is pressed else if isPressed digitalWrite LED BUILTIN LOW isPressed false switchServiceCharacteristic writeValue isPressed Serial println Switch is depressed Now if we connect to the Arduino serial port using a terminal such as Putty for example we should be able to see some console logging when the switch is pressed and depressed Let s talk BLEIn the sketch above I gave the Arduino board a Bluetooth device name My Arduino I then added a service with one characteristic and also state that this characteristic can be read or be notified when the value changes Just as a side note because the raspberry pi initiated the Bluetooth connection it is considered as a BLE central device a client The Arduino board on the other hand accepts connection requests and is providing a service it is considered as a BLE peripheral device a server Let s add some Python code to the raspberry pi to start receiving BLE updates from out Arduino board import asyncio import sys from bleak import BleakScanner from bleak backends bluezdbus client import BleakClientBlueZDBus device name My Arduino switch status char uuid bfe e ff ad aed def notification handler sender data print Switch is active format bool data async def run client None device await BleakScanner find device by filter lambda d ad d name and d name lower device name lower if device is None print not found format device name sys exit else print found format device client BleakClientBlueZDBus device while True if not client is connected try if await client connect print Connected to format device name await client start notify switch status char uuid notification handler except print Connected to failed or lost format device name await asyncio sleep client BleakClientBlueZDBus device print Retrying else await asyncio sleep loop asyncio get event loop loop run until complete run Basically what the above python code does is scan for a specific BLE device with the name of My Arduino If one was in range it will connect to it The program then start observing the switch status characteristic and when an update is received it will be handled by notification handler Let s see them in actionBelow is a short clip showing Arduino Nano IoT powered by a portable USB chargerA switch connected to the ArduinoPhone connected to Raspberry Pi via SSH Using Termius As we can see when the switch is pressed or depressed we can see that the phone received a BLE notification That is basically it it doesn t have to be a switch We can connect whatever sensor we like analog or digital and add the necessary BLE services to the Arduino device as required This blog post was originally posted on my blog site An IoT Odyssey 2022-04-11 21:06:47
海外科学 NYT > Science New Drug Slashed Deaths Among Patients With Severe Covid, Maker Claims https://www.nytimes.com/2022/04/11/health/covid-sabizabulin-veru.html New Drug Slashed Deaths Among Patients With Severe Covid Maker ClaimsA late stage trial was halted after strong early results according to the company but the data have not yet been published or peer reviewed 2022-04-11 21:52:16
海外科学 NYT > Science This Psychiatric Hospital Used to Chain Patients. Now It Treats Them. https://www.nytimes.com/2022/04/11/health/this-psychiatric-hospital-used-to-chain-patients-now-it-treats-them.html health 2022-04-11 21:13:18
ニュース BBC News - Home Ukraine conflict: 'Russian soldiers raped me and killed my husband' https://www.bbc.co.uk/news/world-europe-61071243?at_medium=RSS&at_campaign=KARANGA conflict 2022-04-11 21:15:23
ニュース BBC News - Home Britney Spears says she is pregnant after conservatorship ends https://www.bbc.co.uk/news/entertainment-arts-61075379?at_medium=RSS&at_campaign=KARANGA depression 2022-04-11 21:26:22
ニュース BBC News - Home Why desperate Ukraine mother wrote details on toddler's back https://www.bbc.co.uk/news/world-europe-61071172?at_medium=RSS&at_campaign=KARANGA backsasha 2022-04-11 21:18:41
ニュース BBC News - Home Freddy Rincon: Former Colombia captain in critical condition after car crash https://www.bbc.co.uk/sport/football/61075440?at_medium=RSS&at_campaign=KARANGA Freddy Rincon Former Colombia captain in critical condition after car crashFormer Real Madrid midfielder Freddy Rincon is in a critical condition with severe head injuries suffered in a car crash in Cali Colombia 2022-04-11 21:27:15

コメント

このブログの人気の投稿

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