投稿時間:2021-04-20 23:42:18 RSSフィード2021-04-20 23:00 分まとめ(67件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWS Compute Blog Modelling workflow input and output path processing with data flow simulator https://aws.amazon.com/blogs/compute/modeling-workflow-input-output-path-processing-with-data-flow-simulator/ Modelling workflow input and output path processing with data flow simulatorAWS Step Functions recently introduced a new data flow simulator to model input and output path processing This new feature makes it easier to evaluate JSON based input and output data as it passes through a state helping to build workflows faster Developers build Step Functions workflows to orchestrate multiple services into business critical applications with minimal … 2021-04-20 13:11:28
python Pythonタグが付けられた新着投稿 - Qiita 時系列性を持つデータに対するLightGBM予測モデルをhyperoptでパラメータチューニングした:結果の再現とn_estimatorsを整数型にするのにハマった件 https://qiita.com/shincomcom/items/e54d94867c01ea693d2f ここで、nestimatorsのように整数型で渡さないといけないものについては、argsnestimatorsintargsnestimators…のようにします。 2021-04-20 22:43:16
python Pythonタグが付けられた新着投稿 - Qiita プログラミング初心者が3ヶ月間Aidemyを受講してみた。 https://qiita.com/tkcnnm/items/d1808efae9a31825f15b 円周率算出のためにプロットした点を散布図にして表示します。 2021-04-20 22:03:32
js JavaScriptタグが付けられた新着投稿 - Qiita Chrome拡張 初級チュートリアル https://qiita.com/sy250f/items/07e887624ce32b1b0b05 マニフェストファイルのcontentscriptsに特定のページで動作する為のマッチパターンと、マッチした時に動作させるJavaScriptファイルを指定します。 2021-04-20 22:44:56
js JavaScriptタグが付けられた新着投稿 - Qiita Javascript 100 40 配列 復習 https://qiita.com/Hoshi10Lighthouse/items/046d95a33ff28521624b Javascript配列復習配列dataからとの値を取り出し、つの値を合算し表示するプログラムを作成。 2021-04-20 22:06:54
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) PHPの変数(配列)の値を、JavaScriptで操作したい https://teratail.com/questions/334300?rss=all PHPの変数配列の値を、JavaScriptで操作したい※既存のソースを特急で改修しなければならないため、「そもそもそんなことをやろうとしているのがおかしい」といったご指摘はご容赦ください。 2021-04-20 22:58:53
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) チェックボックスにチェックをしたらコンテンツ表示させたい https://teratail.com/questions/334299?rss=all 2021-04-20 22:50:36
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) windowsでキーボードのピアノのアプリを作りたい https://teratail.com/questions/334298?rss=all windowsでキーボードのピアノのアプリを作りたいプログラムの勉強を始めた初心者です。 2021-04-20 22:46:56
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) CSSを用いた画像配置について https://teratail.com/questions/334297?rss=all CSSを用いた画像配置について問題点Djangoを使用し、ホームページの作成を行っています。 2021-04-20 22:43:47
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) お問い合わせフォームから届く内容を変えたい https://teratail.com/questions/334296?rss=all お問い合わせフォームから届く内容を変えたい前提・実現したいこと問い合わせフォームから届く内容を変更したい発生している問題・エラーメッセージ作成した問い合わせフォームcebdcbbfcfbfjpegこちらの画像がメールに届く内容以下の順番でメッセージが届くようにしたい。 2021-04-20 22:40:39
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) numpy配列から複数条件で値を検索し、指定のデータ数を抜き出して新しい行列を生成する https://teratail.com/questions/334295?rss=all numpy配列から複数条件で値を検索し、指定のデータ数を抜き出して新しい行列を生成する画像にあるような列のnumpy配列の中からとが連続して続く箇所を検索し、その次から個分のデータを抜き出して別の変数に格納する方法を教えていただきたいです。 2021-04-20 22:25:34
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) ユーザーの編集機能、更新できない(Ruby on Rails) https://teratail.com/questions/334294?rss=all ユーザーの編集機能、更新できないRubyonRails前提・実現したいことrubynbsponnbsprailsnbspを使用して、レシピ共有アプリを作成中です今回は、ユーザー情報の編集ができないので、お力をいただければ幸いです。 2021-04-20 22:25:09
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) エラーの見方がわかりません。 https://teratail.com/questions/334293?rss=all エラーの見方がわかりません。 2021-04-20 22:20:43
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) $ rails db:create RAILS_ENV=production  でエラー発生 https://teratail.com/questions/334292?rss=all railsdbcreateRAILSENVproductionでエラー発生やろうとしている事RubynbsponnbspRailsで作ったアプリをAWSでデプロイする過程で、DBはMySQLで、つのEC上にアプリと一緒にDBを作ろうとしています。 2021-04-20 22:18:55
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 【AWS】VMwareからEC2に移行後の拡張 https://teratail.com/questions/334291?rss=all 【AWS】VMwareからECに移行後の拡張AWSのvmimport機能を使い、VMware仮想マシンvmdkファイルをECに移行しました。 2021-04-20 22:16:26
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 急に502 Bad Gatewayと表記されるようになりました https://teratail.com/questions/334290?rss=all badgateway 2021-04-20 22:08:10
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 地域検索から該当企業の所在地を地図で表示させてるページがあるのですが、一部ページで同じ企業が2件表示されてしまいます。 https://teratail.com/questions/334289?rss=all 地域検索から該当企業の所在地を地図で表示させてるページがあるのですが、一部ページで同じ企業が件表示されてしまいます。 2021-04-20 22:02:14
Ruby Rubyタグが付けられた新着投稿 - Qiita Railsのtryメソッドは何をしている? https://qiita.com/supercell1023koeda/items/0688182bb5204085b69c tryメソッドの使い方と、使用することのメリット対象のオブジェクトがnilの場合、処理を実行しないため、エラーになるのを防ぐことができる。 2021-04-20 22:12:31
Ruby Rubyタグが付けられた新着投稿 - Qiita Linebot作ってたらセキュリティのお話が出てきた https://qiita.com/ta-iga/items/a17f160f5c9cd0878dfa DNSリバインディング攻撃DNSリバイディング攻撃はサイバー攻撃の一種であり、ドメイン名に対応するIPアドレスを短時間で変更し、罠サイトに仕掛けたJavascriptから攻撃対象サイトに対して悪さをするものRailsではDNSリバインディング攻撃の対策のため、localhostなどの指定されたホスト名以外でローカル環境にアクセスできないようになっている。 2021-04-20 22:07:10
Linux Ubuntuタグが付けられた新着投稿 - Qiita WSL2のUbuntuでphpcsを使う(VSCode) https://qiita.com/rowpure/items/fcf84ae42d8e5ed81ad1 WSLのUbuntuでphpcsを使うVSCodeはじめにDockerについて、WSLに移行するまでは、WindowsにPHP、Composerをインストールし、VSCodeとコード静的解析のphpcsを連携させて開発していましたが、移行後にphpcsの恩恵が受けられなくなりましたnotfoundとVSCodeに怒られる…怒られるのはツラいので、WSLで利用するUbuntuディストリビューションにphpcsを設定し、そちらをVSCodeで読み込むようにしますバージョンWindowsProHVSCodeUbuntuLTS前提DockerでWSLに移行が済んでいること拡張機能インストール手順中盤までは、ほぼこちらの記事と同様です。 2021-04-20 22:29:58
AWS AWSタグが付けられた新着投稿 - Qiita 【AWS】クラウドを理解する https://qiita.com/mzmz__02/items/a55e9e2e3175c9f485fa メリット自社でハードウェアを自由にコントロールできる。 2021-04-20 22:47:44
AWS AWSタグが付けられた新着投稿 - Qiita AWSとJavaで、できるだけシンプルにtwitter botを作る https://qiita.com/NoOne/items/5589c099f7829382ae9d 関数名はhandleRequestというLambdaのデフォルト関数名にしていますが名前は何でもOKです。 2021-04-20 22:37:59
Linux CentOSタグが付けられた新着投稿 - Qiita WSL2でCentOSを使う https://qiita.com/honahuku/items/a5832d9e5a935b8b19b2 WSLでCentOSを使うこの記事ではWSLを有効化し、CentOSstreamをインストールします。 2021-04-20 22:57:03
Ruby Railsタグが付けられた新着投稿 - Qiita Railsのtryメソッドは何をしている? https://qiita.com/supercell1023koeda/items/0688182bb5204085b69c tryメソッドの使い方と、使用することのメリット対象のオブジェクトがnilの場合、処理を実行しないため、エラーになるのを防ぐことができる。 2021-04-20 22:12:31
Ruby Railsタグが付けられた新着投稿 - Qiita Linebot作ってたらセキュリティのお話が出てきた https://qiita.com/ta-iga/items/a17f160f5c9cd0878dfa DNSリバインディング攻撃DNSリバイディング攻撃はサイバー攻撃の一種であり、ドメイン名に対応するIPアドレスを短時間で変更し、罠サイトに仕掛けたJavascriptから攻撃対象サイトに対して悪さをするものRailsではDNSリバインディング攻撃の対策のため、localhostなどの指定されたホスト名以外でローカル環境にアクセスできないようになっている。 2021-04-20 22:07:10
海外TECH Ars Technica HTC’s wireless Vive Air headset outed by a premature award https://arstechnica.com/?p=1758262 awardall 2021-04-20 13:37:12
海外TECH DEV Community Tokenization and Sequencing in TensorFlow https://dev.to/balapriya/tokenization-and-sequencing-in-tensorflow-3p0n Tokenization and Sequencing in TensorFlowIn this blog post we shall seek to learn how to implement tokenization and sequencing important text pre processing steps in Tensorflow OutlineIntroduction to TokenizerUnderstanding Sequencing Introduction to TokenizerTokenization is the process of splitting the text into smaller units such as sentences words or subwords In this section we shall see how we can pre process the text corpus by tokenizing text into words in TensorFlow We shall use the Keras API with TensorFlow backend The code snippet below shows the necessary imports import tensorflow as tffrom tensorflow import kerasfrom tensorflow keras preprocessing text import TokenizerAnd voila we have all modules imported Let s initialize a list of sentences that we shall tokenize sentences Life is so beautiful Hope keeps us going Let us celebrate life The next step is to instantiate the Tokenizer and call the fit on texts method tokenizer Tokenizer tokenizer fit on texts sentences Well when the text corpus is very large we can specify an additional num words argument to get the most frequent words For example if we d like to get the most frequent words in the corpus then tokenizer Tokenizer num words does just that To know how these tokens have been created and the indices assigned to words we can use the word index attribute word index tokenizer word indexprint word index Here s the output life us is so beautiful hope keeps going let celebrate Well so far so good But what happens when the test data contains words that we ve not accounted for in the vocabulary test data Our life is to celebrate Hoping for the best Let peace prevail everywhere We have introduced sentences in test data which contain words that are not in our earlier vocabulary How do we account for such words which are not in vocabulary We can define an argument oov token to account for such Out Of Vocabulary OOV tokens tokenizer Tokenizer oov token lt OOV gt The word index now returns the following output lt OOV gt life us is so beautiful hope keeps going let celebrate Understanding SequencingIn this section we shall build on the tokenized text using these generated tokens to convert the text into a sequence We can get a sequence by calling the texts to sequences method sequences tokenizer texts to sequences sentences Here s the output Let s now take a step back What happens when the sentences are of different lengths Then we will have to convert all of them to the same length We shall import pad sequences function to pad our sequences and look at the padded sequences from tensorflow keras preprocessing sequence import pad sequencespadded pad sequences sequences print nPadded Sequences print padded OutputPadded Sequences By default the length of the padded sequence length of the longest sentence However we can limit the maximum length by explicitly setting the maxlen argument padded pad sequences sequences maxlen print nPadded Sequences print padded OutputPadded Sequences Now let s pad our test sequences after converting them to sequences test seq tokenizer texts to sequences test data print nTest Sequence test seq padded pad sequences test seq maxlen print nPadded Test Sequence print padded And here s our output Output Test Sequence Padded Test Sequence We see that all the padded sequences are of length maxlen and are padded with s at the beginning What if we would like to add trailing zeros instead of at the beginning We only need to specify padding post padded pad sequences test seq maxlen padding post print nPadded Test Sequence print padded OutputPadded Test Sequence So far none of the sentences have length exceeding maxlen but in practice we may have sentences that are much longer than maxlen In that case we have to truncate the sentences and can set the argument truncating post or pre to drop the first few or the last few words that exceed the specified maxlen Happy learning and coding ‍ ReferenceNatural Language Processing in TensorFlow 2021-04-20 13:50:16
海外TECH DEV Community Simple User Selection Color HTML & CSS https://dev.to/nikhil27b/simple-user-selection-color-html-css-145 Simple User Selection Color HTML amp CSSHello Today I choose a very simple topic to how to change a user selection color The selection is a CSS pseudo element that applies styles to the part of a document or text highlighted by the user selection color fff background ff As an above example you can change different colors and it s very useful I hope you like this also comments about your thoughts For more content follow me on Instagram developer nikhil If you want to more support me then buy me a coffee Thank you 2021-04-20 13:47:18
海外TECH DEV Community How to publish TypeScript package to NPM https://dev.to/loonywizard/how-to-publish-typescript-package-to-npm-2k54 How to publish TypeScript package to NPMIn this article I m going to cover a process of publishing TypeScript package with external dependencies to NPM Write some codeThe package we re going to publish is React js custom hook for throttling values react use throttle I ve already written article about developing this hook and now we re going to publish it to NPMFirst things first we need to write code for the package I ve put my code to src index ts file tsconfig jsonIn order to develop with TypeScript we need to add tsconfig to our repository My config looks like this include src compilerOptions strict true declaration true generates declaration files esModuleInterop true To learn more about different options please look at TSConfig Reference Set up RollupRollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex such as a library or applicationRollup allows developers easily compile code into different JavaScript module systems such as ESModules UMD AMD or CommonJS There s a great article covering major differences between themThis is my rollup config js file it exports an array of objects where each object defines how Rollup should build our code in specified format Here we re building code for ES and UMD modules because there re most common nowadays Each bundle has TypeScript and Babel plugins and UMD bundle also has terser plugin for code minificationimport typescript from rollup plugin typescript import babel from rollup plugin babel import terser from rollup plugin terser export default ES Modules input src useThrottle ts output file dist index es js format es plugins typescript babel extensions ts UMD input src useThrottle ts output file dist index umd min js format umd name reactUseThrottle indent false plugins typescript babel extensions ts exclude node modules terser To learn more about Rollup configuration please look at Rollup quick start guide Build code and publish package to NPMWe need to specify the following fields in package json file name react use throttle version main dist index umd min js module dist index es js types dist useThrottle d ts files dist name and version together identify package completely uniquemain is the primary entry point to our packagemodule is the entry point for ESModulestypes is the entry point for TypeScript type declarationsfiles is an array of patterns that describes the entries to be included when your package is installed as a dependencyLearn more about different fields in package json file Package json docsAlso we need to specify react as peerDependency because it will not be added to final build peerDependencies react To build code with rollup we need to run the following command rollup cIt will build our package based on rules we defined in rollup config js Code will be generated to dist folderNow we re ready to publish our package to do this we need to run the following commands npm login this will ask you for your NPM login and passwordnpm publishPackage was successfully published to NPM Linksreact use throttle package on NPMGitHub repoCodeSandbox demoArticle about developing useThrottle hookMy personal website 2021-04-20 13:33:39
海外TECH DEV Community 200+ JS Resources to master programming 💥 Cheat Sheet https://dev.to/devlorenzo/200-js-resources-to-master-programming-3aj6 JS Resources to master programming Cheat SheetHello World I felt bored after completing the Ultimate Cheat Sheet Compilation so I just decided to create another one The most complete javascript cheat sheet and resource compilation you can find online Waaait don t leave this page without bookmarking it Giveaway We are giving away any course you need on Udemy Any price any course Steps to enter the giveaway gt React to this post gt Subscribe to our Newsletter lt Very importantPS It took me around hours to complete the article So please remember the like ️ and super like Let s reach the top of the month this time Table of content My cheat SheetProjects ideas to become a javascript master Other resourcesComplete Javascript cheat sheetsJS promisesJS ArraysJS loopsPreprocessorCoffeScriptEJSBabelJS Frameworks amp LibrariesAngularVueReactJQueryOthersNodeOther resourcesRemember the like ️and maybe super like For beginners What is JS Javascript JavaScript is a scripting or programming language that allows you to implement complex features on web pages ーevery time a web page does more than just sit there and display static information for you to look at ーdisplaying timely content updates interactive maps animated D D graphics scrolling video jukeboxes etc ーyou can bet that JavaScript is probably involved It is the third layer of the layer cake of standard web technologies MDN What it used for To put things simply JavaScript is an object orient programming language designed to make web development easier and more attractive In most cases JavaScript is used to create responsive interactive elements for web pages enhancing the user experience Things like menus animations video players interactive maps and even simple in browser games can be created quickly and easily with JavaScript JavaScript is one of the most popular programming languages in the world BitDegree What Is JavaScript Used For And Why You Should Learn It Hello World In Javascript alert Hello World ーOutput data in an alert box in the browser windowconfirm Hello World ーOpens up a yes no dialog and returns true false depending on user clickconsole log Hello World ーWrites information to the browser console good for debugging purposesdocument write Hello World ーWrite directly to the HTML documentprompt Remember the like ーCreates a dialogue for user input Resources to learn it Mozilla s JavaScript GuideJavaScript track on Codecademy Interactive tutorials for beginners JavaScript for Cats by Max OgdenEloquent JavaScript by Marijn HaverbekeWikibooks JavaScript bookJavaScript Lectures by Douglas CrockfordYou Don t Know JS Possibly the best book written on modern JavaScript completely readable online for free or can be bought to support the author braziljs js the right way An easy to read quick reference for JS best practices accepted coding standards and links around the Web JSbooks Directory of free JavaScript ebooks Superhero js A collection of resources about creating testing and maintaining a large JavaScript code base SJSJ Simplified JavaScript Jargon is a community driven attempt at explaining the loads of buzzwords making the current JavaScript ecosystem in a few simple words How to Write an Open Source JavaScript Library A comprehensive guide through a set of steps to publish a JavaScript open source library JavaScript Tutorials Learn Javascript online from a diverse range of user ranked online tutorials Functional Light JavaScript Pragmatic balanced FP in JavaScript Clean Code JavaScript Clean Code concepts adapted for JavaScript List at GitHub Awesome Javascript By Alexandru Gherasim At Reddit What Things Should a Serious Javascript Developer Know Right Now Scope If you don t understand this intimately then you aren t that serious about this language This is the number one point intentionally and I cannot stress it enough Architecture You don t have to be a master software architect but if you cannot perform some basic planning and put pieces together without massive layers of tooling you are an imposter Expecting frameworks and other tools to simply do it for you isn t very impressive DOM It is very common to see developers hiding from the DOM by layers of abstractions and other stupid crap querySelectors are great but are also x slower than the standard DOM methods That isn t trivial These methods are super simple so there is no valid excuse for developers fumbling over this or hiding in fear Node js If you are a serious developer should have a pretty solid grasp of how to walk the file system You should understand how to conveniently read files as text or less conveniently read files as bit for bit binary buffers Timing and asynchronous operations Events timers network requests are all asynchronous and separate from each other and exist both in Node and in the browser You have to be able to understand how to work with callbacks or promises Accessibility The interactions imposed by JavaScript can present accessibility barriers A serious JavaScript developer is already familiar with WCAG and knows how to work within its recommendations or when to push back on violating business requirements Security You need to have at least a basic understanding of security violations security controls and privacy You don t need to be a CISSP but you need to be able to supply recommendations and avoid obvious failures If you cannot get this right in the most basic sense you aren t a serious developer Data structures You need to understand how to organize data in a way that allows the fastest possible execution without compromising maintenance This is something that is learned through academic study and repeated experience writing applications Presentation and semantics You really need to have a basic understanding how to properly organize the content your users will consume and how to present in a consumable way efficiently This is something almost completely learned from experience only You might think CSS and HTML are simple skills that can be picked up when needed but you would be absolutely wrong Knowing when to avoid the bullshit Many developers lack the years of experience to be confident in their performance so some of these developers will try to fake it Don t be an imposter because everybody will see straight through it Hoping mountains of abstractions tooling frameworks compilers and other bullshit will save you just bogs down your application and screws over your teammates If you aren t confident then be honest about that and seek mentorship or get involved with open source software outside of work Source JS Cheat Sheet gt Download the PDF Version of this Cheat Sheet here Include Javascript lt script type text javascript gt lt script gt or Include it in an external file this is a comment This is also another way you can insert comments Multiline normally lt script src myscript js gt lt script gt lt code gt lt code gt PS Remember to sub to our newsletter for the Giveaway Variables var myVariable this can be a string or number var is globally definedlet myVariable this can be a string or number let is block scopedconst myVariable this can be a string or number const is block scoped and can t be reassignedVariables in the block scope which means those variables exist only within the corresponding blockJavaScript Variables wschools JS Finally discover how to Hide and Show elements DevLorenzo・Feb ・ min read javascript tutorial webdev codequality Data Types stringvar string ASCII text intvar integer floatvar float boolean can be true or falsevar t true var f false undefinedvar undef defaults to undefinedvar undef undefined not common use null nullvar nul null arrayvar arr Hello my name is Dr Hippo null objectvar person name John Smith age functionvar fun function return Source Datatypes In JavaScript c sharpcorner com OperatorsBasic Operators ーAddition ーSubtraction ーMultiplication ーDivision ーGrouping operator operations within brackets are executed earlier than those outside ーModulus remainder ーIncrement numbers ーDecrement numbers JS The useful trick that allows you to change text on hover DevLorenzo・Feb ・ min read html javascript webdev tutorial Comparison Operators Equal to Equal value and equal type Not equal Not equal value or not equal type gt Greater than lt Less than gt Greater than or equal to lt Less than or equal to Ternary operatorLogical Operators amp amp Logical and Logical or Logical notBitwise Operators amp AND statement OR statement NOT XOR lt lt Left shift gt gt Right shift gt gt gt Zero fill right shift Loopsfor loops through a block of code a number of times for statement statement statement Coooode for in loops through the properties of an object for of loops through the values of an iterable object while loops through a block of code while a specified condition is true var i while i lt console log i i Break and ContinueWhen you use break without a label it terminates the innermost enclosing while do while for or switch immediately and transfers control to the following statement When you use break with a label it terminates the specified labeled statement When you use continue without a label it terminates the current iteration of the innermost enclosing while do while or for statement and continues execution of the loop with the next iteration In contrast to the break statement continue does not terminate the execution of the loop entirely In a while loop it jumps back to the condition In a for loop it jumps to the increment expression When you use continue with a label it applies to the looping statement identified with that label Source Loops and iteration MDN JS Make things happen OnScroll and create better interactive websites DevLorenzo・Feb ・ min read javascript tutorial webdev codequality Stringsdev to Article JavaScript string methods you should know by frugencefidel Escape characters ーSingle quote ーDouble quote ーBackslash b ーBackspace f ーForm feed n ーNew line r ーCarriage return t ーHorizontal tabulator v ーVertical tabulator Array and array methodsTop JavaScript Array Methods You Should Know By Rachel Cole at morioh comconcat arr Joins two or more arrays and returns a copy of the joined arrayscopyWithin target start end Copies array elements within the array to and from specified positionsentries Returns a key value pair Array Iteration Objectevery function currentval index arr thisVal Checks if every element in an array pass a testfill val start end Fill the elements in an array with a static valuefilter function currentval index arr thisVal Creates a new array with every element in an array that pass a testfind function currentval index arr thisVal Returns the value of the first element in an array that pass a testfindIndex function currentval index arr thisVal Returns the index of the first element in an array that pass a testforEach function currentval index arr thisVal Calls a function for each array elementfrom obj mapFunc thisVal Creates an array from an objectincludes element start Check if an array contains the specified elementindexOf element start Search the array for an element and returns its positionisArray obj Checks whether an object is an arrayjoin seperator Joins all elements of an array into a stringkeys Returns a Array Iteration Object containing the keys of the original arraylastIndexOf element start Search the array for an element starting at the end and returns its positionmap function currentval index arr thisVal Creates a new array with the result of calling a function for each array elementpop Removes the last element of an array and returns that elementpush item Adds new elements to the end of an array and returns the new lengthreduce function total currentval index arr initVal Reduce the values of an array to a single value going left to right reduceRight function total currentval index arr initVal Reduce the values of an array to a single value going right to left reverse Reverses the order of the elements in an arrayshift Removes the first element of an array and returns that elementslice start end Selects a part of an array and returns the new arraysome function currentval index arr thisVal Checks if any of the elements in an array pass a testsort compareFunc Sorts the elements of an arraysplice index quantity item Adds Removes elements from an arraytoString Converts an array to a string and returns the resultunshift item Adds new elements to the beginning of an array and returns the new lengthvalueOf Returns the primitive value of an array FunctionsSyntaxfunction name parameter parameter parameter code to be executed Examplesfunction myFunction p p return p p The function returns the product of p and p let x myFunction Function is called return value will end up in xfunction myFunction a b return a b Function returns the product of a and b Convert Fahrenheit to Celsius function toCelsius fahrenheit return fahrenheit document getElementById demo innerHTML toCelsius Source JavaScript Functions wschools MathsMethods Finally How to understand math Awesome resource list DevLorenzo・Mar ・ min read productivity webdev beginners javascript PropertiesE ーEuler s numberLN ーThe natural logarithm of LN ーNatural logarithm of LOGE ーBase logarithm of ELOGE ーBase logarithm of EPI ーThe number PISQRT ーSquare root of SQRT ーThe square root of Date JS How to get current date and make your sites more up to date DevLorenzo・Feb ・ min read javascript tutorial webdev codequality Javascript date objects allow us to work with date and time We can retrieve information for it by creating a date and assign and assigning it to a variable let d new Date We usually call it d or dateDate object provide us a lot of different methods the most used are year month day hours minutes seconds and milliseconds Remember that you always have to precise the entire year and not only that we always start with so for example December is the eleventh a minute is composed of seconds and that day is in a hours format You can then retrieve from date a lot of differents info d getDate Returns the day of the month from d getDay Returns the day of the week from d getFullYear Returns the yeard getHours Returns the hour from d getMilliseconds Returns the milliseconds from d getMinutes Returns the minutes from d getMonth Returns the month from d getSeconds Returns the seconds from We can also set things Open the article to continue reading Events Mouse onclick The event occurs when the user clicks on an elementoncontextmenu User right clicks on an element to open a context menuondblclick The user double clicks on an elementonmousedown User presses a mouse button over an elementonmouseenter The pointer moves onto an elementonmouseleave Pointer moves out of an elementonmousemove The pointer is moving while it is over an elementonmouseover When the pointer is moved onto an element or one of its childrenonmouseout User moves the mouse pointer out of an element or one of its childrenonmouseup The user releases a mouse button while over an element Keyboard onkeydown When the user is pressing a key downonkeypress The moment the user starts pressing a keyonkeyup The user releases a key Frame onabort The loading of a media is abortedonbeforeunload Event occurs before the document is about to be unloadedonerror An error occurs while loading an external fileonhashchange There have been changes to the anchor part of a URLonload When an object has loadedonpagehide The user navigates away from a webpageonpageshow When the user navigates to a webpageonresize The document view is resizedonscroll An element s scrollbar is being scrolledonunload Event occurs when a page has unloaded Form onblur When an element loses focusonchange The content of a form element changes for and onfocus An element gets focusonfocusin When an element is about to get focusonfocusout The element is about to lose focusoninput User input on an elementoninvalid An element is invalidonreset A form is resetonsearch The user writes something in a search field for onselect The user selects some text for and onsubmit A form is submitted Drag ondrag An element is draggedondragend The user has finished dragging the elementondragenter The dragged element enters a drop targetondragleave A dragged element leaves the drop targetondragover The dragged element is on top of the drop targetondragstart User starts to drag an elementondrop Dragged element is dropped on the drop target Clipboard oncopy User copies the content of an elementoncut The user cuts an element s contentonpaste A user pastes content in an element Media onabort Media loading is abortedoncanplay The browser can start playing media e g a file has buffered enough oncanplaythrough When browser can play through media without stoppingondurationchange The duration of the media changesonended The media has reached its endonerror Happens when an error occurs while loading an external fileonloadeddata Media data is loadedonloadedmetadata Meta Metadata like dimensions and duration are loadedonloadstart Browser starts looking for specified mediaonpause Media is paused either by the user or automaticallyonplay The media has been started or is no longer pausedonplaying Media is playing after having been paused or stopped for bufferingonprogress Browser is in the process of downloading the mediaonratechange The playing speed of the media changesonseeked User is finished moving skipping to a new position in the mediaonseeking The user starts moving skippinginstalled The browser is trying to load the media but it is not availableonsuspend Browser is intentionally not loading mediaontimeupdate The playing position has changed e g because of fast forward onvolumechange Media volume has changed including mute onwaiting Media paused but expected to resume for example buffering animationend A CSS animation is completeanimationiteration CSS animation is repeatedanimationstart CSS animation has started Other transitionend Fired when a CSS transition has completedonmessage A message is received through the event sourceonoffline Browser starts to work offlineononline The browser starts to work onlineonpopstate When the window s history changesonshow A element is shown as a context menuonstorage A Web Storage area is updatedontoggle The user opens or closes the elementonwheel Mouse wheel rolls up or down over an elementontouchcancel Screen touch is interruptedontouchend User finger is removed from a touch screenontouchmove A finger is dragged across the screenontouchstart Finger is placed on touch screen Asynchronous JS and Error handling Asynchronous JS Finally discover how to use SetTimeout and SetInterval DevLorenzo・Feb ・ min read javascript tutorial webdev codequality SetTimeout will wait foo seconds and then execute the action SetInterval will execute this same action every foo seconds Both can be inline or multiline I recommend using multiline of the time It s important to notice that they work in milliseconds SetTimeout setTimeout function alert Hello World seconds setTimeout function alert The fifth episode of the series SetInterval setInterval function alert I want to show you another Javascript trick setInterval function alert How to work with SetTimeout and SetInterval If you want to remove the first delay you have to add code a first time out of the function I recommend you save this code in a separate function you can call whenever you need Continue reading here Asynchronous JS Finally discover how to use SetTimeout and SetInterval DevLorenzo・Feb ・ min read javascript tutorial webdev codequality First it s important to notice that a majority of backend actions have an unknown result we don t know if it will work when we write our code So we always have to write two different codes one if the action works another if the action results in an error This is exactly how a try catch work we submit a code to try if it works code continues if it doesn t we catch the error avoiding the app crashing and run another code This is a very common thing we don t only use in web development also in Android app development with java for example Try Catch try Try to run this code For example make a request to the server catch e console log e if any error Code throws the error For example display an error message to the user PromisesThe big problem with try catch is that when you have to nest it and you will have it s really messy and difficult to read and write So Javascript support promises with async functions Syntax new Promise executor executor accept reject gt var asyncronus function number gt return new Promise accept reject gt This function returns a promise object If function end well we return a accept otherwise reject More hereBack to Top Projects ideas to become a javascript master Projects ideas to become a javascript master Resource compilation Giveaway DevLorenzo・Apr ・ min read javascript webdev programming beginners a General for beginners ConvertersWord CounterTimer ClockRandom password generatorCalculatorb GamesGuess the numberMath time Other Gamesc Social amp WebsitesLog in Sign upFilterTo Do ListSocialPortfolioOpen the post for more info about each project Back to Top Other resources Table of content My cheat SheetProjects ideas to become a javascript master Other resourcesComplete Javascript cheat sheetsJS promisesJS ArraysJS loopsPreprocessorCoffeScriptEJSBabelJS Frameworks amp LibrariesAngularVueReactJQueryOthersNode Complete JS cheat sheets By dev hints Incredible resource gt By website setupPDF Version Two Others By overapiBy HTML cheat sheet com Interactive JS promises Asynchronous JS Dev to article Asynchronous JS Working with try catch and promises DevLorenzo・Feb ・ min read javascript tutorial webdev codequality Dev to article Asynchronous JS Finally discover how to use SetTimeout and SetInterval DevLorenzo・Feb ・ min read javascript tutorial webdev codequality By codecadamy JS Arrays By dev hints JS Loops By codecademy JS preprocessor CoffeeScript CoffeeScript website Others At karloeaspirity ioQuick reference By autotelicum PDF VersionJS to CoffeeScript EJS EJS websiteEJS docs At one compilerOr at GitHub Babel Babel websiteBabel docs By karloespiritu ioOr at Medium JavaScript based Frameworks amp Libraries Article Angular vs vue vs react at codeinwp comBest Javascript Frameworks article at hackr io Angular By angular io By dev hints VueBy vue mastery By dev hintsOther By marozed React By dev hintsOthers By react cheat sheet comAt GitHub React Typescript cheat sheet JQueryAJAX intro cheat sheet at GitHubBy ascarotero com Really well doneBy Website Setup PDF VersionBy make website hubPDF VersionArticle about top jquery cheat sheetsOr by over API Others Ember js Website Meteor Website Mithril Website NodeWebsite Other Resources Advanced TopicsHow Browsers Work Behind the scenes of modern web browsersLearning Advanced JavaScript by John ResigJavaScript Advanced Tutorial by HTML DogWebGL FundamentalsLearning JavaScript Design Patterns by Addy OsmaniIntro to Computer Science in JavaScriptImmutable data structures for JavaScript Libraries Frameworks ToolsIntroduction to React videoReact Interview QuestionsJavaScript Promises A Tutorial with ExamplesKhan Academy Making webpages interactive with jQueryA Beginner s Guide To Grunt Build Tool for JavaScriptGetting Started with Underscore jsjQuery Course by Code SchoolThinkster io Courses on React and AngularThe Languages And Frameworks You Should Learn In ES Tools List on GitHubGetting Started with Redux Server side JavaScriptReal time Web with Node js Course by Code SchoolNodeSchool CourseNode js First Look on LyndaAll about NodeJS Course on UdemyServer side Development with NodeJS Course on CourseraSource with links resources to help you start learning JavaScript By Daniel Borowski At MediumRead also JavaScript Tips amp Tricks That No One Teaches Giveaway Garvit Motwani・Apr ・ min read javascript webdev html es Thanks for reading and Happy coding Full Compilation of cheat sheets The ultimate Cheat sheets compilation Roadmap to dev DevLorenzo・Mar ・ min read productivity webdev beginners javascript Giveaway We are giving away any course you need on Udemy Any price any course Steps to enter the giveaway gt React to this post gt Subscribe to our Newsletter lt Very important gt Follow me on Twitter lt x Chances of winningThe winner will be announced on May Via Twitter Subscribe to my Newsletter The PDF version of this article Monday Weekly digeeeeeests Wednesday Discussions and dev insights We debate around developer lifes Examples The importance of coffee behind development If you weren t a dev you d be a ​Gifts lots of We send cheat sheets coding advice productivity tips and many more That s gt free lt and you help me PS It took me around hours to complete the article So please remember the like ️ and super like Let s reach the top of the month this time Back to Top 2021-04-20 13:30:49
海外TECH DEV Community Extract-Transform-Load with RxJS: save time and memory with backpressure https://dev.to/ghusse_16/extract-transform-load-with-rxjs-save-time-and-memory-with-backpressure-jaa Extract Transform Load with RxJS save time and memory with backpressureLet s say that you have to extract M objects from a database make some transformations on them and then load them into another storage system Problems will arise as soon as writing into the second DB will become slower than reading from the first Depending on the implementation you could face one of these issues extracted data stacks up in your memory and your program crashes because of the memory usage you send too many requests in parallel to your target database your program is slow because you process each page of data in sequence At Forest Admin we recently faced this issue to move data from a Postgresql database to ElasticSearch These problems can be addressed by processing data in streams that support backpressure It allows the stream to process data at the pace of the slowest asynchronous processing in the chain RxJS is a great streaming library but it does not natively support backpressure and it s not easy to find examples So I decided to share one Let s illustrate with an exampleLet s fake the extract method just for the purpose of this article async function extract pageSize page Just fake an async network access that resolves after ms await new Promise resolve gt setTimeout resolve Math random if pageSize page gt return return new Array pageSize fill map index gt id pageSize page index label Random label Math random title Random title Math random value Math random createdAt new Date The load method could be asynchronous but that s not useful in this example function transform i return i And now let s fake the load method async function load items Let s fake an async network access that takes max ms to write all the items await new Promise resolve gt setTimeout resolve Math random Example of backpressure in RxJSThe backpressure is ensured by the BehaviorSubject named drain in the example below You ll see that the code allow to push data concurrently on the target database with a limit of requests in parallel Input data is also loaded with concurrency but this time the pace is regulated by the drain subject Every time a page is sent to the target database we allow another one to be extracted const BehaviorSubject require rxjs const mergeMap map tap filter require rxjs operators async function extractTransformLoad const CONCURRENCY const PAGE SIZE This allows us to load a fixed number of pages from the beginning const drain new BehaviorSubject new Array CONCURRENCY fill return drain This is necessary because the observable streams arrays This allows us to push a fixed number of pages to load from the beginning pipe mergeMap v gt v Values inside the arrays don t really matter we only use values indices to generate page numbers pipe map index gt index EXTRACT pipe mergeMap page gt extract PAGE SIZE page Terminate if it was an empty page the last page pipe tap results gt if results length drain complete pipe filter results gt results length TRANSFORM and LOAD pipe transform pipe mergeMap load CONCURRENCY Just make sure to not keep results in memory pipe map gt undefined When a page has been processed allow to extract a new one pipe tap gt drain next undefined toPromise In the example above we initialized the concurrency to meaning that requests can be sent to the target database at the same time In order to reduce the time waiting for new data the BehaviorSubject named drain ensures to load twice as much pages of data In this example memory will contain pages of data at the maximum the processing will be as fast as possible with the maximum concurrency that we defined only queries can be made in parallel to the target database 2021-04-20 13:22:20
海外TECH DEV Community 15 YouTube Channels to Learn Data Science for Free https://dev.to/theinsightfulcoder/15-youtube-channels-to-learn-data-science-for-free-487b YouTube Channels to Learn Data Science for FreeData Science is termed as the sexiest job of the st century According to ZipRecruiter the entry level salary for a Data Scientist is estimated to be and the average salary for a mid level data scientist to be around With such an immense scope in the industry the demand for Data Scientists has increased by folds In this post we are going to explore Youtube Channels where you can get started and learn Data Science for free FreecodecampFreeCodeCamp doesn t need any introduction It is my go to channel to get knowledge on any computer science concept FreeCodeCamp s Data Scientist Playlist has videos on Data Science Data Visualisation Data Analysis and more Data Science DojoData Science Dojo is an amazing channel with over M views on their videos and k subscribers They host a day Data Science Bootcamp around the world which has been attended by professionals from over companies globally You can check their schedule for here Data Science Dojo is one of the channels that post videos on Data Science tutorials on both R and Python programming language You can explore their playlists by clicking here Data ScienceWith Million views and k subscribers on their channel Data Science contains videos on Basics of Probability Probability Distribution Roadmaps for various positions in Data Science and everything in between They also offer courses on Python Data Preprocessing SQL Data Visualisation Deep learning and more on their website at datascience com StatQuest with Josh StarmerThis resource is a goldmine for people wanting to learn statistics and machine learning StatQuest breaks down complicated Statistics and Machine Learning methods into small bite sized pieces that are easy to understand StatQuest doesn t dumb down the material instead it builds you up so that you are smarter and have a better understanding of Statistics and Machine Learning This channel has whooping M views and k subscribers You can access StatQuests s playlists from here Alex The AnalystFor people who want to specifically focus on the Data Analysis side of Data Science Alex is your guy His show Alex the Analyst Show is one of my favourite resources on the internet For people who want real life advice rather than tutorials do check him out Ken JeeKen Jee has been working in the data science field doing sports analytics for the last years He has held data science positions in companies ranging from startups to fortune organizations His youtube channel has over M views and k subscribers He has some amazing playlist on Data Science Jobs Data Science Fundamentals and Data Science Projects and more DataCampDataCamp s youtube channel has over M views and k subscribers DataCamp has educated million people around the world through their courses at DataCamp com They ve playlist for R Tutorials for DataScience and Python for Data Science For a review of its courses I d recommend Alex s video on DataCamp Data ProfessorChanin Nantasenamat aka Data Professor is a Professor of Bioinformatics at a Research University where he leads a research laboratory that harnesses data science for unravelling the hidden knowledge of big data in medicine Chanin has more than years of experience in data science and has published more than research articles review articles and book chapters His playlists ーData Science Data Science Toolbox Python Data Science projects and R Data Science projects are just phenomenal BlueBrownBlueBrown has animated tutorials on concepts of Maths and Entertainment It is a great resource to understand any mathematical concepts such as calculus differential equations neural networks and more Krish NaikKrish Naik is a lead Data Scientist pioneering in machine learning deep learning and computer vision an educator and a mentor with over years of experience in the industry In his channel Krish explains various topics on machine learning deep learning and AI with many real world problem scenarios The best part about this channel is that Krish has made a video where he explains how to learn Data Science via his channel by following various playlists It goes as Python for Machine Learning gt Statistics in ML gt Feature Engineering gt Machine Learning gt ML Pipelines gt Deep Learning gt Projects Code BasicsCode Basics is a channel by Dhaval Patel and who has more than years of experience working as a software engineer He has over M views on his channel with k subscribers He has a Data Science Playlist of videos where he covers Python Jupyter Notebook Numpy Pandas Matplotlib for data visualization Machine Learning using sklearn amp deep learning using tensorflow EdurekaEdureka is another platform that needs no introduction It has M views on its channel with M subscribers It has a hour Data Science course where all the major concepts are covered in detail It is suited for both beginners and professionals You can access the hour Data Science Full Course by Edureka here IntellipaatIntellipaat is a channel with M views and k subscribers It has an hour course on complete data science starting from what is data science to various data science concepts data science projects and data science interview questions amp answers It is an end to end data science full course SimplilearnSimplilearn is a channel with M views and k subscribers Similar to Edureka it has a hour course where it provides a learning path of Data Science in a correct manner It is filled with lots of Practical Examples and is beginner friendly You can access the Hour Data Science Course by Simplilearn here Great LearningGreat learning has a Data Science Course by Dr Abhinanda Sarkar Dr Sarkar is the Academic Director at Great Learning for Data Science and Machine Learning Programs He is ranked amongst the Top Most Prominent Analytics amp Data Science Academicians in India He has taught applied mathematics at the Massachusetts Institute of Technology MIT as well as been visiting faculty at Stanford and ISI and continues to teach at the Indian Institute of Management IIM Bangalore and the Indian Institute of Science IISc You can also get a free certificate from Great Learning for Data Science by visiting here I hope this article was useful for you Mastering Data Science requires a lot of hard work patience and knowledge If you re just in for the money it offers you can opt for becoming a software engineer too It pays the same and some times even more With that said Data Science holds a lot of potentials and is already changing the way we look at business My articles are fueled by coffees If you find my content valuable and want to support my efforts consider buying me one Bonus Insights by The Insightful Coder Interested in Building Creative Beginner Level Python Projects Check out the Python Projects for Beginners Series Interested in Building Your Own Artificial Intelligence Projects using Python Check out the Python AI SeriesI m also dropping useful dev resources interactive quizzes and Interview preparation on my Instagram Page Make sure to follow me up Find and Download All My Project Source Codes at My Github Repository 2021-04-20 13:15:27
海外TECH DEV Community Tree shaking for JavaScript library authors https://dev.to/livechat/tree-shaking-for-javascript-library-authors-4lb0 Tree shaking for JavaScript library authorsContrary to what most developers think tree shaking isn t very complicated The discussion around the nomenclature dead code elimination vs tree shaking can introduce some confusion but this issue along with some others is clarified throughout the article As JavaScript library authors we want to achieve the most lightweight code bundle possible In this post I ll walk you through the most popular patterns that deoptimize your code as well as share my advice on how to tackle certain cases or test your library A bit of theoryTree shaking is a fancy term for dead code elimination There is no exact definition of it We can treat it as a synonym for dead code elimination or try to put only certain algorithms under that umbrella term If we look at the definition listed on the webpack s docs page it seems to be mentioning both approaches “Tree shaking is a term commonly used in the JavaScript context for dead code elimination It relies on the static structure of ES module syntax i e import and export The first sentence implies it s a synonym while the second one mentions some specific language features that are used by this algorithm Nomenclature dispute“Rather than excluding dead code dead code elimination we re including live code tree shaking elimination distinguishes Rich Harris in his excellent post on the topic One practical difference between both approaches is that the so called tree shaking usually refers to the work done by bundlers whereas dead code elimination is performed by minifiers like Terser As a result the whole process of optimizing the final output often has steps if we are discussing the creation of production ready files In fact webpack actively avoids doing dead code eliminations and offloads some of that work to Terser while dropping only the necessary bits All of this is to make the work easier for Terser as it operates on files and has no knowledge of modules or the project structure Rollup on the other hand does things the hard way and implements more heuristics in its core which allows for generating less code It s still advised to run the resulting code through Terser though to achieve the best overall effect If you ask me there is little point in arguing which definition is correct It s like battling over whether we should say function parameters or function arguments There s a difference in meaning but people have been misusing the terms for so long that these terms became interchangeable in everyday use Speaking of tree shaking I understand Rich s point but I also think that trying to distinguish separate approaches has introduced more confusion than clarification and that ultimately both techniques check the exact same things That is why I m going to use both terms interchangeably throughout this post Why even bother The frontend community often seems to be obsessed with the size of JavaScript bundles that we ship to our clients There are some very good reasons behind this concern and we definitely should pay attention to how we write code how we structure our applications and what dependencies we include The primary motivating factor is to send less code to the browser which translates to both faster download and execution which in turn means that our sites can be displayed or become interactive faster No magicThe currently popular tools like webpack Rollup Terser and others don t implement a lot of overly complicated algorithms for tracking things through function method boundaries etc Doing so in such a highly dynamic language as JavaScript would be extremely difficult Tools like Google Closure Compiler are much more sophisticated and they re capable of performing more advanced analysis but they re rather unpopular and tend to be hard to configure Given that there is not that much magic involved in what those tools do some things simply cannot be optimized by them The golden rule is that if you care about the bundle size you should prefer composable pieces rather than functions with tons of options or classes with a lot of methods and so on If your logic embeds too much and your users use only of that they will still pay the cost of the whole using the currently popular tooling there is just no way around it General view on how minifiers and bundlers workAny given tool performing static code analysis operates on the Abstract Syntax Tree representation of your code It s basically the source text of a program represented with objects which form a tree The translation is pretty much to and converting between the source text and AST is semantically reversible you can always deserialize your source code to AST and later serialize it back to the semantically equivalent text Note that in JavaScript things like whitespaces or comments don t have semantic meaning and most tools don t preserve your formatting What those tools have to do is figure out how your program behaves without actually executing the program It involves a lot of book keeping and cross referencing deduced information based on that AST Based on that tools can drop certain nodes from the tree once they prove that it won t affect the overall logic of the program Side effectsGiven the language you use certain language constructs are better than others for static code analysis If we consider this very basic program function add a b return a b function multiply a b return a b console log add We can safely say that the whole multiply function isn t used by this program and therefore doesn t need to be included in the final code A simple rule to remember is that a function can almost always be safely removed if it stays unused because a mere declaration doesn t execute any side effects Side effects are the most vital part to understand here They are what actually affects the outer world for example a call to a console log is a side effect because it yields an observable outcome of a program It wouldn t be OK to remove such a call as users usually expect to see it It s hard to list all possible side effect types a program might have but to name a few Assigning a property to a global object like window Changing all other objectsCalling many builtin functions like fetch Calling user defined functions that contain side effectsThe code that has no side effects is called pure Minifiers and bundlers have to always assume the worst and play safe since removing any given line of code incorrectly can be very costly It can tremendously alter the program s behavior and waste people s time on debugging bizarre problems that manifest only on production Minifying the code during development is not a popular choice Popular deoptimizing patterns and how to fix themAs mentioned at the beginning this article is dedicated primarily to library authors Application development usually focuses on functionality rather than optimization Over optimizing the aspects mentioned below in the application code is generally not advised Why The application codebase should contain only the code that s actually in use profits coming from the implementation of eyebrow raising techniques would be negligible Keep your apps simple and understandable It s really worth noting that any advice given in this article is only valid for the initialization path of your modules for what gets executed right away when you import a particular module Code within functions classes and others is mostly not a subject of this analysis Or to put it differently such code is rarely unused and easily discoverable by linting rules like as no unused vars and no unreachable Property accessThis might be surprising but even reading a property cannot be dropped safely const test someFunction test barThe problem is that the bar property might actually be a getter function and functions can always have side effects Given that we don t know much about someFunction as its implementation might be too complex to be analyzed we should assume the worst case scenario this is a potential side effect and as such cannot be removed The same rule applies when assigning to a property Function callsNote that even if we were able to remove that property read operation we d still be left with the following someFunction As the execution of this function potentially leads to side effects Let s consider a slightly different example that might resemble some real world code export const test someFunction Assume that thanks to the tree shaking algorithms in a bundler we already know that test isn t used and thus can be dropped which leaves us with const test someFunction A simple variable declaration statement doesn t contain any side effects either therefore it can be dropped as well someFunction In a lot of situations however the call itself cannot be dropped Pure annotationsIs there anything that can be done It turns out that the solution is quite simple We have to annotate the call with a special comment that the minifying tool will understand Let s put it all together export const test PURE someFunction This little thing tells our tools that if the result of the annotated function stays unused then that call can be removed which in turn can lead to the whole function declaration being dropped if nothing else refers to it In fact parts of the runtime code generated by bundlers are also annotated by such comments leaving the opportunity of the generated code being dropped later Pure annotations vs property accessDoes PURE work for getters and setters Unfortunately not There isn t much that can be done about them without changing the code itself The best thing you could do is to move them to functions Depending on the situation it might be possible to refactor the following code const heavy getFoo heavyexport function test return heavy compute To this export function test let heavy getFoo heavy return heavy compute And if the same heavy instance is needed for all future calls you can try the following let heavyexport function test lazy initialization heavy heavy getFoo heavy return heavy compute You could even try to leverage PURE with an IIFE but it looks extremely weird and might raise eyebrows const heavy PURE gt getFoo heavy export function test return heavy compute Relevant side effectsIs it safe to annotate side effectful functions like this In the library context it usually is Even if a particular function has some side effects a very common case after all they are usually only relevant if the result of such a function stays used If the code within a function cannot be safely dropped without altering the overall program s behavior you should definitely not annotate a function like this BuiltinsWhat might also come as a surprise is that even some well known builtin functions are oftentimes not recognized as pure automatically There are some good reasons for that The processing tool cannot know in what environment your code will actually get executed so for example Object assign foo bar could very well just throw an error like Uncaught TypeError Object assign is not a function The JavaScript environment can be easily manipulated by some other code the processing tool isn t aware of Consider a rogue module that does the following Math random function throw new Error Oops As you can see it s not always safe to assume even the basic behavior Some tools like Rollup decide to be a little bit more liberal and choose pragmatism over guaranteed correctness They might assume a non altered environment and in effect allow to produce more optimal results for the most common scenarios Transpiler generated codeIt s rather easy to optimize your code once you sprinkle it with the PURE annotations given you re not using any additional code transpiling tools However we often pass our code through tools like Babel or TypeScript to produce the final code that will get executed and the generated code cannot be easily controlled Unfortunately some basic transformations might deoptimize your code in terms of its treeshakeability so sometimes inspecting the generated code can be helpful in finding those deoptimization patterns I ll illustrate what I mean with a simple class having a static field Static class fields will become an official part of the language with the upcoming ES specification but they are already widely used by developers class Foo static defaultProps Babel output class Foo defineProperty Foo defaultProps TypeScript output class Foo Foo defaultProps Using the knowledge gained throughout this article we can see that both outputs have been deoptimized in a way that might be hard for other tools to handle properly Both outputs put a static field outside the class declaration and assign an expression to the property either directly or through the defineProperty call where the latter is more correct according to the specification Usually such a scenario isn t handled by tools like Terser sideEffects falseIt s been quickly realized that tree shaking can automatically yield only some limited benefits to the majority of users The results are highly dependent on the included code since a lot of the code in the wild uses the above mentioned deoptimizing patterns In fact those deoptimizing patterns aren t inherently bad and most of the time shouldn t be seen as problematic it s normal code Making sure that code isn t using those deoptimizing patterns is currently mostly a manual job so maintaining a library tree shakeable tends to be challenging in the long run It s rather easy to introduce harmless looking normal code that will accidentally start retaining too much Therefore a new way to annotate the whole package or just some specific files in a package as side effect free has been introduced It s possible to put a sideEffects false in a package json of your package to tell bundlers that files in that package are pure in a similar sense that was described previously in the context of the PURE annotations However I believe that what it does is vastly misunderstood It doesn t actually work like a global PURE for function calls in that module nor does it affect getters setters or anything else in the package It s just a piece of information to a bundler that if nothing has been used from a file in such a package then the whole file can be removed without looking into its content To illustrate the concept we can imagine the following module foo jsconsole log foo initialized export function foo console log foo called bar jsconsole log bar initialized export function bar console log bar called index jsimport foo from foo import bar from bar export function first foo export function second bar If we only import first from the module then the bundler will know it can omit the whole bar js file thanks to the sideEffects false flag So in the end this would be logged foo initialized foo called This is quite an improvement but at the same time it s not in my humble opinion a silver bullet The main problem with this approach is that one needs to be extra careful about how the code is organized internally the file structure etc in order to achieve the best results It s been common advice in the past to flat bundle library code but in this case it s to the contrary flat bundling is actively harmful to this flag This can also be easily deoptimized if we decide to use anything else from the bar js file because it will only be dropped if no export from the module ends up being used How to test thisTesting is hard especially since different tools yield different results There are some nice packages that can help you but I ve usually found them to be faulty in one way or another I usually try to manually inspect the bundles I get after running webpack amp Rollup on a file like this import some library The ideal result is an empty bundle no code in it This rarely happens therefore a manual investigation is required One can check what got into the bundle and investigate why it could have happened knowing what things can deoptimize such tools With the presence of sideEffects false my approach can easily produce false positive results As you may have noticed the import above doesn t use any export of the some library so it s a signal for the bundler that the whole library can be dropped This doesn t reflect how things are used in the real world though In such a case I try to test the library after removing this flag from its package json to check what would happen without it and to see if there s a way to improve the situation Happy tree shaking Don t forget to check our other content on dev to If you want to collaborate with us on expanding the area of business messaging visit our Developer Program 2021-04-20 13:13:14
海外TECH DEV Community Recommended reads for the week: highlighting underrated posts! 📣 https://dev.to/technoglot/recommended-reads-for-the-week-highlighting-underrated-posts-20ef Recommended reads for the week highlighting underrated posts Photo by Juliana Romão on UnsplashHello world How s life treating you Hope you are doing fine by ALL means Today I wanted to do something a little different I want to share with you some underrated reads that I believe should have gotten more attention Ready Disclaimer I m doing this out of my personal motivation None of these great authors bloggers asked me for any promo I still think they deserve a shout out so here it goes Oh and the order I listed the posts in is totally random by the way Pick ️⃣This post by tarynmcmillan is great even if you are not a stay at home mom tarynmcmillan shares great tips and resources to make it through the daysofcode challenge Go take a look and show some love My Experience Doing DaysofCode as a Stay at Home Mom Taryn McMillan・Apr ・ min read learncoding daysofcode beginnerdevelopers Pick ️⃣ ederchrono did an awesome job telling us the importance of TDD Test Driven Development Take notes and put out those fires you started TDD debugging Eder Díaz・Apr ・ min read productivity javascript testing Pick ️⃣ ishfillet shared some actionable tips for choosing a brandable domain name Maybe something for you Actionable tips to finding a brandable domain name ishfillet・Apr ・ min read sideprojects discuss productivity domain Pick ️⃣Do you like pickles I don t not so much at least haha grayhat tells us about what Pickle is in the context of Python Yikes what could that be Spoiler it is not terrifying at all I dare you to take a look at this one What is Pickle in python Mwenda Harun Mbaabu・Apr ・ min read python datascience machinelearning dseafam Pick ️⃣And last but certainly not least naseki Arguably not an underrated post but definitely TIL material I had no idea about this nifty trick until I stumbled upon naseki s post TIP Never leave your email address raw in the mailto link Here s what to do instead Naseki・Apr ・ min read beginners webdev html security It s a wrap That s all folks Who knows maybe I ll do this more often in the near future Let me know how you liked these posts if you check them out See you soon ‍ 2021-04-20 13:02:52
Apple AppleInsider - Frontpage News Eve releases first Thread-enabled HomeKit light switch in EU https://appleinsider.com/articles/21/04/20/eve-releases-first-thread-enabled-homekit-light-switch-in-eu?utm_medium=rss Eve releases first Thread enabled HomeKit light switch in EUEve is continuing its rollout of Thread amongst its devices with the launch of an updated version of its European HomeKit wall switch Eve light switch now supports ThreadThe new switch looks the same as the prior generation but is updated with new radios to allow Thread communication as well as Bluetooth Previously the Eve HomeKit light switch relied purely on Bluetooth Read more 2021-04-20 13:21:58
Apple AppleInsider - Frontpage News Last call: Babbel Lifetime Subscription with 14 languages on sale for $199 ($300 off) https://appleinsider.com/articles/21/04/04/deals-babbel-lifetime-subscription-with-14-languages-on-sale-for-199-300-off?utm_medium=rss Last call Babbel Lifetime Subscription with languages on sale for off Readers this week can save on a lifetime Babbel language learning subscription with languages included This marks the return of holiday pricing for the popular language learning app Low Babbel costThe Babbel deal includes lifetime access to learn languages including Spanish German Italian and French Read more 2021-04-20 13:45:24
Apple AppleInsider - Frontpage News Cheap M1 Mac mini deals deliver prices as low as $645 (up to $110 off) https://appleinsider.com/articles/21/04/15/new-m1-mac-mini-deals-deliver-prices-as-low-as-645-up-to-110-off?utm_medium=rss Cheap M Mac mini deals deliver prices as low as up to off Apple s Mac mini is on sale this week with exclusive coupon savings knocking up to off M models M Mac mini savingsMid April Mac mini deals mark the return of fan favorite discounts with the standard Mac mini currently off Read more 2021-04-20 13:50:27
Apple AppleInsider - Frontpage News Flash deals: save up to $280 on Apple's iPhone 12, plus free gifts ahead of Apple Event https://appleinsider.com/articles/21/04/19/flash-deals-save-up-to-280-on-apples-iphone-12-plus-free-gifts-ahead-of-apple-event?utm_medium=rss Flash deals save up to on Apple x s iPhone plus free gifts ahead of Apple EventFor two days only Verizon owned Visible is knocking up to off Apple s iPhone with a free gift card offer and free next day shipping for new users that switch iPhone flash dealIn celebration of tomorrow s Apple Event Visible is dropping the price on the iPhone in its latest flash promotion Read more 2021-04-20 13:41:46
海外TECH Engadget Russia is considering leaving the ISS for its own space station https://www.engadget.com/russia-leaving-iss-own-space-station-133854949.html agency 2021-04-20 13:38:54
海外TECH Engadget Lego adds a Luigi set to its Super Mario collection https://www.engadget.com/lego-luigi-starter-course-super-mario-set-130533658.html plumber 2021-04-20 13:05:33
海外TECH Network World Weekly internet health check, US and worldwide https://www.networkworld.com/article/3534130/covid-19-weekly-health-check-of-isps-cloud-providers-and-conferencing-services.html#tk.rss_all Weekly internet health check US and worldwide The reliability of services delivered by ISPs cloud providers and conferencing services a k a unified communications as a service UCaaS is an indication of how well served businesses are via the internet ThousandEyes is monitoring how these providers are handling the performance challenges they face It will provide Network World a roundup of interesting events of the week in the delivery of these services and Network World will provide a summary here Stop back next week for another update and see more details here Get regularly scheduled insights by signing up for Network World newsletters To read this article in full please click here 2021-04-20 13:25:00
Cisco Cisco Blog Giving sellers the intelligence they need to close deals https://blogs.cisco.com/customerspotlight/giving-sellers-the-intelligence-they-need-to-close-deals Giving sellers the intelligence they need to close dealsHow do you turn CRM data into actionable intelligence for sellers Cisco Venture Labs and AI startup SetSail collaborated to solve this challenge 2021-04-20 13:22:37
金融 金融庁ホームページ 衆議院財務金融委員会における麻生金融担当大臣の「破綻金融機関の処理のために講じた措置の内容等に関する報告」概要説明について公表しました。 https://www.fsa.go.jp/common/diet/houkoku/030420/20210420.html 財務金融委員会 2021-04-20 15:00:00
金融 金融庁ホームページ ギャンブル等依存症問題啓発週間について公表しました。 https://www.fsa.go.jp/policy/kashikin/gambling/20210514.html 週間 2021-04-20 15:00:00
ニュース @日本経済新聞 電子版 新型コロナ、国内感染54万2175人 新たに4335人確認 https://t.co/GoKNT4xigx https://twitter.com/nikkei/statuses/1384493530865758212 新型 2021-04-20 13:05:55
海外ニュース Japan Times latest articles ASEAN calls summit on Myanmar crisis as EU imposes sanctions https://www.japantimes.co.jp/news/2021/04/20/asia-pacific/myanmar-summit-plans/ protocols 2021-04-20 22:54:52
海外ニュース Japan Times latest articles Xi challenges U.S. global leadership at event billed as China’s Davos https://www.japantimes.co.jp/news/2021/04/20/asia-pacific/politics-diplomacy-asia-pacific/xi-jinping-us-leadership/ Xi challenges U S global leadership at event billed as China s Davos What we need in today s world is justice not hegemony the Chinese president said at the conference attended by global leaders via video link 2021-04-20 22:52:01
海外ニュース Japan Times latest articles ‘Self-serving’ Super League opens unprecedented conflict across European soccer https://www.japantimes.co.jp/sports/2021/04/20/soccer/super-league-conflict-european-soccer/ Self serving Super League opens unprecedented conflict across European soccerSunday s announcement of a breakaway competition featuring as many as elite clubs has resulted in international uproar 2021-04-20 22:15:18
ニュース BBC News - Home European Super League: 'No action off the table' over breakaway group - No 10 https://www.bbc.co.uk/news/uk-politics-56810962 government 2021-04-20 13:29:14
ニュース BBC News - Home Covid-19: India red list add 'may be too late', Prof Mark Walport says https://www.bbc.co.uk/news/uk-56813025 walport 2021-04-20 13:37:51
ニュース BBC News - Home Bomb left at police officer's home near Dungiven https://www.bbc.co.uk/news/uk-northern-ireland-56814575 dungivenni 2021-04-20 13:09:21
ニュース BBC News - Home 'World's oldest' Humboldt penguin celebrates birthday https://www.bbc.co.uk/news/uk-england-humber-56814242 yorkshire 2021-04-20 13:07:11
ニュース BBC News - Home Aldi brings back Cuthbert the Caterpillar cake for charity https://www.bbc.co.uk/news/business-56812445 alleges 2021-04-20 13:16:55
ニュース BBC News - Home Fifa says ESL clubs 'must live with consequences of their choices' while UK government will take 'necessary' action https://www.bbc.co.uk/sport/football/56813819 Fifa says ESL clubs x must live with consequences of their choices x while UK government will take x necessary x actionGianni Infantino strongly disapproves of the European Super League and says the clubs will have to live with the consequences of their actions 2021-04-20 13:34:21
ニュース BBC News - Home RFU backs Jones as England coach after review https://www.bbc.co.uk/sport/rugby-union/56819737 finish 2021-04-20 13:39:28
LifeHuck ライフハッカー[日本版] Microsoftが新型Surface Laptop 4を発売 https://www.lifehacker.jp/2021/04/microsoft-surface-laptop-4-specs-features-price.html Microsoftによると、SurfaceLaptopはSurfaceLaptopからパフォーマンスを最大向上させたとしています。 2021-04-20 22:05:00
北海道 北海道新聞 オ11―3西(20日) オリックス連敗止める https://www.hokkaido-np.co.jp/article/535451/ 連敗 2021-04-20 22:19:00
北海道 北海道新聞 関西圏「変異株への置き換わり進む」 道内も「増加から高止まり」 専門家組織が見解 https://www.hokkaido-np.co.jp/article/535449/ 厚生労働省 2021-04-20 22:16:57
北海道 北海道新聞 ロ8―4日(20日) 日ハム投壊、逆転負け https://www.hokkaido-np.co.jp/article/535441/ 逆転勝ち 2021-04-20 22:09:17
北海道 北海道新聞 北電ネット、再エネ出力制御を指示か 5月の大型連休中 https://www.hokkaido-np.co.jp/article/535448/ 北海道電力 2021-04-20 22:05:35
北海道 北海道新聞 実習中事故、県に賠償命令 機械で指切断、岡山地裁 https://www.hokkaido-np.co.jp/article/535430/ 岡山地裁 2021-04-20 22:06:13
ビジネス 東洋経済オンライン 中国TCLが「第8.6世代」パネルを製造する狙い ノートPC向け中型パネルでシェア奪取目指す | 「財新」中国Biz&Tech | 東洋経済オンライン https://toyokeizai.net/articles/-/423069?utm_source=rss&utm_medium=http&utm_campaign=link_back biztech 2021-04-20 22:30:00
仮想通貨 BITPRESS(ビットプレス) 日本暗号資産ビジネス協会(JCBA)、FATFの改訂ガイダンスに関する募集意見を取りまとめFATFへ意見提出 https://bitpress.jp/count2/3_17_12447 資産 2021-04-20 22:57:40
仮想通貨 BITPRESS(ビットプレス) [Fintech Journal] デジタル収益が「5割超えない」銀行は消える、Bank 4.0著者が語る“残酷な現実” https://bitpress.jp/count2/3_9_12446 fintechjournal 2021-04-20 22:49:50
仮想通貨 BITPRESS(ビットプレス) [CoinChoice] 米連邦準備理事会(FRB)がデジタルドルの2種のプロトタイプを7月にも公開へ https://bitpress.jp/count2/3_9_12445 coinchoice 2021-04-20 22:30:25
仮想通貨 BITPRESS(ビットプレス) [AFP] 「ブリットコイン」? 英、デジタル通貨の創設検討 https://bitpress.jp/count2/3_9_12444 創設 2021-04-20 22:29:00
仮想通貨 BITPRESS(ビットプレス) [Bloomberg] デジタル人民元、ドルに取って代わる意図ない-中国人民銀副総裁 https://bitpress.jp/count2/3_9_12443 bloomberg 2021-04-20 22:27:05

コメント

このブログの人気の投稿

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