Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles
Affichage des articles dont le libellé est Recent Questions - Stack Overflow. Afficher tous les articles

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

Angularjs - bind dynamic data to predefined template

I'm trying to bind dynamic scope variable with predefined html template. The data is being built based on user selection via drop-down and has ng-click on a button that calls the method to build scope variable, see below for an example:

HTML:

<select id="category" class="form-control" ng-model="dataParam.category">
    <option value="">Choose Category</option>
    <option value="">overview</option>
    <option value="">mention</option>
    <option value="">sentiment</option>
</select>
<button ng-click="buildMetricData()" class="form-control">New</button>

I have template defined as overview-form-temp.html and using ng-include to load it on the view:

<section id="overview" class="well custom-margin" ng-include="'Views/overview-form-temp.html'"></section>

Template:

<form id="overview-form" name="overview-form" novalidate>
    <fieldset class="space-bottom">
        <legend>U.S. Brand Reputation</legend>
        <div class="form-horizontal form-widgets col-sm-12">
            <div class="form-group">
                <label for="awarness" class="col-sm-3">Awareness:</label>
                <div class="col-sm-2">
                    <input type="number" min="0" id="awareness" class="form-control" ng-model="metricData.subcategory['us total']['awareness']" />
                </div>
                <div style="clear:both;"></div>
                <label for="hight-trust" class="col-sm-3">High Trust:</label>
                <div class="col-sm-2">
                    <input type="number" min="0" id="high-trust" class="form-control" ng-model="metricData.subcategory['us total']['high trust']" />
                </div>
            </div>
        </div>
    </fieldset>
</form>

Controller:

var app = angular.module('AdminApp',[]);
app.controller('MainDataContrl', ['$scope','$compile', function($scope,$compile){
    $scope.buildMetricData = function(){

        $scope.metricData = {
            params:{},
            subcategory:{}
        }

        switch($scope.metricData .params.category){
            case 'Overview':
                $scope.metricData.subcategory['us total'] = {};
                break;
        }
    }
}]);

The data is building the way expected but I'm having issues binding it to the template above.



via Chebli Mohamed

How unreferred values from string pool get removed?

I'm curious how values from a string-pool get removed?

suppose:

String a = "ABC"; // has a reference of string-pool
String b = new String("ABC"); // has a heap reference

b = null;
a = null;

In case of GC, "ABC" from the heap gets collected but "ABC" is still in the pool (because its in permGen and GC would not affect it).

If we keep adding values like:

String c = "ABC"; // pointing to 'ABC' in the pool. 

for(int i=0; i< 10000; i++) {
  c = ""+i;
  // each iteration adds a new value in the pool. Previous values don't have a pointer.
}

What I want to know is:

  • Will the pool remove values that are not referred to? If not, it means that the pool is eating up unnecessary memory.
  • What is the point then because the JVM is using the pool?
  • When could this be a performance risk?


via Chebli Mohamed

Attempt to invoke virtual method 'void android.support.v4.widget.DrawerLayout.setDrawerShadow(int, int)' on a null object reference

Due to my lack of knowledge on this I'm jumping from one problem to another. I've been trying to figure it out for hours now and looked through various previous questions but not getting anywhere. Most recent is this error:

 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v4.widget.DrawerLayout.setDrawerShadow(int, int)' on a null object reference
        at XXXX.NavigationDrawerFragment.setUp(NavigationDrawerFragment.java:136)
        at XXXX.EditFactFind.onCreate(EditFactFind.java:72)
        at android.app.Activity.performCreate(Activity.java:5990)

My Activity (the main point that it's failing) is:

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;


import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.DrawerLayout;
//import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class EditFactFind extends Activity implements NavigationDrawerFragment.NavigationDrawerCallbacks {

    public static final int RESULT_DELETE = -500;
    private boolean isInEditMode = true;
    private boolean isAddingFactFind = true;
    private NavigationDrawerFragment mNavigationDrawerFragment;
    private CharSequence mTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_factfind);

        final Button saveButton = (Button)findViewById(R.id.saveButton);
        final Button cancelButton = (Button)findViewById(R.id.cancelButton);
        final EditText titleEditText = (EditText)findViewById(R.id.titleEditText);
        //final EditText factFindEditText = (EditText)findViewById(R.id.factFindEditText);
        final TextView dateTextView = (TextView)findViewById(R.id.dateTextView);
        final Button nextButton =(Button) findViewById(R.id.nextButton);

        //Create fragment and give it an argument for the selected article
        secA_pg1 iniSecFrag = new secA_pg1();
        Bundle args = new Bundle();
        args.putInt(secA_pg1.ARG_INDEX, 1);
        iniSecFrag.setArguments(args);

        FragmentTransaction initialTransaction = getFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack so the user can navigate back
        initialTransaction.replace(R.id.fragment_container, iniSecFrag);
        initialTransaction.addToBackStack(null);

        //Commit the transaction
        initialTransaction.commit();

        mNavigationDrawerFragment = (NavigationDrawerFragment)
                getFragmentManager().findFragmentById(R.id.navigation_drawer);
        mTitle = getTitle();

        // Set up the drawer.
        mNavigationDrawerFragment.setUp(
                R.id.navigation_drawer,
                (DrawerLayout) findViewById(R.id.drawer_layout));

        Serializable extra = getIntent().getSerializableExtra("FactFind");
        if(extra != null)
        {
            FactFind factFind = (FactFind) extra;
            titleEditText.setText(factFind.getTitle());
          //  factFindEditText.setText(factFind.getFactFindTitle());

            DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
            String date = dateFormat.format(factFind.getDate());

            dateTextView.setText(date);

            isInEditMode = false;
            titleEditText.setEnabled(false);
          //  factFindEditText.setEnabled(false);
            saveButton.setText("Edit");

            isAddingFactFind = false;

        }

        cancelButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                setResult(RESULT_CANCELED, new Intent());
                finish();
            }
        });

        nextButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                //secA_pg1 secFrag = (secA_pg1) getFragmentManager().findFragmentById(R.id.Sec_A_pg1_fragment);
                //Create fragment and give it an argument for the selected article
                secA_pg2 newSecFrag = new secA_pg2();
                Bundle args = new Bundle();
                args.putInt(secA_pg2.ARG_INDEX, 2);
                newSecFrag.setArguments(args);

                FragmentTransaction transaction = getFragmentManager().beginTransaction();

                // Replace whatever is in the fragment_container view with this fragment,
                // and add the transaction to the back stack so the user can navigate back
                transaction.replace(R.id.fragment_container, newSecFrag);
                transaction.addToBackStack(null);

                //Commit the transaction
                transaction.commit();
            }
        });

        saveButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {


                if(isInEditMode)
                {
                    Intent returnIntent = new Intent();
                    FactFind factFind = new FactFind(titleEditText.getText().toString(),Calendar.getInstance().getTime());
                    returnIntent.putExtra("FactFind", factFind);
                    setResult(RESULT_OK, returnIntent);
                    finish();

                }
                else
                {
                    isInEditMode = true;
                    saveButton.setText("Save");
                    titleEditText.setEnabled(true);
                   // factFindEditText.setEnabled(true);
                }

            }
        });
    }

and my Navigation drawer is failing at the setUp method:

package XXXX;

import android.support.v4.app.FragmentActivity;

import android.app.ActionBar;

//import android.support.v7.app.ActionBar;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.app.Activity;
import android.app.Fragment;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.support.v7.widget.Toolbar;

    public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer opens
   // mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    ) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }

        //    getActivity().InvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager
                        .getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

          //  getActivity().InvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }
    };

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

XML of the drawer is

<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.DrawerLayout
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="XXXX.MainActivity">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- android:layout_gravity="start" tells DrawerLayout to treat
         this as a sliding drawer on the left side for left-to-right
         languages and on the right side for right-to-left languages.
         If you're not building against API 17 or higher, use
         android:layout_gravity="left" instead. -->
    <!-- The drawer is given a fixed width in dp and extends the full height of
         the container. -->
    <fragment
        android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:name="XXXX.NavigationDrawerFragment"
        tools:layout="@layout/fragment_navigation_drawer" />

</android.DrawerLayout>

I'm assuming that mDrawerLayout isn't being picked up correctly and is therefore returning null but I can't figure out why that is.

Thanks.



via Chebli Mohamed

Create new worksheet if does not exist, rename based on cell value, then reference that worksheet

I have 2 workbooks one has the vba (MainWb), the other is just a template (TempWb) that the code paste values and formulas from the mainworkbook. The TempWb only has one blank sheet named graphs. The code needs to open the xltx file (TempWb), add a sheet and rename based on value in a certain cell on the MainWb (if it does not already exist) and then to reference that new sheet in the copy values process from the MainWb. I tried recording a macro but it didn't really help. I have researched and put some stuff together but not sure if it fits and works. Any suggestions would be appreciated.

This is what I have so far.

Option Explicit
Sub ExportSave()

Dim Alpha           As Workbook 'Template
Dim Omega           As Worksheet 'Template
Dim wbMain          As Workbook 'Main Export file
Dim FileTL          As String   'Test location
Dim FilePath        As String   'File save path
Dim FileProject     As String   'Project information
Dim FileTimeDate    As String   'Export Date and Time
Dim FileD           As String   'Drawing Number
Dim FileCopyPath    As String   'FileCopy save path
Dim FPATH           As String   'File Search Path
Dim Extract         As Workbook 'File Extract Data
Dim locs, loc                   'Location Search
Dim intLast         As Long     'EmptyCell Search
Dim intNext         As Long     'EmptyCell Seach
Dim rngDest         As Range    'Paste Value Range
Dim Shtname1        As String   'Part Platform
Dim Shtname2        As String   'Part Drawing Number
Dim Shtname3        As String   'Part Info
Dim rep             As Long

With Range("H30000")
            .Value = Format(Now, "mmm-dd-yy   hh-mm-ss AM/PM")
        End With

FilePath = "C:\Users\aholiday\Desktop\FRF_Data_Macro_Insert_Test"
FileCopyPath = "C:\Users\aholiday\Desktop\Backup"
FileTL = Sheets("Sheet1").Range("A1").Text
FileProject = Sheets("Sheet1").Range("E2").Text
FileTimeDate = Sheets("Sheet1").Range("H30000").Text
FileD = Sheets("Sheet1").Range("E3").Text
FPATH = "C:\Users\aholiday\Desktop\FRF_Data_Macro_Insert_Test\"
Shtname1 = wbMain.Sheets("Sheet1").Range("E2")
Shtname2 = wbMain.Sheets("Sheet1").Range("E3")
Shtname3 = wbMain.Sheets("Sheet1").Range("E4")

Select Case Range("A1").Value

    Case "Single Test Location"



    Case "Location 1"

    Application.DisplayAlerts = False
    Set wbMain = Workbooks("FRF Data Export Graphs.xlsm")
    wbMain.Sheets("Sheet1").Copy
    ActiveWorkbook.SaveAs FileName:=FileCopyPath & "\" & FileProject & Space(1) & FileD & Space(1) & FileTL & Space(1) & FileTimeDate & ".xlsx", FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close False

    Set Alpha = Workbooks.Open("\\plymshare01\Public\Holiday\FRF Projects\Templates\FRF Data Graphs.xltx")




    For rep = 1 To (Worksheets.Count)
        If LCase(Sheets(rep)).Name = LCase(Shtname1 & Space(1) & Shtname2 & Space(1) & Shtname3) Then
            MsgBox "This Sheet already exists"
            Exit Sub
        End If
    Next

    Sheets.Add after:=Sheets(Sheets.Count)
    Sheets(ActiveSheet.Name).Name = Shtname1 & Space(1) & Shtname2 & Space(1) & Shtname3


            Set Omega = Workbooks(ActiveWorkbook.Name).Sheets("ActiveWorksheet.Name")

            locs = Array("FRF Data Export Graphs.xlsm")



                    'set the first data block destination
                        Set rngDest = Omega.Cells(3, 1).Resize(30000, 3)

                    For Each loc In locs

                    Set Extract = Workbooks.Open(FileName:=FPATH & loc, ReadOnly:=True)

                    rngDest.Value = Extract.Sheets("Sheet1").Range("A4:D25602").Value

                    Extract.Close False

                    Set rngDest = rngDest.Offset(0, 4) 'move over to the right 4 cols

                    Next loc

                          With ActiveWorksheet.Range("D3:D25603").Formula = "=SQRT((B3)^2+(C3)^2)"

                                ActiveWorkbook.Charts.Add
                                ActiveChart.ChartType = xlXYScatterLines
                                ActiveChart.SetSourceData Source:=Sheets("Graphs").Range("A3:D7"), PlotBy:=xlRows
                                ActiveChart.Location Where:=xlLocationAsNewSheet, Name:=Shtname2

                                With ActiveChart
                                    .HasTitle = True
                                    .ChartTitle.Characters.Text = Shtname2
                                    .Axes(xlCategory, xlPrimary).HasTitle = True
                                    .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Hz"
                                    .Axes(xlValue, xlPrimary).HasTitle = True
                                    .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Blank"
                                End With

        Application.ScreenUpdating = True

    Case "Location 2"
    Case "Location 3"
    Case "Location 4"
    Case Else

        MsgBox "Export Failed!"

    End Select


    Application.DisplayAlerts = True

 End Sub

Run-time error '91' Object variable or With block not set code lines

Shtname1 = wbMain.Sheets("Sheet1").Range("E2")
Shtname2 = wbMain.Sheets("Sheet1").Range("E3")
Shtname3 = wbMain.Sheets("Sheet1").Range("E4")

This is supposed to tell the code what to name the new created sheet

Fixed: Moved under

Set = wbMain = Workbooks("FRF Data Export Graphs.xlsm")

New Error: Object doesnt support this property or method code

   If LCase(Sheets(rep)).Name = LCase(Shtname1 & Space(1) & Shtname2 & Space(1) & Shtname3) Then  



via Chebli Mohamed

checking well formed xml and logging the error to file

I have 4,000 xml files in folders a, b, c, and d Each folder contains 1000 files each. All folders are in main folder called library I need to check if the xml files are well formed using

xmllint --noout 100.xml"

command or may be with something better. Now incase of error, log the file name plus folder name in a log file.

log "library/a/100.xml"

Below is the Pseudo code. I need to build the script to run in shell script or something faster

#program check xml format
#!/bin/bash
echo Please, get ready to process
 for i in $(cat "/home/thrinity/library/);
  do
    xmllint --noout "$i" ;
    if error
      #log filefolder & file name
      print error to errorlog.txt
    else
end do

I am looking for error where a tag is missing.. something like.. 038339 here the invoice closing tag is missing or any way I can capture this

For those who might be intrested. The code below worked for me in Ubuntu 14.04 machine

find /YourMainFolder -name '*.xml' -print | xargs -I "{}" sh -c 'File="{}";xmllint --noout "${File}" || readlink -f {} >> errorlog.txt



via Chebli Mohamed

Corona SDK While loop crash

What is wrong with this code that it crashes the simulator? I'm new to Corona SDK, but I know alot of Lua from Roblox.

local x,y,touching,active = 2,2,false,true
local background = display.newImage("Icon.png",(display.pixelWidth/2)+30,y)
background:scale(60,60)
print("Started")

function move()
    y=y+1
end

function onObjectTouch(event)
    if event.phase == "began" then
        touching = true
        while touching == true do
            timer.performWithDelay( 1000, move)
        end
    elseif event.phase == "ended" then
        touching = false
    end
    return true
end

background:addEventListener("touch",onObjectTouch)



via Chebli Mohamed

CreateDialog in BHO always fails with error 1813 (resource not found)

I'm working on a BHO written a long time ago in C++, without the use of any of the VS wizards. As a result, this project deviates from the COM conventions and the boilerplate for a COM product. I worked with COM long ago, but never really did any Windows GUI/dialog stuff...

I'm trying to add a dialog box to allow the user to set the values of some new settings:

// serverDialog will be NULL
HWND serverDialog = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PROPPAGE_SETTINGS), NULL, DialogProc);

id (!serverDialog) 
{
    int error = GetLastError(); //1813
    ...
}

....

1813 means that the resource cannot be found. The IDD used there is in resource.h, which I manually included where needed.

DialogProc is defined as:

INT_PTR CALLBACK DialogProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    return FALSE;
}

Which I know I will have to change later if I want the dialog to actually process messages, but I haven't gotten that far yet. The 1813 error suggests failure before the dialog is even created as does the NULL dialog handle returned.

To add the dialog I used the Add Resource wizard and added a small property page.

I've tried to follow advice here, but to no avail.

Thanks!



via Chebli Mohamed

How to format a US currency string using python or sed

I have numerous invoices that I sent to clients with this string at the bottom: Total: 1,000.00 or whatever the amount. Some are 2 figures, some 5 figures + the decimal part.

The thing is that the number's format is inconsistant accross all invoices. Sometimes its 1.000,00 and it keeps on switching the dot and the coma.

so with grep, awk and sed, i am able to only get the amount part from all invoices, without the dollar sign in order to sum them up to a grand total. But the dot and coma switching confuses python, obviously.

So in python (could be in sed as well), i am looking to convert the third char from the right to a dot and then from there on, every fourth char it finds, convert it to a coma.

In other words, it has to be able to separate the digits in groups of 3 from the right, add a coma in between each of them except for the first group at the far right which would be 2 digits separated by a dot.

Hope that is clear enough...



via Chebli Mohamed

Write a million records into an Excel

I tried to write data into excel with a million record using phpExcel. but it take too much time.

 

    $header=array('test1','test1','test1','test1','test1','test1','test1','test1');
    
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file");
$objPHPExcel->getActiveSheet()->fromArray($header,NULL,'A1');
$sheet = $objPHPExcel->getActiveSheet();
// $final_xls_data1 is set of small records // $rowcount this variable is set of old rowcounts and set
$rowcount=$rowcount +1.
// create 8 small set of records. then add array in excel object $sheet->fromArray($final_xls_data1,NULL,'A'.$rowcount); $objPHPExcel->getActiveSheet()->setTitle('Simple'); $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="01simple.xlsx"'); header('Cache-Control: max-age=0'); header('Cache-Control: max-age=1'); header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header ('Pragma: public'); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save($xls_file_path);

How can I do this?



via Chebli Mohamed

Dynamics CRM 2015 - update Opportunity Owner id via javascript

I'm trying to update the OwnerId on an opportunity in Dynamics CRM 2015.

So far I am using the following code but my changes are not taking effect.

Xrm.Page.data.entity.attributes.get('ownerid').setValue('487ecd0c-d8c1-e411-80eb-c4346bade4b0')
Xrm.Page.data.entity.save();

This is a view of the GetValue call.

enter image description here

The attribute type is "lookup" and when I call getIsDirty(), it returns false after I do setValue, so I'm not sure if that's the correct way to set the value on a "lookup" type.



via Chebli Mohamed

Bash readline history previous line before history expansion

There are usually the keys Up and Ctrl+P mapped to previous-history Readline command in Bash which moves back in history to previous line with history expanded.

How to move to the previous line before History expansion? E.g. to line like

!!:gs/20010910/20010911/



via Chebli Mohamed

Should I use sync or blocking channels?

I have several go routines and I use unbuffered channels as sync mechanism. I'm wondering if there is anything wrong in this(e.g. compared with a WaitGroup implementation). A known "drawback" that I'm aware of is that two go routines may stay blocked until the 3rd(last) one completes because the channel is no buffered but I don't know the internals/what this really means.

func main() {
    chan1, chan2, chan3 := make(chan bool), make(chan bool), make(chan bool)
    go fn(chan1)
    go fn(chan2)
    go fn(chan3)
    res1, res2, res3 := <-chan1, <-chan2, <-chan3
}



via Chebli Mohamed

Polymer 1.0: google-signin sign in still success when user revoke permissions

I am using a google-signin element to have access to user's access scopes. I found, if I as a user authorize the my app with certain scopes, then revoke those scopes without clicking on "Sign out" button (basically the google-signin element), the google-sign is result as onSigninSuccess event even without the authorization.

This is weird. It should be onSigninFailure because the app doesn't have the corresponding scopes of authorizations from the user.



via Chebli Mohamed