投稿時間:2022-04-10 06:21:42 RSSフィード2022-04-10 06:00 分まとめ(21件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
Ruby Railsタグが付けられた新着投稿 - Qiita さくらvpsにRailsアプリをデプロイするまで (4) Homebrew導入 https://qiita.com/kyokucho1989/items/1a5fa8584d97f775cb6c homebrew 2022-04-10 05:57:01
海外TECH MakeUseOf The Best Wild Foraging Resources to Help Expand Your Palate https://www.makeuseof.com/wild-foraging-resources/ The Best Wild Foraging Resources to Help Expand Your PalateCan you eat that mushroom Will those plants provide health benefits If you re entering the world of foraging you should check out these resources 2022-04-09 20:45:13
海外TECH DEV Community Threads in NodeJS: Going beyond eventloop using Rust https://dev.to/iostreamer/threads-in-nodejs-going-beyond-eventloop-using-rust-3ch7 Threads in NodeJS Going beyond eventloop using RustCircumventing the single thread bottleneckIndex NodeJS RefresherA brief overview of how eventloop works internallyLet s block the main threadHow a simple code can bring down the performance of NodeJSA qr generator serviceA realistic example and the results of load testingHow to improve Can we do better than Node Rust solutionUsing rust and neon to save the dayComparisonIt s a number s gameConclusionIt s all about choosing the best tool for the job NodeJS refresherAt this point we have all heard and read how nodejs is singlethreaded but not really But just in case here s a refresher NodeJS relies on the concept of event loop The idea is to ask the os kernel to do the heavylifting and expect a signal saying hey this is done Each os has their own thing going on linux has epoll wait osx has kqueue and windows has something weird These kernel api calls are the ones doing the actual job It kinda looks like this pseudocodewhile event epoll wait if event type socket do something or in our case execute the relevant callback NodeJS doesn t have a one size fit all event loop rather it has a phased setup For example it checks timers setTimeout etc first Here it s the OS s show again and it uses epoll or equivalent to know if it needs to execute a callback or not Then we have the microtask queue which handles promises and nextTicks And more checkout this video for full pictureAt the end of the phased setup it checks if there are still any more events that it needs to handle or wait for If yes the loop continues if not the loop and the program exits After getting a signal saying hey this is done the associated callback that you provided is executed Now mind you the loop itself is what s single threaded The tasks that node does in the loop all on one thread And the associated callback that it needs to run Well you guessed it the same event loop thread And now you case see why there might be some confusion around the execution Afterall it s singlethreaded but not really Also what happens if the callback you provided is trying to calculate the meaning of life That s when we have a problem because now our eventloop isn t going to do anything until the callback function s execution is complete That s what we mean by blocking the main thread in NodeJS Let s block the main threadLet s say we have a NodeJS express server with us And on each request we calculate a cryptographic hash of given query parameters And just to stress the system we do this hashing k times and then return the result back const express require express const app express const port function getHash text let hashedString text for const i i lt i do fancy hashing return hashedString app get async req res gt const text req query text const result getHash text res send result app listen port gt console log App listening on port port Based on what we discussed in previous section we can see how this setup can backfire and undermine the performance of NodeJS But to show again NodeJS starts up and starts executing our scriptIt asks OS to tell when the server startsIt asks OS to also tell when that server receives a connection requestAnd now the grand loop runs in phased manner checking timer first then i o and so onSince NodeJS still has some events that it s waiting for server connection requests the loop doesn t quitLet s say someone hits our api then the os tells NodeJS of that eventIn the next iteration tick of the grand phased loop it checks timers first finds nothing and then it checks i oIt finds that there s a request and promptly starts executing associated callbackOnce the execution of callback is finished the grand phased loop is iterated again and the queues are checked for more connection requests Now our callback isn t very easy breezy it can take a good amount of time to execute relatively speaking And that will delay the next iteration of the grand phased loop which will delay knowing if there s a new connection or not And that s one very good way of losing i o performance in NodeJS If you look at the code it s quite innocent looking nothing weird about it But one nefarious loop or thread blocking operation is all it takes A qr generator serviceThe previous example of hash calculation isn t very realistic So let s say we have to build a service which can create a qr image of any given text This service will have a simple GET api which will take text in query params After that it will return a base string representing the QR version of given text Let s use NodeJS and commonly used libraries for this service Here s how it looks in code const QRCode require qrcode const express require express const app express const port app get async req res gt const text req query text QR TEST const result await QRCode toDataURL text res send result app listen port gt console log App listening on port port Voilà We have what we needed A very simple script which does what we planned to do But here s the catch if you look at the source code of qrcode library you ll find there are no async calls It s all done in one synchronous function And now our code looks a lot like the k hashing one But how bad can it really be To answer that I setup pm for some advanced monitoring and artillery for load testing Here s how it went ┌ーCustom Metrics ー┐┌ーMetadata ー┐│Used Heap Size MiB ││App Name index ││Heap Usage ││Namespace default ││Heap Size MiB ││Version ││Event Loop Latency p ms ││Restarts ││Event Loop Latency ms ││Uptime m ││Active handles ││Script path home iostreamer projects node qr test index js ││Active requests ││Script args N A ││HTTP req min ││Interpreter node ││HTTP P Latency ms ││Interpreter args N A ││HTTP Mean Latency ms ││Exec mode fork ││││Node js version │ Summary report http codes http request rate sechttp requests http response time min max median p p Some important stats out of this exercise event loop latency p mscurrent mshttp response time min ms max ms median ms p ms p msThe response times that we are seeing a median of ms and p p of ms and ms respectively seem like a lot It s a fairly simple service it makes sense to expect better We know that we have a performance bottleneck and apparently this is how it crops up But we still don t if this is really bad or not or if we can do better or not and if so then by how much How to improve We know the bottleneck is that we only have one thread and if we block it we are doomed We need more threads for this What if we tried worker threads Introduced in node these are separate threads with their own eventloops but they share the same node and v instance unlike child processes This is what makesthem analogous to standard threads in other runtimes Well we probably can use them and it might even work but I wanted to go all in and have a much leaner solution That s why I went with Rust to get some near native performance ArchitectureThe idea is to use NodeJS for what it s known for i e brilliant i o and async performance and rust for managing threads This way we get to have best of both the worlds NodeJS has n api node api as a layer which enables FFI Foreign Function Interface Essestially it allows node to call functions running in entirely different runtime written in some other language Here are the steps involved in this new architecture for our service NodeJS will still handle the http connection aspectOn a new request it will call our rust program to create qrThis will be an async call where our rust program can be viewed like an os kernel callLike registering a callback for event except the event is that our rust program is ready with qr base string Once in rust domain we will parse and clean our input given by NodeJS processIn rust runtime we will spawn a new threadWe will create a qr for given text whereOnce done we will intimate that we have a result for the event and pass it back to NodeJS runtime Once NodeJS knows there s data for the event it will execute the registered callback with given data The result is that we have simulated qr creation as an os kernel api which epoll wait or equivalent can take care of This is huge because our NodeJS program is now about handling http requests as fast as it can without worrying about doing something heavy on its main thread Rust solutionWe are using neon to help us with creating a Rust binding for NodeJS They have pretty good docs and example for you to start tinkering with it I started with their hello world example and then used that as a template Neon creates a node compatible binary which our NodeJS program then loads as a library and runs Here s the rust code use neon prelude use image DynamicImage ImageOutputFormat Luma use base encode as bencode use qrcode QrCode use neon event Channel fn create qr text String gt Result lt String String gt let width let height if let Ok qrcode QrCode new text as bytes let qrcode image buffer qrcode render lt Luma lt u gt gt max dimensions width height build let qrcode dynamic image DynamicImage ImageLuma qrcode image buffer let mut image bytes Vec lt u gt Vec new if let Ok v qrcode dynamic image write to amp mut image bytes ImageOutputFormat Png Ok bencode image bytes else Err Error Cannot get image bytes to string else Err Error Cannot encode this text to string fn create qr and send back text String callback Root lt JsFunction gt channel Channel let result create qr text channel send move mut cx let callback callback into inner amp mut cx let this cx undefined let args match result Ok imageString gt Save the data in a result object let obj cx empty object let str cx string imageString obj set amp mut cx imageString str vec cx null upcast lt JsValue gt obj upcast Err err gt let err cx string err to string vec err upcast lt JsValue gt callback call amp mut cx this args Ok fn parse js and get qr mut cx FunctionContext gt JsResult lt JsUndefined gt The types String Root lt JsFunction gt and Channel can all be sent across threads let text cx argument lt JsString gt value amp mut cx let callback cx argument lt JsFunction gt root amp mut cx let channel cx channel Spawn a background thread to complete the execution The background execution will not block the JavaScript event loop std thread spawn move Do the heavy lifting inside the background thread create qr and send back text callback channel Ok cx undefined neon main fn main mut cx ModuleContext gt NeonResult lt gt cx export function createQR parse js and get qr Ok Here s the js code which uses it const lib require const createQR require util promisify lib createQR const express require express const app express const port app get async req res gt const text req query text QR TEST const imageString await createQR text res send imageString app listen port gt console log App listening on port port And it works If we run this code we will get our base representation of a qr code But is it any good Does this perform better than our main thread blocking version ┌ーCustom Metrics ー┐┌ーMetadata ー┐│Used Heap Size MiB ││App Name index ││Heap Usage ││Namespace default ││Heap Size MiB ││Version ││Event Loop Latency p ms ││Restarts ││Event Loop Latency ms ││Uptime s ││Active handles ││Script path home iostreamer projects node rust hello world index js ││Active requests ││Script args N A ││HTTP req min ││Interpreter node ││HTTP P Latency ms ││Interpreter args N A ││HTTP Mean Latency ms ││Exec mode fork ││││Node js version │ Summary report http codes http request rate sechttp requests http response time min max median p p Important stats event loop latency p mscurrent mshttp response time min ms max ms median ms p ms p ms ComparisonHTTP performance Latency in msEventloop performance Latency in ms ConclusionWe see a tremendous performance increase especially in p and p cases We successfully modified our app such that not only is it faster on average but the users facing hiccups aren t far by a huge margin This x increase in performance tells a lot about where node shines and where it shouldn t be used This ability to create native addons has huge implications for JS projects Imagine you have your entire stack in typescript and all the engineers well versed with TS JS ecosystem but you finally hit the limit Now you can rewrite and retrain or you can simply create a fast low surface area library which anyone can plug and play as easily as downloading it from npm All in all it s looking good for NodeJS with projects like neon and languages like Rust Given that NodeJS democratized server side development it has been fascinating to see how the pitfalls have been plugged over the years We now have typescript to instill confidence and now wasm and ffi backed by reliable safe and blazing fast languages It s fair to say NodeJS now has almost everything for everyone 2022-04-09 20:08:18
海外TECH DEV Community Release 0.23.0 of Spellcheck (GitHub) Action - feature release enabling French https://dev.to/jonasbn/release-0230-of-spellcheck-github-action-feature-release-enabling-french-2df Release of Spellcheck GitHub Action feature release enabling FrenchHourra nous avons une nouvelle versionI am happy to announce that the Spellcheck GitHub Action now supports French in addition to SpanishGermanAnd EnglishYou can specify the language by setting lang like so lang frFor French in your configuration matrix name Markdown aspell lang fr dictionary wordlists wordlist txt encoding utf pipeline pyspelling filters markdown pyspelling filters html comments false ignores code pre sources README md default encoding utf In addition the Docker base images have been updated from used in and to That is all If you experience any issues please report them via GitHub thanks to gcattan for the request I am working on a bug fix release not related to any of the recent releases but a general issue with how GitHub Actions pass parameters to a Docker image and how these are parsed I have been doing some investigation but have not come to a conclusion on how to handle this where backwards compatibility can be honored more information will follow or you can follow along via issue thanks to Mike Starov xsaero for reporting the issue At the same time I have started to look into a sunset strategy for some of the older releases and their respective Docker images initial notes currently in the Wiki I plan to sunset release which is almost a year old I have only been able to locate one user of this old release to whom I have submitted a PR with an update My plan for now is to hold on to older releases for at least days Which mean that release will require some more work since there are several users of this older release I plan to start using GitHub discussions to announce well announcements related to releases sunsets etc Change log for feature release update not requiredSupport for the French language Support requested by gcattan via issue Docker image updated to Python slim via PR from dependabot Release notes for Python Docker image updated to Python slim via PR from dependabot Release notes for Python 2022-04-09 20:05:17
海外TECH DEV Community All you need to know about object destructuring https://dev.to/rahulmandyal/javascript-object-destructuring-all-you-need-to-know-about-object-destructuring-5ca3 All you need to know about object destructuringAs we all know javascript es version had came with a lot of feature and it made javascript slightly better Object destructring also came with the es version it somehow also made our job easier Before es version when we want to assign object properties into a variable we typically do it like this let user firstname Rahul lastname thakur email example gmail com let userName user name let userAge user age But now object destructuring provides us better syntax that can help us to reduce our code and also provide an alternative way to assign properties of an object to a variable let name username age userage user the syntax is let property variablename property variablename object Make your code more shorter If your variable have the same name as the properties of the object then we can make our code more shorterlet name age user this is equivalent to the previous one now instead of writing two two lines of code we can do it within one line of code undefined values Suppose you are trying to assign a property that does not exits in the object then then variable is set to undefined for example Here in this example phone lastname email is not present inside the user object so those variable which are not present inside the obejct are initialized with the undefiend value Setting default values we can assign a default value to the variable if the property does not exits inside the the object then instead of undefined the variable is initialized with the default value for example Summary Object destructuring just making our job easier It provides us better syntax to store object properties value inside variables with in one line of code 2022-04-09 20:04:40
海外TECH DEV Community An Intro to Version Control https://dev.to/arsalakhan/an-intro-to-version-control-2hk3 An Intro to Version Control What is a Version Control System VCS A VCS tracks the history of changes as people and teams collaborate on projects together As the project evolves teams can run tests fix bugs and contribute new code with the confidence that they can recover any version Developers can review the project s history to find out What changes were madeWho made the changesWhen were the changes madeWhy were changes needed CollaborationA VCS allows multiple people to work on the same set of files in structured harmony Messaging your teammates about which file you re changing and telling them to keep their fingers off is not the optimal workflow Neither is storing zip snapshots of your code on a shared online drive With a VCS team members can work on any project file on their local version and merge their changes into a shared version The latest version of a file or the whole project is always in a shared location managed by the VCS Storing VersionsSaving a version of your project after making changes is an essential habit But without a VCS this becomes tedious and confusing very quickly How much do we save Only the changed files or the complete project How do we name these versions If you re a very organized person you might be able to stick to a coherent naming system How can we know exactly what files changed in these versions It is problematic to expect humans to carefully document each change consistently A version control system acknowledges that there is only one project Therefore there s only one version on your disk that you re currently working on All the past versions and variants of your project are available through the VCS Restoring Previous VersionsBeing able to restore older versions of a file or the whole project means you can t mess up If the changes you make prove to be garbage you can undo them with a few commands Knowing this should make you more relaxed when working on a project Understanding What HappenedEvery time you save a new version of your project your VCS requires you to briefly describe what was changed to help you understand how your project evolved between versions You can see also see what file contents were changed BackupA distributed VCS like Git can also act as a backup Every team member has a repository of the project on their disk with its entire version history All you need to recover your entire project is one copy of the git repository What is Distributed Version control SystemA distributed version control system DVCS is a type of version control where the complete codebase ーincluding its full version history ーis mirrored on every developer s computer Which VCS Which VCS do we use in practice At Grey Software we use Git like the overwhelmingly vast majority of software development companies Next up Git 2022-04-09 20:02:19
海外TECH DEV Community 3.0 Alpha #1: Transforming to Supabase https://dev.to/beamazedvariable/30-alpha-1-transforming-to-supabase-32bp Alpha Transforming to SupabaseHere is my update on my way working to finish the alpha version of the Telescope mobile app Looking at the docSupabase is amazing in doc I have developed a good habit of taking a look at the doc before searching for any tutorial And the doc provide details how we can start using Supabase with different framework and some of them are very popular such as React Angular etc The doc show you how to use supabase for authentication which is a classic popular use case when it come to mind when talking about integrate a server into your project Mine use case this time is much more simpler which is to contain all the quotes from student quotes js so as we can share and avoid duplicate information between our wep app and our mobile app Start working on the projectSince my use case is much more simpler I might not need to have to use all of the configuration option when creating the Supabase client This is when blogging become amazing During of the meeting our prof always try to press how important writing blog and be able to reach out with other developers When working on the issue I come a across a wonderful article where he tackle all the basic incompatible between react native and supabase Blog about it After reading such an amazing article This sentence from my prof keep running through in my mind Your struggle might become a treasure for whoever come after and be able to read about it So here are some highlighted issues that I have been able to tackle Working with env for the very first timeYes this is my first time ever working with the env file and it also a best practice I learn from the telescope web team Before I did read some guides on how to run Telescope but did not bother dig into it and see what is actually in those files untill I have to do it myself Like I said after creating a habit of reading docs I feel more pleasant to spend time with it than a feel short stackoverflow answer which not gonna last in my mind more than a day after the problem has been solved After reading the expo doc on how to work with environment variables with expo I have no hard time implemented it but then it coming to another problem where I would not be able to connect to the client Trouble connecting the supabase client in local developmentFor this matter I have been able to reach out the Kelvin through Linkedin to see if he have experienced the same thing but it seem he not be able to spot it out Then after talking with peoples of the supasbase upstream to see if they have some idea on how I would be able to solve the problem but there is no luck Then it come to my final option to search for stackoverflow and Duke had sent me a link as he know I was having problem with connecting to supabase The answer pointing out localhost mean is not pointing to the real machine when interpreted through mobile device so in local development we will change localhost to and finally I had be able to connect to the supabase client My PR 2022-04-09 20:01:45
Apple AppleInsider - Frontpage News Fans slam Apple TV+ 'Friday Night Baseball' stream outages, commentary team https://appleinsider.com/articles/22/04/09/fans-slam-apple-tv-friday-night-baseball-stream-outages-commentary-team?utm_medium=rss Fans slam Apple TV x Friday Night Baseball x stream outages commentary teamThe first broadcast of Apple TV s Friday Night Baseball wasn t smooth sailing with fans encountering teething issues with the sports stream on its first outing The initial streams of Friday Night Baseball on Apple TV took place on Friday with the New York Mets taking on the Washington Nationals and the Houston Astros versus the Los Angeles Angels However fans are complaining on Twitter that the inaugural event was subpar Complaints covered a number of areas of the broadcast with arguably the biggest being connectivity Some fans tuning in to watch the games couldn t start watching the stream or had it interrupted Read more 2022-04-09 20:34:59
海外TECH Engadget Google Fi cuts plan pricing, adds more high-speed data https://www.engadget.com/google-fi-unlimited-plan-pricing-201955454.html?src=rss Google Fi cuts plan pricing adds more high speed dataGoogle Fi is making its unlimited data plans more affordable In an email the MVNO sent to Engadget it shared it was reducing the monthly cost of its Simply Unlimited and Unlimited Plus plans by up to and respectively with the former starting at per month for one line and the latter at every days Moreover both plans now come with additional high speed data With a Simply Unlimited package you can use up to GB of data up from GB previously before Google will begin throttling your connection As an Unlimited Plus customer meanwhile the high speed cap is now at GB Simply Unlimited subscribers can also look forward to having up to GB per month for hotspot tethering That s a feature that was previously limited to the more expensive Plus plan Lastly all Fi customers including those on the MVNO s Flexible plan can look forward to complimentary calling within Canada and Mexico Previously it was only possible to make calls to nbsp Canada and Mexico while still in the US for free With the price cut and feature tweaks Google s Simply Unlimited plan compares favorably with entry level unlimited plans from other carriers For instance T Mobile s Essentials package starts at per month for one line and comes with GB of high speed data and unlimited G data when tethering devices to your phone but you re limited to p when streaming videos 2022-04-09 20:19:55
ニュース @日本経済新聞 電子版 学生支援機構の奨学金制度 世帯年収で選択肢に違い https://t.co/yjF2Yobyoc https://twitter.com/nikkei/statuses/1512890996069072900 世帯年収 2022-04-09 20:31:36
ニュース @日本経済新聞 電子版 豊洲・晴海で計画 「幻の東京万博」とは https://t.co/g48DBZU23m https://twitter.com/nikkei/statuses/1512888764074381315 豊洲 2022-04-09 20:22:44
ニュース @日本経済新聞 電子版 英、ウクライナ追加支援へ ジョンソン首相がキーウ訪問 https://t.co/goPLTLJ4wJ https://twitter.com/nikkei/statuses/1512887631390318592 追加支援 2022-04-09 20:18:14
ニュース @日本経済新聞 電子版 なぜ心に鬼が宿るのか 小松和彦さん https://t.co/n7htnoLqMx https://twitter.com/nikkei/statuses/1512884471070355457 小松和彦 2022-04-09 20:05:40
ニュース BBC News - Home Imran Khan ousted as Pakistan's PM after key vote https://www.bbc.co.uk/news/world-asia-61055210?at_medium=RSS&at_campaign=KARANGA confidence 2022-04-09 20:25:33
ニュース BBC News - Home Southampton 0-6 Chelsea: Saints blown away by devastating Blues display https://www.bbc.co.uk/sport/football/60963798?at_medium=RSS&at_campaign=KARANGA Southampton Chelsea Saints blown away by devastating Blues displayChelsea put a terrible week behind them to return to winning ways in devastating style as they score four times in the opening minutes against Southampton 2022-04-09 20:27:49
ビジネス ダイヤモンド・オンライン - 新着記事 漫画『キングダム』作者が夢見る理想の「最後」とは?生原稿と共に語る裏側 - 漫画「キングダム」にビジネスパーソンが夢中になる理由 https://diamond.jp/articles/-/301074 入山章栄 2022-04-10 05:25:00
ビジネス ダイヤモンド・オンライン - 新着記事 JR東海・東西、京王、東急…「コロナ大減収」から回復できない鉄道業界の深刻 - ダイヤモンド 決算報 https://diamond.jp/articles/-/301314 2022-04-10 05:20:00
ビジネス ダイヤモンド・オンライン - 新着記事 ビル・ゲイツが「手書きでメモ」を取る理由、IT王の脱パソコン思考法 - 「超一流」の流儀 https://diamond.jp/articles/-/301336 打ち合わせ 2022-04-10 05:15:00
ビジネス ダイヤモンド・オンライン - 新着記事 持病の悪化で無収入!48歳共働き夫婦の老後・子どもの教育費は大丈夫? - お金持ちになれる人、貧乏になる人の家計簿 深野康彦 https://diamond.jp/articles/-/301309 共働き夫婦 2022-04-10 05:05:00
北海道 北海道新聞 パキスタン下院が首相に不信任 即時失職 https://www.hokkaido-np.co.jp/article/667763/ 失職 2022-04-10 05:19:00
北海道 北海道新聞 ロシア、子ども12万人連れ去り ウクライナが主張 https://www.hokkaido-np.co.jp/article/667762/ 最高会議 2022-04-10 05:19:00

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)