save

Ruby on Rails+PostgreSQL: usage of custom sequences

一笑奈何 提交于 2019-11-30 13:48:40
Say I have a model called Transaction which has a :transaction_code attribute. I want that attribute to be automatically filled with a sequence number which may differ from id (e.g. Transaction with id=1 could have transaction_code=1000 ). I have tried to create a sequence on postgres and then making the default value for the transaction_code column the nextval of that sequence. The thing is, if I do not assign any value to @transaction.transaction_code on RoR, when I issue a @transaction.save on RoR, it tries to do the following SQL: INSERT INTO transactions (transaction_code) VALUES (NULL);

How to save email attachment using OpenPop

久未见 提交于 2019-11-30 13:21:24
问题 I have created a Web Email Application, How do I view and save attached files? I am using OpenPop , a third Party dll, I can send emails with attachments and read emails with no attachments. This works fine: Pop3Client pop3Client = (Pop3Client)Session["Pop3Client"]; // Creating newPopClient int messageNumber = int.Parse(Request.QueryString["MessageNumber"]); Message message = pop3Client.GetMessage(messageNumber); MessagePart messagePart = message.MessagePart.MessageParts[1]; lblFrom.Text =

save images in webbrowser control without redownloading them from the internet

心已入冬 提交于 2019-11-30 13:18:24
问题 Is it possible to save images in a webbroswer control directly to hard disk, without needing to download them again from the internet? Let's say I navigate to a website that has 15 images. They are all viewed in my webbrowser, but how can I save them now without the need to download them? 回答1: This is the only way I could find. Curious if anyone else has a better way. Copied from CodeProject You have to add a reference to Microsoft.mshtml and of course wait for the document to finish loading.

Take picture with camera intent and save to file [duplicate]

Deadly 提交于 2019-11-30 12:35:06
Possible Duplicate: Android Camera - Save image into a new folder in SD Card i'm trying to take picture and save it to a file. The problem cames i'm trying to save the bitmap to a file. Here is my code: private void takePic() { Intent cameraIntent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, 2); } public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 2) { Bitmap photo = (Bitmap) data.getExtras().get("data"); ImageView test = (ImageView) findViewById(R.id.test); test.setImageBitmap(photo); try {

How do I save data in an application scope in PHP?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 11:42:25
I'm a Java and C# developer, and, I admit, I'm not that good in PHP. I need to store an object in an application scope that lives as long as the app itself is running. I can't save it in the Session, because it expires, also I can't serialize it to disk. Is there something like a C# Application object in PHP? Theodore R. Smith 2018 Edit: Time has not been kind to APC, especially since PHP 7 includes bundled support for Zend Optimizer+, which does largely the same thing (except the key-store). These days, the key store aspect has been forked over into the APCu project . However, in 2018, the

Swift: save video from NSURL to user camera roll

匆匆过客 提交于 2019-11-30 11:26:18
问题 I have a variable videoURL of type NSURL. If I call println(videoURL) it would return something like this: http://files.parsetfss.com/d540f71f-video.mp4 I have a button set up that should take this videoURL and save the video to the user's camera roll. The best I have done is this: UISaveVideoAtPathToSavedPhotosAlbum(videoPath: String!, completionTarget: AnyObject!, completionSelector: Selector, contextInfo: UnsafeMutablePointer<Void>) While I'm not even sure if this will work or not, I can't

Saving in-memory H2 database to disk

删除回忆录丶 提交于 2019-11-30 11:25:30
How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading. I want to use this for caching data so I don't have to run all the lines of create table/insert clauses every time. Thomas Mueller Instead of using an in-memory database, you could use a regular (persisted) database. You can still use in-memory tables even then (create memory table). The easiest way to persist a completely in-memory database to disk is to use the SCRIPT TO 'fileName' SQL statement. This will create an SQL script. The data is stored in text form, which doesn't

Save CoreData-entities in NSUserDefaults

懵懂的女人 提交于 2019-11-30 11:11:04
Imagine an CoreData entity (e.g. named searchEngine ). NSManagedObjectContext manages some "instances" of this entity. The end-user is going to be able to select his "standard searchEngine" with a NSPopupButton . The selected object of NSPopupButton should be binded to the NSUserDefaults. The problem: 1) @try{save} a) If you try to save the selected "instance" directly to NSUserDefaults there comes something like this: -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value ' (entity: searchEngine; id: 0x156f60 ; data: { url = " http://google.de/ "; someAttribute = 1; name =

Save byte array to file [duplicate]

戏子无情 提交于 2019-11-30 11:10:49
问题 This question already has answers here : Can a Byte[] Array be written to a file in C#? (8 answers) Closed 6 years ago . I have a byte array (an IEnumerable actually), and I need to save it to a new file containing this data. How do I do that? I found some answers telling how to create a MemoryStream from that, but still can't save it to a brand new file. 回答1: You can use: File.WriteAllBytes("Foo.txt", arrBytes); // Requires System.IO If you have an enumerable and not an array, you can use:

Save a html canvas image

我与影子孤独终老i 提交于 2019-11-30 10:51:20
I know there is probably an answer already to this question but I haven't been able to find it yet and there is a deadline on my project. So I have made an html5 canvas and I would like to be able to do two things with one(or more) buttons. I would like the user to be able to save what he has just done by clicking on the save button and ideally I would like the image to be downloaded (as opposed to having to right click and "Save image as". This is what I have been able to do so far). I would also like the image to be saved (maybe to a database? or a server? I don't know how it works) so that