copy

Copy an array backwards? Array.Copy?

爷,独闯天下 提交于 2019-12-05 13:02:38
I have a List<T> that I want to be able to copy to an array backwards, meaning start from List.Count and copy maybe 5 items starting at the end of the list and working its way backwards. I could do this with a simple reverse for loop; however there is probably a faster/more efficient way of doing this so I thought I should ask. Can I use Array.Copy somehow? Originally I was using a Queue as that pops it off in the correct order I need, but I now need to pop off multiple items at once into an array and I thought a list would be faster. Looks like Array.Reverse has native code for reversing an

Javascript - How to clone an object?

不羁岁月 提交于 2019-12-05 12:50:08
问题 I am confused. I create a copy from myObjOne , than i delete an entry from myObjOne and JS delete the entry in my copy( myObjTwo ) too? But why? myObjOne = {}; myObjOne['name'] = 'xxx'; myObjOne['id'] = 'yyy'; myObjOne['plz'] = 'zzz'; // clone myObjTwo = myObjOne; // remove something delete myObjOne['name']; console.dir(myObjTwo); example http://jsbin.com/itixes/edit#javascript,html 回答1: Update: Removing Object.create as a method of cloning as indicated in comments. myObjTwo = myObjOne; does

Copy permissions from one Windows Folder to another

♀尐吖头ヾ 提交于 2019-12-05 10:47:32
I need to create a small C# Windows app which copies security permissions from one folder to another. That includes copying group permissions too. What would be the best way to approach such a challenge? Yosief Kesete First get out the folder with DirectoryInfo then get out an instance of the DirectorySecurity class using the GetAccessControl method. Then you'll be able to call GetAccessRules and AddAccessRule which should hopefully get you started. Rather than writing the whole thing yourself, why don't you get your app to run a tool like AccessChk (use the -l parameter), and then apply

How can I copy an entire directory in Perl?

我的未来我决定 提交于 2019-12-05 10:36:37
I need to copy entire directory to some location. What is the best way to do so ? File::Copy copies only file by file as I saw it. By the way I work under Windows. Thanks for help. unwind Maybe look into File::Copy::Recursive . Adam Luchjenbroers A quick google search for "perl copy directory file::" finds File::Copy::Recursive Looks what you're after. 来源: https://stackoverflow.com/questions/1865883/how-can-i-copy-an-entire-directory-in-perl

Method to copy down rows R

泄露秘密 提交于 2019-12-05 10:08:39
Suppose we have a dataframe or matrix with one column specifying an integer value N as below (col 5). Is there a vector approach to repopulate the object such that each row gets copied N times? > y [,1] [,2] [,3] [,4] [,5] [1,] -0.02738267 0.5170621 -0.01644855 0.48830663 1 [2,] -0.30076544 1.8136359 0.02319640 -1.59649330 2 [3,] 1.73447245 0.4043638 -0.29112385 -0.25102988 3 [4,] 0.01025271 -0.4908636 0.80857300 0.08137033 4 The result would be as follows. [1,] -0.02738267 0.5170621 -0.01644855 0.48830663 1 [2,] -0.30076544 1.8136359 0.02319640 -1.59649330 2 [2,] -0.30076544 1.8136359 0

How to copy tab-delimited text to clipboard from within a unix shell while preserving the tabs?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:02:07
I am trying to copy and paste a few lines of a file from within a UNIX environment into a webpage. I want to preserve the original formatting with disrupting the tabs. However, when I select a block of text and copy and paste it into a webpage, all of the tabs have been converted to various length runs of spaces. Can someone please tell me what I can do to preserve the original tabs? It needs to be as simple as possible so that newbie users can do the same! Thanks Based on your comment that the text that you're copying is missing the tabs, I suspect that the ptty you're using has converted

How to copy one file to many locations simultaneously

别等时光非礼了梦想. 提交于 2019-12-05 09:53:21
I want to find a way to copy one file to multiple locations simultaneously (with C#). means that i don't want the original file to be read only one time, and to "paste" the file to another locations (on local network). as far as my tests showed me, the File.Copy() will always read the source again. and as far as i understand, even while using memory, that memory piece gets locked. so basically, i want to mimic the "copy-paste" to the form of one "copy", and multiple "paste", without re-reading from the Hard Drive again. Why ? because eventually, i need to copy one folder (more than 1GB) to

Copy Hash Table in Lisp

自古美人都是妖i 提交于 2019-12-05 09:37:21
I have recently been working with hash tables in Common Lisp. I have been wondering how to make a separate copy of a hash table containing all the same values as the first. Is there an official way to do this? If not, can you give me an example using maphash? Sim As clhs does not list a copy table function I'd assume that maphash is the way to go. (defun copy-table (table) (let ((new-table (make-hash-table :test (hash-table-test table) :size (hash-table-size table)))) (maphash #'(lambda(key value) (setf (gethash key new-table) value)) table) new-table)) (let ((table (make-hash-table))) (mapcar

Python copy on PIL image object

瘦欲@ 提交于 2019-12-05 09:33:39
问题 I'm trying to create a set of thumbnails, each one separately downscaled from the original image. image = Image.open(path) image = image.crop((left, upper, right, lower)) for size in sizes: temp = copy.copy(image) temp.thumbnail((size, height), Image.ANTIALIAS) temp.save('%s%s%s.%s' % (path, name, size, format), quality=95) The above code seemed to work fine but while testing I discovered that some images (I can't tell what's special about them, maybe only for PNG) raise this error: /usr

How can I recursively copy the contents of directory using Perl?

泪湿孤枕 提交于 2019-12-05 08:57:35
I am running the current version of ActivePerl on Windows Vista, and I was wondering if you could show me the best and simplest way to copy a folder and it's contents to another location. Contents would include various files, and most likely some more nested folders. I imagine there must be a module out there somewhere that I don't know about that does this - but if there is a simple homebrew type of solution I'd like to see that also. Brandon E Taylor Take a look at File::Copy::Recursive . If you are simply copying and not doing any processing on the files, there is no reason not to use xcopy