August 19, 2016
Leetcode 278 - binary search algorithm and discussion
1. http://blog.csdn.net/ebowtang/article/details/50735869
A. Good discussion on the deadloop prevention - make sure that +1 or -1 somewhere
B. discussion of ?
Good discussion of tips:
1. base case
2. overflow issue
http://www.cnblogs.com/airwindow/p/4791234.html
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Friday, August 19, 2016
Wednesday, August 17, 2016
Become a Full-stack .NET Developer - pluralsight.com
August 17, 2016
Start to work on this 3 hours course on pluralsight.com.
Start from beginner level, enjoy the course. Take some notes.
Related course:
http://juliachencoding.blogspot.ca/2016/08/become-full-stack-net-developer.html
Leetcode workout:
1. Leetcode 278 - binary search algorithm and discussion
1. http://blog.csdn.net/ebowtang/article/details/50735869
A. Good discussion on the deadloop prevention - make sure that +1 or -1 somewhere
B. discussion of
Good discussion of tips:
1. base case
2. overflow issue
http://www.cnblogs.com/airwindow/p/4791234.html
Leetcode 125
1. study the code:
http://blog.csdn.net/DERRANTCM/article/details/47651267
Leetcode 125 - write code based on this version
short function name - isalnum - very good name
http://blog.csdn.net/nomasp/article/details/50623165
5 practices - interest journey !
1st practice: failed static analysis - miss a bug - easy to spot --, not++
https://gist.github.com/jianminchen/ed12d3004dbe85815f41fef047d48823
there is a bug in first writing, line 62, shoud be right--; not right++.
static analysis did not catch the bug - be careful next time.
2nd practice:
https://gist.github.com/jianminchen/1e1724c79805d2f40195f08135ec4d02
highlights of practice 2:
1. Fail to pass the online judge
2. line 24 - 27, logic and reasoning has flaws
both are ok
both are failed
A is failed
B is failed
Those are 4 cases - in the specific order as well.
3rd practice:
https://gist.github.com/jianminchen/8f9ae3839499718790180aa58965d3de
highlights of 3rd practice:
1. Fix the bug first, add these line 59 -67 two "else if", one "else", pass online judge
2. But code "else if" from line 59 -67 can be shortened, avoidable.
4th practice:
https://gist.github.com/jianminchen/c6a4318a06aa271de834e1e9c1afa7e4
break else if statement, make it more flat - line 60 - 65, only two if, avoid " else if" in 3rd practice.
5th practice:
https://gist.github.com/jianminchen/8f9ae3839499718790180aa58965d3de
6th practice:
follow the flow of real processing - skip left/right if need, comparison failed, or continue to compare
https://gist.github.com/jianminchen/71421f776948086fd653e441725b3732
3. Hackthon - programming etc.
http://blog.csdn.net/DERRANTCM/article/category/6247554
http://blog.csdn.net/derrantcm/article/details/51512284
4. Review palindrom blog
Start to work on this 3 hours course on pluralsight.com.
Start from beginner level, enjoy the course. Take some notes.
Related course:
http://juliachencoding.blogspot.ca/2016/08/become-full-stack-net-developer.html
Leetcode workout:
1. Leetcode 278 - binary search algorithm and discussion
1. http://blog.csdn.net/ebowtang/article/details/50735869
A. Good discussion on the deadloop prevention - make sure that +1 or -1 somewhere
B. discussion of
Good discussion of tips:
1. base case
2. overflow issue
http://www.cnblogs.com/airwindow/p/4791234.html
Leetcode 125
1. study the code:
http://blog.csdn.net/DERRANTCM/article/details/47651267
Leetcode 125 - write code based on this version
short function name - isalnum - very good name
http://blog.csdn.net/nomasp/article/details/50623165
5 practices - interest journey !
1st practice: failed static analysis - miss a bug - easy to spot --, not++
https://gist.github.com/jianminchen/ed12d3004dbe85815f41fef047d48823
there is a bug in first writing, line 62, shoud be right--; not right++.
static analysis did not catch the bug - be careful next time.
2nd practice:
https://gist.github.com/jianminchen/1e1724c79805d2f40195f08135ec4d02
highlights of practice 2:
1. Fail to pass the online judge
2. line 24 - 27, logic and reasoning has flaws
both are ok
both are failed
A is failed
B is failed
Those are 4 cases - in the specific order as well.
3rd practice:
https://gist.github.com/jianminchen/8f9ae3839499718790180aa58965d3de
highlights of 3rd practice:
1. Fix the bug first, add these line 59 -67 two "else if", one "else", pass online judge
2. But code "else if" from line 59 -67 can be shortened, avoidable.
4th practice:
https://gist.github.com/jianminchen/c6a4318a06aa271de834e1e9c1afa7e4
break else if statement, make it more flat - line 60 - 65, only two if, avoid " else if" in 3rd practice.
5th practice:
https://gist.github.com/jianminchen/8f9ae3839499718790180aa58965d3de
6th practice:
follow the flow of real processing - skip left/right if need, comparison failed, or continue to compare
https://gist.github.com/jianminchen/71421f776948086fd653e441725b3732
http://blog.csdn.net/DERRANTCM/article/category/6247554
http://blog.csdn.net/derrantcm/article/details/51512284
4. Review palindrom blog
JavaScript Style Guide Study - Airbnb
August 17, 2016
Plan to spend 3+ hours to go over the JavaScript Style Guide.
1. Airbnb JavaScript Style Guide() - English Version
https://github.com/airbnb/javascript
2. Airbnb JavaScript Style Guide() - Chinese version
https://github.com/yuche/javascript#table-of-contents
36 Topics
Types
References
Objects
Arrays
Destructuring
Strings
Functions
Arrow Functions
Classes & Constructors
Modules
Iterators and Generators (NO. 11)
Properties
Variables
Hoisting
comparison Operators & Equality
Blocks
Comments
Whitespace
commas
Semicolons
Type Casting & Coercion (No. 21)
Naming Conventions
Accessors
Events
jQuery
ECMAScript 5 Compatibility
ECMAScript 6 Styles
Testing
Performance
Resources
In the Wild
Translation
The JavaScript Style Guide Guide
Chat With Us about JavaScript
Contributors
License
Reading while going through JavaScript style guide from Airbnb:
1. JavaScript spread syntax... - 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator
2. Read JavaScript Array.From - 20 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from
3. Destructuring assignment 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
4. Template literals - 10 minutes reading
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
new terms: back-tick(``), neither double nor single quotes
5. Default parameters -
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
Editorial notes:
1. Write down all new terms in the guide. Understand the terms.
2. Try to memorize all the guide. Design some drills to help.
3. Invest time first to read the good style code, and then, start to write more JavaScript code.
4. Focus on the document, understand why? What to avoid? Good or bad or Excellent idea?
Favorite blogs of day:
web front technologies
1. https://github.com/qiu-deqing/FE-learning
Plan to spend 3+ hours to go over the JavaScript Style Guide.
1. Airbnb JavaScript Style Guide() - English Version
https://github.com/airbnb/javascript
2. Airbnb JavaScript Style Guide() - Chinese version
https://github.com/yuche/javascript#table-of-contents
36 Topics
Types
References
Objects
Arrays
Destructuring
Strings
Functions
Arrow Functions
Classes & Constructors
Modules
Iterators and Generators (NO. 11)
Properties
Variables
Hoisting
comparison Operators & Equality
Blocks
Comments
Whitespace
commas
Semicolons
Type Casting & Coercion (No. 21)
Naming Conventions
Accessors
Events
jQuery
ECMAScript 5 Compatibility
ECMAScript 6 Styles
Testing
Performance
Resources
In the Wild
Translation
The JavaScript Style Guide Guide
Chat With Us about JavaScript
Contributors
License
1. JavaScript spread syntax... - 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator
2. Read JavaScript Array.From - 20 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from
3. Destructuring assignment 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
4. Template literals - 10 minutes reading
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
new terms: back-tick(``), neither double nor single quotes
5. Default parameters -
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals
Editorial notes:
1. Write down all new terms in the guide. Understand the terms.
2. Try to memorize all the guide. Design some drills to help.
3. Invest time first to read the good style code, and then, start to write more JavaScript code.
4. Focus on the document, understand why? What to avoid? Good or bad or Excellent idea?
Favorite blogs of day:
web front technologies
1. https://github.com/qiu-deqing/FE-learning
Tuesday, August 16, 2016
Leetcode 380 - Insert, delete, getRandom() O(1) time - Practice 4
August 16, 2016
The first 3 practices:
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1.html
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1_16.html
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1_89.html
Read the blog:
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
Java code from the above blog:
https://gist.github.com/jianminchen/9561828feda21bac20bc9ba4da0d13c8
4th practice using C#:
https://gist.github.com/jianminchen/7741fabf57413ccbb1080f6f691bb532
Highlights of 4th practice:
1. Thinking problem solving using an array:
Insertion of array is to append the number at the end of array, O(1);
Delete a number from the array, for example, at index position i of array with length n, then, all elements from i+1 to n-1 should be shifted to left one position - time complexity is O(n-i) = O(n)
getRandom() - time complexity is O(1), just get a random number r from 0 to n, and then, return arr[r].
Array value can be any integer number, and in the range of Int32.min - Int32.max, so given an integer value, it may not be in the array; if it is, to find the index of array to hold the value, we need to look up a hashmap with value/ index of array pair first.
So, in order to make it O(1) for the deletion, we can use extra space to speed up time to O(1). The idea is to move last number in the array to the position of deleted element.
Extra space - a hashmap to store each number in the array as key, and the value is the position in the array.
4. Introduce new design in the practice?
arrayDeletionO1 - line 150 API - array deletion, arrayDeletionO1 (Dictionary<Int32, Int32> arr, Dictionary<Int32, Int32> map, int val)
- implement the array deletion in time complexity O(1)
move - line 173 API - array move - move an entry from the dictionary from one location to another location. move(Dictionary<Int32, Int32> dict, int from, int to)
mapUpdateForArrayDeletion - line 129 - hashmap update - mapUpdateForArrayDeletion(Dictionary<Int32, Int32> arr, Dictionary<Int32, Int32> map, int val)
Cons and pros for modified deletion for the array-like data structure:
1. Cons: If the array is sorted, then the order is lost. No longer in the order.
2. Study Array API for C, C++, C#, JavaScript, none of them has API like this. Why?
Array - JavaScript
http://juliachencoding.blogspot.ca/2016/07/javascript-array-mozilla-60-minutes.html
C# array
http://juliachencoding.blogspot.ca/2016/06/array-class-c-c-javascript-java.html
3. For the deletion, update can be done directly instead of first deletion, and then move of the last one to the deleted item's position. line 182, line 183 can be merged to one line - update.
4th practice using C#:
https://gist.github.com/jianminchen/7741fabf57413ccbb1080f6f691bb532
4. JavaScript array is sparse, the array is not contiguous. For Leetcode 380, Julia thought about array deletion design, if the array is leaving as sparse after deletion, then, getRandom() can not be O(1). If the sparse slot is selected by random algorithm, need to select another one.
Related articles:
1. Uber map article:
http://goo.gl/nmRv18
Google search keyword:
red-black tree - C++ implements the map
http://stackoverflow.com/questions/5288320/why-is-stdmap-implemented-as-a-red-black-tree
2. Uber algorithm question:
https://goo.gl/fWq132
The first 3 practices:
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1.html
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1_16.html
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1_89.html
Read the blog:
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
Java code from the above blog:
https://gist.github.com/jianminchen/9561828feda21bac20bc9ba4da0d13c8
4th practice using C#:
https://gist.github.com/jianminchen/7741fabf57413ccbb1080f6f691bb532
Highlights of 4th practice:
1. Thinking problem solving using an array:
Insertion of array is to append the number at the end of array, O(1);
Delete a number from the array, for example, at index position i of array with length n, then, all elements from i+1 to n-1 should be shifted to left one position - time complexity is O(n-i) = O(n)
getRandom() - time complexity is O(1), just get a random number r from 0 to n, and then, return arr[r].
Array value can be any integer number, and in the range of Int32.min - Int32.max, so given an integer value, it may not be in the array; if it is, to find the index of array to hold the value, we need to look up a hashmap with value/ index of array pair first.
So, in order to make it O(1) for the deletion, we can use extra space to speed up time to O(1). The idea is to move last number in the array to the position of deleted element.
Extra space - a hashmap to store each number in the array as key, and the value is the position in the array.
4. Introduce new design in the practice?
arrayDeletionO1 - line 150 API - array deletion, arrayDeletionO1 (Dictionary<Int32, Int32> arr, Dictionary<Int32, Int32> map, int val)
- implement the array deletion in time complexity O(1)
move - line 173 API - array move - move an entry from the dictionary from one location to another location. move(Dictionary<Int32, Int32> dict, int from, int to)
mapUpdateForArrayDeletion - line 129 - hashmap update - mapUpdateForArrayDeletion(Dictionary<Int32, Int32> arr, Dictionary<Int32, Int32> map, int val)
Cons and pros for modified deletion for the array-like data structure:
1. Cons: If the array is sorted, then the order is lost. No longer in the order.
2. Study Array API for C, C++, C#, JavaScript, none of them has API like this. Why?
Array - JavaScript
http://juliachencoding.blogspot.ca/2016/07/javascript-array-mozilla-60-minutes.html
C# array
http://juliachencoding.blogspot.ca/2016/06/array-class-c-c-javascript-java.html
3. For the deletion, update can be done directly instead of first deletion, and then move of the last one to the deleted item's position. line 182, line 183 can be merged to one line - update.
4th practice using C#:
https://gist.github.com/jianminchen/7741fabf57413ccbb1080f6f691bb532
4. JavaScript array is sparse, the array is not contiguous. For Leetcode 380, Julia thought about array deletion design, if the array is leaving as sparse after deletion, then, getRandom() can not be O(1). If the sparse slot is selected by random algorithm, need to select another one.
Related articles:
1. Uber map article:
http://goo.gl/nmRv18
Google search keyword:
red-black tree - C++ implements the map
http://stackoverflow.com/questions/5288320/why-is-stdmap-implemented-as-a-red-black-tree
2. Uber algorithm question:
https://goo.gl/fWq132
Leetcode 380 - Insert, delete, getRandom() O(1) time - Practice 3
August 16, 2016
After first 2 practices, Julia read the blog:
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
3rd practice using C#:
https://gist.github.com/jianminchen/9a8aef6220d285aac3f22abac984e0b3
After first 2 practices, Julia read the blog:
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
3rd practice using C#:
https://gist.github.com/jianminchen/9a8aef6220d285aac3f22abac984e0b3
Leetcode 380 - Insert, delete, getRandom() O(1) time - Practice 2
August 16, 2016
First practice on Leetcode 380:
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1.html
Add one more function - design API - Julia likes to design API, after she tried to memorize all APIs of JavaScript array.
Second practice - one function:
https://gist.github.com/jianminchen/84a0945eb49d3ae7af36b4ca5f0f0c41
Blog:
1. CSS style -
http://codeguide.bootcss.com/
2. http://www.ruanyifeng.com/blog/2012/10/javascript_module.html
First practice on Leetcode 380:
http://juliachencoding.blogspot.ca/2016/08/leetcode-380-insert-delete-getrandom-o1.html
Add one more function - design API - Julia likes to design API, after she tried to memorize all APIs of JavaScript array.
Second practice - one function:
https://gist.github.com/jianminchen/84a0945eb49d3ae7af36b4ca5f0f0c41
Design API -
move an entry from the dictionary from one location
to another
location
assume that
dictionary contains the entry of from
assume that
to position is available in the dictionary
public bool move(Dictionary<Int32,
Int32> dict, int from, int to)
Blog:
1. CSS style -
http://codeguide.bootcss.com/
2. http://www.ruanyifeng.com/blog/2012/10/javascript_module.html
Leetcode 380 - Insert, delete, getRandom() O(1) time - Practice 1
August 8, 2016
Problem statement:
Problem statement:
Design a data structure that supports all following operations in average O(1) time.
insert(val): Inserts an item val to the set if not already present.remove(val): Removes an item val from the set if present.getRandom: Returns a random element from current set of elements. Each element must have the same probability of being returned.
Go over the website Java code, write a C# version:
http://www.programcreek.com/2014/08/leetcode-insert-delete-getrandom-o1-java/
Java code from the above webpage:
https://gist.github.com/jianminchen/b6ab09a8a047db42da4ad663036d621a
C# code written by Julia
https://gist.github.com/jianminchen/9ebfbe7462c17689344578be31c804c0
Highlights of practice:
1. Spent 20+ minutes to write the function remove(int val)
2. Put test cases into main function, test the code to understand the problem.
3. Did not understand the design, why two hashmaps are used.
4. Concern about function remove - line 133 - 165
The function is not readable - one function does so many things - break Single Responsibility Principle.
Java code from the above webpage:
https://gist.github.com/jianminchen/b6ab09a8a047db42da4ad663036d621a
C# code written by Julia
https://gist.github.com/jianminchen/9ebfbe7462c17689344578be31c804c0
Highlights of practice:
1. Spent 20+ minutes to write the function remove(int val)
2. Put test cases into main function, test the code to understand the problem.
3. Did not understand the design, why two hashmaps are used.
4. Concern about function remove - line 133 - 165
The function is not readable - one function does so many things - break Single Responsibility Principle.
Sunday, August 14, 2016
Microsoft Development Service - watch and learn
August 14, 2016
Great time to watch and learn. First thing in the Sunday morning is to relax and learn.
Blogs to read:
http://stories.visualstudio.com/bing-continuous-delivery/
Videos:
1. Full Keynote: The Future of Microsoft Tools and Services for the New Role of Developers
https://www.youtube.com/watch?v=Gks7Ngzt5Yw
2. Keynote: Visual Studio 2015 - Any App, Any Developer
https://www.youtube.com/watch?v=Nj1luMpj7mI
Blogs to read:
1. Leetcode 380: (code study: Leetcode blogs)
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
2. Leetcode 380 - Insert Delete GetRandom O(1)
https://leetcode.com/problems/insert-delete-getrandom-o1/
3. Read the article
http://www.programcreek.com/2014/08/leetcode-insert-delete-getrandom-o1-java/
4. Read Uber map article:
http://goo.gl/nmRv18
Google search keyword:
red-black tree - C++ implements the map
2.
https://goo.gl/fWq132
Great time to watch and learn. First thing in the Sunday morning is to relax and learn.
Blogs to read:
http://stories.visualstudio.com/bing-continuous-delivery/
Videos:
1. Full Keynote: The Future of Microsoft Tools and Services for the New Role of Developers
https://www.youtube.com/watch?v=Gks7Ngzt5Yw
2. Keynote: Visual Studio 2015 - Any App, Any Developer
https://www.youtube.com/watch?v=Nj1luMpj7mI
Blogs to read:
1. Leetcode 380: (code study: Leetcode blogs)
http://www.guoting.org/leetcode/leetcode-380-insert-delete-getrandom-o1/
2. Leetcode 380 - Insert Delete GetRandom O(1)
https://leetcode.com/problems/insert-delete-getrandom-o1/
3. Read the article
http://www.programcreek.com/2014/08/leetcode-insert-delete-getrandom-o1-java/
4. Read Uber map article:
http://goo.gl/nmRv18
Google search keyword:
red-black tree - C++ implements the map
2.
https://goo.gl/fWq132
Friday, August 12, 2016
Clip: cropping an image - CSS learning and sharing on JSFiddle
August 12, 2016
Clip is the CSS feature to clip an image using scripts. Julia spent more than one hour to work on a few lines of CSS code, and then, she chose to use a specific image to help.
If you have an image with 500px x 500px, you may like to get one small image with size 100px x 100px without using Microsoft paint to cut and save as a new file. The solution is to use CSS clip.
Basics to find out the solution:
CSS:
1. position relative/ absolute
2. rect
3. clip
4. an example to explain how to put together
5. play with Firefox firebug, and then figure out CSS settings.
Study the article:
http://www.xul.fr/en/css/clip.php
Spent more than 1 hour to figure out how to set up .clipzone width and height. There are a few ways to set up CSS, but she likes to write down her tips to solve the problem.
After more than one hour confusion, she decided to customize an image with some grids and text, with size of 500px x 500px, see the following:
With a few mistakes, she figured out how to configure them quickly. Let us talk about a problem, and then, solve the problem using CSS clip property based on the article (ref. 2).
Problem statement:
How to clip the image 100px x 100px in the center of the above image, with text 13?
Here is the image:
The element is to be cropped in an outer container, and the clip zone
- Julia's tip 1: make the zone the whole image:
.clipzone
{
position: relative;
width: 500px;
height: 500px;
overflow: hidden;
}
.clipped
{
position: absolute;
}
<div class="clipzone"> <img class="clipped" id="image1" src="" /> </div>
This container is integrated in the flow of the contents of the page with the relative position and allows the content to have the absolution position. The property overflow: hidden avoids exceeding the limit of the container.
so add the clip css property and value into class clipped, and add this rule:
.clipped
{
position: absolute;
clip: rect(200px, 200px, 300px, 300px); /* top left right bottom*/
}
And then, the image using clip CSS property will be:
Julia's tip 2:
Add one more rule:
margin-left: -200px;
With the above rule, the clipped image will be positioned at 0 position; in other words, to get any image, for example,
with text: 11, set margin-left: 0px;
with text: 12: set margin-left: -100px;
with text: 13: set margin-left: -200px;
with text: 14, set margin-left: -300px;
with text: 15, set margin-left: -400px;
so the image is always positioned the same place.
References:
1. http://www.w3schools.com/cssref/pr_pos_clip.asp
2. http://www.xul.fr/en/css/clip.php
Actionable Items:
1. clip an image using CSS
https://jsfiddle.net/jianminchen/ksdcgomx/
2. original image vs clipped image
https://jsfiddle.net/jianminchen/hxgakk5n/
1. clipped image: 2. orginal image comparison to the clipped image
Blog reading:
1. Google keyword search: JavaScript Separate of concern
how to structure JavaScript better?
Study the code - example to follow
http://stephen-young.me.uk/2013/01/05/maintainable-js-with-modules.html
Watch and learn: Microsoft agile development - Bing
Microsoft Development Services for the DevOps Era
Clip is the CSS feature to clip an image using scripts. Julia spent more than one hour to work on a few lines of CSS code, and then, she chose to use a specific image to help.
If you have an image with 500px x 500px, you may like to get one small image with size 100px x 100px without using Microsoft paint to cut and save as a new file. The solution is to use CSS clip.
Basics to find out the solution:
CSS:
1. position relative/ absolute
2. rect
3. clip
4. an example to explain how to put together
5. play with Firefox firebug, and then figure out CSS settings.
Study the article:
http://www.xul.fr/en/css/clip.php
Spent more than 1 hour to figure out how to set up .clipzone width and height. There are a few ways to set up CSS, but she likes to write down her tips to solve the problem.
After more than one hour confusion, she decided to customize an image with some grids and text, with size of 500px x 500px, see the following:
With a few mistakes, she figured out how to configure them quickly. Let us talk about a problem, and then, solve the problem using CSS clip property based on the article (ref. 2).
Problem statement:
How to clip the image 100px x 100px in the center of the above image, with text 13?
Here is the image:
The element is to be cropped in an outer container, and the clip zone
- Julia's tip 1: make the zone the whole image:
.clipzone
{
position: relative;
width: 500px;
height: 500px;
overflow: hidden;
}
.clipped
{
position: absolute;
}
<div class="clipzone"> <img class="clipped" id="image1" src="" /> </div>
This container is integrated in the flow of the contents of the page with the relative position and allows the content to have the absolution position. The property overflow: hidden avoids exceeding the limit of the container.
so add the clip css property and value into class clipped, and add this rule:
.clipped
{
position: absolute;
clip: rect(200px, 200px, 300px, 300px); /* top left right bottom*/
}
And then, the image using clip CSS property will be:
Julia's tip 2:
Add one more rule:
margin-left: -200px;
With the above rule, the clipped image will be positioned at 0 position; in other words, to get any image, for example,
with text: 11, set margin-left: 0px;
with text: 12: set margin-left: -100px;
with text: 13: set margin-left: -200px;
with text: 14, set margin-left: -300px;
with text: 15, set margin-left: -400px;
so the image is always positioned the same place.
References:
1. http://www.w3schools.com/cssref/pr_pos_clip.asp
2. http://www.xul.fr/en/css/clip.php
Actionable Items:
1. clip an image using CSS
https://jsfiddle.net/jianminchen/ksdcgomx/
2. original image vs clipped image
https://jsfiddle.net/jianminchen/hxgakk5n/
1. clipped image: 2. orginal image comparison to the clipped image
1. Google keyword search: JavaScript Separate of concern
how to structure JavaScript better?
Study the code - example to follow
http://stephen-young.me.uk/2013/01/05/maintainable-js-with-modules.html
Watch and learn: Microsoft agile development - Bing
Microsoft Development Services for the DevOps Era
Thursday, August 11, 2016
JavaScript - a programmer random thoughts
August 11, 2016
Julia likes to have a small research every day, later she can add some thoughts for the topic. Today the topic is "how to balance coding writing vs reading API documents".
Julia likes to have a small research every day, later she can add some thoughts for the topic. Today the topic is "how to balance coding writing vs reading API documents".
In order to write good JavaScript code, read a lot of JavaScript code first. She did write JavaScript/ CSS/ Html code 8 hours nonstop at work, she likes to take a break while she was at home enjoying the evening.
Julia reviewed the blog about JavaScript while watching interviews.
Interviews she enjoyed - Vogue 73 questions series:
1. Serena Williams
Serena offers 1 hour
$100 master class - video class - She is really good at teaching, she shows in
the interview how to make a hidden drop shot.
2. Iggy Azalea - 7 3 questions
https://www.youtube.com/watch?v=AMh5f8xRLRE
3. Song writer, singer Swift Taylor
https://www.youtube.com/watch?v=XnbCSboujF4
Random thoughts:
1. How to stay calm, answer questions very well?
2. Airbnb JavaScript Style Guide() - English Version
https://github.com/airbnb/javascript
Reading while going through JavaScript style guide from Airbnb:
1. JavaScript spread syntax... - 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator
3. Read JavaScript Array.From - 20 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from
2. Celebrate the day by learning CSS, working on clipping image etc.:
A. clip techniques - outside - relative, inside, absolute
how to define it and practice it!
http://www.xul.fr/en/css/clip.php
B. Text over the image:
https://css-tricks.com/text-blocks-over-image/
C. Bootstrap 3 Thumbnail Slider / Carousel
http://www.bootply.com/XeZvDD059P#
3. Song writer, singer Swift Taylor
https://www.youtube.com/watch?v=XnbCSboujF4
Random thoughts:
1. How to stay calm, answer questions very well?
2. Airbnb JavaScript Style Guide() - English Version
https://github.com/airbnb/javascript
Reading while going through JavaScript style guide from Airbnb:
1. JavaScript spread syntax... - 10 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator
3. Read JavaScript Array.From - 20 minutes
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from
2. Celebrate the day by learning CSS, working on clipping image etc.:
A. clip techniques - outside - relative, inside, absolute
how to define it and practice it!
http://www.xul.fr/en/css/clip.php
B. Text over the image:
https://css-tricks.com/text-blocks-over-image/
C. Bootstrap 3 Thumbnail Slider / Carousel
http://www.bootply.com/XeZvDD059P#
Monday, August 8, 2016
Designing Fluent APIs in C# - pluralsight.com
August 8, 2016
Plan to work on course - Designing Fluent APIs in C#
http://app.pluralsight.com/author/floyd-may
video to watch:
https://www.youtube.com/watch?v=uKtMwmWv6Q0
Plan to work on course - Designing Fluent APIs in C#
http://app.pluralsight.com/author/floyd-may
video to watch:
https://www.youtube.com/watch?v=uKtMwmWv6Q0
Mastering C# 4.0 - pluralsight.com
August 8, 2016
Plan to work on this course - Mastering C# 4.0 - pluralsight.com, 11 hours.
http://app.pluralsight.com/author/jon-skeet
Plan to work on this course - Mastering C# 4.0 - pluralsight.com, 11 hours.
http://app.pluralsight.com/author/jon-skeet
C# Design Strategies - pluralsight.com
August 8, 2016
Plan to work on this course on pluralsight.com - C# design strategies - 3 hours.
http://app.pluralsight.com/author/jon-skeet
Plan to work on this course on pluralsight.com - C# design strategies - 3 hours.
http://app.pluralsight.com/author/jon-skeet
.NET distributed system architecture - pluralsight.com
August 8, 2016
Plan to work on the course - .NET distributed system architecture - 5 hour 30 minutes
Lecturer's website:
http://app.pluralsight.com/author/scott-seely
Plan to work on the course - .NET distributed system architecture - 5 hour 30 minutes
Lecturer's website:
http://app.pluralsight.com/author/scott-seely
Become a Full-stack .NET Developer - Architecture and Testing - pluralsight.com
August 8, 2016
Plan to study the course:
Become a Full-stack .NET Developer - Architecture and Testing
Lecturer's website:
http://app.pluralsight.com/author/mosh-hamedani
Notes:
1. Remaining use cases
2. Modularize JavaScript Code
3. Refactoring towards the clean architecture
4. Programming against interfaces
5. Test Controllers
6. Test Repositories
7. Adding Integration Tests
Modularizing JavaScript Code - 40m 56s
Introduction
Extracting JavaScript Code
Revealing Module Pattern
Refactoring using Revealing Module Patten
Cleaning the init Method
Applying the DRY Principle
Better Separation of Concerns
Module Dependencies
Physical Separation
Optimization
Exercise
Code Review
Summary
Programming Against Interfaces
Introduction
Dependency Inversion Principles
Extracting Interfaces
Dependency Injection
Adding Ninject
Does Entity Framework Really implement the Repository Pattern?
Package Dependencies
Restructure the Application
Complexity Fallacy
Productivity Fallacy
Exercise
Refactoring Data Annotations
Complexity Fallacy
Productivity Fallacy
Exercise
Refactoring Data Annotations
Summary
Testing Controllers
Introduction
Extracting Queries
Repository pattern
When to use the repository pattern
extracting repositories
extracting queries with eager loading
exercise
code review
clean architecture
decoupling from entity framework
unit of work pattern
implementing the unit of work
consolidating dependencies
summary
Programming Against interfaces
introduction
Dependency inversion principle
extracting interfaces
Repository pattern is already in entity framework - no need to use? it depends.
Design to solve problems - repository pattern
complexity of design - be pragmatic
meidum/ large projects
problems :
complex queries/ fat controllers/ fat services
SQL Injection etc. website common attacks -
SQL injection, XSS, CSRF, preventing CSRF attacks -
http://www.veracode.com/security/xss
Plan to study the course:
Become a Full-stack .NET Developer - Architecture and Testing
Lecturer's website:
http://app.pluralsight.com/author/mosh-hamedani
Notes:
1. Remaining use cases
2. Modularize JavaScript Code
3. Refactoring towards the clean architecture
4. Programming against interfaces
5. Test Controllers
6. Test Repositories
7. Adding Integration Tests
Modularizing JavaScript Code - 40m 56s
Introduction
Extracting JavaScript Code
Revealing Module Pattern
Refactoring using Revealing Module Patten
Cleaning the init Method
Applying the DRY Principle
Better Separation of Concerns
Module Dependencies
Physical Separation
Optimization
Exercise
Code Review
Summary
Programming Against Interfaces
Introduction
Dependency Inversion Principles
Extracting Interfaces
Dependency Injection
Adding Ninject
Does Entity Framework Really implement the Repository Pattern?
Package Dependencies
Restructure the Application
Complexity Fallacy
Productivity Fallacy
Exercise
Refactoring Data Annotations
Complexity Fallacy
Productivity Fallacy
Exercise
Refactoring Data Annotations
Summary
Testing Controllers
Introduction
Extracting Queries
Repository pattern
When to use the repository pattern
extracting repositories
extracting queries with eager loading
exercise
code review
clean architecture
decoupling from entity framework
unit of work pattern
implementing the unit of work
consolidating dependencies
summary
Programming Against interfaces
introduction
Dependency inversion principle
extracting interfaces
Repository pattern is already in entity framework - no need to use? it depends.
Design to solve problems - repository pattern
complexity of design - be pragmatic
meidum/ large projects
problems :
complex queries/ fat controllers/ fat services
SQL Injection etc. website common attacks -
SQL injection, XSS, CSRF, preventing CSRF attacks -
http://www.veracode.com/security/xss
C# Extension Methods - pluralsight.com
August 8, 2016
Plan to study the course "C# Extension Methods". 3 hours course.
Lecturer's website:
http://app.pluralsight.com/author/elton-stoneman
August 8, 1 hour, Introduction Extension Methods
Plan to study the course "C# Extension Methods". 3 hours course.
Lecturer's website:
http://app.pluralsight.com/author/elton-stoneman
August 8, 1 hour, Introduction Extension Methods
Sunday, August 7, 2016
A small research - tennis coaching vs algorithm lecturing
August 7, 2016
Julia likes to pick up a small topic to do some research and practice her research muscle. Since she was amazed about USATP master professional Rick Macci's teaching video, and amazed how good the presentation is. A lot of technologies are applied on tennis coaching and tennis matches. For example, on the tennis court, on the grand slam matches, there are hundreds of camera on the court, hundreds of technologies on speed measuring, and all other things.
Here is the link:
https://www.youtube.com/watch?v=5MHugAF2DiQ
1. Lecture on Roger Federer's tennis forehand stroke, and show 3D technologies how to do analysis
2. Before vs After, two videos are comparing.
3. Statistics: How many views? over half a million views. -
4. Producer: USPTA
- how good USPTA can utilize the technologies and help the teaching.
Lecture notes:
Forehand - 7 steps: (P, J, E, T, F, FS, F)
Preparation
Joint angles
Elbow Extension
Tap the dog
The Flip
Forward Swing
The Finish
Goal: Racket Speed, keep the ball in the court
And teaching lectures she spent time to work on this weekend:
Algorithm: count inversion
extended merge sort:
Julia also likes the lecture content about count inversion - merge sort, the examples and discussions.
So, Julia likes to study those lecture notes, take time to enjoy reading.
1. http://www.cs.umd.edu/class/fall2009/cmsc451/lectures/Lec08-inversions.pdf
Standford University:
https://www.coursera.org/learn/algorithm-design-analysis/lecture/GFmmJ/o-n-log-n-algorithm-for-counting-inversions-i
https://www.coursera.org/learn/algorithm-design-analysis/lecture/IUiUk/o-n-log-n-algorithm-for-counting-inversions-ii
Julia started to work on the double alley drill - learning is fun!
one more:
Julia likes to pick up a small topic to do some research and practice her research muscle. Since she was amazed about USATP master professional Rick Macci's teaching video, and amazed how good the presentation is. A lot of technologies are applied on tennis coaching and tennis matches. For example, on the tennis court, on the grand slam matches, there are hundreds of camera on the court, hundreds of technologies on speed measuring, and all other things.
Here is the link:
https://www.youtube.com/watch?v=5MHugAF2DiQ
1. Lecture on Roger Federer's tennis forehand stroke, and show 3D technologies how to do analysis
2. Before vs After, two videos are comparing.
3. Statistics: How many views? over half a million views. -
4. Producer: USPTA
- how good USPTA can utilize the technologies and help the teaching.
Lecture notes:
Forehand - 7 steps: (P, J, E, T, F, FS, F)
Preparation
Joint angles
Elbow Extension
Tap the dog
The Flip
Forward Swing
The Finish
Goal: Racket Speed, keep the ball in the court
And teaching lectures she spent time to work on this weekend:
Algorithm: count inversion
extended merge sort:
Julia also likes the lecture content about count inversion - merge sort, the examples and discussions.
So, Julia likes to study those lecture notes, take time to enjoy reading.
1. http://www.cs.umd.edu/class/fall2009/cmsc451/lectures/Lec08-inversions.pdf
https://www.coursera.org/learn/algorithm-design-analysis/lecture/GFmmJ/o-n-log-n-algorithm-for-counting-inversions-i
https://www.coursera.org/learn/algorithm-design-analysis/lecture/IUiUk/o-n-log-n-algorithm-for-counting-inversions-ii
Julia learns tennis from over 20 top coaches in the world and also actively practice what she learns through lessons:
Here is one of them she learned from the coach -
https://www.youtube.com/watch?v=n7ApnK3BGcUJulia started to work on the double alley drill - learning is fun!
one more:
Friday, August 5, 2016
Count inversions - Extended merge sort - 3 Lecture Notes Study
August 5, 2016
Choose topic: extended merge sort
Algorithm: count inversions
count inversions - extended merge sort
1. http://jane4532.blogspot.ca/2013/06/zz-google-onsite-interview.html
2. http://www.geeksforgeeks.org/counting-inversions/
3. http://www.cs.umd.edu/class/fall2009/cmsc451/lectures/Lec08-inversions.pdf
4. https://www.cp.eng.chula.ac.th/~piak/teaching/algo/algo2008/count-inv.htm
Play to win; stop Recognize when you are using negative self-talks and replace it with positive; when in doubt, remember: Play to win.
Memorize 8 tips to help you to perform to your highest potential in Tennis (? code practice, etc.):
1. Let go of what others think
2. Perform for yourself, not to impress or to "not disappoint" others
3. Accept that you will make mistakes, and let them go
4. Focus on what you can control
5. Recognize when you are using negative self-talk and replace it with positive
6. Rather than performing perfectly, perform to see improvement
7. Be objective about your performance, not subjective
8. Focus on the Journey, not the Destination
Play not to lose or Play to win - Julia plays to win!
Choose topic: extended merge sort
Algorithm: count inversions
count inversions - extended merge sort
1. http://jane4532.blogspot.ca/2013/06/zz-google-onsite-interview.html
2. http://www.geeksforgeeks.org/counting-inversions/
3. http://www.cs.umd.edu/class/fall2009/cmsc451/lectures/Lec08-inversions.pdf
4. https://www.cp.eng.chula.ac.th/~piak/teaching/algo/algo2008/count-inv.htm
5. https://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/05DivideAndConquerI.pdf
6. http://www.cs.colostate.edu/~cs320/Slides/05_inv.pdf
problem statement:
In merge sort we do not swap all elements that are out of order with each other, we make larger distance "swaps".
Actionable Items:
Julia, write down favorite notes one sentence a time, on page 16, 17
Q. How to count inversions (a,b) with a ∈ A and b ∈ B?
A. Easy if A and B are sorted!
sort A sort B
3 7 10 14 18 2 11 16 17 23
binary search to count inversions (a, b) with a ∈ A and b ∈ B
3 7 10 14 18 2 11 16 17 23
5 2 1 1 0
-------
6. http://www.cs.colostate.edu/~cs320/Slides/05_inv.pdf
problem statement:
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion count is the maximum.
Formally speaking, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j
Formally speaking, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j
Example:
The sequence 2, 4, 1, 3, 5 has three inversions (2, 1), (4, 1), (4, 3).
The sequence 2, 4, 1, 3, 5 has three inversions (2, 1), (4, 1), (4, 3).
Lecture Notes -
1. First lecture study:
1. How many inversions at most in the array n?
n(n-1)/2, special case, like {n, n-1, ..., 1}, any two nodes in the array is one inversion pair.
or: What is the maximum number of inversions for a list of length n?
n(n-1)/2
2. If each inversion is counted once, then the time of the algorithm is O(n^2), n is the number of elements in the array. Not optimal, we should not count each inversion.
3. Ideas to solve the algorithm:
Bubble sort?
Selection sort?
Insertion sort?
These are O(n^2)
Bubble and insertion sort count each individual inversion. To do better we must not count each individual inversion.
So, better algorithm is to beat O(n^2), using merge sort, nlogn - divide and conquer - sort and count inversion in the same time.
In merge sort we do not swap all elements that are out of order with each other, we make larger distance "swaps".
Questions: Sorting and counting inversion - merge part how to count the inversions.
Keywords in the lecture notes (7):
Collaborative filtering
inversions
Meta-search tools
Rank analysis
Recurrence Analysis - T(n) = 2 T(n/2) + cn
Rank analysis
Recurrence Analysis - T(n) = 2 T(n/2) + cn
similarity/ dissimilarity / in the middle
the number of out of place rankings
1. Merging part with diagram: <- Julia, can you draw a diagram as well
2. Count Inversions: Algorithm pseudo code - write down here:
2. 2nd Lecture Notes Study:
Julia, write down favorite notes one sentence a time, on page 16, 17
-------
Counting inversions: how to combine two subproblems?Q. How to count inversions (a,b) with a ∈ A and b ∈ B?
A. Easy if A and B are sorted!
Warmup algorithm.
Sort A and B.
For each element b ∈ B,
- binary search in A to find how elements in A are greater than b.
list A list B
7 10 18 3 14 17 23 2 11 16sort A sort B
3 7 10 14 18 2 11 16 17 23
binary search to count inversions (a, b) with a ∈ A and b ∈ B
3 7 10 14 18 2 11 16 17 23
5 2 1 1 0
-------
3. 3rd Lecture Notes Study: (Inversions Count)
http://www.cs.umd.edu/class/fall2009/cmsc451/lectures/Lec08-inversions.pdfGreat tips for sports coaching, https://t.co/6m29a8l1z0— jianmin chen (@jianminchen) July 22, 2016
Memorize 8 tips to help you to perform to your highest potential in Tennis (? code practice, etc.):
1. Let go of what others think
2. Perform for yourself, not to impress or to "not disappoint" others
3. Accept that you will make mistakes, and let them go
4. Focus on what you can control
5. Recognize when you are using negative self-talk and replace it with positive
6. Rather than performing perfectly, perform to see improvement
7. Be objective about your performance, not subjective
8. Focus on the Journey, not the Destination
Play not to lose or Play to win - Julia plays to win!
Some people play not to lose. I play to win each and every second I'm on court. #SpeedTakes aggression. pic.twitter.com/ae5xlriogs— Simona Halep (@Simona_Halep) July 2, 2016
Subscribe to:
Posts (Atom)




