batch-processing

Mongoid Batch Update/Upsert Alternative?

烂漫一生 提交于 2019-11-29 13:52:59
I know that Mongoid v3+ supports batch inserts via Model.collection.insert() . However, I don't think it supports batch updates where the attributes differ for each record (so I don't think update_all would work either). Is there a way to do batch update/upsert instead of a single-record lookup & update? Here's a simplified example in which I have 2 models: class Product ... has_and_belongs_to_many :lists end class List ... has_and_belongs_to_many :products end When a new Product is created, I associate it with one or more Lists . However, I also need to update the Product attributes daily

How can I hide ms-dos window when running a .bat file?

烂漫一生 提交于 2019-11-29 13:52:02
I am running a .bat file for my script (Scheduled Tak (CronJob)) per minute. When it runs, windows command prompt appears for a fiction of time. My batch code like this; @ECHO OFF C:\wamp\bin\php\php5.4.3\php.exe -f "C:\wamp\www\tst\index.php" How can I hide this window when it run? Use a VBScript Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("C:\yourbatch.bat"), 0, True Run that which will run your batch file hidden. I don't like VBScript solution. Download and copy nircmd.exe to your %systemroot%\system32 folder, then add this command to first line of your batch: nircmd

batch processing pandoc conversions

自作多情 提交于 2019-11-29 12:42:59
问题 Sorry or being thick. I've searched high and low to try and work out how to batch process pandoc. I cannot for the life of me work it out. How do I convert a folder and nested folders containing html files to markdown? I should mention that I'm using os x 10.6.8 回答1: You can apply any command across the files in a directory tree using find : find . -name \*.md -type f -exec pandoc -o {}.txt {} \; would run pandoc on all files with a .md suffix, creating a file with a .md.txt suffix. (You will

batch file + convert LF to CR+LF

天涯浪子 提交于 2019-11-29 11:04:10
We have a shell script file named LineFeed.sh which does a function of converting a Linefeed( LF ) to Carriage Return + LineFeed. We want the same to be done by a batch file in windows . Is it possible? Linux shell file E_WRONGARGS=65 cat OutputList|while read -r Line do if [ -z "$Line" ] then echo "Usage: `basename $0` filename-to-convert" exit $E_WRONGARGS fi NEWFILENAME=$Line.unx CR='\015' # Carriage return. # 015 is octal ASCII code for CR. # Lines in a DOS text file end in CR-LF. # Lines in a UNIX text file end in LF only. tr -d $CR < $1 > $NEWFILENAME // here its deleting CR but i need

How to execute a for loop in batches?

我与影子孤独终老i 提交于 2019-11-29 09:28:25
for x in records: data = {} for y in sObjectName.describe()['fields'] data[y['name']] = x[y['name']] ls.append(adapter.insert_posts(collection, data)) I want to execute the code ls.append(adapter.insert_post(collection, x)) in the batch size of 500, where x should contain 500 data dicts. I could create a list a of 500 data dicts using a double for loop and a list and then insert it. I could do that in the following way, , is there a better way to do it? : for x in records: for i in xrange(0,len(records)/500): for j in xrange(0,500): l=[] data = {} for y in sObjectName.describe()['fields']:

Spring Batch how to filter duplicated items before send it to ItemWriter

浪尽此生 提交于 2019-11-29 04:44:24
I read a flat file (for example a .csv file with 1 line per User, Ex: UserId;Data1;Date2 ). But how to handle duplicated User item in the reader (where is no list of previus readed users...) stepBuilderFactory.get("createUserStep1") .<User, User>chunk(1000) .reader(flatFileItemReader) // FlatFileItemReader .writer(itemWriter) // For example JDBC Writer .build(); Michael Minella Filtering is typically done with an ItemProcessor . If the ItemProcessor returns null, the item is filtered and not passed to the ItemWriter . Otherwise, it is. In your case, you could keep a list of previously seen

Best way to insert a good amount of records in hibernate

佐手、 提交于 2019-11-29 03:43:05
问题 I'm using hibernate + play! framework at work, is there a "best practice" on inserting a good amount of records using hibernate? They are around 6,000 to 10,000 per text file so I don't know if Hibernate is going to choke on the job or throw an exception. Any suggestion let me know, let me know if I have to explain more 回答1: From *Java Persistence and Hibernate" (Manning) and following a comment from Pangea, use a stateless session (which doesn't have a persistence context cache) :

webapi batching and delegating handlers

回眸只為那壹抹淺笑 提交于 2019-11-29 02:04:28
based on my last post I was able to get batching working... until a certain point. In addition to registering the route specific handler I also have 2 delegating handlers Authenticate the user logging the batch handler goes through the delegating handlers authenticating the user and logging the request. when the messagehandlerinvoker starts to send the child/nested requests the following exception is thrown. System.ArgumentException was unhandled by user code HResult=-2147024809 Message=The 'DelegatingHandler' list is invalid because the property 'InnerHandler' of 'AuthenticationMessageHandler

How to close the command line window after running a batch file?

泄露秘密 提交于 2019-11-28 18:36:20
I've got a batch file. After it finished running, i.e. all command lines have been executed, the cmd.exe window stays open. However, I'd like to have it closed right after the batch file finishes its job. So far I've tried using the exit command within the batch file to close the cmd window (I also have a shortcut on the desktop) but it doesn't seem to work: tncserver.exe C:\Work -p4 -b57600 -r -cFE -tTNC426B exit It should close automatically, if it doesn't it means that it is stuck on the first command. In your example it should close either automatically (without the exit ) or explicitly

Recursively batch process files with pngquant

六月ゝ 毕业季﹏ 提交于 2019-11-28 16:52:41
I have a lot of images that I would like to process with pngquant. They are organized in a pretty deep directory structure, so it is very time-consuming to manually cd into every directory and run pngquant -ext .png -force 256 *.png Is there a way to get this command to run on every *.png in every directory within the current one, as many layers deep as necessary? If you have limited depth of directories and not too many files, then lazy solution: pngquant *.png */*.png */*/*.png A standard solution: find . -name '*.png' -exec pngquant --ext .png --force 256 {} \; and multi-core version: find