copy

Does a copy constructor/operator/function need to make clear which copy variant it implements?

寵の児 提交于 2019-12-03 23:55:12
问题 Yesterday I asked a question about copying objects in C#, and most answers focussed on the difference between deep copy and shallow copy , and the fact that it should be made clear which of both copy variants a given copy constructor (or operator, or function) implements. I find this odd. I wrote a lot of software in C++, a language that heavily relies on copying, and I never ever needed multiple copy variants. The only kind of copy operation I ever used is the one I call " deep enough copy "

Python copy on PIL image object

你说的曾经没有我的故事 提交于 2019-12-03 23:53:21
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/local/lib/python2.6/site-packages/PIL/PngImagePlugin.py in read(self=<PIL.PngImagePlugin.PngStream instance

Javascript - How to clone an object?

百般思念 提交于 2019-12-03 22:31:43
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 Narendra Yadala Update: Removing Object.create as a method of cloning as indicated in comments. myObjTwo = myObjOne; does not clone. It simply copies the reference. If you want to clone, you can use JSON.parse and

h5复制剪切板

耗尽温柔 提交于 2019-12-03 21:57:12
angular serve ; ( function ( app ) { app.service( 'ClipBoard' , [ 'URL' , '$rootScope' , function ( URL, $rootScope ) { //定义函数 var textArea, copy; // 判断是不是ios端 function isOS ( ) { return navigator.userAgent.match( /ipad|iphone/i ); } //创建文本元素 function createTextArea ( text ) { textArea = document .createElement( 'textArea' ); textArea.value = text; document .body.appendChild(textArea); textArea.setAttribute( 'readonly' , 'readonly' ); } //选择内容 function selectText ( ) { var range, selection; if (isOS()) { range = document .createRange(); range.selectNodeContents(textArea); selection = window

How can I create a PowerShell script to copy a file to a USB flash drive?

拈花ヽ惹草 提交于 2019-12-03 21:53:15
问题 I have a virtual hard disk .vhd file that I would like to backup on a daily basis by clicking on a shortcut on my Windows Vista laptop. I wrote a half-hazard batch script file (BACKUP.BAT) which accomplishes the job, where it open the cmd window and copies the file to the flash drive, but I would like to mimic (macro) the way the copying is displayed when you manually drag and drop the file into the flash drive in my computer. Another problem is that depending on what computer this is done,

Copy a file into USB flash drive root using batch files

假如想象 提交于 2019-12-03 21:24:53
I want to create a batch file to copy a file from any Dir into root folder that the .bat file located on that like a USB flash drive . My incomplete command : xcopy /s "%userprofile%\Desktop\test.txt" "?" What can I replace with "?" ??? Thanks guys This will do exactly as you want to any and all connected USB drives. @echo off for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do ( if %%l equ 2 ( xcopy /s "%userprofile%\Desktop\test.txt" %%i\ ) ) xcopy /s "%userprofile%\Desktop\test.txt" "\" You should replace it with drive letter of USB

Fast file copy with progress

↘锁芯ラ 提交于 2019-12-03 20:46:31
I'm writing an SDL application for Linux, that works from the console (no X server). One function I have is a file copy mechanism, that copies specific files from HDD to USB Flash device, and showing progress of this copy in the UI. To do this, I'm using simple while loop and copying file by 8kB chunks to get copy progress. The problem is, that it's slow. I get to copy a 100 MB file in nearly 10 minutes, which is unacceptable. How can I implement faster file copy? I was thinking about some asynchronous API that would read file from HDD to a buffer and store the data to USB in separate thread,

Does std::copy handle overlapping ranges?

无人久伴 提交于 2019-12-03 20:35:09
问题 When copying data from one range to another, you have to be careful if there's partial overlap between the source and destination ranges. If the beginning of the destination range overlaps the tail of the source range, a plain sequential copy will garble the data. The C run-time library has memmove in addition to memcpy to handle such overlap problems. I assume std::copy works like memcpy , in that it doesn't pay any regard to overlap between the source and destination regions. If you try to

How to change slow parametrized inserts into fast bulk copy (even from memory)

旧街凉风 提交于 2019-12-03 20:10:07
I had someting like this in my code (.Net 2.0, MS SQL) SqlConnection connection = new SqlConnection(@"Data Source=localhost;Initial Catalog=DataBase;Integrated Security=True"); connection.Open(); SqlCommand cmdInsert = connection.CreateCommand(); SqlTransaction sqlTran = connection.BeginTransaction(); cmdInsert.Transaction = sqlTran; cmdInsert.CommandText = @"INSERT INTO MyDestinationTable" + "(Year, Month, Day, Hour, ...) " + "VALUES " + "(@Year, @Month, @Day, @Hour, ...) "; cmdInsert.Parameters.Add("@Year", SqlDbType.SmallInt); cmdInsert.Parameters.Add("@Month", SqlDbType.TinyInt); cmdInsert

Maven project with native dependency and copying files

久未见 提交于 2019-12-03 20:07:48
问题 I have the following scenario: mylib is a library (for which I have the sources, so I'd like to put them into a Maven project mylib:mylib for example). This library has a jar dependency for which I only have the jar, and it is not to be found in the Maven repository (and I do NOT want to install it there either). To make it compile, something like this would work: add the jar file to the mylib project in a "lib" folder, e.g. "lib/thirdpartylib.jar" and in mylib's pom.xml, add a dependency