Vanilla JS only please  That is, its the output should be an object that only contains data, and ignores the original's methods/prototype.  Complex data structures that inherit from the default Object, like Array, can be copied in a shallow manner, as references.  The way I do it now is:  function shallowCopyObjectData(obj) {   output = {};   for (var i in item) {     output[i] = obj[i];   }   return output; };   The other way I've seen is:  function shallowCopyObjectData(obj) {   return JSON.parse(JSON.stringify(obj)); };   What is the most performant way to do it?  I've made a running jsPerf to compare speeds.  If you come up with a solution, please feel free to fork and add:   Edit @Barmar: I know a , but it asked about the fastest way to clone an object, which implied a deep copy that keep the constructor, prototype, etc.  This question asks about the fastest way to copy just the data in the top level
What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but . I've done things like obj = JSON.parse(JSON.stringify(o)); but question the efficiency.  I've also seen recursive copying functions with various flaws.  I'm surprised no canonical solution exists.
Tracking down where disk space has gone on Linux? I want to set an environment variable from the command prompt and then be able to access it globally (for instance, I should see it by going to System -> Environment Variables).    When I use the set command, it isn't accessible in a new cmd session.  set NEWVAR=SOMETHING echo %NEWVAR%   Related questions: Shortcut or button for copying posted code from Stack Overflow I might just be lazy, but do you ever find it tiresome to select all the source code from a large post on Stack&nbsp;Overflow to copy it?  I would like a feature, possibly a Firefox extension, but preferably a JavaScript script, for automatically copying source examples to the clipboard. It's no big deal for a small snippet, but a 1000+ line posting is cumbersome to copy.  Do you guys have a better way of copying large source posts? I'm using Firefox 3.5.5 on Windows&nbsp;7. Is there a geometrical method to prove $x<\frac{\sin x +\tan x}{2}$? Suppose $x \in (0,\frac{\pi}{2})$ and we want to prove $$x&lt;\frac{\sin x +\tan x}{2}$$I tried to prove it by taking $f(x)=\sin x+ \tan x -2x$ and show $f(x) &gt;0 ,when\space  x \in (0,\frac{\pi}{2})$ take f'$$f'=\cos x +1+\tan ^2 x-2\\=\tan^2 x-(1-\cos x)\\=\tan ^2 x-2sin^2(\frac x2)$$ I get stuck here ,because the last line need to be proved $\tan ^2 x&gt;2sin^2(\frac x2) ,when\space  x \in (0,\frac{\pi}{2})$ $\bf{Question}:$ Is there a geometrical method to prove the first inequality ? (or other idea)  Thanks in advance.    $\bf{Remark}: $I can see the function is increasing $when\space  x \in (0,\frac{\pi}{2})$ like below : I'm trying to make a material node setup to set final render colors, regardless of lighting conditions. Is such a setup possible? PostgreSQL CPU 100% after configure Wal log shipping hot standby I have configured Hight Avaliabily WAL Log Shipping Hot Standby (SSL) with one node. But after I configure, both hosts (primary and secondary) take 100% CPU usage. The most strange is because I have only one database called &quot;TESTE&quot; with one table called &quot;EXAMPLE&quot; to check if replication was OK. The replication worked perfectly but I don't understand why my CPU takes 100% usage because I don't have any application connect on my cluster. I ran HTOP command and get this results: Image 1 - Primary Server HTOP Info  Image 2 - Secondary Server HTOP info  S.O. version: No LSB modules are available. Distributor ID: Debian Description:    Debian GNU/Linux 10 (buster) Release:        10 Codename:       buster  PostgreSQL version: postgres (PostgreSQL) 12.3 (Debian 12.3-1.pgdg100+1)  Primary server postgres.conf file: max_connections = 100 SSL = on shared_buffers = 2GB work_mem = 10485kb maintenance_work_mem = 512MB dynamic_shared_memory_type = posix effective_io_concurrency = 200 max_worker_processes = 4 max_parallel_maintenance_workers = 2 max_parallel_workers_per_gather = 2 max_parallel_workers = 4 wal_level = replica wal_buffers = 16MB max_wal_size = 200MB min_wal_size = 80MB checkpoint_completion_target = 0.7 archive_mode = on max_wal_senders = 3 wal_keep_segments = 8 hot_standby = on hot_standby_feedback = on random_page_cost = 1.1 effective_cache_size = 6GB default_statistics_target = 100  pg_stat_activity info:  pg_stat_archiver info:  pg_stat_replication info:  If I stop postgres service in both servers the CPU still has 100% usage. Anyone can help me? How can I change the margins for only part of the text? Sometimes the margins need to be changed for a particular page, paragraph, or other section of text.  For example, if I'm writing a letter and want the left margin to be almost at the right side of the page for the four lines of my address, or if I am combining prose with poetry and want the poems to be indented relative to the rest of the work.  What is the best way to change both left and right margins on the fly? I have a lot of svg images I want to include in a TeX-File.   So far I didn't have problems using the \usepackage{svg} with \includesvg.  However recently I've added a few more layers to the svg-files and now a lot of stuff is missing.   The resulting svg-tex.pdf files now have up to 61 pages and if I look into the svg-tex.pdf_tex files with texmaker I found the culprit: it only goes up to 50 pages:  \put(0,0){\includegraphics[width=\unitlength,page=50]{Sym_9999_svg-tex.pdf}}%   Putting the pages in manually like:   \put(0,0){\includegraphics[width=\unitlength,**page=51**]{Sym_9999_svg-tex.pdf}}%   does work, but would be very time inefficient (I have 100+ svg images) additionally the layers don't have the correct sequence and cover up text sometimes.   Does anyone have a solution for this problem?   If I open up the svg-image it shows up just fine.   One possibility would be to just export the svgs in one pdf file without the text as extra latex file, but this way I can't add formulas in Tex-Form. What happens when the Runner stack is empty? When the corporation R&amp;D is empty the corporation loses.  What happens when the Runner's stack is empty?    I think that: He must finish the game with only the cards on the table.  or  I doubt that: He reshuffles the heap into a new stack. I have a directory where daily subdirectories are created, literally named according to $date. How can I delete folders and their contents that are older than 7 days according to the YYYYMMDD in the file name and not the metadata date? Say I have (skipped some for brevity):  20170817 20170823 20170828 20170901   I would end up with the following folders (which those should keep):  20170828 20170901   I created a variable that holds the date 7 days ago: dt_prev=$(date -d "`date`-7days" +%Y%m%d)  My thought was to ls -l a list of these folder names and compare row by row, but this involves cleaning that list, etc., and I figure there has to be an easier way. Ubuntu has been crashing on me recently. I think its because it runs out of memory so I ran the free -m command and found that my memory usage was really high. So then, i ran top to find the culprit, but the displayed processes were using less than 1.5% of memory. How do I know which program is making ubuntu crash/run out of memory? Below is the output:  shafee@shafee-pc:~$ free -m              total       used       free     shared    buffers     cached Mem:          3824       3714        110          0        978       1954 -/+ buffers/cache:        780       3044 Swap:           99          0         99  shafee@shafee-pc:~$ top top - 02:12:14 up  1:24,  2 users,  load average: 0.16, 0.42, 1.49 Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie Cpu(s):  2.9%us,  1.9%sy,  0.3%ni, 79.3%id, 15.5%wa,  0.0%hi,  0.2%si,  0.0%st Mem:   3916708k total,  3803848k used,   112860k free,  1002308k buffers Swap:   102396k total,        0k used,   102396k free,  2001852k cached    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND              4200 root      20   0  289m  53m  38m S    2  1.4   1:06.45 Xorg                 5590 shafee    20   0 19348 1368  956 R    2  0.0   0:00.01 top                     1 root      20   0 24124 2136 1264 S    0  0.1   0:02.05 init                    2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd                3 root      20   0     0    0    0 S    0  0.0   0:24.23 ksoftirqd/0             6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0             7 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/1             9 root      20   0     0    0    0 S    0  0.0   0:00.11 ksoftirqd/1            11 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/2            13 root      20   0     0    0    0 S    0  0.0   0:03.89 ksoftirqd/2            14 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/3            16 root      20   0     0    0    0 S    0  0.0   0:00.16 ksoftirqd/3            17 root       0 -20     0    0    0 S    0  0.0   0:00.00 cpuset                 18 root       0 -20     0    0    0 S    0  0.0   0:00.00 khelper                19 root       0 -20     0    0    0 S    0  0.0   0:00.00 netns                  21 root      20   0     0    0    0 S    0  0.0   0:00.01 sync_supers         shafee@shafee-pc:~$   Or is it normal to have 110mb of free memory and is my issue related to something else? Proving the series $\sum_{n=0}^{\infty}\sin(e\pi n!)$ converges What characters do I need to escape when using sed in a sh script? Take the following script:  #!/bin/sh sed 's/(127\.0\.1\.1)\s/\1/' [some file]   If I try to run this in sh (dash here), it'll fail because of the parentheses, which need to be escaped. But I don't need to escape the backslashes themselves (between the octets, or in the \s or \1). What's the rule here? What about when I need to use {...} or [...]? Is there a list of what I do and don't need to escape? What is the rule for adjective order? I remember being taught that the correct order of adjectives in English was something along the lines of "Opinion-Size-Age-Color-Material-Purpose."  However, it's been a long time and I'm pretty sure I've forgotten a few categories (I think there were eight or nine). Can anyone fill them in? I'm a C++ newbie, but I wasn't able to find the answer to this (most likely trivial) question online.  I am having some trouble compiling some code where two classes include each other.  To begin, should my #include statements go inside or outside of my macros?  In practice, this hasn't seemed to matter.  However, in this particular case, I am having trouble.  Putting the #include statements outside of the macros causes the compiler to recurse and gives me "#include nested too deeply" errors.  This seems to makes sense to me since neither class has been fully defined before #include has been invoked.  However, strangely, when I try to put them inside, I am unable to declare a type of one of the classes, for it is not recognized.  Here is, in essence, what I'm trying to compile:  A.h  #ifndef A_H_ #define A_H_  #include "B.h"  class A {     private:         B b;      public:         A() : b(*this) {} };  #endif /*A_H_*/   B.h  #ifndef B_H_ #define B_H_  #include "A.h"  class B {     private:             A&amp; a;      public:         B(A&amp; a) : a(a) {}  };  #endif /*B_H_*/   main.cpp  #include "A.h"  int main() {     A a; }   If it makes a difference, I am using g++ 4.3.2.  And just to be clear, in general, where should #include statements go?  I have always seen them go outside of the macros, but the scenario I described clearly seems to break this principle.  Thanks to any helpers in advance!  Please allow me to clarify my intent if I have made any silly mistakes! Say for a game with irregular hotspots (say Risk, or a strategy game like Paradox's Hearts of Iron or Crusader Kings), how do you   Define a non-rectangular hotspot of irregular shape (much like a territory on a map?), in code? What tool can you use to trace out the hotspot and import into your game? What is the algorithm for detecting if someone has clicked within such a hotspot? Better than premium Is there something higher (better) than the word premium, or does it mean the best? Also, is there something in between premium and deluxe?  Graphically: Does any word fit here? > Premium > Does any word fit here? > Deluxe Using "answer your own question" to advertise completed open source project? What does: Error Broken count >0 mean? The blackboard bold font in the AMSFonts package only has capital letters.  I sometimes wish to use a blackboard bold "1", for which I can use \usepackage{bbold}. But this changes the entire blackboard bold font, and I like the original AMSFonts versions of the capital letters better.  Is there a simple way for me to get \mathbb{1} from one package and the blackboard bold capitals from another?