问:
NotSerializableException: android.graphics.drawable.BitmapDrawable
I get the following error, I know this means that Some class has to be implements Serializable but the problem is all the classes I've created does implement Serializable.

```<code>Process: com.example.awarrior.gallery, PID: 2554
                                                                            java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.awarrior.gallery.Item)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1526)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1474)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:723)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1133)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:763)
                                                                                at android.content.Intent.writeToParcel(Intent.java:8655)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:819)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:796)
                                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
                                                                                at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57)
                                                                                at android.view.View.performClick(View.java:5610)
                                                                                at android.view.View$PerformClick.run(View.java:22265)
                                                                                at android.os.Handler.handleCallback(Handler.java:751)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                             Caused by: java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable
                                                                                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224)
                                                                                at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584)
                                                                                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549)
                                                                                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
                                                                                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1521)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1474)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:723)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1133)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:763)
                                                                                at android.content.Intent.writeToParcel(Intent.java:8655)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:819)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:796)
                                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
                                                                                at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57)
                                                                                at android.view.View.performClick(View.java:5610)
                                                                                at android.view.View$PerformClick.run(View.java:22265)
                                                                                at android.os.Handler.handleCallback(Handler.java:751)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
</code>```

here's the code that causes the error.

```<code>holder.ivImg.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context, Detail.class);
                intent.putExtra("item", item);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        });
</code>```

答: The problem was that you can't serialize Bitmaps so instead you may serialize its URL, but I'm not sure what to do if the image was in drawble folder. </p>

Body:
I get the following error, I know this means that Some class has to be implements Serializable but the problem is all the classes I've created does implement Serializable.

Process: com.example.awarrior.gallery, PID: 2554
                                                                            java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.awarrior.gallery.Item)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1526)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1474)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:723)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1133)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:763)
                                                                                at android.content.Intent.writeToParcel(Intent.java:8655)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:819)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:796)
                                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
                                                                                at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57)
                                                                                at android.view.View.performClick(View.java:5610)
                                                                                at android.view.View$PerformClick.run(View.java:22265)
                                                                                at android.os.Handler.handleCallback(Handler.java:751)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                             Caused by: java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable
                                                                                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1224)
                                                                                at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1584)
                                                                                at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1549)
                                                                                at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1472)
                                                                                at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1218)
                                                                                at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
                                                                                at android.os.Parcel.writeSerializable(Parcel.java:1521)
                                                                                at android.os.Parcel.writeValue(Parcel.java:1474)
                                                                                at android.os.Parcel.writeArrayMapInternal(Parcel.java:723)
                                                                                at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1408)
                                                                                at android.os.Bundle.writeToParcel(Bundle.java:1133)
                                                                                at android.os.Parcel.writeBundle(Parcel.java:763)
                                                                                at android.content.Intent.writeToParcel(Intent.java:8655)
                                                                                at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3052)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1518)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:819)
                                                                                at android.app.ContextImpl.startActivity(ContextImpl.java:796)
                                                                                at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
                                                                                at com.example.awarrior.gallery.ItemAdapter$1.onClick(ItemAdapter.java:57)
                                                                                at android.view.View.performClick(View.java:5610)
                                                                                at android.view.View$PerformClick.run(View.java:22265)
                                                                                at android.os.Handler.handleCallback(Handler.java:751)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:154)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                at java.lang.reflect.Method.invoke(Native Method)

here's the code that causes the error.

holder.ivImg.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context, Detail.class);
                intent.putExtra("item", item);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        });


来源: stackexchange

问:
How can I measure the duration of a package execution?
I have an SSIS job that I would like to run from a procedure, and then, using the job start and job end date execute a select statement.

Getting the job start time is easy- just save the current time from just before you call the job.

How can I get the end tim? Can I use @endTime = GETDATE()? Does starting the job wait for it to end ?

Is it true in general about calls inside SQL procedures?

EDIT:
As people asked, I wanted to call an SSIS job using this code, which I found here:

```<code> declare @execution_id bigint
 exec ssisdb.catalog.create_execution
 @folder_name = 'mssqltips'
 ,@project_name = 'exec-ssis-stored-proc-ssis-sample'
 ,@package_name = 'Sample.dtsx'
 ,@execution_id = @execution_id output
 exec ssisdb.catalog.start_execution @execution_id
</code>```

答:
It depends on how to you run SSIS via SP. Is it a sql agent job or package execution (catalog)?

If you run it as package, it can be run synchronously or asynchronously.

If it is in asynchronous mode, SP just starts the SSIS package and doesn't wait.

IF it is in synchronous mode, it will wait.

The mode depends on SYNCHRONIZED parameter. This parameter should be set BEFORE execution starts, see the link below how to set it.

https://learn.microsoft.com/en-us/sql/integration-services/system-stored-procedures/catalog-set-execution-parameter-value-ssisdb-database

If you run SQL job from SP and that job executes SSIS package, then SP does not wait, it just activates the SQL Agent Job.

ContentLicense: CC BY-SA 3.0

Body:
I have an SSIS job that I would like to run from a procedure, and then, using the job start and job end date execute a select statement.

Getting the job start time is easy- just save the current time from just before you call the job.

How can I get the end tim? Can I use @endTime = GETDATE()? Does starting the job wait for it to end ?

Is it true in general about calls inside SQL procedures?

EDIT:
As people asked, I wanted to call an SSIS job using this code, which I found here:

 declare @execution_id bigint
 exec ssisdb.catalog.create_execution
 @folder_name = 'mssqltips'
 ,@project_name = 'exec-ssis-stored-proc-ssis-sample'
 ,@package_name = 'Sample.dtsx'
 ,@execution_id = @execution_id output
 exec ssisdb.catalog.start_execution @execution_id


问:
When user allow using photo I can't see any thing in swift 3
I have collection view with Images of photo library But there is a problem just for first time that user Allows using photos - when the app runs for the first time and user allows to use photos the user can't see anyImages and should dismiss that view controller and come back again to see the Images

here is the codes :

```<code>import UIKit
import Photos

class typeandtranslateViewController: UIViewController , UIImagePickerControllerDelegate , UINavigationControllerDelegate , UICollectionViewDelegate, UICollectionViewDataSource  , UITextFieldDelegate {

static var checkTextField = Bool()

@IBOutlet var backgroundimg: UIImageView!
@IBOutlet var frontimg: UIImageView!
@IBOutlet weak var typeView: UIView!

let arr_img = NSMutableArray()
let arr_selected = NSMutableArray()

@IBOutlet var collview: UICollectionView!

@IBOutlet weak var sefareshTitleTextField: UITextField!

@IBAction func caneraButton(_ sender: UIButton) {

    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.camera ;

        imagePicker.allowsEditing = false
        self.present(imagePicker,animated: true , completion: nil)
    }

    print("Camera!")

}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage

    UIImageWriteToSavedPhotosAlbum(selectedImage,self,nil,nil)

    dismiss(animated: true, completion: nil)

    print("save Image ")

}
@IBOutlet weak var viewCamera: UIView!
override func viewDidLoad() {
    super.viewDidLoad()

    print("Text Field Condition ")

    if sefareshTitleTextField!.text! == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
    } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

    }

    self.sefareshTitleTextField.delegate = self

    collview?.allowsMultipleSelection = true

    let allPhotosOptions : PHFetchOptions = PHFetchOptions.init()
    allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
    let allPhotosResult = PHAsset.fetchAssets(with: .image, options: allPhotosOptions)
    allPhotosResult.enumerateObjects({ (asset, idx, stop) in

        self.arr_img.add(asset)

    })

    self.typeView.layer.cornerRadius = self.typeView.frame.size.height/50
    self.typeView.layer.borderWidth = 1
    self.typeView.layer.borderColor = UIColor.clear.cgColor
    self.typeView.clipsToBounds = true

    self.viewCamera.layer.cornerRadius = 5
    self.viewCamera.layer.borderWidth = 1
    self.viewCamera.layer.borderColor = UIColor.clear.cgColor
    self.viewCamera.clipsToBounds = true

    self.tabBarController?.tabBar.isHidden = true
    self.navigationController?.isNavigationBarHidden = true

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
    let blurView = UIVisualEffectView(effect: blurEffect)

    blurView.frame =  CGRect(x: self.backgroundimg.frame.origin.x, y: self.backgroundimg.frame.origin.y, width: self.backgroundimg.frame.size.width, height: self.backgroundimg.frame.size.height)

    blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    self.backgroundimg.addSubview(blurView)

}

func getAssetThumbnail(asset: PHAsset, size: CGFloat) -> UIImage {
    let retinaScale = UIScreen.main.scale
    let retinaSquare = CGSize(width: size * retinaScale, height: size * retinaScale)//CGSizeMake(size * retinaScale, size * retinaScale)
    let cropSizeLength = min(asset.pixelWidth, asset.pixelHeight)
    let square = CGRect(x: 0, y: 0, width: cropSizeLength, height: cropSizeLength)//CGRectMake(0, 0, CGFloat(cropSizeLength), CGFloat(cropSizeLength))
    let cropRect = square.applying(CGAffineTransform(scaleX: 1.0/CGFloat(asset.pixelWidth), y: 1.0/CGFloat(asset.pixelHeight)))

    let manager = PHImageManager.default()
    let options = PHImageRequestOptions()
    var thumbnail = UIImage()

    options.isSynchronous = true
    options.deliveryMode = .highQualityFormat
    options.resizeMode = .exact
    options.normalizedCropRect = cropRect

    manager.requestImage(for: asset, targetSize: retinaSquare, contentMode: .aspectFit, options: options, resultHandler: {(result, info)->Void in
        thumbnail = result!
    })

    return thumbnail
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.

}

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    self.view.endEditing(true);

    if sefareshTitleTextField!.text == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
    } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

    }

    return false;

}

func textFieldDidBeginEditing(_ textField: UITextField) {

        if sefareshTitleTextField!.text! == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
        } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

        }

}

//MARK:
//MARK: Collectioview methods

func collectionView(_ collectionView: UICollectionView,
                    numberOfItemsInSection section: Int) -> Int {
    return arr_img.count
}
func collectionView(_ collectionView: UICollectionView,
                    cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "celll",
                                                  for: indexPath)
    let imgview : UIImageView = cell.viewWithTag(20) as! UIImageView
    imgview.image = self.getAssetThumbnail(asset: self.arr_img.object(at: indexPath.row) as! PHAsset, size: 150)

    let selectView : UIImageView = cell.viewWithTag(22) as! UIImageView
    if arr_selected.contains(indexPath.row){

        selectView.image = UIImage(named: "Select.png")
    }else{

        selectView.image = UIImage(named: "radioCircleButton.png")

    }

    cell.layer.cornerRadius = 5
    cell.layer.borderWidth = 1
    cell.layer.borderColor = UIColor.clear.cgColor
    cell.clipsToBounds = true

    return cell
}

var selectedIndexes = [NSIndexPath]() {
    didSet {
        collview.reloadData()
    }
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{

    if arr_selected.contains(indexPath.row){
        arr_selected.remove(indexPath.row)
    }else{
        arr_selected.add(indexPath.row)
    }

    self.collview.reloadData()

}

override func viewDidAppear(_ animated: Bool) {

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
    let blurView = UIVisualEffectView(effect: blurEffect)
    blurView.frame = backgroundimg.bounds
    backgroundimg.addSubview(blurView)
    backgroundimg.frame = self.view.bounds
}

@IBAction func backToTheMainCustom(_ sender: UIButton) {

    performSegue(withIdentifier: "backToTheMainCustom", sender: self)

    sefareshTitleTextField!.text! = ""

    typeandtranslateViewController.checkTextField = false
}

}
</code>```

答:
First you need to ask user for permissions to access to the photo library. If request happens first time, wait for his answer and open the UIImagePickerController again. Please review the following code:

```<code>let photosAccess = PHPhotoLibrary.authorizationStatus()
switch photosAccess {
case .notDetermined:
    // First time here. Request the access
    PHPhotoLibrary.requestAuthorization({status in
        if status == .authorized{
            // Access was just granted
            // Open library here
        }
    })

case .authorized:
    // Open library here

case .denied, .restricted:
    // Photos access is not granted.
    // Good place to take user to app settings.
}
</code>```

The same about camera:

```<code>AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { response in
    if response {
        DispatchQueue.main.async {
            // Show camera UI here
        }
    } else {
        DispatchQueue.main.async {
            // Access is restricred
        }
    }
}
</code>```

Body:
I have collection view with Images of photo library But there is a problem just for first time that user Allows using photos - when the app runs for the first time and user allows to use photos the user can't see anyImages and should dismiss that view controller and come back again to see the Images

here is the codes :

import UIKit
import Photos

class typeandtranslateViewController: UIViewController , UIImagePickerControllerDelegate , UINavigationControllerDelegate , UICollectionViewDelegate, UICollectionViewDataSource  , UITextFieldDelegate {

static var checkTextField = Bool()

@IBOutlet var backgroundimg: UIImageView!
@IBOutlet var frontimg: UIImageView!
@IBOutlet weak var typeView: UIView!

let arr_img = NSMutableArray()
let arr_selected = NSMutableArray()

@IBOutlet var collview: UICollectionView!

@IBOutlet weak var sefareshTitleTextField: UITextField!

@IBAction func caneraButton(_ sender: UIButton) {

    if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = UIImagePickerControllerSourceType.camera ;

        imagePicker.allowsEditing = false
        self.present(imagePicker,animated: true , completion: nil)
    }

    print("Camera!")

}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

    let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage

    UIImageWriteToSavedPhotosAlbum(selectedImage,self,nil,nil)

    dismiss(animated: true, completion: nil)

    print("save Image ")

}
@IBOutlet weak var viewCamera: UIView!
override func viewDidLoad() {
    super.viewDidLoad()

    print("Text Field Condition ")

    if sefareshTitleTextField!.text! == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
    } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

    }

    self.sefareshTitleTextField.delegate = self

    collview?.allowsMultipleSelection = true

    let allPhotosOptions : PHFetchOptions = PHFetchOptions.init()
    allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
    let allPhotosResult = PHAsset.fetchAssets(with: .image, options: allPhotosOptions)
    allPhotosResult.enumerateObjects({ (asset, idx, stop) in

        self.arr_img.add(asset)

    })

    self.typeView.layer.cornerRadius = self.typeView.frame.size.height/50
    self.typeView.layer.borderWidth = 1
    self.typeView.layer.borderColor = UIColor.clear.cgColor
    self.typeView.clipsToBounds = true

    self.viewCamera.layer.cornerRadius = 5
    self.viewCamera.layer.borderWidth = 1
    self.viewCamera.layer.borderColor = UIColor.clear.cgColor
    self.viewCamera.clipsToBounds = true

    self.tabBarController?.tabBar.isHidden = true
    self.navigationController?.isNavigationBarHidden = true

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
    let blurView = UIVisualEffectView(effect: blurEffect)

    blurView.frame =  CGRect(x: self.backgroundimg.frame.origin.x, y: self.backgroundimg.frame.origin.y, width: self.backgroundimg.frame.size.width, height: self.backgroundimg.frame.size.height)

    blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

    self.backgroundimg.addSubview(blurView)

}

func getAssetThumbnail(asset: PHAsset, size: CGFloat) -> UIImage {
    let retinaScale = UIScreen.main.scale
    let retinaSquare = CGSize(width: size * retinaScale, height: size * retinaScale)//CGSizeMake(size * retinaScale, size * retinaScale)
    let cropSizeLength = min(asset.pixelWidth, asset.pixelHeight)
    let square = CGRect(x: 0, y: 0, width: cropSizeLength, height: cropSizeLength)//CGRectMake(0, 0, CGFloat(cropSizeLength), CGFloat(cropSizeLength))
    let cropRect = square.applying(CGAffineTransform(scaleX: 1.0/CGFloat(asset.pixelWidth), y: 1.0/CGFloat(asset.pixelHeight)))

    let manager = PHImageManager.default()
    let options = PHImageRequestOptions()
    var thumbnail = UIImage()

    options.isSynchronous = true
    options.deliveryMode = .highQualityFormat
    options.resizeMode = .exact
    options.normalizedCropRect = cropRect

    manager.requestImage(for: asset, targetSize: retinaSquare, contentMode: .aspectFit, options: options, resultHandler: {(result, info)->Void in
        thumbnail = result!
    })

    return thumbnail
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.

}

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    self.view.endEditing(true);

    if sefareshTitleTextField!.text == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
    } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

    }

    return false;

}

func textFieldDidBeginEditing(_ textField: UITextField) {

        if sefareshTitleTextField!.text! == "" {

        typeandtranslateViewController.checkTextField = false

        print("sefaresh title is nill")
        } else if sefareshTitleTextField!.text! != "" {

        typeandtranslateViewController.checkTextField = true
        print("sefaresh title isnt nill")

        }

}

//MARK:
//MARK: Collectioview methods

func collectionView(_ collectionView: UICollectionView,
                    numberOfItemsInSection section: Int) -> Int {
    return arr_img.count
}
func collectionView(_ collectionView: UICollectionView,
                    cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "celll",
                                                  for: indexPath)
    let imgview : UIImageView = cell.viewWithTag(20) as! UIImageView
    imgview.image = self.getAssetThumbnail(asset: self.arr_img.object(at: indexPath.row) as! PHAsset, size: 150)

    let selectView : UIImageView = cell.viewWithTag(22) as! UIImageView
    if arr_selected.contains(indexPath.row){

        selectView.image = UIImage(named: "Select.png")
    }else{

        selectView.image = UIImage(named: "radioCircleButton.png")

    }

    cell.layer.cornerRadius = 5
    cell.layer.borderWidth = 1
    cell.layer.borderColor = UIColor.clear.cgColor
    cell.clipsToBounds = true

    return cell
}

var selectedIndexes = [NSIndexPath]() {
    didSet {
        collview.reloadData()
    }
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{

    if arr_selected.contains(indexPath.row){
        arr_selected.remove(indexPath.row)
    }else{
        arr_selected.add(indexPath.row)
    }

    self.collview.reloadData()

}

override func viewDidAppear(_ animated: Bool) {

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
    let blurView = UIVisualEffectView(effect: blurEffect)
    blurView.frame = backgroundimg.bounds
    backgroundimg.addSubview(blurView)
    backgroundimg.frame = self.view.bounds
}

@IBAction func backToTheMainCustom(_ sender: UIButton) {

    performSegue(withIdentifier: "backToTheMainCustom", sender: self)

    sefareshTitleTextField!.text! = ""

    typeandtranslateViewController.checkTextField = false
}

}

Body:
First you need to ask user for permissions to access to the photo library. If request happens first time, wait for his answer and open the UIImagePickerController again. Please review the following code:

let photosAccess = PHPhotoLibrary.authorizationStatus()
switch photosAccess {
case .notDetermined:
    // First time here. Request the access
    PHPhotoLibrary.requestAuthorization({status in
        if status == .authorized{
            // Access was just granted
            // Open library here
        }
    })

case .authorized:
    // Open library here

case .denied, .restricted:
    // Photos access is not granted.
    // Good place to take user to app settings.
}

The same about camera:

AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo) { response in
    if response {
        DispatchQueue.main.async {
            // Show camera UI here
        }
    } else {
        DispatchQueue.main.async {
            // Access is restricred
        }
    }
}


问:
Unable to perform click on the "PrestaShop" link in an IFrame like picture shown below
Am having an issue where I need to perform a click using Selenium Java on the link "PrestaShop" shown below. It's in an IFrame and my code is also below the picture.

Link to be clicked

When inspect the link using FireBug, it shows like below

Inspect using FireBug

And below is my code

```<code>try {
                List<WebElement> frames = getAllFrames();
                for (int i = 0; i < frames.size(); i++) {

                    WebElement frame = frames.get(i);
                    driver.switchTo().frame(frame);

                    if (driver.findElement(By.xpath(".//*[@classname='_1drp _5lv6']/a")).getSize() != null) {
                        driver.findElement(By.className(".//*[@classname='_1drp _5lv6']/a")).click();
                    } else {
                        driver.switchTo().defaultContent();
                    }

                }
            } catch (NoSuchElementException ex) {
                System.out.println(ex.getMessage());
            }
</code>```

The code is getting all frames on the page and verify if the link "PrestaShop" is presence on the frame. If yes then it needs to fire a click on the link. Now, instead it returns error message - Unable to locate element: .//*[@classname='_1drp _5lv6']/a

Can please help to advise how can I fire the click successfully on the link?

答:
While checking the presence of element, try using findElements instead of findElement. Below code might give you some idea.

```<code>            List<WebElement> frames = getAllFrames();
            for (int i = 0; i < frames.size(); i++) {

                WebElement frame = frames.get(i);
                driver.switchTo().frame(frame);
                //use driver.findElements
                if (driver.findElements(By.xpath(".//*[@classname='_1drp _5lv6']/a")).getSize() != null) {
                    driver.findElement(By.xpath("//*[contains(text(),'PrestaShop')]")).click();
                } else {
                    driver.switchTo().defaultContent();
                }

            }
        } catch (NoSuchElementException ex) {
            System.out.println(ex.getMessage());
        }
</code>```

Hope this helps you. Thanks.

Body:
Am having an issue where I need to perform a click using Selenium Java on the link "PrestaShop" shown below. It's in an IFrame and my code is also below the picture.

Link to be clicked

When inspect the link using FireBug, it shows like below

Inspect using FireBug

And below is my code

try {
                List<WebElement> frames = getAllFrames();
                for (int i = 0; i < frames.size(); i++) {

                    WebElement frame = frames.get(i);
                    driver.switchTo().frame(frame);

                    if (driver.findElement(By.xpath(".//*[@classname='_1drp _5lv6']/a")).getSize() != null) {
                        driver.findElement(By.className(".//*[@classname='_1drp _5lv6']/a")).click();
                    } else {
                        driver.switchTo().defaultContent();
                    }

                }
            } catch (NoSuchElementException ex) {
                System.out.println(ex.getMessage());
            }

The code is getting all frames on the page and verify if the link "PrestaShop" is presence on the frame. If yes then it needs to fire a click on the link. Now, instead it returns error message - Unable to locate element: .//*[@classname='_1drp _5lv6']/a

Can please help to advise how can I fire the click successfully on the link?

Body:
While checking the presence of element, try using findElements instead of findElement. Below code might give you some idea.

            List<WebElement> frames = getAllFrames();
            for (int i = 0; i < frames.size(); i++) {

                WebElement frame = frames.get(i);
                driver.switchTo().frame(frame);
                //use driver.findElements
                if (driver.findElements(By.xpath(".//*[@classname='_1drp _5lv6']/a")).getSize() != null) {
                    driver.findElement(By.xpath("//*[contains(text(),'PrestaShop')]")).click();
                } else {
                    driver.switchTo().defaultContent();
                }

            }
        } catch (NoSuchElementException ex) {
            System.out.println(ex.getMessage());
        }

Hope this helps you. Thanks.


问:
Place cursor at the end of text in EditText
I am changing the value of an EditText on keyListener.

But when I change the text the cursor is moving to the beginning of the EditText.
I need the cursor to be at the end of the text.

How to move the cursor to the end of the text in a EditText.

答:
Kotlin:

set the cursor to the starting position:

```<code>val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(0)
</code>```

set the cursor to the end of the EditText:

```<code>val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(editText.text.length)
</code>```

Below Code is to place the cursor after the second character:

```<code>val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(2)
</code>```

JAVA:

set the cursor to the starting position:

```<code> EditText editText = (EditText)findViewById(R.id.edittext_id);
 editText.setSelection(0);
</code>```

set the cursor to the end of the EditText:

```<code>EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setSelection(editText.getText().length());
</code>```

Below Code is to place the cursor after the second character:

```<code>EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setSelection(2);
</code>```

Body:
Kotlin:

set the cursor to the starting position:

val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(0)

set the cursor to the end of the EditText:

val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(editText.text.length)

Below Code is to place the cursor after the second character:

val editText = findViewById(R.id.edittext_id) as EditText
editText.setSelection(2)

JAVA:

set the cursor to the starting position:

 EditText editText = (EditText)findViewById(R.id.edittext_id);
 editText.setSelection(0);

set the cursor to the end of the EditText:

EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setSelection(editText.getText().length());

Below Code is to place the cursor after the second character:

EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setSelection(2);

ContentLicense: CC BY-SA 4.0


问:
Declare a variable with SELECT SQL statement to be used in the WHERE clause
I have a very long SQL statement which has the following skeleton (using SQL server 2005):

```<code>SELECT
    a.something AS Something,
    b.otherthing AS Otherthing,
    (SELECT another FROM ... WHERE...) AS Importantvariable,
....
FROM...
INNER JOIN...
INNER JOIN...
WHERE a.columnname = (SELECT another FROM ... WHERE...) ....
</code>```

This Importantvariable is a very long query by itself. However, it is used in other parts of the same query, including the WHERE clause and the INNER JOIN clauses. My question is, how can I somehow save it's value so I don't have to write the whole query every time. In this example above I would like to type a.columnname = Importantvariable instead of the whole query. I tried using DECLARE and save the value in a declared variable but it's not allowing me to do so with the following error:

```<code>A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operation.
</code>```

Of course, that makes sense but my whole point is to perform data retrieval, I just don't want to copy and paste the very long query that defined the Importantvariable on several different places in the query.
Any ideas?

答:
What you are looking for is Microsoft SQL Server's Common Table Expressions (CTE)

You can read about them here:
https://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx

What you do is

```<code>WITH (columns)
AS (query)
SELECT (another query using (possibly many times) the previous query)
</code>```

Body:
I have a very long SQL statement which has the following skeleton (using SQL server 2005):

SELECT
    a.something AS Something,
    b.otherthing AS Otherthing,
    (SELECT another FROM ... WHERE...) AS Importantvariable,
....
FROM...
INNER JOIN...
INNER JOIN...
WHERE a.columnname = (SELECT another FROM ... WHERE...) ....

This Importantvariable is a very long query by itself. However, it is used in other parts of the same query, including the WHERE clause and the INNER JOIN clauses. My question is, how can I somehow save it's value so I don't have to write the whole query every time. In this example above I would like to type a.columnname = Importantvariable instead of the whole query. I tried using DECLARE and save the value in a declared variable but it's not allowing me to do so with the following error:

A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operation.

Of course, that makes sense but my whole point is to perform data retrieval, I just don't want to copy and paste the very long query that defined the Importantvariable on several different places in the query.
Any ideas?

Body:
What you are looking for is Microsoft SQL Server's Common Table Expressions (CTE)

You can read about them here:
https://technet.microsoft.com/en-us/library/ms190766(v=sql.105).aspx

What you do is

WITH (columns)
AS (query)
SELECT (another query using (possibly many times) the previous query)


问:
Default param and Variable parameters in python
Following is my function :

```<code>def compare(a, b, key=None,*arg2):
    print(a,b,key)
</code>```

So in this how do we call the function without specifying value for the key, but providing value for the arg2 tuple...

Thanks.

答:
If I am not wrong You want to pass default value of variable key. If so you can change the order of the variables. like this</p>

```<code>def compare(a, b,*arg2,key=None):
    print(a,b,key,arg2)

compare(2,3,12,134,135,35,4567647,67865)
#output: 2 3 None (12, 134, 135, 35, 4567647, 67865)
</code>```

Body:
Following is my function :

def compare(a, b, key=None,*arg2):
    print(a,b,key)

So in this how do we call the function without specifying value for the key, but providing value for the arg2 tuple...

Thanks.

Body:
If I am not wrong You want to pass default value of variable key. If so you can change the order of the variables. like this

def compare(a, b,*arg2,key=None):
    print(a,b,key,arg2)

compare(2,3,12,134,135,35,4567647,67865)
#output: 2 3 None (12, 134, 135, 35, 4567647, 67865)


问:
Swift: How can I use synchronized thread for Alamofire?
I want to use synchronized thread using Alamofire.

I am using like this code for synchronization.

```<code>    let queue1 = DispatchQueue(label: "queue1")
    let queue2 = DispatchQueue(label: "queue2")
    queue1.async {
        self.dataFromServer.getData()
    }
    queue2.async {
        //check if success to get the data from server
        while(!self.dataFromServer.resultData){}

        DispatchQueue.main.async {
            // do something on screen
        }
    }
</code>```

...

```<code>   func getData() {
        Alamofire.request(url).responseJSON { response in
           if response.error == nil {
            // get data
            self.resultData = true
           }else{
            // error
           }
        }
   }
</code>```

I want to do something after get data from server using Alamofire.
Is this correct?
If this is not good, please tell me about the synchronization please.
Kind regards.

答:
There is another and probably the good way of doing it by using closures.

```<code>// You don't need to create queue and it asynchronously, since Alamofire calls are async.
// You can  remove queue statement
let queue1 = DispatchQueue(label: "queue1")
queue1.async {
    self.dataFromServer.getData(completionClosure: { (resultData) in
        if resultData {

        }
        else {

        }
    })
}
</code>```

Then in your function have a parameter that takes a closure and call it with success or failure boolean.

```<code>func getData(completionClosure: (Bool) -> Void) {
    Alamofire.request(url).responseJSON { response in
        if response.error == nil {
            // get data
            completionClosure(true)
        }
        else{
            completionClosure(false)
        }
    }
}
</code>```

Body:
I want to use synchronized thread using Alamofire.

I am using like this code for synchronization.

    let queue1 = DispatchQueue(label: "queue1")
    let queue2 = DispatchQueue(label: "queue2")
    queue1.async {
        self.dataFromServer.getData()
    }
    queue2.async {
        //check if success to get the data from server
        while(!self.dataFromServer.resultData){}

        DispatchQueue.main.async {
            // do something on screen
        }
    }

...

   func getData() {
        Alamofire.request(url).responseJSON { response in
           if response.error == nil {
            // get data
            self.resultData = true
           }else{
            // error
           }
        }
   }

I want to do something after get data from server using Alamofire.
Is this correct?
If this is not good, please tell me about the synchronization please.
Kind regards.

Body:
There is another and probably the good way of doing it by using closures.

// You don't need to create queue and it asynchronously, since Alamofire calls are async.
// You can  remove queue statement
let queue1 = DispatchQueue(label: "queue1")
queue1.async {
    self.dataFromServer.getData(completionClosure: { (resultData) in
        if resultData {

        }
        else {

        }
    })
}

Then in your function have a parameter that takes a closure and call it with success or failure boolean.

func getData(completionClosure: (Bool) -> Void) {
    Alamofire.request(url).responseJSON { response in
        if response.error == nil {
            // get data
            completionClosure(true)
        }
        else{
            completionClosure(false)
        }
    }
}


问:
How can I assign a bitmap to a Image control in asp.net using c#?
I have an asp.net file as follows:

```<code><body>
<form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </div>
    <div>
        <asp:Image ID="Image1" runat="server" />
    </div>
</form>
</code>```

I want to set the Image1 in the c# using the following code:

```<code>    protected void Button1_Click(object sender, EventArgs e)
{
    Bitmap oBmp1 = new Bitmap(460, 60);
    Graphics oGrp1 = Graphics.FromImage(oBmp1);
    Color ocolor = new Color();
    ocolor = Color.Yellow;
    SolidBrush oBrush = new SolidBrush(ocolor);
    SolidBrush oBrushWrite = new SolidBrush(Color.White);
    oGrp1.FillRectangle(oBrush, 100, 25, 500, 75);
    Response.ContentType = "image/jpeg";
    oBmp1.Save(Response.OutputStream, ImageFormat.Jpeg);
}
</code>```

How can I directly set the image1 in c# after I generate the bitmap without saving bitmap as an image file?

答: you can save the bitmap as image file in any folder and use your image control to locate your image file path to display the image.</p>

Body:
I have an asp.net file as follows:

<form id="form1" runat="server">

        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

        <asp:Image ID="Image1" runat="server" />

</form>

I want to set the Image1 in the c# using the following code:

    protected void Button1_Click(object sender, EventArgs e)
{
    Bitmap oBmp1 = new Bitmap(460, 60);
    Graphics oGrp1 = Graphics.FromImage(oBmp1);
    Color ocolor = new Color();
    ocolor = Color.Yellow;
    SolidBrush oBrush = new SolidBrush(ocolor);
    SolidBrush oBrushWrite = new SolidBrush(Color.White);
    oGrp1.FillRectangle(oBrush, 100, 25, 500, 75);
    Response.ContentType = "image/jpeg";
    oBmp1.Save(Response.OutputStream, ImageFormat.Jpeg);
}

How can I directly set the image1 in c# after I generate the bitmap without saving bitmap as an image file?


问:
How to notify front-end from backend?
I am using multer for file uploading. On the server I have this:

```<code>stream.on('finish', () => {
  console.log('finished')
  next()
})
</code>```

What would be the best way (with what command) to notify the frontend that 'finished' has happened? I want to know this in order to have a loading bar.

答:
That's what websockets are for. The server can send data to the client, and vice-versa. Check out socket.io.

Server : socket.emit("upload finished")

Client : socket.on("upload finished", function...)

Title: How to notify front-end from backend?

Body:
I am using multer for file uploading. On the server I have this:

stream.on('finish', () => {
  console.log('finished')
  next()
})

What would be the best way (with what command) to notify the frontend that 'finished' has happened? I want to know this in order to have a loading bar.


问:
O/R mapping tools ASP
Are there O/R mapping tools for ASP (not ASP.NET) and are these useful in ASP?

Lieven Cardoen

答: I wrote my own a few years ago - it does not bother traversing relationships, but abstracts away data reads and writes very nicely.</p>

OwnerDisplayName: Lieven Cardoen

ContentLicense: CC BY-SA 2.5

Title: O/R mapping tools ASP

LastEditorDisplayName: recursive

OwnerDisplayName: OrbMan


问:
How to set preference for auto-downloading excel in firefox using robot framework
I am new to robot framework. I was trying to override save dialog box so that Excel files get auto-downloaded without asking in FireFox, however, have been unable to do so.

Can anyone help me and tell what should I pass for auto-downloading Excel 97-2003 worksheet in below line of code in place of application/csv

This is written in python and then am using it in test case as below:

```<code>  **Python code**:
  def create_profile(path):
  from selenium import webdriver
  fp =webdriver.FirefoxProfile()
  fp.set_preference("browser.download.folderList",2)
  fp.set_preference("browser.download.manager.showWhenStarting",False)
  fp.set_preference("browser.download.dir",path)
  fp.set_preference("browser.helperApps.neverAsk.saveToDisk",'application/csv')
  fp.update_preferences()
  return fp.path

  **Test case:**
  ${random_string}    generate random string  3
  ${path} Catenate    SEPARATOR=\\    ${TEMPDIR}  ${random_string}
  ${profile_path}= create_profile  ${path}
  open browser    ${app_url}  ff  ff_profile_dir=${profile_path}
</code>```

Note:I tried giving options as application/excel, application/x-excel, application/msexcel but still dialog box is displayed during automation.

答:
You can use following:</p>

```<code>fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/xls;text/csv");
</code>```

Body:
I am new to robot framework. I was trying to override save dialog box so that Excel files get auto-downloaded without asking in FireFox, however, have been unable to do so.

Can anyone help me and tell what should I pass for auto-downloading Excel 97-2003 worksheet in below line of code in place of application/csv

This is written in python and then am using it in test case as below:

  **Python code**:
  def create_profile(path):
  from selenium import webdriver
  fp =webdriver.FirefoxProfile()
  fp.set_preference("browser.download.folderList",2)
  fp.set_preference("browser.download.manager.showWhenStarting",False)
  fp.set_preference("browser.download.dir",path)
  fp.set_preference("browser.helperApps.neverAsk.saveToDisk",'application/csv')
  fp.update_preferences()
  return fp.path

  **Test case:**
  ${random_string}    generate random string  3
  ${path} Catenate    SEPARATOR=\\    ${TEMPDIR}  ${random_string}
  ${profile_path}= create_profile  ${path}
  open browser    ${app_url}  ff  ff_profile_dir=${profile_path}

Note:I tried giving options as application/excel, application/x-excel, application/msexcel but still dialog box is displayed during automation.

Body:
You can use following:

fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/xls;text/csv");


问:
Reactjs every time refreshing page on setState
I'm using MultiSelect Plugin for Select DropDown. Here onChange event I'm storing the value in setState. Here is below code :

```<code>$('#selectbox-id-onChange').multiselect({
    onChange: function(option, checked) {
         var newArray = this.state.options.slice();
         newArray.push($(option).val());
         this.setState({options: newArray});
    }
});
</code>```

The above code is working fine, I'm able to store the array value in state also. But the only issue is that page is refreshing everytime while storing the value in state.

Please do let me know where I'm going wrong here. I tried to figure out but couldn't get the solution.

答:
Yes, that's what React is meant to do. If you do not want it not to re-render then you have to override the shouldComponentUpdate method.</p>

```<code>shouldComponentUpdate() {
    return false; // Will cause component to never re-render.
}
</code>```

Body:
I'm using MultiSelect Plugin for Select DropDown. Here onChange event I'm storing the value in setState. Here is below code :

$('#selectbox-id-onChange').multiselect({
    onChange: function(option, checked) {
         var newArray = this.state.options.slice();
         newArray.push($(option).val());
         this.setState({options: newArray});
    }
});

The above code is working fine, I'm able to store the array value in state also. But the only issue is that page is refreshing everytime while storing the value in state.

Please do let me know where I'm going wrong here. I tried to figure out but couldn't get the solution.

Body:
Yes, that's what React is meant to do. If you do not want it not to re-render then you have to override the shouldComponentUpdate method.

shouldComponentUpdate() {
    return false; // Will cause component to never re-render.
}


问:
Time to axislabel in HH:MM:SS format from seconds in R
I'm new to R and programming in general. I have data with time in format "HH:MM:SS". For plotting purposes I converted it to seconds.

My problem now is how to convert the seconds in axis (x-axis in this case) labels back to this format in a such way that I can choose whether I want one second intervals, one minute intervals or one hour intervals or pretty much any user defined interval. Mostly 1, 15 or 30 seconds/minutes or 1,2 hours or a combination of these such as one minute and 30 seconds and also give these axis labels appropriate positions on the axis.

Open to any kinds of suggestions.

答:
Use lubridate package</p>

```<code>library(lubridate)
t<-seconds_to_period(5000)
parse_date_time(t,"HMS")
</code>```

Body:
Use lubridate package

library(lubridate)
t<-seconds_to_period(5000)
parse_date_time(t,"HMS")


问:
Deploying .war in debug mode fails with an error
Deploying .war in debug mode fails with below error!!
It works fine in nornalt. Run mode is STS.

Stack Trace:

```<code>10:30:06,715 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
10:30:07,718 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
10:30:07,802 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
10:30:09,707 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment shoppingcart-app.war
10:30:10,139 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment shoppingcart.war
10:30:10,148 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found shoppingcart-app.war in deployment directory. To trigger deployment create a file called shoppingcart-app.war.dodeploy
</code>```

答:
I had the exact same problem yesterday.

After doing some searches on the Internet I found the following solution that worked for me:

Open the /standalone/configuration/standalone.xml file from the jboss directory with a text editor and change the following code

```<code><subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>
</code>```

by adding the deployment-timeout="1000" attribute to the deployment-scanner tag

```<code><subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="1000"/>
</subsystem>
</code>```

Body:
Deploying .war in debug mode fails with below error!!
It works fine in nornalt. Run mode is STS.

Stack Trace:

10:30:06,715 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final
10:30:07,718 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final
10:30:07,802 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: WildFly 8.2.0.Final "Tweek" starting
10:30:09,707 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment shoppingcart-app.war
10:30:10,139 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015014: Re-attempting failed deployment shoppingcart.war
10:30:10,148 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found shoppingcart-app.war in deployment directory. To trigger deployment create a file called shoppingcart-app.war.dodeploy

Body:
I had the exact same problem yesterday.

After doing some searches on the Internet I found the following solution that worked for me:

Open the /standalone/configuration/standalone.xml file from the jboss directory with a text editor and change the following code

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000"/>
</subsystem>

by adding the deployment-timeout="1000" attribute to the deployment-scanner tag

<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" deployment-timeout="1000"/>
</subsystem>


问:
how to join two arrays with linq
i am trying to combine two arrays with their relations but cant do exatly.
I have a Posts Table on my database and in Posts table there are questions and answers records. answers are related with question on "relatedPostId" column.
ex:

```<code>Posts (Table)
-------------
int Id (Field)
string Text (Field)
int RelatedPostId (Field)

question(record) : relatedPostId column is null
answer(record) : relatedPostId column is the value of question id
</code>```

My code is like below

```<code>    var posts = DBConnection.GetComments(_post.TopicId).ToArray().OrderByDescending(p => p.CreateDate);

    var questions = posts.Where(p => p.RelatedPostId == null);
    var answers = posts.Where(p => p.RelatedPostId != null);

    var result = from q in questions
                 join a in answers
                 on q.Id equals a.RelatedPostId
                 select  new { q = q, a = a };
</code>```

I want to list posts on a ListBox (lstCurrentTopic.Items.AddRange(...))
Also i want to display answers at the end of each question like

```<code>Question1
 -> Answer1 (relatedPostId is Qustion1.Id)
 -> Answer2 (relatedPostId is Qustion1.Id)
Qestion2
 ->Answer3 (relatedPostId is Qustion2.Id)
 ->Anser4 (relatedPostId is Qustion2.Id)
</code>```

how can i add with this order to listbox

答:
If you want only the questions that have answers then you could use something like this:

```<code>var result =    from q in questions
                join a in answers on q.Id equals a.RelatedPostId
                group a by q;
</code>```

But if you want all the questions regardless of if they have answers:

```<code>var result =    from q in questions
                from a in answers.Where(x => x.RelatedPostId == q.Id).DefaultIfEmpty()
                group a by q;
</code>```

These both return an IGrouping which should be a structure that works for you (although it is really easy to convert it to a dictionary).

```<code>var dict = result.ToDictionary(x => x.Key, x => x.Select(y => y));
</code>```

The dictionary will have the question as the Key, and an IEnumerable of answers as the Value.

Title: how to join two arrays with linq

Body:
i am trying to combine two arrays with their relations but cant do exatly.
I have a Posts Table on my database and in Posts table there are questions and answers records. answers are related with question on "relatedPostId" column.
ex:

Posts (Table)
-------------
int Id (Field)
string Text (Field)
int RelatedPostId (Field)

question(record) : relatedPostId column is null
answer(record) : relatedPostId column is the value of question id

My code is like below

    var posts = DBConnection.GetComments(_post.TopicId).ToArray().OrderByDescending(p => p.CreateDate);

    var questions = posts.Where(p => p.RelatedPostId == null);
    var answers = posts.Where(p => p.RelatedPostId != null);

    var result = from q in questions
                 join a in answers
                 on q.Id equals a.RelatedPostId
                 select  new { q = q, a = a };

I want to list posts on a ListBox (lstCurrentTopic.Items.AddRange(...))
Also i want to display answers at the end of each question like

Question1
 -> Answer1 (relatedPostId is Qustion1.Id)
 -> Answer2 (relatedPostId is Qustion1.Id)
Qestion2
 ->Answer3 (relatedPostId is Qustion2.Id)
 ->Anser4 (relatedPostId is Qustion2.Id)

how can i add with this order to listbox

Body:
If you want only the questions that have answers then you could use something like this:

var result =    from q in questions
                join a in answers on q.Id equals a.RelatedPostId
                group a by q;

But if you want all the questions regardless of if they have answers:

var result =    from q in questions
                from a in answers.Where(x => x.RelatedPostId == q.Id).DefaultIfEmpty()
                group a by q;

These both return an IGrouping which should be a structure that works for you (although it is really easy to convert it to a dictionary).

var dict = result.ToDictionary(x => x.Key, x => x.Select(y => y));

The dictionary will have the question as the Key, and an IEnumerable of answers as the Value.


问:
Show bootstrap modal on the center of a scrolled down page
I am using ace admin template to develop a website, but I have problem placing bootstrap modal on the center of iframe page when I scrolled it down, like this.

```<code>$('#modalId').modal({
    show:true,
    backdrop:'static'
})
</code>```

how to make the modal pop up on the center of current view?

答:
```<code><script language="javascript">
    this.getTopWindow(window).ui_confirm(content);

    function ui_confirm(msg, confirm, cancel){
        bootbox.dialog({
            message: "<h5>"+msg+"<h5>",
            animate: false,
            closeButton: false,
            size: "small",
            buttons: {
                main: {
                    label: "取消",
                    className: "btn-inverse btn-sm",
                    callback: function() {
                        if (typeof cancel !== "undefined" && Object.prototype.toString.call(cancel) === "[object Function]") {
                            cancel();
                        }
                    }
                },
                danger: {
                    label: "确定",
                    className: "btn-primary btn-sm",
                    callback: function() {
                        if (typeof confirm !== "undefined" && Object.prototype.toString.call(confirm) === "[object Function]") {
                            confirm();
                        }
                    }
                }
            }
        });
    }
</script>
</code>```

Body:
I am using ace admin template to develop a website, but I have problem placing bootstrap modal on the center of iframe page when I scrolled it down, like this.

$('#modalId').modal({
    show:true,
    backdrop:'static'
})

how to make the modal pop up on the center of current view?


问:
Kernel panic inside mod_timer()
I am writing a program which uses multiple timers. For every 5 seconds, they will use one same netlink to communicate with userspace.

To be more specifically, every 5 seconds each timer will call a func(), the func() will do lock, sending something, unlock, and:

```<code>delay_us(200);
if(!timer_pending(&timer1)){
    mod_timer(&timer1, jiffies+RTL_SECONDS_TO_JIFFIES(5));
}
</code>```

The strange thing is in very few occasion, the system will crash inside mod_timer(), I disassembly and find it crash at tne  zero,v0,0xc

The piece of code (MIPS instructions) is below:

```<code>    /*
     * This is a common optimization triggered by the
     * networking code - if the timer is re-modified
     * to be the same thing then just return:
     */
    if (timer_pending(timer) && timer->expires == expires)
800216bc:   8e020000    lw  v0,0(s0)
800216c0:   50400005    beqzl   v0,800216d8 <mod_timer+0x98>
800216c4:   8e020010    lw  v0,16(s0)
800216c8:   8e020008    lw  v0,8(s0)
800216cc:   10510042    beq v0,s1,800217d8 <mod_timer+0x198>
800216d0:   24130001    li  s3,1
800216d4:   8e020010    lw  v0,16(s0)
800216d8:   2c420001    sltiu   v0,v0,1
800216dc:   00020336    tne zero,v0,0xc
</code>```

I am in great pain to debug. I doubt timer race but technically if so, crash should not inside mod_timer() right? It looks very likely some kind of racing happen but it's beyond my knowledge. Any debug suggestions are appreciated.

EDIT :I just add some important dump message below：

```<code>Call Trace:
[<800243a4>] mod_timer+0x9c/0x1b8
[<8002399c>] call_timer_fn+0x20/0x88
[<80023bd0>] run_timer_softirq+0x1cc/0x244
[<8001de80>] __do_softirq+0x118/0x218
[<8001e05c>] do_softirq+0x58/0x78
[<8001e0e0>] irq_exit+0x64/0x80
[<8000044c>] ret_from_irq+0x0/0x4
[<800036cc>] __copy_user_common+0x44/0x2b8
[<8006701c>] file_read_actor+0x9c/0x114
[<8006a47c>] generic_file_aio_read+0x4f4/0x7f4
[<80092f00>] do_sync_read+0x90/0xd4
[<80093fc8>] vfs_read+0xb0/0x158
[<80094170>] SyS_read+0x60/0x9c
[<800017b0>] stack_done+0x20/0x40

Code: 24130001  8e020010  2c420001 <00020336> 02002021  0c008f12  27a50010  8e030000  10600015
</code>```

EDIT:The callback function is like:

```<code>void send_info(unsigned long task_priv)
{
    unsigned long flags;

    struct target_priv *priv = (struct target_priv *)task_priv;

    SMP_LOCK(flags);

    construct_netlink_send(priv);

    SMP_UNLOCK(flags);

    delay_us(200);

    if ((!strcmp(priv->name, "timer0")) && (!timer_pending(&priv->timer0))){
                mod_timer(&priv->timer0, jiffies+SECONDS_TO_JIFFIES(5));
                    return;
            }
    ...//do same for the rest 9 timers
}
</code>```

答:
Some advice for you do debug this problems.

reduce your timer count, make sure every thing is OK when has only one timer.

please attach some panic info, and maybe I can find some useful info to help you solve the problem.

I am not sure if the "delay_us(200);" may cause the problem. the timer callback is in the soft-interrupt content, and it's cannot be block. So, the lock you have used also need to check if it may block the content.

Title: Kernel panic inside mod_timer()

Body:
I am writing a program which uses multiple timers. For every 5 seconds, they will use one same netlink to communicate with userspace.

To be more specifically, every 5 seconds each timer will call a func(), the func() will do lock, sending something, unlock, and:

delay_us(200);
if(!timer_pending(&timer1)){
    mod_timer(&timer1, jiffies+RTL_SECONDS_TO_JIFFIES(5));
}

The strange thing is in very few occasion, the system will crash inside mod_timer(), I disassembly and find it crash at tne  zero,v0,0xc

The piece of code (MIPS instructions) is below:

    /*
     * This is a common optimization triggered by the
     * networking code - if the timer is re-modified
     * to be the same thing then just return:
     */
    if (timer_pending(timer) && timer->expires == expires)
800216bc:   8e020000    lw  v0,0(s0)
800216c0:   50400005    beqzl   v0,800216d8 <mod_timer+0x98>
800216c4:   8e020010    lw  v0,16(s0)
800216c8:   8e020008    lw  v0,8(s0)
800216cc:   10510042    beq v0,s1,800217d8 <mod_timer+0x198>
800216d0:   24130001    li  s3,1
800216d4:   8e020010    lw  v0,16(s0)
800216d8:   2c420001    sltiu   v0,v0,1
800216dc:   00020336    tne zero,v0,0xc

I am in great pain to debug. I doubt timer race but technically if so, crash should not inside mod_timer() right? It looks very likely some kind of racing happen but it's beyond my knowledge. Any debug suggestions are appreciated.

EDIT :I just add some important dump message below：

Call Trace:
[<800243a4>] mod_timer+0x9c/0x1b8
[<8002399c>] call_timer_fn+0x20/0x88
[<80023bd0>] run_timer_softirq+0x1cc/0x244
[<8001de80>] __do_softirq+0x118/0x218
[<8001e05c>] do_softirq+0x58/0x78
[<8001e0e0>] irq_exit+0x64/0x80
[<8000044c>] ret_from_irq+0x0/0x4
[<800036cc>] __copy_user_common+0x44/0x2b8
[<8006701c>] file_read_actor+0x9c/0x114
[<8006a47c>] generic_file_aio_read+0x4f4/0x7f4
[<80092f00>] do_sync_read+0x90/0xd4
[<80093fc8>] vfs_read+0xb0/0x158
[<80094170>] SyS_read+0x60/0x9c
[<800017b0>] stack_done+0x20/0x40

Code: 24130001  8e020010  2c420001 <00020336> 02002021  0c008f12  27a50010  8e030000  10600015

EDIT:The callback function is like:

void send_info(unsigned long task_priv)
{
    unsigned long flags;

    struct target_priv *priv = (struct target_priv *)task_priv;

    SMP_LOCK(flags);

    construct_netlink_send(priv);

    SMP_UNLOCK(flags);

    delay_us(200);

    if ((!strcmp(priv->name, "timer0")) && (!timer_pending(&priv->timer0))){
                mod_timer(&priv->timer0, jiffies+SECONDS_TO_JIFFIES(5));
                    return;
            }
    ...//do same for the rest 9 timers
}


问:
Create Excel with string values
I would like to create an excel with string rows in it.Now by default the excel creates numeric rows and the value i want to set is 00000111.the code i am using is the following :

```<code>Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add

oSheet = oBook.Worksheets("Sheet1")

oSheet.Range("A1").Value = "0000111"
oSheet.Range("B1").Value ="Name"
oSheet.Range("C1").Value = "Name2"
oSheet.Range("D1").Value = "Phone"

oBook.SaveAs("C:\New folder\excel\" & datenw & ".xlsx")
oExcel.Quit()
</code>```

Kind Regards ,
Ifigenia

答:
You have to set the number format for the cell to Text. So need to add a line in your code.</p>

```<code>Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add

oSheet = oBook.Worksheets("Sheet1")

oSheet.Range("A1").NumberFormat = "@"    'This is the added line
oSheet.Range("A1").Value = "0000111"
oSheet.Range("B1").Value ="Name"
oSheet.Range("C1").Value = "Name2"
oSheet.Range("D1").Value = "Phone"

oBook.SaveAs("C:\New folder\excel\" & datenw & ".xlsx")
oExcel.Quit()
</code>```

Title: Create Excel with string values

Body:
I would like to create an excel with string rows in it.Now by default the excel creates numeric rows and the value i want to set is 00000111.the code i am using is the following :

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add

oSheet = oBook.Worksheets("Sheet1")

oSheet.Range("A1").Value = "0000111"
oSheet.Range("B1").Value ="Name"
oSheet.Range("C1").Value = "Name2"
oSheet.Range("D1").Value = "Phone"

oBook.SaveAs("C:\New folder\excel\" & datenw & ".xlsx")
oExcel.Quit()

Kind Regards ,
Ifigenia

Body:
You have to set the number format for the cell to Text. So need to add a line in your code.

Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add

oSheet = oBook.Worksheets("Sheet1")

oSheet.Range("A1").NumberFormat = "@"    'This is the added line
oSheet.Range("A1").Value = "0000111"
oSheet.Range("B1").Value ="Name"
oSheet.Range("C1").Value = "Name2"
oSheet.Range("D1").Value = "Phone"

oBook.SaveAs("C:\New folder\excel\" & datenw & ".xlsx")
oExcel.Quit()


问:
Generics and Inheritance corner case
I have following code and it is not behaving as i am thinking. I have put the comments inline , that what is happening and what is expected.

```<code>class C<T> {
    void m(T arg) {
    }
}

interface I {
    void m(Class arg);
}

class D extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: error -- abstract method not overridden

abstract class E extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: no error, but no bridge method
</code>```

Can some one please help me understand this behavior.

答:
I try to explain what's going on, step by step:

Class D extends C<Class<String>> which introduces the method with signature void m(Class<String> arg) at compile-time as of the definition of class C. But due to type erasure the information about the type parameter String will be eliminated after compilation. Hence the byte code will create a method void m(Class arg) defined by class C.

In addition, class D implements interface I which requires D to implement a method m(Class arg) which at compile-time is different from the method m(Class<String> arg) due to the type parameter. Hence you have to provide an implementation for former method or declare D abstract.

If you provide an implementation for the method m(Class arg) declared by interface I you in fact override the method defined by class C, because both will have the same signature after type erasure is applied.

Things change if you make class D extend C<Collection<String>>. In this case class C will introduce a method with signature void m(Collection<String> arg) at compile-time which changes to void m(Collection args) as byte code after type erasure happened. But now the method void m(Class arg) declared by interface I does have a different signature and hence will not override but overload method m defined by class C.

Here a simple Java example:

```<code>class C<T> {
    void m(T arg) {
        System.out.println("Method [m] of class [C] called");
    }
}

class D extends C<Class<String>> implements I {
    @Override
    public void m(Class arg) {
        System.out.println("Method [m] of class [D] called");
    }
}

class DD extends C<Collection<String>> implements I {

    @Override
    public void m(Class arg) {
        System.out.println("Method [m] of class [DD] called");
    }
}
</code>```

and here a sequence of calls and the output:

```<code>public static void main(String[] args) {
    new D().m(D.class);
    new D().m((Class<String>) null);

    new DD().m(DD.class);
    new DD().m(new ArrayList<String>());
}
</code>```

Output

```<code>Method [m] of class [D] called
Method [m] of class [D] called
Method [m] of class [DD] called
Method [m] of class [C] called.
</code>```

Title: Generics and Inheritance corner case

Body:
I have following code and it is not behaving as i am thinking. I have put the comments inline , that what is happening and what is expected.

class C<T> {
    void m(T arg) {
    }
}

interface I {
    void m(Class arg);
}

class D extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: error -- abstract method not overridden

abstract class E extends C<Class<String>> implements I {
}
// expected : error -- conflicting inherited methods
// actual: no error, but no bridge method

Can some one please help me understand this behavior.

Body:
I try to explain what's going on, step by step:

Class D extends C<Class<String>> which introduces the method with signature void m(Class<String> arg) at compile-time as of the definition of class C. But due to type erasure the information about the type parameter String will be eliminated after compilation. Hence the byte code will create a method void m(Class arg) defined by class C.

In addition, class D implements interface I which requires D to implement a method m(Class arg) which at compile-time is different from the method m(Class<String> arg) due to the type parameter. Hence you have to provide an implementation for former method or declare D abstract.

If you provide an implementation for the method m(Class arg) declared by interface I you in fact override the method defined by class C, because both will have the same signature after type erasure is applied.

Things change if you make class D extend C<Collection<String>>. In this case class C will introduce a method with signature void m(Collection<String> arg) at compile-time which changes to void m(Collection args) as byte code after type erasure happened. But now the method void m(Class arg) declared by interface I does have a different signature and hence will not override but overload method m defined by class C.

Here a simple Java example:

class C<T> {
    void m(T arg) {
        System.out.println("Method [m] of class [C] called");
    }
}

class D extends C<Class<String>> implements I {
    @Override
    public void m(Class arg) {
        System.out.println("Method [m] of class [D] called");
    }
}

class DD extends C<Collection<String>> implements I {

    @Override
    public void m(Class arg) {
        System.out.println("Method [m] of class [DD] called");
    }
}

and here a sequence of calls and the output:

public static void main(String[] args) {
    new D().m(D.class);
    new D().m((Class<String>) null);

    new DD().m(DD.class);
    new DD().m(new ArrayList<String>());
}

Output

Method [m] of class [D] called
Method [m] of class [D] called
Method [m] of class [DD] called
Method [m] of class [C] called.


问:
How to select a partial of a table for exporting using SQL?
I have a dataset which has about 25 millions rows. I want to export it to ACCESS. However, I cannot export it as a whole. So I exported the top 10 millions rows. I have used the codes which is shown below.

```<code>SELECT TOP (10000000) [TRD_EVENT_DT]
  ,[TRD_EVENT_TM]
  ,[TRD_STCK_CD]
  ,[TRD_PR]
  ,[TRD_TUROVR]
FROM [trade92].[dbo].[trade]
</code>```

Now, I want to select second 10 millions rows and Then final 5 millions rows for export them to ACCESS.

How can I do that?

答:
You can also use offset and fetch in your query:</p>

```<code>SELECT [TRD_EVENT_DT]
,[TRD_EVENT_TM]
,[TRD_STCK_CD]
,[TRD_PR]
,[TRD_TUROVR]
FROM [trade92].[dbo].[trade]
ORDER BY [TRD_EVENT_DT]
OFFSET 10000000 ROWS
FETCH NEXT 5000000 ROWS ONLY
</code>```

Body:
I have a dataset which has about 25 millions rows. I want to export it to ACCESS. However, I cannot export it as a whole. So I exported the top 10 millions rows. I have used the codes which is shown below.

SELECT TOP (10000000) [TRD_EVENT_DT]
  ,[TRD_EVENT_TM]
  ,[TRD_STCK_CD]
  ,[TRD_PR]
  ,[TRD_TUROVR]
FROM [trade92].[dbo].[trade]

Now, I want to select second 10 millions rows and Then final 5 millions rows for export them to ACCESS.

How can I do that?

Body:
You can also use offset and fetch in your query:

SELECT [TRD_EVENT_DT]
,[TRD_EVENT_TM]
,[TRD_STCK_CD]
,[TRD_PR]
,[TRD_TUROVR]
FROM [trade92].[dbo].[trade]
ORDER BY [TRD_EVENT_DT]
OFFSET 10000000 ROWS
FETCH NEXT 5000000 ROWS ONLY


问:
Invalid operand to binary expression Error
I'm trying to write this swift line in Objective-C.

Swift

```<code>timeRemainingLabel.text = String(format: "%02d:%02d", ((lround(timeRemaining) / 60) % 60), lround(timeRemaining) % 60)
</code>```

Objective-C

```<code>timeRemainingLabel.text = [NSString stringWithFormat:@"%02d:%02d", ((roundf(timeRemaining) / 60) % 60), roundf(timeRemaining) % 60];
</code>```

But it gives this error:

Invalid operand to binary expression Error.('float' and 'float')

How to fix this?

答:
You need to cast the results of roundf into integers.
Your line should look something like this

timeRemainingLabel.text = [NSString stringWithFormat:@"%02d:%02d",
  (((int)roundf(timeRemaining) / 60) % 60), (int)roundf(timeRemaining) %
  60];

Edit: The working answer from a comment:

```<code>CGFloat timeRemaining = 109.13;
NSString *string = [NSString stringWithFormat:@"%02d:%02d", ((int)(roundf(timeRemaining) / 60) % 60), ((int)roundf(timeRemaining) % 60)];
NSLog(@"String = %@", string);
</code>```

Body:
I'm trying to write this swift line in Objective-C.

Swift

timeRemainingLabel.text = String(format: "%02d:%02d", ((lround(timeRemaining) / 60) % 60), lround(timeRemaining) % 60)

Objective-C

timeRemainingLabel.text = [NSString stringWithFormat:@"%02d:%02d", ((roundf(timeRemaining) / 60) % 60), roundf(timeRemaining) % 60];

But it gives this error:

Invalid operand to binary expression Error.('float' and 'float')

How to fix this?

Body:
You need to cast the results of roundf into integers.
Your line should look something like this

timeRemainingLabel.text = [NSString stringWithFormat:@"%02d:%02d",
  (((int)roundf(timeRemaining) / 60) % 60), (int)roundf(timeRemaining) %
  60];

Edit: The working answer from a comment:

CGFloat timeRemaining = 109.13;
NSString *string = [NSString stringWithFormat:@"%02d:%02d", ((int)(roundf(timeRemaining) / 60) % 60), ((int)roundf(timeRemaining) % 60)];
NSLog(@"String = %@", string);


问:
Groovy Execute Bash Script in Jenkins
I am trying to run a bash script from Groovy in Jenkins but I am not able to find the lucky commands.

I can run this and it creates my "RJ" directory:

```<code>process = "mkdir /app/jenkins/workspace/TEST/RJ"
println process.execute()
</code>```

But when I try to run my bash it is not creating my output file.  I am able to run this bash script on the server directly and it is creating my expected output file.

```<code>process = "/app/jenkins/workspace/TEST/info_file.sh"
println process.execute()
</code>```

答:
first, you don't check the stderr and not waiting for process to end.

similar problem was here:

Curl request from command line and via Groovy script

with error text it's easier to solve the error.

Title: Groovy Execute Bash Script in Jenkins

Body:
I am trying to run a bash script from Groovy in Jenkins but I am not able to find the lucky commands.

I can run this and it creates my "RJ" directory:

process = "mkdir /app/jenkins/workspace/TEST/RJ"
println process.execute()

But when I try to run my bash it is not creating my output file.  I am able to run this bash script on the server directly and it is creating my expected output file.

process = "/app/jenkins/workspace/TEST/info_file.sh"
println process.execute()


问:
Having multiple versions of Rails installed on OS X
OS X 10.6 has Rails 2.2.2 installed by default.

How to upgrade to Rails 2.3.8?

Since Rails 3 is out, is it possible to have multiple versions of Rails (like 2.3.8 and 3) installed on OS X?

(For example, I could be working on two Rails projects, one is Rails 2.x and the other is Rails 3.x).

答:
http://rubygems.org/

It's all you need =)


问:
how to show the UI Slider value in two different fields?
i am tying to show the UI range slider value in input box. i have done this but i want show the same value on another  also, that span is in another .

here i am getting the slider value on this input box but the same value must reflect on another div's  also.

How do i do it , help me out of this

$("#slider").slider({
    range: "min",
    value: 1,
    step: 10,
    min: 210,
    max: 850,
    slide: function (event, ui) {
        $(".inputCount").val(ui.value);
        $(".borrowMonth").val(ui.value);
    }
});
$(".inputCount").change(function () {
    $("#slider").slider("value",this.value);
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="slider"></div>
<label>£</label>
<input type="text" value="200" class="inputCount"/>

<div class="borrowMonth">£ <span>200</span> </div></code>```

答:
You need to use text() instead of val()

And you need to select you span tag instead of div

```<code>$(".borrowMonth span").text(ui.value);
</code>```

http://jsfiddle.net/9uza54ku/

Body:
i am tying to show the UI range slider value in input box. i have done this but i want show the same value on another  also, that span is in another .

here i am getting the slider value on this input box but the same value must reflect on another div's  also.

How do i do it , help me out of this

$("#slider").slider({
    range: "min",
    value: 1,
    step: 10,
    min: 210,
    max: 850,
    slide: function (event, ui) {
        $(".inputCount").val(ui.value);
        $(".borrowMonth").val(ui.value);
    }
});
$(".inputCount").change(function () {
    $("#slider").slider("value",this.value);
});

£
<input type="text" value="200" class="inputCount"/>

£ 200

Body:
You need to use text() instead of val()

And you need to select you span tag instead of div

$(".borrowMonth span").text(ui.value);

http://jsfiddle.net/9uza54ku/