03 2019 档案

摘要:Pattern matching in functional programming languages is a way to break up expressions into individual cases. We are going to go through how to pattern 阅读全文
posted @ 2019-03-31 20:08 Zhentiw 阅读(176) 评论(0) 推荐(0) 编辑
摘要:Normally when you create a Volume, it will store in Docket Host, you can also tell the folder which you want docket to store the volume. You can check 阅读全文
posted @ 2019-03-31 19:06 Zhentiw 阅读(185) 评论(0) 推荐(0) 编辑
摘要:PureScript types are very extensive and we are going to experiment with type constructors and how to make then use them. We can define a custom data t 阅读全文
posted @ 2019-03-30 23:54 Zhentiw 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Algorithm or program to check for balanced parentheses in an expression using stack data structure. For example: The idea to solve the problem is: ope 阅读全文
posted @ 2019-03-30 23:34 Zhentiw 阅读(202) 评论(0) 推荐(0) 编辑
摘要:JavaScript does its error-checking at runtime, but PureScript has a compiler, which makes sure that your program has no errors before it converts it a 阅读全文
posted @ 2019-03-29 21:07 Zhentiw 阅读(171) 评论(0) 推荐(0) 编辑
摘要:For example we have a function to check the filesize: It works fine, but the 'fileSize' function has a problem, those part of code run in sync, not as 阅读全文
posted @ 2019-03-28 21:40 Zhentiw 阅读(272) 评论(0) 推荐(0) 编辑
摘要:The idea to solve the problem is set five variable, first direction, we need to switch direction after we finish printing one row or one column. Then 阅读全文
posted @ 2019-03-28 03:23 Zhentiw 阅读(290) 评论(0) 推荐(0) 编辑
摘要:Here we refactor a React TypeScript class component to a function component with a useState hook and discuss how props and state types can be modeled 阅读全文
posted @ 2019-03-27 21:00 Zhentiw 阅读(415) 评论(0) 推荐(0) 编辑
摘要:Because @types/react has to expose all its internal types, there can be a lot of confusion over how to type specific patterns, particularly around hig 阅读全文
posted @ 2019-03-27 20:45 Zhentiw 阅读(1025) 评论(0) 推荐(0) 编辑
摘要:Imaging we have a deck of cards, eveytimes we need to pick one card from deck, the result we want to have is: For selected, each time we want only one 阅读全文
posted @ 2019-03-27 19:17 Zhentiw 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Give you set of meetings start time and end time, count how many meeting rooms needed. For example: We can use a memo table to store the at which time 阅读全文
posted @ 2019-03-27 02:03 Zhentiw 阅读(184) 评论(0) 推荐(0) 编辑
摘要:If we pushed our changes already to the remote repository we have to pay attention to not change the git history (using commands like rebase, reset, a 阅读全文
posted @ 2019-03-26 20:54 Zhentiw 阅读(263) 评论(0) 推荐(0) 编辑
摘要:When you accidentally committed some changes to your branch you have various possibilities to “undo” that operation and add some more changes. One is 阅读全文
posted @ 2019-03-26 20:51 Zhentiw 阅读(172) 评论(0) 推荐(0) 编辑
摘要:By given an array [1,2,3]: Return all possible combinations. for example: [[], [1], [2], [3], [1, 2].... [1,2,3]] 阅读全文
posted @ 2019-03-26 20:18 Zhentiw 阅读(325) 评论(0) 推荐(0) 编辑
摘要:Using Naive JS: The main problem is inside 'rando' function, not really a FP way doing stuff. Arrow approach: It becomes complex with we need to do Pa 阅读全文
posted @ 2019-03-26 17:15 Zhentiw 阅读(245) 评论(0) 推荐(0) 编辑
摘要:We don't need to 阅读全文
posted @ 2019-03-26 00:35 Zhentiw 阅读(134) 评论(0) 推荐(0) 编辑
摘要:Did you make a typo in your last commit message? No problem, we can use the git --amend command to change it very easily. Note: This only holds if you 阅读全文
posted @ 2019-03-25 21:34 Zhentiw 阅读(235) 评论(0) 推荐(0) 编辑
摘要:Often you have your feature branch you’ve been working on and once it’s ready, you just want it to merge into master as a single commit. You don’t car 阅读全文
posted @ 2019-03-25 21:30 Zhentiw 阅读(188) 评论(0) 推荐(0) 编辑
摘要:Gosh no, I just added all of these commits to master. They were thought to be peer reviewed first in a dedicated branch! No worries, in this lesson we 阅读全文
posted @ 2019-03-25 20:59 Zhentiw 阅读(202) 评论(0) 推荐(0) 编辑
摘要:Recently, I am learning Working with ADT. Got some extra thought about State Monad. Basiclly how to thinking in State. First, we need to know the type 阅读全文
posted @ 2019-03-25 19:06 Zhentiw 阅读(258) 评论(0) 推荐(0) 编辑
摘要:Given a sorted array, for example: Then we rotated it 1 time, it becomes: 2 times: So now given you an array which is rotated N times based on an sort 阅读全文
posted @ 2019-03-25 05:12 Zhentiw 阅读(193) 评论(0) 推荐(0) 编辑
摘要:In previous post, Arrow Functor with contramap, we have seen how to opreating on params before we invoke the function by using Arrow + contramap. It h 阅读全文
posted @ 2019-03-24 22:06 Zhentiw 阅读(323) 评论(0) 推荐(0) 编辑
摘要:This lesson teaches you how arguments passed to a curried function allow us to store data in closure to be reused in our programs and applications. Si 阅读全文
posted @ 2019-03-23 22:10 Zhentiw 阅读(161) 评论(0) 推荐(0) 编辑
摘要:To demonstrate the difference between mutability and immutability, imagine taking a drink from a glass of water. If our glass is mutable, when we take 阅读全文
posted @ 2019-03-23 21:58 Zhentiw 阅读(177) 评论(0) 推荐(0) 编辑
摘要:When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular Elements is one of them. In this lesson we learn how 阅读全文
posted @ 2019-03-22 16:41 Zhentiw 阅读(316) 评论(0) 推荐(0) 编辑
摘要:It helps to understands how recursive calls works. So for our 'helper' function, when calling it, it stop there until when reach the end. one | two | 阅读全文
posted @ 2019-03-21 23:57 Zhentiw 阅读(144) 评论(0) 推荐(0) 编辑
摘要:What is Arrow Functor? Arrow is a Profunctor that lifts a function of type a -> b and allows for lazy execution of the function. Arrow can be consider 阅读全文
posted @ 2019-03-21 00:22 Zhentiw 阅读(331) 评论(0) 推荐(0) 编辑
摘要:Let's say we are going to find out number of occurrences of a number in a sorted array using binary search in O(log n) time. For example the given arr 阅读全文
posted @ 2019-03-20 20:36 Zhentiw 阅读(167) 评论(0) 推荐(0) 编辑
摘要:One approach to building high performance applications with webpack is to take advantage of code-splitting to only load the needed JavaScript on initi 阅读全文
posted @ 2019-03-20 16:20 Zhentiw 阅读(288) 评论(0) 推荐(0) 编辑
摘要:Given a stream of elements too large to store in memory, pick a random element from the stream with uniform probability. To solve the problem which n 阅读全文
posted @ 2019-03-20 03:22 Zhentiw 阅读(418) 评论(0) 推荐(0) 编辑
摘要:You run an e-commerce website and want to record the last N order ids in a log. Implement a data structure to accomplish this, with the following API: 阅读全文
posted @ 2019-03-20 02:24 Zhentiw 阅读(256) 评论(0) 推荐(0) 编辑
摘要:Let's we have some prediction functions, for each prediction function has a corresponding tag: So if we have input as: Also we wish our program to the 阅读全文
posted @ 2019-03-19 21:11 Zhentiw 阅读(264) 评论(0) 推荐(0) 编辑
摘要:In a real world scenario we obviously need to be able to communicate with an Angular Element embedded into our static HTML site. In this lesson we wil 阅读全文
posted @ 2019-03-19 16:56 Zhentiw 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Converting all of our modern JavaScript into ES5 compatible syntax is a great way to use modern features while targeting older browsers. What happens 阅读全文
posted @ 2019-03-19 16:49 Zhentiw 阅读(476) 评论(0) 推荐(0) 编辑
摘要:We can separate our custom application code from the common libraries we leverage, such as React and ReactDOM. In this lesson we'll configure webpack  阅读全文
posted @ 2019-03-18 20:35 Zhentiw 阅读(246) 评论(0) 推荐(0) 编辑
摘要:Bundle size has a huge impact on JavaScript performance. It's not just about download speed, but all the JavaScript we ship to the browser needs to be 阅读全文
posted @ 2019-03-18 20:32 Zhentiw 阅读(273) 评论(0) 推荐(0) 编辑
摘要:Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 阅读全文
posted @ 2019-03-18 19:32 Zhentiw 阅读(349) 评论(0) 推荐(0) 编辑
摘要:We can treat Angular Element as each standlone lib and compile each Angular element spreatly. Tool we are using to compile Angular element is 'ngx-bui 阅读全文
posted @ 2019-03-18 16:20 Zhentiw 阅读(1038) 评论(0) 推荐(0) 编辑
摘要:Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s a 阅读全文
posted @ 2019-03-17 18:10 Zhentiw 阅读(374) 评论(0) 推荐(0) 编辑
摘要:For example we have an array of words: What is the best data structure to store the data and easy for search? We can use Trie data structure, it is a 阅读全文
posted @ 2019-03-17 04:29 Zhentiw 阅读(238) 评论(0) 推荐(0) 编辑
摘要:What we are going to do in this post, is to build a random number generator. As you might know that Javascript provides Math.random(), but the problem 阅读全文
posted @ 2019-03-16 20:07 Zhentiw 阅读(212) 评论(0) 推荐(0) 编辑
摘要:For example we have array of meeting objects: For a day, 8 hours, we want to take as any meetings as possible: You should write function 'optimizeMeet 阅读全文
posted @ 2019-03-15 21:35 Zhentiw 阅读(1371) 评论(0) 推荐(0) 编辑
摘要:.bash_profile is a file that bash invokes (or more technically sources) before the start of a new bash session. In .bash_profile, we have the opportun 阅读全文
posted @ 2019-03-14 18:00 Zhentiw 阅读(305) 评论(0) 推荐(0) 编辑
摘要:For example we have the array like this: First step is using Counting sort for last digit, in our example is: Then sort according to the last digit: T 阅读全文
posted @ 2019-03-14 15:45 Zhentiw 阅读(303) 评论(0) 推荐(0) 编辑
摘要:A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. Given the root to a binary tree, count the 阅读全文
posted @ 2019-03-13 20:54 Zhentiw 阅读(442) 评论(0) 推荐(0) 编辑
摘要:For a menu item, when we tab onto it, we want this element get 'focus' event, so that the submenu will show up. In the post, we will see how to achiev 阅读全文
posted @ 2019-03-13 16:29 Zhentiw 阅读(205) 评论(0) 推荐(0) 编辑
摘要:Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseconds 阅读全文
posted @ 2019-03-13 06:05 Zhentiw 阅读(237) 评论(0) 推荐(0) 编辑
摘要:By given a tree structure, task is to find lowest common ancestor: For example, LCA(4, 5) --> >3 LCA(4,2) --> 1 LCA(3, 5) --> 3 LCA(6, 6) --> 6 Soluti 阅读全文
posted @ 2019-03-12 21:07 Zhentiw 阅读(202) 评论(0) 推荐(0) 编辑
摘要:We will see how you can use npx to pull and execute code from a GitHub repository. If you need even more control, you can target a specific branch of 阅读全文
posted @ 2019-03-12 19:23 Zhentiw 阅读(511) 评论(0) 推荐(0) 编辑
摘要:We will incorporate npm specific environment variables when executing various npx commands. In our example, we will transpile code to a folder name th 阅读全文
posted @ 2019-03-12 19:09 Zhentiw 阅读(311) 评论(0) 推荐(0) 编辑
摘要:We will use npx to run a package using different versions of Node.js. This can become valuable when testing the various new features that are introduc 阅读全文
posted @ 2019-03-12 19:05 Zhentiw 阅读(192) 评论(0) 推荐(0) 编辑
摘要:We can using gzip and crypto with stream: Also unzip it: 阅读全文
posted @ 2019-03-12 14:49 Zhentiw 阅读(341) 评论(0) 推荐(0) 编辑
摘要:Node.js come alone with many Stream API. Stream is useful when handling large trunck of data. For example, we have a big file to read from file system 阅读全文
posted @ 2019-03-12 14:31 Zhentiw 阅读(295) 评论(0) 推荐(0) 编辑
摘要:The act of currying can be described as taking a multivariate function and turning it into a series of unary functions. Let's see an example: This is 阅读全文
posted @ 2019-03-12 00:08 Zhentiw 阅读(152) 评论(0) 推荐(0) 编辑
摘要:By given an array of number, each number indicate the number of step you can move to next index: For example index = 0, value is 4, means at most you 阅读全文
posted @ 2019-03-11 22:07 Zhentiw 阅读(435) 评论(0) 推荐(0) 编辑
摘要:By given a binary tree, and a root node, find the deepest node of this tree. We have way to create node: Way to create tree: Way to construct tree: Th 阅读全文
posted @ 2019-03-11 21:00 Zhentiw 阅读(388) 评论(0) 推荐(0) 编辑
摘要:Let's say given a number of array, you should print out, all the subet of this array. Example: [1, 2] Output: > "" > 1> 2 > 1,2 The number of subset s 阅读全文
posted @ 2019-03-10 22:43 Zhentiw 阅读(135) 评论(0) 推荐(0) 编辑
摘要:This post is similar to previous post. The difference is in this post, we are going to see how to handle both successfuly result and error result by u 阅读全文
posted @ 2019-03-10 21:17 Zhentiw 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Let's say we are going to read some files, return the first file which pass the prediction method, this prediction method can be just check whether th 阅读全文
posted @ 2019-03-10 04:24 Zhentiw 阅读(241) 评论(0) 推荐(0) 编辑
摘要:For example you have a server.js file, and you want to debug some problems; What you can do is: Then go to chrome broswer: You will find node.js targe 阅读全文
posted @ 2019-03-09 18:16 Zhentiw 阅读(171) 评论(0) 推荐(0) 编辑
摘要:It might be possible for our node server has some downtime, no matter it is because server update or simply some crashs in the code. We want to minizi 阅读全文
posted @ 2019-03-09 17:16 Zhentiw 阅读(373) 评论(0) 推荐(0) 编辑
摘要:Let's see how to do load balancing in Node.js. Before we start with the solution, you can do a test to see the ability concurrent requests your curren 阅读全文
posted @ 2019-03-08 22:51 Zhentiw 阅读(236) 评论(0) 推荐(0) 编辑
摘要:When build server, if we have a API endpoint requires some heavy calculation process, it will block the whole world. In this post, we will see how to 阅读全文
posted @ 2019-03-08 22:13 Zhentiw 阅读(304) 评论(0) 推荐(0) 编辑
摘要:/**@abstract * Write your own Math.pow(a int, b int) function * */ function pow (a, b) { let result = 0; let nigate = b = 2) { result = isEven ? pow(a, b / 2) * pow(a, b / 2) : a * pow(... 阅读全文
posted @ 2019-03-08 19:06 Zhentiw 阅读(184) 评论(0) 推荐(0) 编辑
摘要:cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and 阅读全文
posted @ 2019-03-08 18:16 Zhentiw 阅读(293) 评论(0) 推荐(0) 编辑
摘要:Showing how to use 'uqrl' library to do GraphQL in React. 阅读全文
posted @ 2019-03-08 14:36 Zhentiw 阅读(363) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive intege 阅读全文
posted @ 2019-03-08 02:56 Zhentiw 阅读(358) 评论(0) 推荐(0) 编辑
摘要:Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string 阅读全文
posted @ 2019-03-07 04:28 Zhentiw 阅读(525) 评论(0) 推荐(0) 编辑
摘要:// Code goes here function countNegative (M, n, m) { count = 0; i = 0; j = m - 1; while (j >=0 && i < n) { if (M[i][j] < 0) { count += (j+1) i += 1; } else { j... 阅读全文
posted @ 2019-03-06 14:25 Zhentiw 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Let's say we are given an array: We want to get K = 3 smallest items from the array and using Max heap data structure. So this is how to think about i 阅读全文
posted @ 2019-03-05 22:38 Zhentiw 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Shadow DOM is part of the web components specification. It allows us to ship self contained components along with their style and isolate the componen 阅读全文
posted @ 2019-03-05 19:39 Zhentiw 阅读(275) 评论(0) 推荐(0) 编辑
摘要:Forms in React are not easy. T hey are verbose and several lines of code. However, forms with Formik are much simpler. Formik maintains the state of i 阅读全文
posted @ 2019-03-05 19:33 Zhentiw 阅读(210) 评论(0) 推荐(0) 编辑
摘要:You probably have functions that aren’t equipped to accept a Maybe as an argument. And in most cases, altering functions to accept a specific containe 阅读全文
posted @ 2019-03-05 17:28 Zhentiw 阅读(244) 评论(0) 推荐(0) 编辑
摘要:We can dot-chain our way to great success with an instance of Maybe, but there are probably cases where you need to apply the same series of transform 阅读全文
posted @ 2019-03-05 17:15 Zhentiw 阅读(425) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original ar 阅读全文
posted @ 2019-03-05 02:35 Zhentiw 阅读(120) 评论(0) 推荐(0) 编辑
摘要:For example there is a staricase N = 3 | | | | | | | | | | There is N = 3 staricase, for each step, you can either take {1 or 2} step at a time. So as 阅读全文
posted @ 2019-03-05 01:36 Zhentiw 阅读(179) 评论(0) 推荐(0) 编辑
摘要:We've seen how we can transduce from arrays or other iterables, but plain objects aren't iterable in Javascript. In this lesson we'll modify our trans 阅读全文
posted @ 2019-03-04 20:57 Zhentiw 阅读(277) 评论(0) 推荐(0) 编辑
摘要:For example we have 'a' -> 1 'b' -> 2 .. 'z' -> 26 By given "12", we can decode the string to give result "ab" or 'L', 2 ways to decode, your function 阅读全文
posted @ 2019-03-04 01:58 Zhentiw 阅读(294) 评论(0) 推荐(0) 编辑
摘要:We see three varied examples of where natural transformations come in handy. Let's mark the law here for Natural Transformations: Then let's see why w 阅读全文
posted @ 2019-03-01 22:24 Zhentiw 阅读(274) 评论(0) 推荐(0) 编辑
摘要:Natural Transformations, let's explain it by using a coding example, for example, we have a 'Either' holding a value 'a' and we want to transform a' T 阅读全文
posted @ 2019-03-01 21:30 Zhentiw 阅读(261) 评论(0) 推荐(0) 编辑
摘要:We use the traversable instance on List to reimplement Promise.all() type functionality. For example we want to conver: Conver array of Task, into Tas 阅读全文
posted @ 2019-03-01 14:31 Zhentiw 阅读(269) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示