text:
Q: Stop Excel from automatically converting certain text values to dates Does anyone happen to know if there is a token I can add to my csv for a certain field so Excel doesn't try to convert it to a date?
I'm trying to write a .csv file from my application and one of the values happens to look enough like a date that Excel is automatically converting it from text to a date.  I've tried putting all of my text fields (including the one that looks like a date) within double quotes, but that has no effect.

A: (Assuming Excel 2003...)
When using the Text-to-Columns Wizard has, in Step 3 you can dictate the data type for each of the columns.  Click on the column in the preview and change the misbehaving column from "General" to "Text."

A: This is a only way I know how to accomplish this without messing inside the file itself. As usual with Excel, I learned this by beating my head on the desk for hours.
Change the .csv file extension to .txt; this will stop Excel from auto-converting the file when it's opened. Here's how I do it: open Excel to a blank worksheet, close the blank sheet, then File => Open and choose your file with the .txt extension. This forces Excel to open the "Text Import Wizard" where it'll ask you questions about how you want it to interpret the file. First you choose your delimiter (comma, tab, etc...), then (here's the important part) you choose a set columns of columns and select the formatting. If you want exactly what's in the file then choose "Text" and Excel will display just what's between the delimiters.

A: I had a similar problem and this is the workaround that helped me without having to edit the csv file contents:
If you have the flexibility to name the file something other than ".csv", you can name it with a ".txt" extension, such as "Myfile.txt" or "Myfile.csv.txt".  Then when you open it in Excel (not by drag and drop, but using File->Open or the Most Recently Used files list), Excel will provide you with a "Text Import Wizard".
In the first page of the wizard, choose "Delimited" for the file type.
In the second page of the wizard choose "," as the delimiter and also choose the text qualifier if you have surrounded your values by quotes
In the third page, select every column individually and assign each the type "Text" instead of "General" to stop Excel from messing with your data.
Hope this helps you or someone with a similar problem!

A: (EXCEL 2007 and later)
How to force excel not to "detect" date formats without editing the source file
Either:

*

*rename the file as .txt

*If you can't do that, instead of opening the CSV file directly in excel, create a new workbook then go to
Data > Get external data > From Text and select your CSV.

Either way, you will be presented with import options, simply select each column containing dates and tell excel to format as "text" not "general".

A: What I have done for this same problem was to add the following before each csv value:
"="""
and one double quote after each CSV value, before opening the file in Excel.  Take the following values for example:
012345,00198475

These should be altered before opening in Excel to:
"="""012345","="""00198475"

After you do this, every cell value appears as a formula in Excel and so won't be formatted as a number, date, etc.  For example, a value of 012345 appears as:
="012345"

A: None of the solutions offered here is a good solution. It may work for individual cases, but only if you're in control of the final display. Take my example: my work produces list of products they sell to retail. This is in CSV format and contain part-codes, some of them start with zero's, set by manufacturers (not under our control). Take away the leading zeroes and you may actually match another product.
Retail customers want the list in CSV format because of back-end processing programs, that are also out of our control and different per customer, so we cannot change the format of the CSV files. No prefixed'=', nor added tabs. The data in the raw CSV files is correct; it's when customers open those files in Excel the problems start. And many customers are not really computer savvy. They can just about open and save an email attachment.
We are thinking of providing the data in two slightly different formats: one as Excel Friendly (using the options suggested above by adding a TAB, the other one as the 'master'. But this may be wishful thinking as some customers will not understand why we need to do this. Meanwhile we continue to keep explaining why they sometimes see 'wrong' data in their spreadsheets.
Until Microsoft makes a proper change I see no proper resolution to this, as long as one has no control over how end-users use the files.

A: I have jus this week come across this convention, which seems to be an excellent approach, but I cannot find it referenced anywhere.  Is anyone familiar with it?  Can you cite a source for it?  I have not looked for hours and hours but am hoping someone will recognize this approach.
Example 1: =("012345678905") displays as 012345678905
Example 2: =("1954-12-12") displays as 1954-12-12, not 12/12/1954.

A: Hi I have the same issue,
I write this vbscipt to create another CSV file. The new CSV file will have a space in font of each field, so excel will understand it as text.
So you create a .vbs file with the code below (for example Modify_CSV.vbs), save and close it. Drag and Drop your original file to your vbscript file. It will create a new file with "SPACE_ADDED" to file name in the same location.
Set objArgs = WScript.Arguments

Set objFso = createobject("scripting.filesystemobject")

dim objTextFile
dim arrStr ' an array to hold the text content
dim sLine  ' holding text to write to new file

'Looping through all dropped file
For t = 0 to objArgs.Count - 1
    ' Input Path
    inPath = objFso.GetFile(wscript.arguments.item(t))

    ' OutPut Path
    outPath = replace(inPath, objFso.GetFileName(inPath), left(objFso.GetFileName(inPath), InStrRev(objFso.GetFileName(inPath),".") - 1) & "_SPACE_ADDED.csv")

    ' Read the file
    set objTextFile = objFso.OpenTextFile(inPath)

    'Now Creating the file can overwrite exiting file
    set aNewFile = objFso.CreateTextFile(outPath, True)
    aNewFile.Close

    'Open the file to appending data
    set aNewFile = objFso.OpenTextFile(outPath, 8) '2=Open for writing 8 for appending

    ' Reading data and writing it to new file
    Do while NOT objTextFile.AtEndOfStream
        arrStr = split(objTextFile.ReadLine,",")

        sLine = ""  'Clear previous data

        For i=lbound(arrStr) to ubound(arrStr)
            sLine = sLine + " " + arrStr(i) + ","
        Next

        'Writing data to new file
        aNewFile.WriteLine left(sLine, len(sLine)-1) 'Get rid of that extra comma from the loop

    Loop

    'Closing new file
    aNewFile.Close

Next ' This is for next file

set aNewFile=nothing
set objFso = nothing
set objArgs = nothing

A: I have found that putting an '=' before the double quotes will accomplish what you want. It forces the data to be text.
eg. ="2008-10-03",="more text"
EDIT (according to other posts): because of the Excel 2007 bug noted by Jeffiekins one should use the solution proposed by Andrew: "=""2008-10-03"""

A: 2018
The only proper solution that worked for me (and also without modifying the CSV).
Excel 2010:

*

*Create new workbook

*Data > From Text > Select your CSV file

*In the popup, choose "Delimited" radio button, then click "Next >"

*Delimiters checkboxes: tick only "Comma" and uncheck the other options, then click "Next >"

*In the "Data preview", scroll to the far right, then hold shift and click on the last column (this will select all columns). Now in the "Column data format" select the radio button "Text", then click "Finish".

Excel office365: (client version)

*

*Create new workbook

*Data > From Text/CSV > Select your CSV file

*Data type detection > do not detect

Note: Excel office365 (web version), as I'm writing this, you will not be able to do that.

A: WARNING: Excel '07 (at least) has a(nother) bug: if there's a comma in the contents of a field, it doesn't parse the ="field, contents" correctly, but rather puts everything after the comma into the following field, regardless of the quotation marks.
The only workaround I've found that works is to eliminate the = when the field contents include a comma.
This may mean that there are some fields that are impossible to represent exactly "right" in Excel, but by now I trust no-one is too surprised.

A: While creating the string to be written to my CSV file in C# I had to format it this way:
"=\"" + myVariable + "\""

A: Its not the Excel. Windows does recognize the formula, the data as a date and autocorrects. You have to change the Windows settings.
"Control Panel" (-> "Switch to Classic View") -> "Regional and Language
Options" -> tab "Regional Options" -> "Customize..." -> tab "Numbers" -> And
then change the symbols according to what you want.
http://www.pcreview.co.uk/forums/enable-disable-auto-convert-number-date-t3791902.html
It will work on your computer, if these settings are not changed for example on your customers' computer they will see dates instead of data.

A: Without modifying your csv file you can:

*

*Change the excel Format Cells option to "text"

*Then using the "Text Import Wizard" to define the csv cells.

*Once imported delete that data

*then just paste as plain text

excel will properly format and separate your csv cells as text formatted ignoring auto date formats.
Kind of a silly work around, but it beats modifying the csv data before importing.   Andy Baird and Richard sort of eluded to this method, but missed a couple important steps.

A: In my case, "Sept8" in a csv file generated using R was converted into "8-Sept" by Excel 2013. The problem was solved by using write.xlsx2() function in the xlsx package to generate the output file in xlsx format, which can be loaded by Excel without unwanted conversion. So, if you are given a csv file, you can try loading it into R and converting it into xlsx using the write.xlsx2() function.

A: I know this is an old question, but the problem is not going away soon. CSV files are easy to generate from most programming languages, rather small, human-readable in a crunch with a plain text editor, and ubiquitous.
The problem is not only with dates in text fields, but anything numeric also gets converted from text to numbers. A couple of examples where this is problematic:

*

*ZIP/postal codes

*telephone numbers

*government ID numbers

which sometimes can start with one or more zeroes (0), which get thrown away when converted to numeric. Or the value contains characters that can be confused with mathematical operators (as in dates: /, -).
Two cases that I can think of that the "prepending =" solution, as mentioned previously, might not be ideal is

*

*where the file might be imported into a program other than MS Excel (MS Word's Mail Merge function comes to mind),

*where human-readability might be important.

My hack to work around this
If one pre/appends a non-numeric and/or non-date character in the value, the value will be recognized as text and not converted. A non-printing character would be good as it will not alter the displayed value. However, the plain old space character (\s, ASCII 32) doesn't work for this as it gets chopped off by Excel and then the value still gets converted. But there are various other printing and non-printing space characters that will work well. The easiest however is to append (add after) the simple tab character (\t, ASCII 9).
Benefits of this approach:

*

*Available from keyboard or with an easy-to-remember ASCII code (9),

*It doesn't bother the importation,

*Normally does not bother Mail Merge results (depending on the template layout - but normally it just adds a wide space at the end of a line). (If this is however a problem, look at other characters e.g. the zero-width space (ZWSP, Unicode U+200B)

*is not a big hindrance when viewing the CSV in Notepad (etc),

*and could be removed by find/replace in Excel (or Notepad etc).

*You don't need to import the CSV, but can simply double-click to open the CSV in Excel.

If there's a reason you don't want to use the tab, look in an Unicode table for something else suitable.
Another option
might be to generate XML files, for which a certain format also is accepted for import by newer MS Excel versions, and which allows a lot more options similar to .XLS format, but I don't have experience with this.
So there are various options. Depending on your requirements/application, one might be better than another.

Addition
It needs to be said that newer versions (2013+) of MS Excel don't open the CSV in spreadsheet format any more - one more speedbump in one's workflow making Excel less useful... At least, instructions exist for getting around it. See e.g. this Stackoverflow: How to correctly display .csv files within Excel 2013?
.

A: In Excel 2010 open a new sheet.
On the Data ribbon click "Get External Data From Text".
Select your CSV file then click "Open".
Click "Next".
Uncheck "Tab", place a check mark next to "Comma", then click "Next".
Click anywhere on the first column.
While holding the shift key drag the slider across until you can click in the last column, then release the shift key.
Click the "text" radio button then click "Finish"
All columns will be imported as text, just as they were in the CSV file.

A: Still an issue in Microsoft Office 2016 release, rather disturbing for those of us working with gene names such as MARC1, MARCH1, SEPT1 etc.
The solution I've found to be the most practical after generating a ".csv" file in R, that will then be opened/shared with Excel users:

*

*Open the CSV file as text (notepad)

*Copy it (ctrl+a, ctrl+c).

*Paste it in a new excel sheet -it will all paste in one column as long text strings.

*Choose/select this column.

*Go to Data- "Text to columns...", on the window opened choose "delimited" (next). Check that "comma" is marked (marking it will already show the separation of the data to columns below) (next), in this window you can choose the column you want and mark it as text (instead of general) (Finish).

HTH

A: Here is the simple method we use at work here when generating the csv file in the first place, it does change the values a bit so it is not suitable in all applications:
Prepend a space to all values in the csv
This space will get stripped off by excel from numbers such as " 1"," 2.3" and " -2.9e4" but will remain on dates like " 01/10/1993" and booleans like " TRUE", stopping them being converted into excel's internal data types.
It also stops double quotes being zapped on read in, so a foolproof way of making text in a csv remain unchanged by excel EVEN IF is some text like "3.1415" is to surround it with double quotes AND prepend the whole string with a space, i.e. (using single quotes to show what you would type) ' "3.1415"'. Then in excel you always have the original string, except it is surrounded by double quotes and prepended by a space so you need to account for those in any formulas etc.

A: Working off of Jarod's solution and the issue brought up by Jeffiekins, you could modify
"May 16, 2011"

to
"=""May 16, 2011"""

A: I know this is an old thread. For the ones like me, who still have this problem using Office 2013 via PowerShell COM object can use the opentext method. The problem is that this method has many arguments, that are sometimes mutual exclusive. To resolve this issue you can use the invoke-namedparameter method introduced in this post.
An example would be
$ex = New-Object -com "Excel.Application"
$ex.visible = $true
$csv = "path\to\your\csv.csv"
Invoke-NamedParameter ($ex.workbooks) "opentext" @{"filename"=$csv; "Semicolon"= $true}

Unfortunately I just discovered that this method somehow breaks the CSV parsing when cells contain line breaks. This is supported by CSV but Microsoft's implementation seems to be bugged.
Also it did somehow not detect German-specific chars. Giving it the correct culture did not change this behaviour. All files (CSV and script) are saved with utf8 encoding.
First I wrote the following code to insert the CSV cell by cell.
$ex = New-Object -com "Excel.Application"
$ex.visible = $true;
$csv = "path\to\your\csv.csv";
$ex.workbooks.add();
$ex.activeWorkbook.activeSheet.Cells.NumberFormat = "@";
$data = import-csv $csv -encoding utf8 -delimiter ";";
$row = 1;
$data | %{ $obj = $_; $col = 1; $_.psobject.properties.Name |%{if($row -eq1){$ex.ActiveWorkbook.activeSheet.Cells.item($row,$col).Value2= $_ };$ex.ActiveWorkbook.activeSheet.Cells.item($row+1,$col).Value2 =$obj.$_; $col++ }; $row++;}

But this is extremely slow, which is why I looked for an alternative. Apparently, Excel allows you to set the values of a range of cells with a matrix. So I used the algorithm in this blog to transform the CSV in a multiarray.
function csvToExcel($csv,$delimiter){
     $a = New-Object -com "Excel.Application"
     $a.visible = $true

    $a.workbooks.add()
     $a.activeWorkbook.activeSheet.Cells.NumberFormat = "@"
     $data = import-csv -delimiter $delimiter $csv;
     $array = ($data |ConvertTo-MultiArray).Value
     $starta = [int][char]'a' - 1
     if ($array.GetLength(1) -gt 26) {
         $col = [char]([int][math]::Floor($array.GetLength(1)/26) + $starta) + [char](($array.GetLength(1)%26) + $Starta)
     } else {
         $col = [char]($array.GetLength(1) + $starta)
     }
     $range = $a.activeWorkbook.activeSheet.Range("a1:"+$col+""+$array.GetLength(0))
     $range.value2 = $array;
     $range.Columns.AutoFit();
     $range.Rows.AutoFit();
     $range.Cells.HorizontalAlignment = -4131
     $range.Cells.VerticalAlignment = -4160
}

 function ConvertTo-MultiArray {
     param(
         [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)]
         [PSObject[]]$InputObject
     )
     BEGIN {
         $objects = @()
         [ref]$array = [ref]$null
     }
     Process {
         $objects += $InputObject
     }
     END {
         $properties = $objects[0].psobject.properties |%{$_.name}
         $array.Value = New-Object 'object[,]' ($objects.Count+1),$properties.count
         # i = row and j = column
         $j = 0
         $properties |%{
             $array.Value[0,$j] = $_.tostring()
             $j++
         }
         $i = 1
         $objects |% {
             $item = $_
             $j = 0
             $properties | % {
                 if ($item.($_) -eq $null) {
                     $array.value[$i,$j] = ""
                 }
                 else {
                     $array.value[$i,$j] = $item.($_).tostring()
                 }
                 $j++
             }
             $i++
         }
         $array
     }
}
csvToExcel "storage_stats.csv" ";"

You can use above code as is; it should convert any CSV into Excel. Just change the path to the CSV and the delimiter character at the bottom.

A: EASIEST SOLUTION
I just figured this out today.

*

*Open in Word

*Replace all hyphens with en dashes

*Save and Close

*Open in Excel

Once you are done editing, you can always open it back up in Word again to replace the en dashes with hyphens again.

A: A workaround using Google Drive (or Numbers if you're on a Mac):

*

*Open the data in Excel

*Set the format of the column with incorrect data to Text (Format > Cells > Number > Text)

*Load the .csv into Google Drive, and open it with Google Sheets

*Copy the offending column

*Paste column into Excel as Text (Edit > Paste Special > Text)

Alternatively if you're on a Mac for step 3 you can open the data in Numbers.

A: (EXCEL 2016 and later, actually I have not tried in older versions)

*

*Open new blank page

*Go to tab "Data"

*Click "From Text/CSV" and choose your csv file

*Check in preview whether your data is correct.

*In сase when some column is converted to date click "edit" and then select type Text by clicking on calendar in head of column

*Click "Close & Load"

A: If someone still looking for answer, the line below worked perfectly for me
I entered =("my_value").
i.e. =("04SEP2009") displayed as 04SEP2009 not as 09/04/2009
The same worked for integers more than 15 digits. They weren't getting trimmed anymore.

A: If you can change the file source data
If you're prepared to alter the original source CSV file, another option is to change the 'delimiter' in the data, so if your data is '4/11' (or 4-11) and Excel converts this to 4/11/2021 (UK or 11-4-2021 US), then changing the '/' or '-' character to something else will thwart the unwantwed Excel date conversion. Options may include:

*

*Tilde ('~')

*Plus ('+')

*Underscore ('_')

*Double-dash ('--')

*En-dash (Alt 150)

*Em-dash (Alt 151)

*(Some other character!)

Note: moving to Unicode or other non-ascii/ansi characters may complicate matters if the file is to be used elsewhere.
So, '4-11' converted to '4~11' with a tilde will NOT be treated as a date!
For large CSV files, this has no additional overhead (ie: extra quotes/spaces/tabs/formula constructs) and just works when the file is opened directly (ie: double-clicking the CSV to open) and avoids pre-formatting columns as text or 'importing' the CSV file as text.
A search/replace in Notepad (or similar tool) can easily convert to/from the alternative delimiter, if necessary.
Import the original data
In newer versions of Excel you can import the data (outlined in other answers).
In older versions of Excel, you can install the 'Power Query' add-in. This tool can also import CSVs without conversion. Choose: Power Query tab/From file/From Text-CSV, then 'Load' to open as a table. (You can choose 'do not detect data types' from the 'data type detection' options).

A: Okay found a simple way to do this in Excel 2003 through 2007.  Open a blank xls workbook.  Then go to Data menu, import external data.  Select your csv file.  Go through the wizard and then in "column data format" select any column that needs to be forced to "text".  This will import that entire column as a text format preventing Excel from trying to treat any specific cells as a date.

A: This issue is still present in Mac Office 2011 and Office 2013, I cannot prevent it happening. It seems such a basic thing.
In my case I had values such as "1 - 2" & "7 - 12" within the CSV enclosed correctly within inverted commas, this automatically converts to a date within excel, if you try subsequently convert it to just plain text you would get a number representation of the date such as 43768. Additionally it reformats large numbers found in barcodes and EAN numbers to 123E+ numbers again which cannot be converted back.
I have found that Google Drive's Google Sheets doesnt convert the numbers to dates. The barcodes do have commas in them every 3 characters but these are easily removed. It handles CSVs really well especially when dealing with MAC / Windows CSVs.
Might save someone sometime.

A: I do this for credit card numbers which keep converting to scientific notation: I end up importing my .csv into Google Sheets. The import options now allow to disable automatic formatting of numeric values. I set any sensitive columns to Plain Text and download as xlsx.
It's a terrible workflow, but at least my values are left the way they should be.

A: I made this VBA macro which basically formats the output range as text before pasting the numbers. It works perfectly for me when I want to paste values such as 8/11, 23/6, 1/3, etc. without Excel interpreting them as dates.
Sub PasteAsText()
' Created by Lars-Erik Sørbotten, 2017-09-17
Call CreateSheetBackup

Columns(ActiveCell.Column).NumberFormat = "@"

Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
DataObj.GetFromClipboard

ActiveCell.PasteSpecial

End Sub

I'm very interested in knowing if this works for other people as well. I've been looking for a solution to this problem for a while, but I haven't seen a quick VBA solution to it that didn't include inserting ' in front of the input text. This code retains the data in its original form.

A: If your working in Javascript and trying to upload CSV with cell value Martin18 or any string with number it shows some date value in JSON
Solution:
      const bstr = event.target.result;
      const wb = XLSX.read(bstr, { type: 'string', raw: true });
      /* Get first worksheet */
      const wsname = wb.SheetNames[0];
      const ws = wb.Sheets[wsname];
      /* Convert array of arrays */
      const data = XLSX.utils.sheet_to_json(ws, { header: 1, defval: ''});

it works for me :)
Source of solution :  https://github.com/SheetJS/sheetjs/issues/940

A: CSV - comma separated values. Just create/edit through text editor instead of xls/xlsx/exel.
In editing you can set date in required format and it must be kept intact.
This is assuming same file is then getting processed programatically.

A: SELECT CONCAT('\'',NOW(),'\''), firstname, lastname
FROM your_table
INTO OUTFILE 'export.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n'

A: Prefixing space in double quotes resolved the issue!!
I had data like "7/8" in one of the .csv file columns and MS-Excel was converting it to date as "07-Aug". But with "LibreOffice Calc" there was no issue.
To resolve this, I just prefixed space character(added space before 7) like " 7/8" and it worked for me. This is tested for Excel-2007.

A: If you put an inverted comma at the start of the field, it will be interpreted as text.
Example:
25/12/2008 becomes '25/12/2008
You are also able to select the field type when importing.

A: An alternate method:
Convert the format of the column you want to change to 'Text'. Select all the cells you want to preserve, copy. Without deselecting those columns, click "Edit > Paste Special > As values"
Save as CSV. Note that this has to be the last thing you do to the file because when you reopen it, it will format itself as dates since cell formats cannot be saved in CSV files.

A: Paste table into word. Do a search/replace and change all - (dashes) into -- (double dash). Copy and paste into Excel. Can do same for other symbols (/), etc. If need to change back to a dash once in Excel, just format the column to text, then make the change. Hope this helps.


text:
Q: Ember unable to pass route action to component I have a component that need to receive an action that I placed on the route since its job is to refresh part of the model.
Apparently I can call the route action from a button but I am not able to pass the same action down to the component.

The router

export default Ember.Route.extend({
    actions: {
        doSomething: function(){
            alert('Router handled!');
        }
    }
});

The page template

<button {{action "doSomething"}}>speak</button>
{{myComponent onGetUsers=(action "doSomething")}}

The component

export default Ember.Component.extend({
    actions: {
        onPageClicked: function(pageNo){
            this.sendAction('onGetUsers', pageNo);
        }
    }
});

The button click works. When I use the component I make it to its action but the sendAction never work or fires.
Is there a rule that I cannot pass actions to down line components? or am I doing something wrong in the code?

A: sendActions - can be used for component to Component communication.
send - can be used for controller to route communication.
You can't use either way.
For Component to route communication, you can use below addon.
ember install ember-route-action-helper

By defining action in route, you can call it from template.hbs
<button {{action (route-action 'appRouteAction' 'fromApplication.hbs') }}>button</button>

and You can call from my-component.hbs
<button {{action (route-action 'appRouteAction' 'from MyComponent.hbs') }}>My-Component button</button>

and If you would like to call Component action first and then action in route,
In template.hbs - include Component with route-action as closure action,
{{my-component2 appRouteAction=(route-action 'appRouteAction')}}

In my-compoent2.hbs,
<button {{action 'appRouteAction' 'CallFromComponentActions-my-compoent2.hbs' }}>CallFromComponentActions</button>

In my-compoent2.js
import Ember from 'ember';
export default Ember.Component.extend({
  actions:{
    appRouteAction(fromWhere){
      console.log('appRouteAction in my-component ');
      this.get('appRouteAction')(...arguments);
    }
  }
});

Sample Twiddle- to play around ember-route-action-helper-addon.

A: sendAction is kind of an old concept. It's still functional, but it's basically been superseded by closure actions which it seems like you're aware of.
The reason it currently doesn't work for the route actions is because of trying to create a closure for an unknown target. At the time the template is inserted into the DOM, the closure action tries to identify the exact function and target it fire when invoked. This is done for simplicity and so that the action can return a value. When that action is on a controller or a parent component, it's very easy. When that action is on a route, it's not so easy because it would have to walk the route chain to find the nearest route implementing that action. Also since route actions can return false to allow the action to bubble further, it would be tricky to fully support.
There is an ember-cli addon that will help bridge this gap though. Checkout: https://github.com/DockYard/ember-route-action-helper. Here is a JSBin showing it in action: http://jsbin.com/luruyegice/edit?html,js,output

redpajama_set_name: RedPajamaStackExchange


text:
Q: Find/replace text string containing the character '*' with cscope The cscope program allows finding/replacing text in a full C code distributed in many files, and navigating easily through the source code. Does anyone know how to search-and-replace patterns that contain the character '*' with cscope?
Whenever I look for a string containing '*' I always get the error message "Could not find the text string: *ptr" (here I looked for '*ptr' which does exists in the code).
According to the source code of cscope (I am using version 15.7a), "findstring" will just escape the characters '. * [ \ ^ $ + ? | ( ) ' with '\' and then search for an egrep pattern ('find.c' @ line 474).
Using directly egrep on a given file and escaping '*' with '\' works. Using cscope to find an egrep pattern instead of a string does not work either.

A: You happened to have picked a buggy version of cscope. It was reported as not working in version 15.8a but working in 15.5, so broke somewhere in between. It was fixed again and works as expected in 15.8b.
More details at #87 special char escaping broken in 15.8 in egrep
You're testing by using the egrep command-line utility, but that isn't what's used by cscope. cscope is using a custom regex implementation, see src/egrep.y. The bug was in there.

A: You can always use an old trick to place "magic characters" into a character class ([...]) to match them as literal characters.
Use [*] to find a literal asterisk symbol.


text:
Q: Asymptotic Analysis of Algorithms:how to insert k new elements into a sorted list of size n in time O(k log k + n) This example demonstrates how to determine the index at which an element should be inserted into a sorted list. Although binarySearch() is used to locate existent elements, it can also be used to determine the insert index for non-existent elements.
// Create a list with an ordered list of items
List sortedList = new LinkedList();
sortedList.addAll(Arrays.asList(new String[]{"ant", "bat", "cat", "dog"}));
// Search for the non-existent item int index = Collections.binarySearch(sortedList, "cow");
// -4 // Add the non-existent item to the list
if (index < 0) { sortedList.add(-index-1, "cow"); }

How I cant to insert elements for time O(k log k + n).
k is the number of lists.
n is the total number of elements in all of the lists (n = n1 + n2 + ... + nk).
Explain in Asymptotic Analysis of Algorithms???

A: This sounds like it deserves a homework flag, so I won't spoil it totally for you, but review your very classical sort algorithms and don't think of it as inserting elements, think of it as creating a still ordered list that contains all elements from both lists.


text:
Q: calling Access query from Excel macro I have a VBA macro in Excel that calls a query in an Access database (.mdb).  However, the Access has been updated to a .accdb file and I don't know how to change up the macro (and/or include any libraries as I don't truly understand that part yet) so that the code will work.
Here is the current "header" code:
'Step 1: Declare your variables
Dim MyDatabase As DAO.Database
Dim MyQueryDef As DAO.QueryDef
Dim MyRecordset As DAO.Recordset

'Step 2: Identify the database and query
Set MyDatabase = DBEngine.OpenDatabase("C:\Users\Ben\Google Drive\Database\Production\FOREAL PROD.mdb")

A: If you are getting an "unrecognizable database format" error then your Excel project may be using an older DAO (Data Access Objects) reference that does not know how to deal with .accdb files.
In the VBA window, choose Tools > References.... If you see an old DAO reference like...
"Microsoft DAO 3.6 Object Library"
...then that could explain the problem.
You'll want to upgrade that old DAO reference to this one...
"Microsoft Office 14.0 Access Database Engine Object Library"
...and to do that you'll need to download and install the Microsoft Access Database Engine 2010 Redistributable from here.


text:
Q: How do I make an image stretch to fill in this WPF / XAML application? When my program displays an image which is smaller than the Image GUI object defined in XAML, it does not get stretched to fit as I would like it to.
For example a 256x256 image only occupies the upper left quadrant of my 512x512 Image GUI object. I am puzzled because I have set Stretch="Fill" in the XAML code. What else do I need to be doing?  Any help with the code (see below) would be greatly appreciated.
XAML code defining the GUI
  <Window x:Class="MyProgram.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MyProgarm" Height="900" Width="890" Name="mainWindow" Icon="Icon.ico" MouseDown="mouseDown">
        <Grid Name="mainGrid" Background="#FFEBE7F0" Width="800.10">
          <Border Margin="139,32,0,0" Name="border1" Height="512" VerticalAlignment="Top" HorizontalAlignment="Left" Width="512" Background="#F0D4D0D0" />
          <Border Margin="138,602,0,0" Name="border2" Height="256" VerticalAlignment="Top" HorizontalAlignment="Left" Width="256" Background="#F0D4D0D0" />
          <Border Margin="400,602,0,0" Name="border3" Height="256" VerticalAlignment="Top" HorizontalAlignment="Left" Width="256" Background="#F0D4D0D0" />
          <Image Margin="135,32,0,0" Name="imagePanel1" Stretch="Fill" HorizontalAlignment="Left" Width="512" MouseMove="imagePanelAxl_MouseMove" Height="512" VerticalAlignment="Top" Canvas.Left="-135" Canvas.Top="-32">
          </Image>

Code I use to draw the image:
byte[] myColorImage=// 256x256 RGB image loaded from disk

int W=256;
int H=256;  // dimensions of myColorImage
// Use multiple cores
image.Dispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action<byte[]>(
      delegate(byte[] myColorImage_IN)
      {
          const int dpi = 96;

          BitmapSource bmpsrc = BitmapSource.Create(W, H, dpi, dpi, PixelFormats.Bgr24, null, myColorImage_IN, W * 3);
          image.Source = bmpsrc;

      }
  ), myColorImage);

A: As many people said above here is the code for using ImageBrush. Which also sets the image while MouseOver.
Thought it might helps new users.
<Grid.Resources>
    <ImageBrush x:Key="AddButtonImageBrush" ImageSource="/DemoApp;component/Resources/AddButton.png" Stretch="Uniform"/>

    <Style x:Key="AddButtonImageStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{StaticResource AddButtonImageBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Background="{TemplateBinding Background}">
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background"  Value="{StaticResource AddButtonImageBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Grid.Resources>

<Button Content="If Text is also Required" Style="{StaticResource AddButtonImageStyle}"/>

A: Instead of Image use Image Brush that will do the work for you
 <Border.Background>
            <ImageBrush x:Name="image" Stretch="UniformToFill"/>
 </Border.Background>

And in the Code Behind you can Set
   image.ImageSource = bmpsrc; // if you can give the URL of the File Located on the Disk

A: If you known the URI of the image on the disk you should use the ImageBrush control.

A: I have a few comments on your code:
And in your XAML you name your image:
imagePanel1

and in codebehind you used:
image

In the image tag in the XAML you said:
Canvas.Left="-135" Canvas.Top="-32"

This image tag is not in a canvas,, it is in a grid.

In the code behind you use the dispatcher to make things use multiple cores?
The dispatcher is used to execute thing from other threads into the UI thread. And if image (from which you use the dispatcher) is also in the UI thread (what I guess it is since it is a UI object) then this wont make your application use multiple cores.

If you set the image margin to 0 and remove the horizontal and vertical alignment. Also remove the width and height. Then your image should completely fill your window.
Can you test this for me.

And you can always use and Uri to set the bitmapsource to the file on your system.
BitmapImage bi3 = new BitmapImage();
bi3.BeginInit();
bi3.UriSource = new Uri("smiley_stackpanel.PNG", UriKind.Relative); //instead you can also use Urikind.Absolute
bi3.EndInit();
imagePanel1.Stretch = Stretch.Fill;
imagePanel1.Source = bi3;


text:
Q: Popular algorithms for recognition of this image I have some image like following image:

I have developed my own algorithm to find corresponding image to test image in my DB.
My problem is that I want to compare my algorithm with well-known algorithms. Since my pattern is kind of unique I have no Idea about well-known algorithm which works for me.

*

*Anybody has any suggestion about type of image processing algorithm that works for me?

*Any other suggestion for measuring my algorithm performance?

A: As no-one is answering, I will make a first attempt and maybe that will spur others into action.
My initial reaction would be to look a Fingerprint Recognition techniques which analyse ridge endings (line ends), bifurcations (junctions) and short ridges, loops and whorls. See Wikipedia.
This can be done readily at the command line with ImageMagick and there are some excellent techniques written up by Anthony Thyssen here. There are Perl, PHP, Python, Java, C/C++ bindings too if you prefer those languages.
So, let's look at line endings. You can find the line endings like this:
convert dendrite.png -threshold 50% -morphology HMT LineEnds result.png

And you can put red circles around them like this:

And you can count them like this:
convert dendrite.png -threshold 50% -morphology HMT LineEnds -format "%[fx:mean*w*h]" info:
59

Anthony goes on to look at junctions and loops, but get it straight from the maestro...
Hope that helps. How about sharing your own technique?


text:
Q: Start different Neo4j versions in the same program Is it possible to start different Neo4j versions in the same java program?
I'd like to start different Versions of Neo4j in different Threads.
(Multiversion programming - Fault tolerance purposes)
I don't need them to interact in HA mode, they will interact through my own interface.

A: Yes, you can connect to different Neo4j servers and make cypher requests to those.
I wouldn't recommend writing an unmanaged server extension that connects to different environments though.


text:
Q: How to use same gradient on multiple columns in gt? I am creating this table in gt.

The gradient in the columns are on two different scales--notice how .1424 in Var2 is darker blue than .2206 in Var1. How might it be possible to change the palette so that both columns are on the same color scale? So in the new table the darkest blue would be the largest value in the two columns (.4199) and the darkest red would be the smallest in the two columns (.0003), all 8 other cells falling somewhere between on that spectrum?
Here is my data/code:
ex <- structure(list(Var1 = c(0.0015, 0.22058, 0.335, 0.3747612, 0.4199048
), Var2 = c(0.0002778, 0.1424279, 0.1233159, 0.1684, 0.1816663
)), class = "data.frame", row.names = c(NA, -5L))
ex %>%
  gt() %>%
  tab_header(title = md("Title")) %>%

  fmt_number(
    vars(`Var1`, `Var2`), decimals = 4) %>%

  data_color(vars(`Var1`, `Var2`),
             colors = scales::col_numeric(palette = c("red", "white", "blue"), domain = NULL)

  )

A: If you specify the domain (per the docs), that should solve your issue, e.g.
library(gt)
ex <- structure(list(Var1 = c(0.0015, 0.22058, 0.335, 0.3747612, 0.4199048
), Var2 = c(0.0002778, 0.1424279, 0.1233159, 0.1684, 0.1816663
)), class = "data.frame", row.names = c(NA, -5L))

ex %>%
  gt() %>%
  data_color(vars(`Var1`, `Var2`),
             scales::col_numeric(palette = c("red", "white", "blue"),
                                 domain = c(0, 0.5)))

If you change the color scheme you can see the gradient change more clearly, e.g.
ex %>%
  gt() %>%
  data_color(vars(`Var1`, `Var2`),
             scales::col_numeric(palette = c("red", "white"),
                                 domain = c(0, 0.5)))


text:
Q: Нужно определения дня недели Код на java. Нужно чтобы от пользователя запрашивался номер дня недели, а получалось название. Не пойму, что не так. Помогите, пожалуйста, Добрые Люди
    import java.util.Scanner;

public class JavaApplication5 {

    public static void main(String[] args) {

        Scanner sw = new Scanner(System.in);
        System.out.print("Введите число: ");
        int week = sw.nextInt();
        sw.nextLine();
        System.out.println(Month.dayOFWeek(week));
       // System.out.println("The day is "+day);

}

class Month{
    static String dayOFWeek(int week) {
        String day = "";

        switch (week) {
            case 1:
                day = "Monday";
                break;
            case 2:
                day = "Tuesday";
                break;
            case 3:
                day = "Wednesday";
                break;
            // match the value of week
            case 4:
                day = "Thursday";
                break;
            case 5:
                day = "Friday";
                break;
            case 6:
                day = "Saturday";
                break;
            case 7:
                day = "Sunday";
                break;
            default:
                day = "---";
                break;
        }
        return day;
    }
}
}

A: *

*некорректное использование метода nextInt();

при вводе и нажатии "Enter"  nextInt()считывает число, а перевод на новую строку
nextLine ("\n") остаётся и может быть непредвиденное поведение.
надо либо после nextInt прописывать  nextLine
int week = sw.nextInt();
sw.nextLine();

либо парсить
  int week = Integer.parseInt(sw.nextLine());

2)в классе Month создай статик метод принимающий число и возвращающий день
  static String dayOFWeek(int week) {
        String day = "";
//switch
return day;
}

в мейне считываешь число и передаёшь в метод
  System.out.println(Month.dayOFWeek(week));

если версия jdk выше 11 или 13 не помню точно, то можно так написать
class Month {

    static String dayOFWeek(int week) {

        return switch (week) {
            case 1 -> "Monday";
            case 2 -> "Tuesday";
            case 3 -> "Wednesday";
            case 4 -> "Thursday";
            case 5 -> "Friday";
            case 6 -> "Saturday";
            case 7 -> "Sunday";
            default -> "---";
        };
    }
}


text:
Q: Use dialofRef to pass config between components in Angular 4 I'm using angular-material in Angular 4 and I want after setting the config (data, id) in my first component to pass it to another component so that I can read the properties.
In my (news-feed.component.ts) I have this function:
editPost(id,item) {
    const config = new MatDialogConfig();
    config.id = id;
    config.data = item;
    const dialogRef: MatDialogRef<PostComponent> = this.dialog.open(PostComponent, config);
    dialogRef.componentInstance.editedPost(config);
}

And in my (post.component.ts):
editedPost(config) {
    console.log(config.data);
}

And this is what I got in my console:

My data is (das) word, that's mean it can read property 'data', and when I press any key the error repeated itself in console. What I've missed here?

A: I found an alternative solution by using dialogRef.
In (news-feed.component.ts):
editPost(id,item) {
        const dialogRef: MatDialogRef<PostComponent> = this.dialog.open(PostComponent);
        dialogRef.componentInstance.myPost = item;
        dialogRef.componentInstance.myId = id;
    }

And in my (post.component.ts):
public myPost: any;
public myId: any;

editedPost() {
        console.log(this.myPost);
        console.log(this.myId);
        return true;
    }


text: Q: use a page with framesets as a modal page in asp.net I have a simple Statistics.aspx page with a frameset, and I want to use it as a modal page in a web user control. I have a javascript function and I use it in a gridview Item template as below ::


text:
Q: Are there any non-trivial convergent sequences in the maximal ideal space of the measure algebra? Consider the measures on the circle, $M(\mathbb T)$, endowed with the convolution product which makes it a unital Banach algebra under the total variation norm. Denote by $\Delta$ the maximal ideal space of $M(\mathbb T)$. This space is quite large–recently it was shown that $\Delta$ is non-separable, for example. It also has many copies of $\beta \mathbb N$, yet it is not extremely disconnected, however, in certain sense, it is not too far from being so.
Extremely disconnected spaces do not have injective convergent sequences, again $\beta \mathbb N$ serves a paradigm example.

Does $\Delta$ have any injective convergent sequences?

I have some evidence that it should not be the case but I am unable to make it into a proof. Maybe this follows from some known facts anyway?

A: Norbert is right (see the paper The Structure of Convolution Measure Algebras). Actually, I had known the result but it didn't occur to me that it would have solved the problem.
The maximal ideal space of $M(\mathbb T)$ contains an analytic disk, which in particular, is a homeomorphic copy of $\mathbb D$, so there are plenty of convergent sequences therein.


text:
Q: Hashing an uploaded file in HTML I am a beginner in HTML and JavaScript. I want to upload an image using HTML5 and get its hash by JavaScript. After that, I want to send the hash value to a PHO server. I uploaded an image with a web browser. But i don't know how i can hash the image. I saw many guides but no one helped me. My HTML code is below. Please fill it and help me.
HTML:
<!DOCTYPE html>
<html>
<body>
<input type="file" id="customerFile" name="Documents"/>
<script>
     // Get hash value
     // Send it to the server
</script>
</body>
</html>

I should hash it in html level. I shouldn't give the server any file

A: Please check the below snippet. You can send hash value to the server by sending a POST request with result.

function calculateMD5Hash(file, bufferSize) {
        let def = Q.defer();

        let fileReader = new FileReader();
        let fileSlicer = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
        let hashAlgorithm = new SparkMD5();
        let totalParts = Math.ceil(file.size / bufferSize);
        let currentPart = 0;
        let startTime = new Date().getTime();

        fileReader.onload = function (e) {
            currentPart += 1;

            def.notify({
                currentPart: currentPart,
                totalParts: totalParts
            });

            let buffer = e.target.result;
            hashAlgorithm.appendBinary(buffer);

            if (currentPart < totalParts) {
                processNextPart();
                return;
            }

            def.resolve({
                hashResult: hashAlgorithm.end(),
                duration: new Date().getTime() - startTime
            });
        };

        fileReader.onerror = function (e) {
            def.reject(e);
        };

        function processNextPart() {
            let start = currentPart * bufferSize;
            let end = Math.min(start + bufferSize, file.size);
            fileReader.readAsBinaryString(fileSlicer.call(file, start, end));
        }

        processNextPart();
        return def.promise;
    }

    function calculate() {

        let input = document.getElementById('file');
        if (!input.files.length) {
            return;
        }

        let file = input.files[0];
        let bufferSize = Math.pow(1024, 2) * 10; // 10MB

        calculateMD5Hash(file, bufferSize).then(
            function (result) {
                // Success
                console.log(result);
                // SEND result TO THE SERVER
            },
            function (err) {
                // There was an error,
            });
    }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/q.js/1.4.1/q.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/spark-md5/2.0.2/spark-md5.min.js"></script>

<div>
    <input type="file" id="file"/>
    <input type="button" onclick="calculate();" value="Calculate Hash" class="btn primary"/>
</div>
</body>
</html>


text:
Q: How to merge arrays of hashes with matching a column value I want to merge two arrays array1 and array2 with matching a column values. Plot ID may or may not match between two arrays. Matching column is Plot ID in array1 and Plotting ID in array2.
Dominant is array1. Column values in array1 should come at first in the expected output.
Merge array2 column names with zero values if array2 doesn't match with array1
array1 = [
{"Date" => "2019-01-01", "Plot ID" => 234},
{"Date" => "2019-01-01", "Plot ID" => 235},
{"Date" => "2019-01-01", "Plot ID" => 236},
{"Date" => "2019-01-01", "Plot ID" => 237},
{"Date" => "2019-01-01", "Plot ID" => 238},
{"Date" => "2019-01-01", "Plot ID" => 239},
{"Date" => "2019-01-01", "Plot ID" => 240},
{"Date" => "2019-01-01", "Plot ID" => 241}
]

array2 = [
{"Date" => "2019-01-01", "Plotting ID" => 234, "size"=> 20, "visit" => 10, "price" => 103},
{"Date" => "2019-01-01", "Plotting ID" => 500,  "size"=> 40, "visit" => 22, "price" => 233},
{"Date" => "2019-01-01", "Plotting ID" => 236,  "size"=> 25, "visit" => 34, "price" => 423},
{"Date" => "2019-01-01", "Plotting ID" => 600,  "size"=> 79, "visit" => 55, "price" => 234}
]

Expected output:
[
{"Date" => "2019-01-01", "Plot ID" => 234, "size"=> 20, "visit" => 10, "price" => 103},
{"Date" => "2019-01-01", "Plot ID" => 235, "size"=> 0, "visit" => 0, "price" => 0},
{"Date" => "2019-01-01", "Plot ID" => 236, "size"=> 25, "visit" => 34, "price" => 423},
{"Date" => "2019-01-01", "Plot ID" => 237, "size"=> 0, "visit" => 0, "price" => 0},
{"Date" => "2019-01-01", "Plot ID" => 238, "size"=> 0, "visit" => 0, "price" => 0},
{"Date" => "2019-01-01", "Plot ID" => 239, "size"=> 0, "visit" => 0, "price" => 0},
{"Date" => "2019-01-01", "Plot ID" => 240, "size"=> 0, "visit" => 0, "price" => 0},
{"Date" => "2019-01-01", "Plot ID" => 241, "size"=> 0, "visit" => 0, "price" => 0}
]

A: This answer only works if array2 doesn't contain any duplicate Plotting ID values. (If there are duplicate Plotting ID it still works, but it uses the last record of the once precent in the array.)
array1 = [{"Date" => "2019-01-01", "Plot ID" => 234}, {"Date" => "2019-01-01", "Plot ID" => 235}, {"Date" => "2019-01-01", "Plot ID" => 236}, {"Date" => "2019-01-01", "Plot ID" => 237}, {"Date" => "2019-01-01", "Plot ID" => 238}, {"Date" => "2019-01-01", "Plot ID" => 239}, {"Date" => "2019-01-01", "Plot ID" => 240}, {"Date" => "2019-01-01", "Plot ID" => 241}]
array2 = [{"Date" => "2019-01-01", "Plotting ID" => 234, "size"=> 20, "visit" => 10, "price" => 103}, {"Date" => "2019-01-01", "Plotting ID" => 500,  "size"=> 40, "visit" => 22, "price" => 233}, {"Date" => "2019-01-01", "Plotting ID" => 236,  "size"=> 25, "visit" => 34, "price" => 423}, {"Date" => "2019-01-01", "Plotting ID" => 600,  "size"=> 79, "visit" => 55, "price" => 234}]

array2_lookup = array2.map(&:dup).map { |record| [record.delete('Plotting ID'), record] }.to_h
array2_lookup.default = { 'size' => 0, 'visit' => 0, 'price' => 0 }
pp array1.map { |record| array2_lookup[record['Plot ID']].merge(record) }
# [{"Date"=>"2019-01-01", "size"=>20, "visit"=>10, "price"=>103, "Plot ID"=>234},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>235},
#  {"Date"=>"2019-01-01", "size"=>25, "visit"=>34, "price"=>423, "Plot ID"=>236},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>237},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>238},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>239},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>240},
#  {"size"=>0, "visit"=>0, "price"=>0, "Date"=>"2019-01-01", "Plot ID"=>241}]

The above solution first loops over array2 and converts it to a hash, by deleting the key/value pair 'Plotting ID' from the hash and using the value as key. For this reason I've added the .map(&:dup) call, preventing the original hashes in array2 from mutating. If the hash mutation is not an issue for you you can simply remove this.
After creating the lookup hash I've added a default that is used when merging the hashes. All that is left to do now is loop through array1, lookup the record (if any) or use the default and merge that with the current element.
This answer leaves the keys somewhat scrambled, but since a hash is based on key lookup anyway (not key/value order) this shouldn't be a huge issue. If you'd like to have all keys in the same order you can do so by providing all the keys to the default, setting their values to nil (or any other value since they are overwritten):
array2_lookup.default = { 'Date' => nil, 'size' => 0, 'visit' => 0, 'price' => 0 }
# ...                        ^ added placeholder for ordering purposes
# [{"Date"=>"2019-01-01", "size"=>20, "visit"=>10, "price"=>103, "Plot ID"=>234},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>235},
#  {"Date"=>"2019-01-01", "size"=>25, "visit"=>34, "price"=>423, "Plot ID"=>236},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>237},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>238},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>239},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>240},
#  {"Date"=>"2019-01-01", "size"=>0, "visit"=>0, "price"=>0, "Plot ID"=>241}]

A: array1 = [{"Date" => "2019-01-01", "Plot ID" => 234}, {"Date" => "2019-01-01", "Plot ID" => 235}, {"Date" => "2019-01-01", "Plot ID" => 236}, {"Date" => "2019-01-01", "Plot ID" => 237}, {"Date" => "2019-01-01", "Plot ID" => 238}, {"Date" => "2019-01-01", "Plot ID" => 239}, {"Date" => "2019-01-01", "Plot ID" => 240}, {"Date" => "2019-01-01", "Plot ID" => 241}]
array2 = [{"Date" => "2019-01-01", "Plotting ID" => 234, "size"=> 20, "visit" => 10, "price" => 103}, {"Date" => "2019-01-01", "Plotting ID" => 500,  "size"=> 40, "visit" => 22, "price" => 233}, {"Date" => "2019-01-01", "Plotting ID" => 236,  "size"=> 25, "visit" => 34, "price" => 423}, {"Date" => "2019-01-01", "Plotting ID" => 600,  "size"=> 79, "visit" => 55, "price" => 234}]

grouped = (array2 + array1).group_by { |h| h["Plot ID"] || h["Plotting ID"] }
merged = grouped.values.map { |a| a.inject(:merge) }

# and in case you want exact formatting:
template = { "Date" => nil, "Plot ID" => nil, "size"=> 0, "visit" => 0, "price" => 0 }
normalized = merged.each { |h| template.merge(h).slice(*template.keys) }

You can see how each line of code does one meaningful and independent transformation of the data. I find code like this much easier to step through in a debugger.
Learn to compose those built-in Enumerable and Hash methods and greatly simplify your code!

A: If i get correctly the answer, maybe this is a possible option.
template = {"size"=> 0, "visit" => 0, "price" => 0}
array1.map do |h|
  begin
    h.merge!(template, array2.find { |hh| hh["Plotting ID"] == h["Plot ID"] })
     .then { |hh| hh.delete("Plotting ID") }
  rescue TypeError
  end
end

I used rescue because find could return nil.

Option without rescue:

template = {"size"=> 0, "visit" => 0, "price" => 0}
array1.map do |h|
  h2 = {} || array2.find { |hh| hh["Plotting ID"] == h["Plot ID"] if hh.has_key("Plotting ID") }
  h.merge!(template, h2).then { |hh| hh.delete("Plotting ID") }
end

Even one liner:
array1.map { |h| h.merge!({"size"=> 0, "visit" => 0, "price" => 0}, {} || array2.find { |hh| hh["Plotting ID"] == h["Plot ID"] if hh.has_key("Plotting ID") }).then { |hh| hh.delete("Plotting ID") } }

It modifies array1, so:

array1

# [{"Date"=>"2019-01-01", "Plot ID"=>234, "size"=>20, "visit"=>10, "price"=>103}, {"Date"=>"2019-01-01", "Plot ID"=>235, "size"=>0, "visit"=>0, "price"=>0}, {"Date"=>"2019-01-01", "Plot ID"=>236, "size"=>25, "visit"=>34, "price"=>423}, {"Date"=>"2019-01-01", "Plot ID"=>237, "size"=>0, "visit"=>0, "price"=>0}, {"Date"=>"2019-01-01", "Plot ID"=>238, "size"=>0, "visit"=>0, "price"=>0}, {"Date"=>"2019-01-01", "Plot ID"=>239, "size"=>0, "visit"=>0, "price"=>0}, {"Date"=>"2019-01-01", "Plot ID"=>240, "size"=>0, "visit"=>0, "price"=>0}, {"Date"=>"2019-01-01", "Plot ID"=>241, "size"=>0, "visit"=>0, "price"=>0}]

A: template = (array2.first.keys - array1.first.keys - ["Plotting ID"]).product([0]).to_h
  #=> {"size"=>0, "visit"=>0, "price"=>0}

h = array1.each_with_object({}) { |g,h| h[g["Plot ID"]] = g.merge(template) }
  #=> {234=>{"Date"=>"2019-01-01", "Plot ID"=>234, "size"=>0, "visit"=>0, "price"=>0},
  #    235=>{"Date"=>"2019-01-01", "Plot ID"=>235, "size"=>0, "visit"=>0, "price"=>0},
  #    ...
  #    241=>{"Date"=>"2019-01-01", "Plot ID"=>241, "size"=>0, "visit"=>0, "price"=>0}}

array2.each_with_object(h) { |g,f| f.update(g["Plotting ID"]=>
    g.transform_keys { |k| k == "Plotting ID" ? "Plot ID" : k }) }.values
  #=> [{"Date"=>"2019-01-01", "Plot ID"=>234, "size"=>20, "visit"=>10, "price"=>103},
  #    {"Date"=>"2019-01-01", "Plot ID"=>235, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>236, "size"=>25, "visit"=>34, "price"=>423},
  #    {"Date"=>"2019-01-01", "Plot ID"=>237, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>238, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>239, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>240, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>241, "size"=> 0, "visit"=> 0, "price"=>  0},
  #    {"Date"=>"2019-01-01", "Plot ID"=>500, "size"=>40, "visit"=>22, "price"=>233},
  #    {"Date"=>"2019-01-01", "Plot ID"=>600, "size"=>79, "visit"=>55, "price"=>234}]

If desired, h could be substituted out in the last expression.
It would be simpler to define template as follows:
template = (%w| size visit price |).product([0]).to_h

This has the disadvantage, however, of being fragile to changes to the names and/or numbers of keys in the elements of array2.
Though less efficient, the following may be clearer and easier to maintain.
a2 = array2.map { |h| h.transform_keys { |k| k == "Plotting ID" ? "Plot ID" : k } }
  # => [{"Date"=>"2019-01-01", "Plot ID"=>234, "size"=>20, "visit"=>10, "price"=>103},
  #     {"Date"=>"2019-01-01", "Plot ID"=>500, "size"=>40, "visit"=>22, "price"=>233},
  #     {"Date"=>"2019-01-01", "Plot ID"=>236, "size"=>25, "visit"=>34, "price"=>423},
  #     {"Date"=>"2019-01-01", "Plot ID"=>600, "size"=>79, "visit"=>55, "price"=>234}]
template = (a2.first.keys - array1.first.keys).product([0]).to_h
  #=> <same as earlier value>
h = array1.each_with_object({}) { |g,h| h[g["Plot ID"]] = g.merge(template) }
  #=> <same as earlier value>
a2.each_with_object(h) { |g,f| f.update(g["Plot ID"]=>g) }.values
  #=> <same as earlier value>


text:
Q: Remove remote git repository Is it possible to completely delete a remote repository (assuming I have write access). I'm trying to completely clear a repository on BitBucket and push a fresh copy. I know I can delete and recreate the repo on BitBucket itself, but I was wondering if I could just "clear" it on the terminal?

A: Nope. There is no remote "delete repo" command in Git. The closest you can come (which seems appropriate since you want to recreate the repo) is to delete all the remote branches.

A: I'm not sure if i understand you right, but if you just want to start with a new history you can delete your local repo init a new one, add the remote repositories path to the new local repo and forcepush that one over your old repo with: git push -f origin master
This is not recommendet if you are working with other developers on the same project and if you are not... you should be careful by doing this as well.


text:
Q: Dynamics 365 Get Guid Button Does anyone know of a managed solution to import into Dynamics 365 that adds functionality for a custom button to copy the Guid of any entity to your clipboard?
In a previous environment we used this one
Of course this can't be imported into the newer Dynamics 365.
I know how to parse out the Guid from the URL, but the button to autocopy it to the clipboard was amazing.

A: The Chrome Extension Level Up has button for Record Id, or you can use the bookmarklet code. Just add the below code to a bookmark in your browser:
//get record id
javascript: (function () { var form = $("iframe").filter(function () { return $(this).css("visibility") == "visible" })[0].contentWindow; window.prompt("Copy to clipboard: Ctrl+C, Enter", form.Xrm.Page.data.entity.getId().slice(1, -1)) })();

A: Try Level Up for Dynamics 365 Chrome Extension, it provides a great variaty of common JScript actions and shortcuts to help with extensibility, diagnostics and administration
if what you need is to pulish an option to your user to get the GUID of a record and prevent the execution of other JS logic such as display all hidden attributes, then you will have to create a ribbon button and execute JS logic contained in a webresource, to make it compatible with CRM v9 and forward, past the execution context to your function (PrimaryControl) and call the native Xrm function executionContext.getFormContext().data.entity.getId()

A: Another extremely useful Chrome called Dynamics Power Pane. Use it together with Level Up for Dynamics 365 will be very powerful.


text:
Q: SyntaxError: unindent does not match any outer indentation level >>> x = 5
>>> y = 3
>>> if x == y:
        print("Yes")
    else:

SyntaxError: unindent does not match any outer indentation level
>>>

I keep having this problem. I am new into Python but I want to learn it seriously and I am struggling with this error. I made research about indentation and tried to review my few lines of code but with  no succes. I cannot understand why it keeps appearing as I tried not to mix tabs and spaces. Thanks in advance for help! (I am currently running Python 3.6.4)

A: add or print some thing in else block. It will resolve your issue.
x = 5
y = 3
if x == y:
   print("Yes")
else:
   print("No")

A: Try the below code without the else block and see if it still gives you the same error.
x = 5
y = 3
if x == y:
    print("Yes")

A: Ok i am also using a Python SoloLearn app and tried to write the same code in the Code Playground and it works just fine. I also did use my fathers laptop and looks ok there too... (He is using 3.3... or similar). So I can only say that maybe its some kind of weird bug occuring on my laptop or on 3.6.4. Anyway thank you all for answers and fast reply. I just wanted to be sure its not my bad and now I'm pretty sure its not :))

A: First I try:
>>> a=30
>>> if(a>100):
        print(">100")
    else:

SyntaxError: unindent does not match any outer indentation level
>>>

Then:
>>> a=30
>>> if (a>100):
        print("+100")
else:
        print("-100")

-100
>>>

The editor use tab, so after the end of a block and press 'Enter',
it add automaticly an indentation. Then just press 'Backspace' (or 'Tab') to align to the correct block.
You notice that the first 'else:' is align to the start of line.
Enjoy


text:
Q: What's so bad about system()? Given that you're building a Windows - exclusive program, why are calls to system() so hated? Ever since I started programming in C++, "don't touch system" was something I've heard an awful lot. I've obeyed that principle docilely but what's so bad about it?

A: What you put inside the system call is dependent on the OS you will run the program on. So it's completely non-portable. Also, many things can go wrong, as you're just throwing a command into the void, and hope that everything will go fine. Error handling (for example - the program you want to run does not exist, or PATH is not set correctly, or you don't have permissions, etc.) is very hard or even impossible.
Beside this, as noted in the comments most of the time (really "most", like 99.999%) there is no need to use system.

A: std::system() requires that you trust the command to do what you want. You have no way of verifying whether this assumption is justified. For example an unusual value for the PATH environment variable may cause a different program to be executed than in the standard setup.
The behaviour of a call to std::system() is system dependant. Even if the requirement at the moment is, that the application does not need to run on other operating system, this requirement can change. Considering that std::system() is often used for purposes that can be achieved in a more portable manner (especially by beginners), introducing platform dependance here is not required.

A: system() invokes the OS's command interpreter as a separate process.  More times than not, there are native APIs available to accomplish the same result directly within the calling process and with more control over it.


text:
Q: Other way to createSchemaNode() ObjectMapper objectMapper = new ObjectMapper();
ObjectNode properties = objectMapper.createObjectNode();
properties.set(KEY1, createSchemaNode("string"));
properties.set(KEY2,getSchemaFor(provider,EnvironmentType.class));
properties.set(KEY3, createSchemaNode("string"));
properties.set(KEY4, createSchemaNode("string"));

Need other approach to set the properties instead of using createSchemaNode() I am trying to upgrade Jackson version from 2.8 to 2.10. After updating Jackson version to  2.10 I am facing issue with createdSchemaNode(). Because createdSchemaNode() is deprecated from Jackson databind version 2.9.0


text:
Q: How do I find number of submissions of a url in digg? API documentation in Digg is totally confusing...does any one know how to count submissions for a particular URL in PHP??
some API paths that will return in XML or Json will do...

A: It looks like the number of diggs is included in the events tag in the response.


text:
Q: need to rewrite this query without using a correlated subquery I know how correlated subqueries work and usually steer away from them.. but for what I was trying to do i couldn't find another way to write this query. I was ok with using it because I didn't have a bunch of records in the table I was using.. but now I need to do the same thing on some tables with > 100,000 records in them which will make this query take a long time. so I need some help with rewriting this query.
INITIAL QUERY:
SELECT
DATE(m.Created_At) AS m_date,
COUNT(m.id) AS daily_count,
(
    SELECT
        COUNT(m1.id)
    FROM members_joined m1
    WHERE m1.has_verified = 1 and DATE(m1.Created_At) <= m_date
) AS member_totals
FROM members_joined AS m
WHERE m.has_verified = 1 and m.Created_At BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()
GROUP BY m_date;

what this query is doing is getting the total count of registered members up to 30 days ago.. and then for every day between the last 30 days its doing the total count again
m_date      daily_count member_totals
2014-05-27      4           619
2014-05-29      1           620
2014-05-30      3           623
2014-06-02      4           627
2014-06-03      7           634
2014-06-04      10          644
2014-06-05      12          656
2014-06-06      4           660
2014-06-07      3           663
2014-06-08      3           666
2014-06-09      3           669
2014-06-10      5           674
2014-06-11      3           677

if you notice it is incrementing the count by each daily count.
this query itself only takes .036 seconds to run which isnt a big deal
but on some of the bigger tables it already takes 12 seconds and they are only going to get bigger.
NOTE: can this be done without using a correlated subquery? assume you cannot use user-defined variables.
if this cant be done in mysql I can hit the database twice and do it in python, but I was hoping to find a solution in MySQL and not hit the database multiple times.
thanks for any pointers / help!

A: This can hardly be done with pure SQL efficiently, but you can use MySQL-specific user defined variables. You will just need to compute counts for each day and accumulate counts for each row.
The main trick is to force MySQL update the variable in the correct order.
The query should look like the following (not sure that it is 100% correct):
SELECT m_date, daily_count, @count:=(daily_count + @count) as member_totals
FROM
(SELECT DATE(Created_At) as m_date, COUNT(*) as daily_count
 FROM members_joined
 WHERE DATE(Created_At) >= CURDATE() - INTERVAL 30 DAY AND has_verified = 1
 GROUP BY m_date
) as days,
(SELECT @count:=COUNT(*) as cnt0
 FROM members_joined
 WHERE DATE(Created_At) < CURDATE() - INTERVAL 30 DAY
   AND has_verified = 1) as init
ORDER BY m_date;

A: EDIT : fix a mistake in the query
EDIT2 : proposal of a python way
You can rewrite it with an explicit auto-join, but I do not think it will be faster
SELECT
DATE(m.Created_At) AS m_date,
COUNT(m.id) AS daily_count,
COUNT(m1.id) AS member_totals
FROM members_joined AS m
JOIN members_joined m1 ON m1.has_verified = 1 and DATE(m1.Created_At) <= DATE(m.Created_At)
WHERE m.has_verified = 1 and m.Created_At BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()
GROUP BY m_date;

You are asking the database to get a quadratic number of rows.
As the autojoin do not improve performance, I think you should 2 simpler queries from your database, and then do the sums in Python.
SELECT
DATE(m.Created_At) AS m_date,
COUNT(m.id) AS daily_count,
FROM members_joined AS m
WHERE m.has_verified = 1 and m.Created_At BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE()
GROUP BY m_date;

to get daily_count per date for the last 30 days, and
SELECT
CURDATE() - INTERVAL 30 DAY AS m_date,
COUNT(m.id) AS member_totals,
FROM members_joined AS m
WHERE m.has_verified = 1 and m.Created_At < CURDATE() - INTERVAL 30 DAY;

to get the cumulative member_totals for the day preceding the first of the other query
Python pseudo code, say second query initialized member_total, and then first query initialized rows (be it a cursor or a list or tuple obtained by fetchall)
for row in rows:
    dat, daily_count = row
    member_totals += daily_count
    # use dat, daily_count, member_totals


text:
Q: How can I make this array? I am trying to figure out the lengths of a house shape based on curtain points on the triangle half. for example every time I move down the long side of the triangle I would take a measurement each time having a shorter measurement than the last. I am trying to right code that will find this for me. I know that the first measurement will be equal to the height from the floor bottom to the peak of the triangle. Then each time it moves three feet down the triangle it will subtract 9 inches. However I need it to stop when it hits zero. I have set up my array like this.
var endwallPanelLength=[]
endwallPanelLength[1]=peakHeight;
endwallPanelLength[2]=peakHeight-peakHeightDecrease;
endwallPanelLength[3]=endwallPanelLength[2]-peakHeightDecrease;
endwallPanelLength[4]=endwallPanelLength[3]-peakHeightDecrease;

I know I have other things to work out for the whole code but how can I at least define these measurements in the array more efficiently.
peakHeightDecrease is just 3 * the slope

A: Is this what you want?
var endwallPanelLength = [peakHeight];
var i = 0;
while (endwallPanelLength[i] >= peakHeightDecrease) {
    endwallPanelLength.push(endwallPanelLength[i] - peakHeightDecrease);
    i++;
}

BTW, array indexes normally start at 0.
Another way is just to divide peakHeight by the the decrease:
var repetitions = Math.floor(peakHeight/peakHeightDecrease);
var endwallPanelLength = [];
for (var i = 0; i <= repetitions; i++) {
    endwallPanelLength.push(peakHeight - peakHeightDecrease*i);
}


text:
Q: Apostrophe CMS + apostrophe-external-notifications: How to implement support for a new event I want to send Slack notifications from my CMS on every 'Submit' event. I successfully got the existing events to fire off in Slack but when I included the following code in the node modules package for apostrophe-external-notifications as follows, I do not receive any notifications.
     self.notifyOn('apostrophe-workflow:afterSubmit', (req, submit) =>
    ['{user} submitted the {type} {title} which has these tags: {string}.', submit.from, submit.from, submit.from.tags]
  );

A: afterSubmit is not a server event that apostrophe-workflow emits at the moment. There's only a browser event, workflowSubmitted, from that action.
Update 2020-03-05: This event was added as of apostrophe-workflow@2.32.0.


text:
Q: Is there a way to detect when my computer plugs into a dock in Task Scheduler? I am trying to run a .PS1 script on my Windows 11 Surface device every time the computer connects to a Surface Dock. I am attempting to figure out if I can use Task Scheduler to detect an event every time the Dock connects, but I can't seem to figure out which event it is (or if this is the wrong way to do this).
Any advice you have would be very welcome!
I tried going through the Event Monitor to find events for the connection of the Dock or something else that also connects at the same time (like a USB device), but I can't quite figure it out


text:
Q: How to differentiate the short form of "would" and "had"? How do you differentiate:
I'd always longed to see... = I would always longed to see...
VS
I'd always longed to see.. = I had always longed to see..

A: Both the auxiliary verbs would and had contract to 'd, usually with pronoun subjects: he'd, I'd, you'd, she'd, it'd, they'd, we'd. Whether spoken or written, you can't tell which one it is, if you only have the contraction.
But you can tell the difference if you notice what comes next.
Like all auxiliary verbs, each of these must be followed by a particular verb form.

*

*Would, like all modal auxiliary verbs, must be followed by an Infinitive verb form:
I would always love to stand on the beach (not *loved).
= I'd always love to stand on the beach

*Have is the auxiliary for the Perfect, and takes a Past Participle verb form:
I had always loved to stand on the beach (not *love).
= I'd always loved to stand on the beach

A: In similar uses, the meaning is realized. But generally, it is known what use it is as a structure. For example, "Would" is usually used with the perfect infinitive (have + past participle), while "Had" is used with the past participle.
In your example, the sentence with had seems correct. Because it should be used as "would always v1".


text:
Q: There is no progress in the Xcode archive I pressed the archive button to finish building the app and post it to the iTunes Store. But in the Compiling Swift source files, the progress bar has stopped and I am waiting for 13 hours. but builds well on my iPhone or test device.
I archived another project that I created earlier. It stopped at a certain point, but the process went well. The only thing I guessed was, is there something wrong with my Mac's RAM? I am currently writing 4 gigabytes,
and while archiving, x-code related programs are using 3.8 gigabytes. Of course, the mouse scrolls or everything else is slow. But obviously in the same condition, the build and archiving of other projects worked well.
xcode version is 8.2.1(8C1002)


text:
Q: Tables float into bibliography I have a sequence of sections of my paper, followed by a bibliography (bibtex).
It looks pretty much like
\input{asection}
\input{appendix}
\bibliography(bibfile}

The problem is, "appendix" contains several tables, and they're being intersperesed among the bibliography. I want to have all of the tables, then the bibliography.
Adding a page break between sections or writing \begin{table}[h!] is not working. Any help would be appreciated!!

A: I think you want the \clearpage command. It forces LaTeX to push out all floating objects (figures and tables), and start a new page. Just put it in the source before you begin the appendix.
A Google search for \clearpage should point you to plenty more references if you want them.


text:
Q: Python - Simple tkinter menu I need help from you.
I want to code a simple menu with tkinter, but i have problem with that.
What I want to do -  In my menu,there are 2 items: "first", "second". When i click on the first, program must write 'The first' and then when I click on the second, it must write second, but the first one there will be not yet.
Can anybody help me? Thx.
I mean something like this
from tkinter import *
root = Tk()

def do_something():
    # this function e.g. write 'The first'
    pass

def do_something_other():
    # this function e.g. write 'The second' (but 'The first' there will be not yet)

main_menu = Menu(root)
root["menu"] = main_menu

submenu1 = Menu(main_menu)
submenu1.add_command(label="Item1", command=do_something)
submenu1.add_command(label="Item2", command=do_something_other)

main_menu.add_cascade(label="Program", menu=submenu1)

My goal is, that the canvas will be changing after clicking on the Item1/Item2

A: You can use a Tkinter Label widget to display text in your GUI. The Label widget has a method called config that you can use to access options of the widget, to include its text attribute.
Here's a simple example. You'll have to modify it to work with your menus and specific needs:
root = Tk()

def callback():                       # this function will access the
    label.config(text='Updated Text') # config method of label to change it

label = Label(root, text='Original text') # make the label and set default text
btn = Button(root, text='Change text', command=callback) # make the button, which executes the callback func

label.pack()
btn.pack()

mainloop()


text:
Q: cannot set cuebanner for kryptontextbox I tried using the following code to set cue banner for a kryptontextbox
Imports System.Runtime.InteropServices

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
       SetCueText(KryptonTextBox1.Handle, "Enter Name here")
    End Sub
End Class

Public Module CueBannerText
    <DllImport("user32.dll", CharSet:=CharSet.Auto)> _
    Private Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As Int32
    End Function
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As IntPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
    Private Const EM_SETCUEBANNER As Integer = &H1501

    Public Sub SetCueText(hWnd As IntPtr, text As String)
      if Not hWnd = IntPtr.Zero Then
         SendMessage(hWnd, EM_SETCUEBANNER, 0, text)
      End If
    End Sub
End Module

however, the text is not getting set. how do i fix this

A: EM_SETCUEBANNER is applicable on a TextBox control. KryptonTextBox in fact is a composite Control which contains a TextBox.
The TextBox is exposed using a TextBox property. You can use KryptonTextBox1.TextBox.Handle to send EM_SETCUEBANNER message.
To see the source code for components take a look at this GitHub repository. Here is a related part of code:
public class KryptonTextBox : VisualControlBase, IContainedInputControl
{
    //...
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [EditorBrowsable(EditorBrowsableState.Always)]
    [Browsable(false)]
    public TextBox TextBox
    {
        get { return _textBox; }
    }
    //...
}


text:
Q: Is CSS Sprite compatible to SVG I've tried using svg on my background. However when I'm
using an SVG file it's not working fine all Icons is showing and it's
too small. My goal is like on the png file type by using
background-position I can control the position of the image that I
converted to CSS Sprite. Can anyone tell me how to do it using svg
file? Also I'm asking if it's possible to change the fill color of the
svg icon that I converted into CSS Sprite?
Also please see image below when I'm trying to use the svg file. All
icons are showing and it's super small. Are CSS Sprite and SVG compatible?

.icon-one ._icon {
    width: 24px;
    height: 24px;
    margin-right: 2px;
    background: url(../media/icons/toolbar/toolbar-icon-svg-type-01.svg) no-repeat 0 0;
    background-position: 0 0;
}


text:
Q: Ordinary Power series How do I find an  exponential generating function for $$\{p(n)/n!\}_{1}^{\infty}$$ where $$ p \in \mathbb{Z}^{+}[x] $$I see a method to find an opsgf for the same sequence by applying $x \frac{d}{dx}$ operator to $e^x$ but I am not able to figure out a good way for egf. Help would be appreciated.
Thank You.

A: With the modified Bessel function $I_0$ we have
$$ \begin{array}{ll} \displaystyle\sum_{n=0}^\infty p(n)\frac{x^n}{n!^2} & \displaystyle = \sum_{n=0}^\infty \Big(\sum_{k=0}^d a_kn^k\Big)\frac{x^n}{n!^2} \\[5pt] & \displaystyle = \Big[\sum_{k=0}^d a_k\Big(x\frac{d}{dx}\Big)^k\Big]\sum_{n=0}^{\infty} \frac{x^n}{n!^2} \\[5pt] & = \displaystyle p\Big(x\tfrac{d}{dx}\Big) I_0(2\sqrt{x}). \end{array} $$


text:
Q: Are there binary way to convert integer hundred position to zero? I'm trying to make a function HundredPosToZero to convert hundred position to zero, for example :
HundredPosToZero(4239) // 4039

This is my implement :
public HundredPosToZero(int num){
  return num / 1000 * 1000 + num % 100;
}

However, I'm thinking of why not use bitwise operator like 4239 & 1011 to do the same thing? But I can not figure out how to implement it since 4239 is not a binary, any advice with this approach?

A: Not really. There is nothing special about decimal hundreds in binary. It would be possible with e.g. a hexadecimal number, but decimal numbers don't play well with binary :)

A: It is simply impossible if you want this operation to be the same for all numbers as "hundreds" in regular representation of integers don't occupy the same set of bits.
If you use some other binary representation of numbers (like BCD) that allocates groups of bits to unique decimal digits then you can do that easily.


text:
Q: How to create a virtual storage space in C++? I'm using a third party SDK, and one of the method goes as following:
void ReadData(string filePath);

As you might have guessed, it requires a filename for the method.
I do not wish having to drop a (sensitive) file into the HDD, then use its filename as the parameter.
I was wondering if there is some way to create an isolated storage space from the user, so I can drop any files I want in there without worrying about people finding it?
EDIT: Strictly for Windows OS only.

A: Just don't worry about it.
You seem to have some misconception about who owns the computer and the data.  The user does.
If you're worried about other users getting access to the file, use the user's private documents or appdata directory, the ACL will prevent unprivileged users from getting to it.
But if your business model relies on denying a user access to the data inside their own computer, you need to rethink that.  There isn't any API to save a flawed business model.

A: since the API of you call asks for a filename instead of a file, we have to asume that you really need a file, not a file-like-object.
A more specific name to the method would be "ReadDataFromFile". Take a look, is there another method that accepts the data itself, instead of a filename?
You are trying to transfer trust from the file owner to/and only to the program that does the call, you are mentioning in your question. So, if that all fails, take a look at File ACLs to restrict the access to the sensitive data, e.g.: https://superuser.com/questions/246280/what-are-windows-acls or http://msdn.microsoft.com/en-us/library/aa374872%28v=vs.85%29.aspx
You still have to put the sensitive file on disk (an worry about deleting it later), but access would be restricted.


text: Q: How do I Develop push notifications with multiple people? A group of friends and I are looking to start a company, and we wanted to develop our app (it uses push notifications) first. However, I'm the only one with a Apple Developer Account, and there's no way to sign the app and download the app onto a phone if the computer being used isn't mine. We looked into buying a program, but the only options we found were Individual and Enterprise. Enterprise seems like its only for 100+ people — is there no "under 50" or "under 10" developer program?


text:
Q: Is it possible to have an enumeration in a EMF Ecore model implement an interface? Is it possible to have an enumeration in a EMF Ecore model implement an interface ? It is possible in Java to have something like : public enum MyEnum implements MyInterface. I'd like to be able to generate something like this via EMF (btw, It seems by default all enums generated by EMF implement org.eclipse.emf.common.util.Enumerator).
I can't find a way to have my generated enumeration implement a particular interface. I can't define inheritance relationships with an enumeration in the ecore diagram editor, nor in the ecore model editor. I can add the implements bit by hand to the enumeration after generating the code, but then it gets overwritten everytime I generate the code again.
Alternatively, is there a way to have the implements (and only it) not being overwritten by EMF's code generation ?
I know I can modify the @generated tag in the class javadoc comment to @generatedNOT so the code generator knows it musn't overwrite the class, but it prevents the class from being updated when I modify the model.
For now what I do is I manually add the implements each time I modify this enumeration in the model and keep the @generatedNOT tag the rest of the time. I feel this will get dangerous in a few months when I'll forget about it, or worse, when someone else tries to modify it, even if properly documented.
Somewhat related : EMF Eclipse: enumeration with custom fields (properties)

A: An Enum is represented by an instance of EEnum. An interface is represented by an instance of EClass that has the value of Interface set to true.
The interfaces to an EClass are then available at getEAllSuperTypes().
Note that EEnum and EClass are distinct subinterfaces of EModelElement and therefore do not share any members beyond those exposed in EModelElement.
This is because java is special in its treatment of Enums, implementing them as special classes. EMF is intended to allow for the more "common" understanding of Enums where they can not expose interfaces.
As such it's not possible in EMF to have Enums implement an interface.
Your only option when adding an interface to an Enum is to do so manually, sidestepping all code generation, because EMF doesn't support that particular behaviour. An alternative you might want to consider is to have one or more static utility methods that provide that interface by way of "currying" transforming this:
interface Foo {
    void bar();
    Baz baz(Quux quux);
}
enum Gen implements Foo { ... }

into:
class GenFoo {
    static void bar(Foo foo);
    static Baz baz(Foo foo, Quux quux);
}

This idea is basically what C# has implemented as "Extension methods", but they have language support for that and Java doesn't :)


text:
Q: Twig block passed to embedded template I'm using twig templates in a slim framework app. I have a template page.phtml which paginates an array of data and has several sub blocks intended for overriding per element specifics like paginating users, events, orders, etc.
page.phtml

    {% block block1 %}default content{% endblock %}

    ...

    {% block block2 %}{% endblock %}

I have an event.phtml template which embeds page.phtml and adds some other content to the page; it also overrides the default page's block1 content
event.phtml

Event Page

        {% embed "page.phtml" %}
            {% block block1 %}event page content{% endblock %}
        {% endembed %}

I have a custom event page which needs only modify a few of the event page's blocks so I extended event.phtml like so
custom_event.phtml
{% extends "event.phtml" %}
{% block block2 %}overridden value{% endblock %}

and expected block2's overridden content to show up in the page.phtml template embedded by the parent template. I can output the value of block2 in the parent template and it's there, but in the embedded template it's not. I tried explicitly passing the block in event.phtml in the embed like so
{%embed "page.phtml" %}
    {% block block2 %}{{parent()}}{% endblock %}
    ...
{% endembed %}

But that yielded no difference. How do I get the overridden block2 from the custom_event.phtml template all the way through the extended event.phtml template and into the embedded page.phtml template?

A: You cannot do this.
{% embed %} technically defines a new (anonymous) template which extends the embedded template (this is how it can overwrite blocks) and gets included into the current templating. This is really just syntactic sugar for {% include %} and {% extends %} to avoid having to store this partial template in its own file and include it only once.
Twig inclusion are not extendable by child templates. Only blocks of the current template are available for extension. And event.phtml does not have any blocks.


text:
Q: Installing the open tool chain template in Xcode 4.3 or 4.4 Is it possible to install the open tool chain template in Xcode 4.3 or 4.4 to do some jailbreak dev? Everything that I find seems to be a little bit outdated.

A: I'm not sure if you've already figured this out,
Anyway, Xcode 4 onwards you do not need this plug in, you can simply create a view based application / empty application with a short and simple .plist edit to make your app work as a daemon and not as a "view based application"
Here is the relevant .plist edit http://chrisalvares.com/blog/38/creating-an-iphone-daemon-part-4/
its the last part of a tutorial written in 2009, but it still applies  . . .
Hope this helps
Taski


text:
Q: C++: capitalizing a character using another character I'm trying to make a function that capitalizes the next character in a string after I input a "^" character. the code looks like this:
void decodeshift( string orig, string search, string replace )
{
    size_t pos = 0;

    while (true) {
    pos = orig.find(search, pos);
    if(pos == string::npos)
        break;
    orig.erase(pos, search.length());
    orig.replace(pos, search.length(), replace);

    cout<<orig<<endl;
    }
}

int main()
{
    string question = "What is the message? ";
    string answer = "The real message is ";

    string shift="^";
    string test="a";

    string answer1;

    //output decoded message
    string answer2;

    cout << question;
    cin >> answer1;
    cout << "decoding . . . " << "\n";

    //decodeback(answer1, back);
    decodeshift(answer1, shift, test);
    return 0;
}

my input will be:
^hello

desired output:
Hello

current output
aello

I can't seem to find the correct function to use and I'm confused on how to use toupper in a situation like this. I just need to find the proper replacement.

A: Try something more like this:
#include <cctype>

void decodeshift( string orig, string search )
{
    size_t pos = orig.find(search);
    while (pos != string::npos)
    {
        orig.erase(pos, search.length());
        if (pos == orig.size()) break;
        orig[pos] = (char) std::toupper( (int)orig[pos] );
        pos = orig.find(search, pos + 1);
    }
    return orig;
}

...

answer1 = decodeshift(answer1, "^");
cout << answer1 << endl;

Or, simply get rid of the shift parameter:
#include <cctype>

string decodeshift( string orig )
{
    size_t pos = orig.find('^');
    while (pos != string::npos)
    {
        orig.erase(pos, 1);
        if (pos == orig.size()) break;
        orig[pos] = (char) std::toupper( (int)orig[pos] );
        pos = orig.find('^', pos + 1);
    }
    return orig;
}

...

answer1 = decodeshift(answer1);
cout << answer1 << endl;


text:
Q: Confusion about the output #include<stdio.h>
int main(void)
{
    int i=1,j=-1;
    if((printf("%d",i))<(printf("%d",j)))
        printf("%d",i);
    else
        printf("%d",j);
    return 0;
}

As printf() returns the number of characters successfully printed, the condition will be if(1<1) which is false but the if part is executed and the output is 1 -1 1.  Why this is happening?

A: I think it is rather obvious: '1' is one character, '-1' is two. One is less than two.

A: printf returns the number of characters (not just digits) written.
So printf("%d",-1) will return 2 not 1
Similarly printf("%d",1) will return 1
Making the condition in the if true.

A: Because printing j prints "-1", that's two characters. so 1<2 is true.

A: For -1 number of characters printed is 2 hence if condition is satisfied.


text:
Q: How do you disable a text area using jQuery? I cannot seem to get this basic jQuery script to work. I thought I could do it but apparently I am fairly uninformed in what is going. I am using Rails 4.
When creating a new report I want to be able to disable the report body when document loads. In the long run I want to disable the report body until the first two field forms are filled out. I don't think the jQuery is getting through at all. I tried a basic .hide() function and it didn't work. I have jQuery working in other portions of my app. Thanks for your time!
new.js.erb
$(document).ready(function () {
  $("#report_body").prop('disabled', true);
});

_form.html.erb
<%= simple_form_for(@report, remote: true) do |f| %>
    ... snippet ...
    <div class="col-lg-12">
        <%= f.input :body, input_html: { rows: 20, style: 'width: 100%;', id: 'report_body' }%>
    </div>
    ... snippet ...
<% end %>

reports controller
  # GET /reports/new
   def new
    @report = Report.new
    # I tried doing a respond to block here for format.js but I think thats only for AJAX callbacks?
   end

application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .

A: First thing you should do is check to see if JQuery can find your DOM element.
Try debugging via console to see if the element can be found with the criteria you're giving. This always helps when trying to isolate DOM elements.
console.debug($("#report_body").contents());

I'm not sure if you have other elements with the same ID beyond the snippet you gave, but if you do, it would be better practice to make report_body a class name instead.
Assuming all those are in check, you may want to try the following:
$('input#report_body').attr('disabled', true);

If there are multiple instances of text areas sharing the same class name,
    $(this).find('input.report_body').each(function () {
        $(this).attr('disabled', true);
    });

Alternatively, you can also have the field disabled by default in Ruby using:
 <%= f.input :body, :disabled => true, input_html: {...}%>


text:
Q: how to draw a 'x' shape like below I am new to python, please someone help to draw a shape like below. The program have to take the number of star as an input.
number of star = 7
*      *
**    **
***  ***
********
***  ***
**    **
*      *

My code:
count = int(input('star count : '))
pattern_size = count + 1
for t in range(1, pattern_size):
    pattern = list(" " * pattern_size)
    pattern[:t] = "*" * t
    pattern[-t:] = '*' * t
    print(''.join(pattern))

star count :  9
*        *
**      **
***    ***
****  ****
**********
**********
**********
**********
**********

A: Here's a easy-to-understand example using two for-loops with your approach: One just the inverse of another
count = int(input('star count : '))
pattern_size = count + 1
for t in range(1, int(pattern_size/2)):
    pattern = list(" " * pattern_size)
    pattern[:t] = "*" * t
    pattern[-t:] = '*' * t
    print(''.join(pattern))

for t in range(int(pattern_size/2), 0, -1):
    pattern = list(" " * pattern_size)
    pattern[:t] = "*" * t
    pattern[-t:] = '*' * t
    print(''.join(pattern))

And a more advanced method would be to use the string method .center() like so:
count = int(input('star count : '))
pattern_size = count + 1
for t in range(1, int(pattern_size/2)):
    print((" " * (pattern_size-t*2)).center(pattern_size, '*'))
for t in range(int(pattern_size/2), 0, -1):
    print((" " * (pattern_size - t * 2)).center(pattern_size, '*'))

A: Just like my comment, this is the complete code:
count = int(input('star count : '))
pattern_size = count + 1
for t in range(1, pattern_size):
    pattern = list(" " * pattern_size)
    len_t = t if t <= (pattern_size / 2) else (pattern_size - t)
    pattern[:len_t] = "*" * len_t
    pattern[-len_t:] = '*' * len_t
    print(''.join(pattern))

Hope this help.