vendredi 11 septembre 2015

changing button image removes skscene

I started my projects as a Spritekit game. Put a button on top of my defaultviewcontroller in storyboard. Presented a scene in viewwilllayoutsubviews.

 if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
            // Configure the view.
            let skView = self.view as! SKView
            self.skView = skView
            skView.showsFPS = true
            skView.showsNodeCount = true

            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.ignoresSiblingOrder = true

            /* Set the scale mode to scale to fit the window */
            scene.scaleMode = SKSceneScaleMode.AspectFill
            println("Width: \(scene.frame.width) andHEight: \(scene.frame.height)")
            scene.gameSceneDelegate = self
            sceneStack.append(scene)
            skView.presentScene(scene)
        }

After some time I transitioned to a new scene through viewcontroller code:

skView.presentScene(scene, transition: transition)

Now the scene changes but the button I had put on view storyboard stays there.. on top of the scene. Now On pressing the button I change the image of button... This surprisingly results in the scene changing back to the previous scene. As a result on changing the buttons any property it results in poping of my new scene and reverts back to the scene I presented initially.



via Chebli Mohamed

merge 2 array key values into one key value php

lets say i have an array like this:

Array
(
    [0] => first one
    [1] => second
)

Essentially i want to get both of the values and put them into the same value but separated with a comma.

The desired output would be this:

Array
(
    [0] => first one, second
)

I'm not sure what function can achieve this



via Chebli Mohamed

MATCH reverse order

In an excel sheet, I have from A1 to A6:

1, 2, 4, 6, 8, 9

I would like, using MATCH function, to retrieve the smallest interval that contains 5. Here, 4 and 6.

I can easily use the MATCH and INDEX function to find 4, but I can't find a way to find the 6.

How can I reverse the order of the Array in the MATCH function?



via Chebli Mohamed

Ruby. Pry. Is there a way to stop a long running command with out exiting out of the whole pry session

I want something to stop a pry command but I don't want to exit to my shell. control-c is not what I'm looking for. I'm not trying to exit out of a loop or out of the entire session. I simply want to return to the pry prompt if I run a line of code that takes a long time...



via Chebli Mohamed

SAS - how to find variable name in string which is similar to a specified sub-string

I want to find if a variable exisits in a string (&fixed) and if so, which word number.

%LET fixed = %STR(variable1 region1 variable3);

%IF %INDEX(&fixed, regio) %THEN
  %DO;
    %LET regioxc = %SCAN(&fixed, %SYSFUNC(FIND(&fixed, regio)));
  %END;

I want to create a macro variable called regioxc, which could be equal to either region1 one time, and the next time the macro is run it could be equal to regiodc, or something else (always with the beginning string 'regio'), if that is the region variable specified within the &fixed string. This only works if the regio variable is specified first within the &fixed string, but in this case it is the second variable, so this does not work. I cannot find a robust method of creating the variable (word) count value from the &fixed string to be able to use the scan function. I know it should be 2, in this case. Any help here would be much appreciaited.



via Chebli Mohamed

Prevent rdlc subreport from growing and moving within main report

I keep dealing with visual studio 2013 report designer.

My biggest problem at the moment is to spare exaclty one sheet of a4 paper (210 mm * 297 mm) per every data record. The length of the details section of the main report varies all the time depending on the lengths of subreports and (seems to me) something else.

Is there a way to keep unchanged both the size and location of a subreport within the main report ?

Thank you in advance !



via Chebli Mohamed

Yii2 Html::dropDownList and Html::activeDropDownList trade-off

In Yii2, using Html::activeDropDownList, I can submit data in a form like the following:

 <?= Html::activeDropDownList($model, 'category', ArrayHelper::map($categories, 'id', 'name'), [
       'multiple' => 'multiple',
       'class' => 'multiselect',
 ]) ?>

Is there a way to specify pre-selected categories in the above? I know it can be done using Html::dropDownLost like the following:

<?= Html::dropDownList('category', [1, 3, 5], ArrayHelper::map($categories, 'id', 'name'), [
     'multiple' => 'multiple',
     'class' => 'multiselect',
]) ?>

But there is a trade-off! There is no place to indicate that this is some data attached to a certain model to submit as there was using Html::activeDropDownList.

One of the solution I found was to use ActiveForm like the following:

<?= $form->field($model, 'category')
      ->dropDownList('category', [1, 3, 5], ArrayHelper::map($categories, 'id', 'name')
]) ?>

The problem I have with that last option is that I am not able to specify the html options such as 'multiple' and css such as 'class'.

Any help on being able to use drop down list with the ability to specify that the list be multiselect and have pre-selected values? Also if someone directed me to a resource where I can read about when and where to choose activeDropDownList or dropDownList, I would really appreciate that.

Thanks!



via Chebli Mohamed