copy

How to copy/clone a hash/object in JQuery?

混江龙づ霸主 提交于 2019-12-03 10:31:59
问题 I have a simple object (or hash) in Javascript: var settings = { link: 'http://example.com', photo: 'http://photos.com/me.jpg' }; I need a copy of it. Is there a settings.clone() type method that will give me another object with the same attributes? I'm using jQuery, so happy to use a jQuery utility method if one exists. 回答1: Yes, extend an empty object with the original one; that way, everything will simply be copied: var clone = $.extend({}, settings); Extending some filled object with

How can I copy several binary files into one file on a Linux system?

霸气de小男生 提交于 2019-12-03 10:29:17
问题 I need to copy the content of a folder which contains binary files to one binary file in another directory. In Windows I can just use: copy file1 + file2 targetfile /B I couldn't find something similar for Linux (I saw an approach with cat , but I'm unsure if this really works for binary files). 回答1: Unix has no distinction between text and binary files, which is why you can just cat them together: cat file1 file2 > target_file 回答2: cat is a very useful utility that will output the content of

System.IO.DirectoryNotFoundException after deleting an empty folder and recreating it

放肆的年华 提交于 2019-12-03 10:28:07
I want to copy a folder, and i want to delete destination folder first. So I am deleting destination folder then recreate it and then copy files. The problem is that i get the An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll when trying to copy files. This is the code static public void CopyFolder(string sourceFolder, string destFolder) { if (Directory.Exists(destFolder)) // check if folde exist { Directory.Delete(destFolder, true); // delete folder } Directory.CreateDirectory(destFolder); // create folder string[] files = Directory.GetFiles

Delphi: Copy Files from folder with Overall progress. CopyFileEx?

耗尽温柔 提交于 2019-12-03 10:16:43
问题 I have found examples of CopyFileEx with progress, but I need to copy some files from a folder with overall progress. Can anybody provide info how to do this? Or is there good alternative (component, function)? Big thanks for help!!! 回答1: Well, I had an answer - but I only just got around to digging it out :( But here it is anyway, I wrote this a few years ago as part of a program that was called "CopyFilesAndFailGraceFully.exe" :) I've modded it a bit to miss out the recovery stuff that

Paste a HTML table into Excel, how to keep the line break in cell

喜夏-厌秋 提交于 2019-12-03 09:47:01
I have a simple html table, for example, just one cell, but when I copy the dom node, and paste it into excel, it will be recognize as two rows, How to make Excel get the correct paste data. <table><tr><td>1<br>2</td><tr></table> I tried to add css style br {mso-data-placement:same-cell;}, But it only works in IE. Note, copy a plain text out is not OK, i need to add color, font information on cells. Himanshu padia As many of you probably know, you can output data (a report, for example) as an Excel file, simply by adding right content-type and content-disposition header: Response.ContentType =

How to “clone” an object into a subclass object?

泪湿孤枕 提交于 2019-12-03 09:37:18
I have a class A and a class B that inherits class A and extends it with some more fields. Having an object a of type A , how can I create an object b of type B that contains all data that object a contained? I have tried a.MemberwiseClone() but that only gives me another type A object. And I cannot cast A into B since the inheritance relationship only allows the opposite cast. What is the right way to do this? There is no means of doing this automatically built into the language... One option is to add a constructor to class B that takes a class A as an argument. Then you could do: B newB =

MySQL database replication

ⅰ亾dé卋堺 提交于 2019-12-03 09:20:08
This is the scenario: I have a MySQL server with a database, let's call it consolidateddb . This database a consolidation of several tables from various databases I have another MySQL server, with the original databases, these databases are production databases and are updates daily. The company wants to copy each update/insert/delete on each table in the production databases to the corresponding tables in consolidateddb . Would replication accomplish that? I know that replication is done on a databas to database, but not on tables that belong to different databases to one target database. I

How to copy a template and insert content from another document?

妖精的绣舞 提交于 2019-12-03 08:37:47
I want to write a Google Docs script that copies a template (which just contains a container bound script) and appends the contents of another document chosen by the user. How would I accomplish this? I already have a way to select the file (the template has a static id), but figure out a way to copy all the content of the document (including inlineImages and hyperLinks) to the my new document. Serge insas I guess the only way is to copy elements one by one... there are a whole bunch of document elements but it shouldn't be too hard to be quite exhaustive. Here is how it goes for the most

How to make Postgres Copy ignore first line of large txt file

爷,独闯天下 提交于 2019-12-03 08:14:37
问题 I have a fairly large .txt file ~9gb and I will like to load this txt file into postgres. The first row is the header, followed by all the data. If I postgres COPY the data directly, the header will cause an error that data type do not match with my postgres table, so I will need to remove it somehow. Sample data: ProjectId,MailId,MailCodeId,prospectid,listid,datemailed,amount,donated,zip,zip4,VectorMajor,VectorMinor,packageid,phase,databaseid,amount2 15,53568419,89734,219906,15,2011-05-11 00

How can I recursively copy a directory into another and replace only the files that have not changed?

此生再无相见时 提交于 2019-12-03 07:48:29
问题 I am looking to do a specific copy in Fedora. I have two folders: 'webroot': holding ALL web files/images etc 'export': folder containing thousands of PHP, CSS, JS documents that are exported from my SVN repo. The export directory contains many of the same files/folders that the root does, however the root contains additional ones not found in export. I'd like to merge all of the contents of export with my webroot with the following options: Overwriting the file in webroot if export's version