Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Shallow copy



  Deep clone of JavaScript object

In JavaScript world, it's frequently seen object clone. Normally when creating a clone of an object, it's only the reference being cloned but not all contents. In some scenarioes, it's desired to clone all the content instead of just the reference such that any change made to the cloned object will not change the original object. Differences between shallow clone and deep clone can be as simple as: Shallow clone : Only the object reference is cloned but not the content Deep clone : Clone all co...

   JAAVSCRIPT,DEEP CLONE,DEEP COPY,SHALLOW CLONE,SHALLOW COPY     2016-10-31 00:27:24

  A Python assignment trap

Python has no assignment, it only has reference. Assume, we have following code snippet: >>> values = [0, 1, 2] >>> values[1] = values >>> values [0, [...], 2] Why the result is not [0, [0, 1, 2], 2], instead it goes into an infinite loop? To understand this, we need to understand some basics about Python. Python has no variables, it only has labels. When we run: values = [0, 1, 2] Python will first create a list object [0,1,2], then it labels it as values. If we later...

   Python,Assignment,Trap,Shallow copy     2013-07-19 22:08:36

  What does super.clone() do?

Object class has a protected clone() method declared to make it possible for all classes make a clone of itself when needed. The clone() is often used when a new instance of the class is needed while at the same time to maintain the same state as the original object. Any class which wants to have clone enabled has to implement the marker interface Cloneable. If a class which implements Cloneable doesn't override the Object.clone() method, the Object.clone() method will be called to just make a b...

   Cloneable,super.clone(),clone,Java     2015-01-07 05:25:52

  Why doesn't Google copy successful startup ideas?

Google is definitely one of the largest players in Internet world. It owns the most popular search engine, mobile operating system and mapping service. It not only has huge user base but also is extremely rich. It can copy and create any product that is proven to be successful with its talent pool and money. But why doesn't Google copy those successful startup ideas? Based on the current status quo and culture gene of Google, there are several reasons Google doesn't copy startup ideas. First, Go...

   Google,Startup,Copy     2013-09-11 07:03:02

  Implement struct no copy in GoLang

There is some case where some of the struct in GoLang which is not meant to be copied. For example, sometimes a global configuration which should have only one version passed around the whole application and should not be copied and modified. In GoLang, there is no intuitive solution on preventing copying of struct. But there is still some way which can be leveraged to help prevent this while developing the code. The trick is to define some struct implementing sync.Locker interface and has this ...

   GO VET,NOCOPY,NO COPY     2020-09-04 22:24:58

  Let's talk about JavaScript deep clone

In JavaScript, deep clone means creating a brand new object that includes all nested objects, with all properties being completely independent copies. This is different from shallow copying, which only copies the first-level properties, with nested objects being referenced rather than copied. There are multiple ways to perform deep copying in JavaScript, but the best one to use depends on the specific use case. Can use JSON.parse & JSON.stringify? ❌ JSON.parse(JSON.stringify(obj)) is a dep...

   JAVASCRIPT,DEEP CLONE     2023-02-25 08:57:11

  How Kafka achieves high throughput low latency

Kafka is a message streaming system with high throughput and low latency. It is widely adopted in lots of big companies. A well configured Kafka cluster can achieve super high throughput with millions of concurrent writes. How Kafka can achieve this? This post will try to explain some technologies used by Kafka. Page cache + Disk sequential write Every time when Kafka receives a record, it will write it to disk file eventually. But if it writes to disk every time it receives a record, it would ...

   BIG DATA,KAFKA     2019-03-08 09:42:57

  Using JavaScript to operate clipboard

Browsers allow JavaScript to read and write data on clipboard. Generally script should not modify user's clipboard to avoid impacting user expectation, but there are cases where this can indeed bring convenience to users. For example, for some code snippet, user can copy it to clipboard with one click instead of select and copy manually. There are three options for clipboard operation provided in JavaScript/browser: document.execCommand() Asynchronous Clipboard API copy and paste events This p...

   JAVASCRIPT,CLIPBOARD,NAVIGATOR.CLIPBOARD     2021-01-23 23:23:34

  GitHub : Code is the most direct way for programmers to communicate

If not invested by Andreessen Horowitz, GitHub might not be noticed by Forbes, CNN, New York Times. People didn't know this tool because it was very far away from the world -- GitHub is a project hosting service used by programmers.But to some programmers, it is not just a place for project hosting, it is`also the hub for open source projects, a place for programmers improving themselves and a social network for programmers.There are around 3.26 million projects hosted on GitHub currently, inclu...

   GitHub,Open source,Hosting,Social     2012-07-20 11:38:31

  Is Facebook becoming Tencent like?

Recently there is news that Facebook is developing a Reader application which is to compete with Flipboard and Pulse. This reminds me a few movements of Facebook in the past few months. First they built a copy of Snapchat named Poke which failed badly at last. Then they launched a new feature on Instagram named Video on Instagram which allows users to shoot and share short videos up to 15 seconds. This feature is to compete with Vine from Twitter. It seems Instagram wins over Vine on this. You c...

   Facebook,Tencent,Copy     2013-06-24 01:17:27