EzDevInfo.com

save interview questions

Top save frequently asked interview questions

The easiest way to write NSData to a file

NSData *data;
data = [self fillInSomeStrangeBytes];

My question is now how I can write this data on the easiest way to an file.

(I've already an NSURL file://localhost/Users/Coding/Library/Application%20Support/App/file.strangebytes)


Source: (StackOverflow)

How to store CLLocation using Core Data (iPhone)?

I'm trying to save a location and retrieve the location on a map afterward using Core Location, MapKit and Core Data frameworks.

What I've done is I just made entity named POI and added properties such as latitude (double type), longitude (double type) with few others.

Simply put, my app saves POI with two NSNumbers. (lat and long) but I feel like there must be a smarter way to store CLLocation than that.

cheers.


Source: (StackOverflow)

Advertisements

How to save svg canvas to local filesystem

Is there a way to allow a user, after he has created a vector graph on a javascript svg canvas using a browser, to download this file to their local filesystem?

SVG is a total new field for me so please be patient if my wording is not accurate.

kind regards, Jeroen.


Source: (StackOverflow)

How can I save a text block in visual mode to a file in Vim?

The title is very descriptive. Just in case, I will give an example:

START BLOCK1
something
END BLOCK1

START BLOCK2
something
somenthing...
END BLOCK2
  1. I select the BLOCK1 in visual mode
  2. I yank it by pressing y
  3. How can I save the yanked BLOCK1 to some other file?

Source: (StackOverflow)

Storing python dictionaries

I'm used to bringing data in and out of python using .csv files, but there are obvious challenges to this. Any advice on a simple ways to store a dictionary (or sets of dictionaries) in a json or pck file? For example:

data = {}
data ['key1'] = "keyinfo"
data ['key2'] = "keyinfo2"

I would like to know both how to save this, and then how to load it back in.


Source: (StackOverflow)

android fragment onRestoreInstanceState

Am I missing something or do Fragments not have a onRestoreInstanceState() method? If not, how do I go about attaining something similar?


Source: (StackOverflow)

Saving an Object (Data persistence in Python)

I've created an object like this:

company1.name = 'banana' 
company1.value = 40

I would like to save this object. How can I do that?


Source: (StackOverflow)

saving timestamp in mysql table using php

I have a field in my mysql table having timestamp data type. I am saving data into that table. But when I pass the timestamp(1299762201428) to save record, it automatically saves value '0000-00-00 00:00:00' into that database table.

So how to store the timestamp in mysql table?

Here is my save query.

INSERT INTO table_name (id,d_id,l_id,connection,s_time,upload_items_count,download_items_count,t_time,status) VALUES (1,5,9,'2',1299762201428,5,10,20,'1'),(2,5,9,'2',1299762201428,5,10,20,'1')

Source: (StackOverflow)

What is difference between --save and --save-dev?

What is difference between

npm install [package_name] --save

and

npm install [package_name] --save-dev?

What does this mean?


Source: (StackOverflow)

Save bitmap to location

I am working on a function to download an image from a web server, display it on the screen, and if the user wishes to keep the image, save it on the SD card in a certain folder. Is there an easy way to take a bitmap and just save it to the SD card in a folder of my choice?

My issue is that I can download the image, display it on screen as a Bitmap. The only way I have been able to find to save an image to a particular folder is to use FileOutputStream, but that requires a byte array. I am not sure how to convert (if this is even the right way) from Bitmap to byte array, so I can use a FileOutputStream to write the data.

The other option I have is to use MediaStore :

MediaStore.Images.Media.insertImage(getContentResolver(), bm,
    barcodeNumber + ".jpg Card Image", barcodeNumber + ".jpg Card Image");

Which works fine to save to SD card, but does not allow you to customize the folder.


Source: (StackOverflow)

How to save as a new file and keep working on the original one in Vim?

Whenever I use the :sav command, it saves the file with a new name and opens the new file open in Vim.

Is it possible to save the file with a new name but keep the original one open for editing?


Source: (StackOverflow)

Permanently add a directory to PYTHONPATH

Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?


Source: (StackOverflow)

Determine what attributes were changed in Rails after_save callback?

I'm setting up an after_save callback in my model observer to send a notification only if the model's published attribute was changed from false to true. Since methods such as changed? are only useful before the model is saved, the way I'm currently (and unsuccessfully) trying to do so is as follows:

def before_save(blog)
  @og_published = blog.published?
end

def after_save(blog)
  if @og_published == false and blog.published? == true
    Notification.send(...)
  end
end

Does anyone have any suggestions as to the best way to handle this, preferably using model observer callbacks (so as not to pollute my controller code)?


Source: (StackOverflow)

Javascript: Create and save file

I have data that I want to write to a file, and open a file dialog for the user to choose where to save the file. It would be great if it worked in all browsers, but it has to work in Chrome. I want to do this all client-side.

Basically I want to know what to put in this function:

saveFile: function(data)
{
}

Where the function takes in data, has the user select a location to save the file, and creates a file in that location with that data.

Thanks in advance.

EDIT: Using HTML is fine too, if that helps.


Source: (StackOverflow)

Save An Image To Application Documents Folder From UIView On IOS

I have a UIImageView that allows a user to place and hold an image until it can be saved. The problem is, I can't figure out how to actually save and retrieve the image I've placed in the view.

I have retrieved and placed the image in the UIImageView like this:

//Get Image 
- (void) getPicture:(id)sender {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    picker.sourceType = (sender == myPic) ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage (UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    myPic.image = image;
    [picker dismissModalViewControllerAnimated:YES];
}

It displays the selected image in my UIImageView just fine, but I have no idea how to save it. I'm saving all the other pieces of the view (mostly UITextfield) in Core Data. I've searched and searched, and tried many bits of code that people have suggested, but either I'm not entering the code correctly, or those suggestions don't work with the way I have my code set up. It's likely the former. I'd like to save the image in the UIImageView using the same action (a save button) I'm using to save the text in the UITextFields. Here's how I'm saving my UITextField info:

// Handle Save Button
- (void)save {

    // Get Info From UI
    [self.referringObject setValue:self.myInfo.text forKey:@"myInfo"];

Like I said earlier, I have tried several methods to get this to work, but can't get a grasp on it. For the first time in my life I've wanted to cause physical harm to an inanimate object, but I've managed to restrain myself.

I'd like to be able to save the image the user places into the UIImageView in the application's documents folder, and then be able to retrieve it and place it in another UIImageView for display when the user pushes that view onto the stack. Any help is greatly appreciated!


Source: (StackOverflow)