text:
Q: Node js require doesn't work properly I am working on a node app, but node doesn't require my classes properly. Instead it returns '{}'.
In order to test what has been included I try to print out the
'require "./core/template"', but it returns '{}':
require './core/template'

res.end util.inspect template

and when I replace this line with e.g. "res.end 'hello world'", I get the following error:
$ /Users/Filipe/Desktop/Smoothic/app.coffee:20
template.parse(template.render("head\n  title= pageTitle\n  script(type='t
                        ^
TypeError: Object #<Object> has no method 'render'
  at Object.handler (/Users/Filipe/Desktop/Smoothic/app.coffee:13:27)
  at final_dispatch (/Users/Filipe/Desktop/Smoothic/node_modules/node-simple-router/lib/router.js:275:26)
  at Server.dispatch (/Users/Filipe/Desktop/Smoothic/node_modules/node-simple-router/lib/router.js:326:14)
  at Server.emit (events.js:98:17)
  at HTTPParser.parser.onIncoming (http.js:2108:12)
  at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
  at Socket.socket.ondata (http.js:1966:22)
  at TCP.onread (net.js:527:27)

So my only guess is that the file maybe isn't compiled to javascript yet, or the compiler has got a bug, but that wouldn't make any sense, because usually all files are compiled before there server starts running.
I would be so thankful for some help
Here is my code:
app.coffee:
http = require 'http'
util = require 'util'
Router = require 'node-simple-router'
cson = require 'cson'

# I'm trying to include this coffee class
template = require './core/template'

router = new Router()

router.get '/', (req, res) ->
  res.writeHead 200

  # This method is supposed to render jade and parse it to the
  # client, but thats not the problem
  template.parse template.render """
                                  head
                                    title= pageTitle
                                    script(type='text/javascript').
                                      if (foo) {
                                         bar(1 + 5)
                                      }
                                  body
                                    h1 Jade - node template engine
                                    #container.col
                                      if youAreUsingJade
                                        p You are amazing
                                      else
                                        p Get on it!
                                      p.
                                        Jade is a terse and simple
                                        templating language with a
                                        strong focus on performance
                                        and powerful features.
                                 """

  # In order to test what has been included I try to print out the
  # 'require "./core/template"', but it returns 'undefined'
  #
  res.end util.inspect template

http.createServer router
  .listen 8080

./core/template.coffee:
path = require 'path'
jsdom = require 'jsdom'

class Template
  constructor: (file) ->
    parse render file

  render: (file) ->
    content = switch path.extname file
      when '.html' then fs.readFileSync file
      when '.jade' then jade.renderFile file

  parse: (content) ->
    jsdom.env
      html: content
      scripts: ["http://code.jquery.com/jquery.js"]
      done: (errors, window) =>
        $ = window.$

A: I am not familiar with coffeescript's hidden features, but you will need to do a exports=Template at the end of your template.coffee file as it is described in the module doc of node.js

A: Either do a module.exports = class Template in your template.coffee and instantiate it using
Template = require "./template"
AppTemplate = new Template()

or instantiate the class on export like this
module.exports = new class PluginManager


text:
Q: Type mismatch on excel data from powershell Good day everyone.
I am a starting programmer in powershell and am trying to make a program input help desk calls into an excel sheet to import into the help desk ticketing system.
My script:
$excel_file_path = 'G:\IT\Helpdesk\Daily Calls.xlsx'

## Instantiate the COM object
$Excel = New-Object -ComObject Excel.Application
$ExcelWorkBook = $Excel.Workbooks.Open($excel_file_path)
$ExcelWorkSheet = $Excel.WorkSheets.item("sheet1")
$ExcelWorkSheet.activate()

## Find the first row where the first 7 columns are empty
$row = ($ExcelWorkSheet.UsedRange.Rows | ? { ($_.Value2 | ? {$_ -eq $null}).Count -eq 7 } | select -first 1)
$test = "this is a test"
$ExcelWorkSheet.Cells.Item($row,1) = $test

$ExcelWorkBook.Save()
$ExcelWorkBook.Close()
$Excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)

Now, I did take this from another page online and modified it to what I need, but it is giving me this error;
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
At H:\Scripts\Call_Log.ps1:12 char:1
+ $ExcelWorkSheet.Cells.Item($row,1)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

OR
Exception from HRESULT: 0x800A03EC
At H:\Scripts\Call_Log.ps1:11 char:1
+ $ExcelWorkSheet.Cells.Item($row,1) = $test
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

I don't understand what is going on or what is mismatched. Could anyone please help?

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to fix kvm owner and members? I'm trying to start an emulator on vs code and i'm getting an error saying:
"Failed to launch Pixel 4 API 24: Error: Emulator didn't connect within 60 seconds"
So i added my user to kvm , it didn't work. sudo adduser <username> kvm
Then i set the owner of the group as my user, the emulator launched but every time i close the emulator and launch it again i need to reset the owner for it to work. sudo chown username -R /dev/kvm
Is there any way to change the owner permanently or to make it work only as a member?


text:
Q: Search Core Data Users By Name I am trying to get a list of users whose names were selected from a tableview and stored in the array selected.
What's wrong with my code? Sorry this is my first time with CoreData so I don't really know what's wrong.
NSFetchRequest *request= [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"AUser"   inManagedObjectContext:_managedObjectContext];
for (id a in selected) {
   NSPredicate *predicate =[NSPredicate predicateWithFormat:@"name==%@",a]; //each user has a name attribute
   [request setEntity:entity];
   [request setPredicate:predicate];

   NSError *error = nil;

   NSArray *array = [_managedObjectContext executeFetchRequest:request error:&error];
   //This array is always empty! Why? What am I doing wrong with the request
}

Tell me if you require any more info/further explanation.
Other things to note - there are no warning/error signs - all variables not declared here are declared elsewhere
Thanks a lot!

A: Since you're not getting any error response, an empty array means that the fetch completed successfully but that it didn't find anything satisfying your predicate. In your code that then implies that selected does not contain values for name that can be found in your data store.
Your code seems to assume that selected is an array of NSStrings which match the name value of some of your stored objects. If that's not the case-- if it contains something other then NSString maybe-- an empty set is to be expected. The fact that a is declared as an id makes me wonder what's really in there.


text:
Q: Setting foreground of one specific textblockelement in a listbox - wp7 I've got a listbox, which ive bound to an array of strings. The listbox contains a textblock, which has the text of a string in the array. I want to change the foreground of one of those (it may vary which one):
 <ListBox x:Name="listBox" ItemsSource="{Binding Options}" ScrollViewer.VerticalScrollBarVisibility="Hidden" Width="400" Height="500" Margin="0,200,0,0" HorizontalAlignment="Center" HorizontalContentAlignment="Center" SelectionChanged="ListBox_SelectionChanged" Loaded="listBox_Loaded">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <ListBoxItem>
                        <Grid Height="75" Width="400" HorizontalAlignment="Center" >
                            <TextBlock HorizontalAlignment="Center" Text="{Binding}" Style="{StaticResource SortingOptions}" />
                        </Grid>
                    </ListBoxItem>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

I just cant seem to get hold of the textblocks, so i can change the foreground on the right one. Does anyone know how i can achieve this? Thanks

A: Bind the Foreground property to the same value as Text and use a BindingConverter to create a Brush out of it.
E.g.
<Grid.Resources>
  <yournamespace:ColorConverter x:Key="colConverter"/>
<Grid.Resources>

<TextBlock
  HorizontalAlignment="Center"
  Text="{Binding}"
  Foreground="{Binding, Converter={StaticResource colConverter}}"
  Style="{StaticResource SortingOptions}" />

Add your converter class:
  public class ColorConverter : IValueConverter
  {
  public object  Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  {
      // TODO: match from the value parameter to a color.

      return new SolidColorBrush(Colors.Red);
  }

  public object  ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  {
      throw new NotImplementedException();
  }
}


text:
Q: Why does terminal takes input line by line? If I use:
strace echo 'a
b
c' > file

The bottom lines are:
write(1, "a\nb\nc\nd\n", 8)             = 8

but in
strace echo 'a
b
c
d' > /dev/pts/0

These lines are:
write(1, "a\n", 2)                      = 2
write(1, "b\n", 2)                      = 2
write(1, "c\n", 2)                      = 2
write(1, "d\n", 2)                      = 2

In second case, why does it is writing line by line, whereas in first case it is writing together. May be because terminal is character device, but I got definition of character device as:

A character (char) device is one that can be accessed as a stream of bytes (like a file).The only relevant difference between a char device and a regular file is that you can always move back and forth in the regular file, whereas most char devices are just data channels, which you can only access sequentially.

Edit: Shell is bash.

A: This is very simple.
The external echo command that you are running from strace is very probably the one from GNU coreutils.  This is written in the C programming language, and uses the C runtime library functions such as putchar() and fputs() to write what it needs to write to the program's standard output.
In the C language, output to standard output can be fully buffered, line buffered, or unbuffered.  The rules for what happens are actually part of the C language specification, apply across operating systems, and are written in abstract terms of whether standard output "can be determined not to refer to an interactive device".
On Unix and Linux operating systems, the concrete way that they apply is that standard output is fully buffered if the isatty() function says that the file descriptor is not a terminal.  That's what "an interactive device" is in this case.  Standard output is otherwise line buffered, on your operating system.  The C language standard does not mandate that latter.  It is what the GNU C library additionally documents that it does, on top of what the C language standard says.
So when your echo command's standard output is not a terminal but a file, the C library in the program buffers up all of the individual writes to standard output and makes one big write() call, when the buffer is full or when the program finishes.  Whereas when standard output is a terminal, the C library only buffers things until a linefeed character is output, at which point it write()s the contents of the buffer.
Hence the observed system calls.
Further reading

*

*https://unix.stackexchange.com/a/407472/5132

*What prevents stdout/stderr from interleaving?

*https://unix.stackexchange.com/a/467061/5132

*SSH output isn't line buffered?


text:
Q: CORS with XMLHttpRequest not working I'm trying to read the audio stream using XMLHttpRequest, but get an error "XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access". I tried to use CORS from this example <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>AUDIO</title>
  </head>
  <body>
    <script type="text/javascript">
        function createCORSRequest(method, url) {
        var xhr = new XMLHttpRequest();
        if ("withCredentials" in xhr) {
          // XHR for Chrome/Firefox/Opera/Safari.
          xhr.open(method, url, true);
        } else if (typeof XDomainRequest != "undefined") {
          // XDomainRequest for IE.
          xhr = new XDomainRequest();
          xhr.open(method, url);
        } else {
          // CORS not supported.
          xhr = null;
        }
        return xhr;
      }

  // Helper method to parse the title tag from the response.
  function getTitle(text) {
    return text.match('<title>(.*)?</title>')[1];
  }

  // Make the actual CORS request.
  function makeCorsRequest() {
    // All HTML5 Rocks properties support CORS.
    var url = 'http://streaming.radionomy.com/VWClassicRock';

    var xhr = createCORSRequest('GET', url);
    if (!xhr) {
      alert('CORS not supported');
      return;
    }

    // Response handlers.
    xhr.onload = function() {
      var text = xhr.responseText;
      var title = getTitle(text);
      alert('Response from CORS request to ' + url + ': ' + title);
    };

    xhr.onerror = function() {
      alert('Woops, there was an error making the request.');
    };

    xhr.send();
  }

  makeCorsRequest();
</script>

</body>
</html>. If I put url into audio html tag like this
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>AUDIO</title>
  </head>
  <body>
    <audio src='http://streaming.radionomy.com/VWClassicRock' controls></audio>
  </body>
</html>, then it works. What should i do, to use it with XMLHttpRequest?

A: I was going through the same problem.
The cors errors represent the client side problem depending upon browsers.
It happens when your local server is making request to external server. Therefore depending upon you local server configuration, the error shows.
From my personal experience came across this using fetch. I was using vue.js on my php framework. So basically what I found is I had to set headers such as
"X-Requested-With": "XMLHttpRequest", "Access-Control-Allow-Origin": "*" and if you are using fetch method use mode: 'no-cors' on the front end code request. Then the error goes away I can call to third party api from the front end.
So you can do xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
For your reference you can look at this gist:
https://gist.github.com/khorramk/2c0828ca296832b0319d0155a36af7af
and these link:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

A: how XMLHttpRequest works?
const data = '{"message":"hi there!"}'
const xhr = new XMLHttpRequest()
xhr.open('POST', endpointURL)
xhr.setRequestHeader('Content-type', 'application/json')
xhr.send(JSON.stringify(data))

First of all the XMLHttpRequest object is doing an OPTIONS call in order to know which methods are available for the endpointURL. The CORS headers are returned from the server too. With this information XMLHttpRequest knows if it can perform a POST call.
If CORS is allowed, XMLHttpRequest is going to work.
In order to test the XMLHttpRequest calls, you can do an OPTIONS call in the postman or rest client tool, or a CURL:
 curl -X OPTIONS -k -H 'Conte -Type: application/json' -i 'https://yourserver/path/hello' --data '{"message": "hello world"}'

and then you can perform an POST call:
curl -X POST -k -H 'Content-Type: application/json' -i 'https://yourserver/path/hello' --data '{"message": "world"}'

In the server side don't forget to enable the allowed methods: GET, POST, OPTIONS, and return the exposedHeaders and allowedHeaders
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("POST","GET","OPTIONS")
                .allowedHeaders("*")
                .allowCredentials(false).maxAge(3600);

    }
}


text:
Q: select method of range .cells fails on 2nd go I've been working on the code below for a while now and I'm almost done. It's taking 3 cells of data from one sheet, copying it in another, saving a copy based on the name in the first sheet and then looping until completed for all filled rows.
The snag I'm hitting is that when the first loop completes and it needs to select the WB that holds the data (the selection is needed for the function) it can't select it due to a fault in WsStam.Cells(row, iKolomnrCorpID).EntireRow.Select. When I debug, switch to the WB and run code it does work.
It's probably something stupid I'm missing. I appreciate your help!
Sub motivatieFormOpmaken()

        Dim wbMotivTemp As Workbook
        Dim wsMotiv As Worksheet
        Dim PathOnly, mot, FileOnly As String
        Dim StrPadSourcenaam As String
        Dim WsStam As Worksheet
        Dim WbStam As Workbook
        Dim LastRow As Long

    Set wbMotivTemp = ThisWorkbook
    Set wsMotiv = ActiveSheet

    StrHoofdDocument = ActiveWorkbook.Name
    StrPadHoofdDocument = ActiveWorkbook.Path
    StrPadSourcenaam = StrPadHoofdDocument & "\" & c_SourceDump

    If Not FileThere(StrPadSourcenaam) Then
       MsgBox "Document " & StrPadSourcenaam & " is niet gevonden."
    Exit Sub
    End If

    Application.ScreenUpdating = False

    Workbooks.Open FileName:=StrPadSourcenaam
    Set WbStam = ActiveWorkbook
    Set WsStam = WbStam.Worksheets("Stambestand")
    Application.Run "Stambestand.xlsm!unhiderowsandcolumns"
    Worksheets("stambestand").Activate

    iLaatsteKolom = Worksheets("stambestand").Cells.SpecialCells(xlLastCell).Column
    iLaatsteRij = Worksheets("stambestand").Cells.SpecialCells(xlLastCell).row

    VulKolomNr
    If KolomControle = False Then Exit Sub

    Cells(1, iKolomnrVerwijderen_uit_de_tellingen).AutoFilter Field:=iKolomnrVerwijderen_uit_de_tellingen, Criteria1:="0"
    LastRow = Cells(1, iKolomnrCorpID).End(xlDown).row

    Dim row As Long
    row = 2
    With WsStam
        Do Until row > iLaatsteRij
            If .Cells(row, iKolomnrCorpID).RowHeight > 0 Then
                WsStam.Cells(row, iKolomnrCorpID).EntireRow.Select 'It crashes at this line, after the first loop
                wsMotiv.Range("motiv_cid") = Cells(row, iKolomnrCorpID).Text
                wsMotiv.Range("motiv_naam") = Cells(row, iKolomnrNaam).Text
                wsMotiv.Range("motiv_ldg") = Cells(row, iKolomnrHuidigeLeidingGevende).Text
                n = naamOpmaken
                wbMotivTemp.Activate
                ActiveWorkbook.SaveAs FileName:=StrPadHoofdDocument & "\Docs\" & n & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
            End If
            row = row + 1
        Loop
    End With

End Sub

Function naamOpmaken() As String
    Dim rng As Range
    Dim row As Range
    Set rng = Selection.SpecialCells(xlCellTypeVisible)

    iRijnummer = rng.row
        If iRijnummer > 1 Then
            naam = Cells(iRijnummer, iKolomnrNaam).Text
            ldg = Cells(iRijnummer, iKolomnrHuidigeLeidingGevende).Text
            cid = Cells(iRijnummer, iKolomnrCorpID).Text

            Dim Position As Long, Length As Long
            Dim n As String
            Position = InStrRev(naam, " ")
            Length = Len(naam)
            n = Right(naam, Length - Position)
        End If
    naamOpmaken = n + "-" + ldg + "-" + cid
End Function

A: you have to activate a worksheet before selecting a cell of
since you're jumping between sheets you have to add
WsStam.Activate

right before
WsStam.Cells(row, iKolomnrCorpID).EntireRow.Select

BTW, you don't seem to need that selection at all so you may want to try and comment that line!

A: Hopefully you may find this useful for the future.
I've had a look through your code and made some updates so you shouldn't have to select any sheets and that problem line is removed completely.  I've also added a new function at the bottom which will find the last cell on any sheet you reference.
Option Explicit  'Very important at top of module.
                 'Ensures all variables are declared correctly.

Sub motivatieFormOpmaken()

    Dim wbMotivTemp As Workbook
    Dim wsMotiv As Worksheet
'    Dim PathOnly, mot, FileOnly As String

    '''''''''''''''''''
    'New code.
    Dim PathOnly As String, mot As String, FileOnly As String
    '''''''''''''''''''

    Dim StrPadSourcenaam As String

    '''''''''''''''''''
    'New code.
    Dim StrHoofdDocument As String
    Dim StrPadHoofdDocument As String
    Dim c_SourceDump As String
    c_SourceDump = "MyFileName.xlsx"
    Dim KolomControle As Boolean
    '''''''''''''''''''

    Dim WsStam As Worksheet
    Dim WbStam As Workbook
    Dim LastRow As Long

    Set wbMotivTemp = ThisWorkbook
    Set wsMotiv = ActiveSheet

    StrHoofdDocument = ActiveWorkbook.Name
    StrPadHoofdDocument = ActiveWorkbook.Path
    StrPadSourcenaam = StrPadHoofdDocument & "\" & c_SourceDump

    If Not FileThere(StrPadSourcenaam) Then
       MsgBox "Document " & StrPadSourcenaam & " is niet gevonden."
    Else
'    Exit Sub
'    End If

        Application.ScreenUpdating = False

'        Workbooks.Open Filename:=StrPadSourcenaam
'        Set WbStam = ActiveWorkbook

        '''''''''''''''''''
        'New code.
        Set WbStam = Workbooks.Open(Filename:=StrPadSourcenaam)
        '''''''''''''''''''

        Set WsStam = WbStam.Worksheets("Stambestand")
'        Application.Run "Stambestand.xlsm!unhiderowsandcolumns"

        '''''''''''''''''''
        'New code as possible replacement for "unhiderowsandcolumns"
        WsStam.Cells.EntireColumn.Hidden = False
        WsStam.Cells.EntireRow.Hidden = False
        '''''''''''''''''''

'        Worksheets("stambestand").Activate

'        iLaatsteKolom = Worksheets("stambestand").Cells.SpecialCells(xlLastCell).Column
'        iLaatsteRij = Worksheets("stambestand").Cells.SpecialCells(xlLastCell).row

        '''''''''''''''''''
        'New code.  You may want to check for filters before finding last row?
        iLaatsteKolom = LastCell(WsStam).Column
        iLaatsteRij = LastCell(WsStam).row
        '''''''''''''''''''

        VulKolomNr 'No idea - getting deja vu here.
'        If KolomControle = False Then Exit Sub

        '''''''''''''''''''
        'New code.
        If KolomControle Then
        '''''''''''''''''''

            WsStam.Cells(1, iKolomnrVerwijderen_uit_de_tellingen).AutoFilter Field:=iKolomnrVerwijderen_uit_de_tellingen, Criteria1:="0"
'            LastRow = Cells(1, iKolomnrCorpID).End(xlDown).row

            '''''''''''''''''''
            'New code.  The function will return the last filtered row.
            LastRow = LastCell(WsStam).row
            '''''''''''''''''''

            Dim row As Long
            row = 2
            With WsStam
                Do Until row > iLaatsteRij
                    If .Cells(row, iKolomnrCorpID).RowHeight > 0 Then
'''''''''''''''''''
'I don't think you even need this line.
'                        WsStam.Cells(row, iKolomnrCorpID).EntireRow.Select 'It crashes at this line, after the first loop
'                        wsMotiv.Range("motiv_cid") = Cells(row, iKolomnrCorpID).Text
'                        wsMotiv.Range("motiv_naam") = Cells(row, iKolomnrNaam).Text
'                        wsMotiv.Range("motiv_ldg") = Cells(row, iKolomnrHuidigeLeidingGevende).Text

                        '''''''''''''''''''
                        'New code.  Note the "." before "Cells" which tells it that cell is on "WsStam" (in the "With")
                        '           Also formatting the cell to text - will need to update as required.
                        wsMotiv.Range("motiv_cid") = Format(.Cells(row, iKolomnrCorpID), "0000")
                        wsMotiv.Range("motiv_naam") = Format(.Cells(row, iKolomnrNaam), "0000")
                        wsMotiv.Range("motiv_ldg") = Format(.Cells(row, iKolomnrHuidigeLeidingGevende), "0000")

'Do you mean this to save on each loop?
'                        n = naamOpmaken
'                        wbMotivTemp.Activate
'                        ActiveWorkbook.SaveAs Filename:=StrPadHoofdDocument & "\Docs\" & n & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

                        '''''''''''''''''''
                        'New code.  Combines the above three lines.
                        wbMotivTemp.SaveAs Filename:=StrPadHoofdDocument & "\Docs\" & naamOpmaken(WsStam) & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

                    End If
                    row = row + 1
                Loop
            End With

        '''''''''''''''''''
        'New code. End of "If KolomControle" block.
        End If
        '''''''''''''''''''

    ''''''''''''''''
    'New code - end of "If Not FileThere" block.
    'Give procedure a single exit point.
    End If

End Sub

'Added the worksheet as an argument to the procedure.
'This is then passed from the main procedure and you don't need to select the sheet first.
Function naamOpmaken(wrkSht As Worksheet) As String
    Dim rng As Range
    Dim row As Range
    Set rng = Selection.SpecialCells(xlCellTypeVisible)

    '''''''''''''''''''
    'New code
    Dim naam As String
    Dim ldg As String
    Dim cid As String
    '''''''''''''''''''

    iRijnummer = rng.row
        If iRijnummer > 1 Then

'            naam = Cells(iRijnummer, iKolomnrNaam).Text
'            ldg = Cells(iRijnummer, iKolomnrHuidigeLeidingGevende).Text
'            cid = Cells(iRijnummer, iKolomnrCorpID).Text

            '''''''''''''''''''
            'New code - not reference to the worksheet, and using default value of cell.
            '           may need to add "FORMAT" to get numericals in correct format.
            naam = wrkSht.Cells(iRijnummer, iKolomnrNaam)
            ldg = wrkSht.Cells(iRijnummer, iKolomnrHuidigeLeidingGevende)
            cid = wrkSht.Cells(iRijnummer, iKolomnrCorpID)
            '''''''''''''''''''

            Dim Position As Long, Length As Long
            Dim n As String
            Position = InStrRev(naam, " ")
            Length = Len(naam)
            n = Right(naam, Length - Position)
        End If

'If n and ldg are numbers this will add them rather than stick them together.
'    naamOpmaken = n + "-" + ldg + "-" + cid

    ''''''''''''''''
    'New code
    naamOpmaken = n & "-" & ldg & "-" & cid
    ''''''''''''''''

End Function

'New function to find last cell containing data on sheet.
Public Function LastCell(wrkSht As Worksheet) As Range

    Dim lLastCol As Long, lLastRow As Long

    On Error Resume Next

    With wrkSht
        lLastCol = .Cells.Find("*", , , , xlByColumns, xlPrevious).Column
        lLastRow = .Cells.Find("*", , , , xlByRows, xlPrevious).row

        If lLastCol = 0 Then lLastCol = 1
        If lLastRow = 0 Then lLastRow = 1

        Set LastCell = wrkSht.Cells(lLastRow, lLastCol)
    End With
    On Error GoTo 0

End Function


text:
Q: Matlab:How to eleiminate the black background and retain the region of interest in my image? I have the following IR (infrared) image of a human fist captured with a webcamera converted to work in IR. The picture has captured the veins under the skin. What i want to do is just retain the fist and get rid of the surrounding black area. How do i do this in MATLAB?

Here is what I have done so far, but I'm just getting a black image for this
a=imread('1.jpg');
figure; imshow(a);
b=rgb2gray(a);
figure;
imshow(b);
[j,k]=size(b);
for g=1:j
for f=1:k
if b(j,k)>0.06
c(j,k)=0;
else c(j,k)=1;
end
end
 end
figure,imshow(c);

Can somebody please tell me what I'm doing incorrectly, and how I can accomplish what I want? Also when i mean i want to get rid of the background i mean I want a white background instead of the black one>Cos the purpose of this project is to retain just the veins, the veins will be retained as black . and then i will take the co ordinates of these points .So i dont want the background to be generated as co ordinates as well...! So i want the background as white ..! how to do this ?

A: What you want to do is called segmentation and is a big topic in image processing. Your image is quite nice, so if you have the image processing toolbox this is pretty easy. And even if you don't its still not that hard.
As Chris mentions, you should convert your image to double before doing anything with it. If you have the image processing toolbox you can then use the function graythresh to find the best threshold level. Please note that you don't need to use for loops to do thresholding, in MATLAB you can threshold the entire matrix in one line.
b = im2double(b);              %convert to double
thresh_level = graythresh(b);  %find best threshold level
c = b > thresh_level;          %do thresholding
imshow(c)

This gives you a binary image, where your fist has value 1 and the background label 0. To keep the fist as it was, we multiply the binary version with the original version. Now the background is all zero, and the fist keeps its original values.
d = im2double(c).*b;           %c is binary, so we need to convert it first
imshow(d,[])

If you don't have the image processing toolbox you need to choose the threshold level manually. This can be a bit tricky. You used 0.06, but graythresh suggests that 0.2980 is the best. I find that a good way to find the threshold value is to look at the histogram of the image.
hist(b(:),256);

We can clearly see from the histogram that we have two clusters of points and that the any value between 2 and 3 would separate the clusters fairly well. So we should use a value in that interval to do thresholding.

A: a couple of problems I see:
In your code you use g and f as loop counters, but you always access the b array as b(j,k).
As well, the imread reads a uint8, so you can't really compare that to a double (0.06). So convert to a double via:
b=im2double(b);

Also, not a big deal in this case, but you dynamically grow c each loop iteration. If the image is large, this will dramatically hinder the performanec of your code. Per allocate it via:
c=ones(j,k);

After these changes it produces something resembling your fist. However, because the background is not a uniform colour, it doesn't work overly well. This part is outside my realm of experience...


text:
Q: How do I end up with smooth DragEnd Flutter How do I end the drop with proper velocity to a given offset
I am trying make something similar to SlidingUpPanel, but can't figure out how to implement.

final bottom = ValueNotifier<double>(0.0);

        Stack(
            children: [
              ValueListenableBuilder<double>(
                valueListenable: bottom,
                builder: (context, value, child) => Positioned(
                  bottom: value,
                  left: 0,
                  right: 0,
                  child: GestureDetector(
                    onVerticalDragStart: (value) {

                    },
                    onVerticalDragUpdate: (DragUpdateDetails value) {
                      bottom.value -= value.delta.dy;
                    },
                    onVerticalDragEnd: (value) {
                      const double minFlingVelocity = 365.0;
                      if (value.velocity.pixelsPerSecond.dy.abs() >=
                          minFlingVelocity) {

                        // bottom.value =
                        //   MediaQuery.of(context).size.height / 2;
                      }
                    },
                    child: Container(
                      width: double.maxFinite,
                      height: 200,
                      color: Colors.green,
                    ),
                  ),
                ),
              )
            ],
          ),


text:
Q: Handlebars template tags in helpers string Is it possible to put handlebar template tag inside generated html string?
For example:
Ember.Handlebars.helper(...) {
  return new Handlebars.SafeString("<button {{action go}}></button>");
}

I know this doesn't work but can anyone suggest the right way? (if exists)
Html source of that is:
<button {{action go}}></button>

but it should be something like that:
<button data-ember-action="x"></button>

where x is some integer
Cheers.

A: You can compile and call the template in runtime:
Ember.Handlebars.helper('trigger-action', function(options) {
  var compiledTemplate = Ember.Handlebars.compile('
Click');
  return compiledTemplate(null, options);
});

Sample http://emberjs.jsbin.com/uhedazok/1/edit
Keep in mind that the template is always compiled, so you can have some performance problems.


text:
Q: Attach file with Capybara - Element is not currently visible and > so may not be interacted with I'm trying to attach file using Capybara.
Input element is:
<input type="file" multiple="multiple" name="uploadfile[]" style="position: absolute; margin: 0px 0px 0px -175px; padding: 0px; width: 220px; height: 30px; font-size: 14px; opacity: 0; cursor: pointer; display: block; z-index: 2147483583; top: 3331px; left: 436px;">

Code for attaching file is:
attach_file 'uploadfile[]', '/home/user/image.jpg'

But it returns error:
biske@biske:~/Documents/Aptana Studio 3 Workspace/AddPlace$ ruby
test.rb  [remote server]
file:///tmp/webdriver-profile20130223-30353-dw596v/extensions/fxdriver@googlecode.com/components/command_processor.js:7537:in
`fxdriver.preconditions.visible': Element is not currently visible and
so may not be interacted with
(Selenium::WebDriver::Error::ElementNotVisibleError)  from [remote
server]
file:///tmp/webdriver-profile20130223-30353-dw596v/extensions/fxdriver@googlecode.com/components/command_processor.js:10207:in
`DelayedCommand.prototype.checkPreconditions_'  from [remote server]
file:///tmp/webdriver-profile20130223-30353-dw596v/extensions/fxdriver@googlecode.com/components/command_processor.js:10226:in
`DelayedCommand.prototype.executeInternal_/h'   from [remote server]
file:///tmp/webdriver-profile20130223-30353-dw596v/extensions/fxdriver@googlecode.com/components/command_processor.js:10231:in
`DelayedCommand.prototype.executeInternal_'   from [remote server]
file:///tmp/webdriver-profile20130223-30353-dw596v/extensions/fxdriver@googlecode.com/components/command_processor.js:10171:in
`DelayedCommand.prototype.execute/<'  from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/response.rb:52:in
`assert_ok'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/response.rb:15:in
`initialize'  from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/common.rb:59:in
`new'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/common.rb:59:in
`create_response'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/default.rb:66:in
`request'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/http/common.rb:40:in
`call'  from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:615:in
`raw_execute'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:593:in
`execute'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/remote/bridge.rb:400:in
`sendKeysToElement'   from
/usr/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/element.rb:126:in
`send_keys'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/selenium/node.rb:33:in
`set'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/node/element.rb:79:in
`block in set'  from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/node/base.rb:78:in
`synchronize'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/node/element.rb:79:in
`set'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/node/actions.rb:144:in
`attach_file'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/session.rb:341:in
`block (2 levels) in <class:Session>'   from
/usr/lib/ruby/gems/1.9.1/gems/capybara-2.0.2/lib/capybara/dsl.rb:51:in
`block (2 levels) in <module:DSL>'  from test.rb:19:in `add_place'
  from test.rb:11:in `run'  from test.rb:33:in `<main>'

How to solve this issue?

A: attach_file('locator', 'path/to/file.jpg', :visible => false )

Should do the trick. Capybara ignores hidden fields by default, all you need to do is pass in a visibility option

A: The :visible option did nothing for me. There seems to be a :make_visible option:
attach_file 'uploadfile[]', '/home/user/image.jpg', :make_visible => true

or instead of true with a Hash of custom style properties which will be set to overwrite before attempting to open the file dialog.

A: Because Ruby is not very good with page loading, if I were you, I'll solve it like this:
!30.times { if (driver.find_element(:xpath, "//input[@type='file']")rescue false) then break else sleep 1; end }

Basically the code above will try 30 times (every 1 sec) to search for the element that you are trying to attach and will exit the loop if the element is present. You can use variables after the break or after the sleep command to direct your flow if you want.
Best of luck


text:
Q: Unable to find text file I am new to VSCODE. I opened a text file via vscode and entered some details. Where can I find the file?
f=open('story.txt','w')
f.write('my name is')
f.write('my age is')
f.close()
f=open('story.txt', 'r')
print(f.readline())
f.close()

this is the output
However I cannot find 'story.txt' in file explorer. I used another text editor and then error came as file not found. but when i reopened the file in vs code I was getting a proper output.

A: When you run python script it will execute from the current working directory by defaut.
If you want to be sure where your file will be, you may pass the complete file path instead of file name only (eg: C:\\filepath\\filename.txt)
or you can move to the desired directory before read/write with os.chdir(filepath)
If you don't know where the script is running you can use os.getcwd() to get this directory from your code
import os

print(os.getcwd()) #will show the current working directory

os.chdir("c:\\") #will move to C:\ directory

f=open('story.txt','w')
f.write('my name is')
f.write('my age is')

f=open('story.txt', 'r')
print(f.readline())
f.close()

A: From the screenshot you supplied it looks like you are running the script from C:\Users\<YourName>, then this is where your story.txt file will be.
To specify another location you need to supply the open() method with a full path
Also, it's best practice to close the file before opening it again for reading. also, you might want to use a context manager to help you with this
If you want your file saved in the directory of your script, you can use os and __file__ to locate your script's directory and use that.
import os
my_dir = os.path.dirname(__file__)
new_path = os.path.join(my_dir, 'story.txt')
print(new_path)

os documentation
__file__ explained

A: When you create a file with Python, the file will be create in the same folder as your script. So, if your folder all_python_scripts contains your script, your file story.txt will be created in this folder. Try to search your file in the script's folder.


text:
Q: How it works the filterMatchMode from PrimeFaces DataTable? Primefaces Datatable let you configure the filtering type you use for a column, using the property filterMatchMode.
Nonetheless, if you use LazyDataModel you have to implement your own search method, which doesn't receive that property at all. is this feature only useful for normal DataModels?

A: Currently this feature is not supported for LazyDataModel out-of-box, however you can still use it with relatively little effort. blemasle posted corresponding patch on primefaces forum, unfortunately there is still no response from the developers.
If you want to use non code-invasive solution, you can try mine.
Filter constraints are obtained with:
 /**
 * @param tableSearchExpr expression, starting from the view root,
 *        which identifies the datatable to retrieve information from
 * @return map, containing pairs of {@code <filtered field id, match mode>}.
 *         Filtered field id is evaluated from the 'filterBy'
 *         attribute of the column in the following way:
 *         #{item.name} -> name
 *         #{item.category.name} -> category.name
 */
public Map<String, FilterMatchMode> getFiltersMatchMode(String tableSearchExpr) {
    FacesContext context = FacesContext.getCurrentInstance();
    Object component = context.getViewRoot().findComponent(tableSearchExpr);

    if (null == component) {
        throw new IllegalArgumentException(
                    "No component found for search expression: "
                            + tableSearchExpr);
    }
    if (!(component instanceof DataTable)) {
        throw new IllegalArgumentException(
                    "Component is not a DataTable: " + tableSearchExpr);
    }

    DataTable table = (DataTable) component;
    Map<String, FilterMatchMode> constraints =
            new HashMap<String, FilterMatchMode>(table.getColumns().size());

    for (UIColumn column : table.getColumns()) {
        ValueExpression filterExpression =
                  column.getValueExpression("filterBy");
        if (null != filterExpression) {
            String filterExpressionString = filterExpression.
                                                   getExpressionString();
            //evaluating filtered field id
            String filteredField = filterExpressionString.substring(
                    filterExpressionString.indexOf('.') + 1,
                    filterExpressionString.indexOf('}'));

            FilterMatchMode matchMode =
                  FilterMatchMode.fromUiParam(column.getFilterMatchMode());

            constraints.put(filteredField, matchMode);
        }
    }

    return constraints;
}

Where FilterMatchMode is:
public enum FilterMatchMode {

STARTS_WITH("startsWith"), ENDS_WITH("endsWith"),
CONTAINS("contains"), EXACT("exact");

/**
 * Value of p:column's filterMatchMode attribute
 *     which corresponds to this math mode
 */
private final String uiParam;

FilterMatchMode(String uiParam) {
    this.uiParam = uiParam;
}

/**
 * @param uiParam value of p:column's filterMatchMode attribute
 * @return MatchMode which corresponds to given UI parameter
 * @throws IllegalArgumentException if no MatchMode
 *          is corresponding to given UI parameter
 */
public static FilterMatchMode fromUiParam(String uiParam) {
    for (FilterMatchMode matchMode : values()) {
        if (matchMode.uiParam.equals(uiParam)) {
            return matchMode;
        }
    }
    throw new IllegalArgumentException("No MatchMode found for " + uiParam);
}

}


text:
Q: Share a folder from terminal osx There's a few ways to supposedly do this, but none of them work for me. I would like to share a folder located at ~/Desktop/Folder using samba, meaning that it would be accessible from smb://192.168.x.x/Folder on another computer. I also need to set a custom password for it.
sudo sharing -s ~/Desktop/Folder does nothing.


text:
Q: keytool error when creating BKS keystore: providerpath is not a legal command I am trying to create a "bks" keystore using keytool (using terminal app on Mac OS X). I am following the instructions in:
keytool error: java.security.KeyStoreException: BKS not found
This is my usage:
keytool -genkeypair -v -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 -keypass android -keystore /Users/djames/dropbox/bc146keystore/debug.keystore -storepass android -storetype BKS -providerclass org.bouncycastle.jce.provider.BouncyCastleProvider –providerpath /Users/djames/dropbox/bc146keystore/bcprov-jdk16-146.jar -dname "CN=Android Debug, OU=Android, O=Android, L=Whitefish, S=MT, C=US"

I am getting the following error:
keytool error: java.lang.RuntimeException: Usage error, ?providerpath is not a legal command
java.lang.RuntimeException: Usage error, ?providerpath is not a legal command
    at sun.security.tools.KeyTool.parseArgs(KeyTool.java:375)

I have seen the -provider path  option recommended in countless web posts (including the one above) and when I run keytool -help it confirms the syntax is legal:
keytool usage:  ...
-genkeypair  [-v] [-protected]
         [-alias <alias>]
         [-keyalg <keyalg>] [-keysize <keysize>]
         [-sigalg <sigalg>] [-dname <dname>]
         [-validity <valDays>] [-keypass <keypass>]
         [-keystore <keystore>] [-storepass <storepass>]
         [-storetype <storetype>] [-providername <name>]
         [-providerclass <provider_class_name> [-providerarg <arg>]] ...
         [-providerpath <pathlist>]

I also tried the following alternative (per http://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html):

*

*deleting the -providerpath option of the keytool command,

*placing the bcprov-jdk16-146.jar inside the {$JAVA_HOME/lib/ext} folder

*adding security.provider.3=org.bouncycastle.jce.provider.BouncyCastleProvider to the java.security file.

But it still failed.
Any ideas on what I can do differently to succeed in creating a BKS keystore?

A: It's many years since, but I am attempting this too.
The answer is that you have the parameters in the wrong order. The -providerpath needs to come before the -providerclass parameter.
I hope that helps someone in future searching for a solution.

A: I was never able to succeed with Keytool. This is what I did to solve the problem instead:            I made a copy of the default debug.keytool (a JKS type keystore) that was created by Eclipse (Indigo, SR2) automatically the first time an android program is run in Eclipse, and used Portecle (http://portecle.sourceforge.net/) to convert this to a BKS type keystore.  Now this is the tricky part:  If I now used the BKS version of debug.keytool in place of the original, I got an "Android packaging error" in Eclipse "java.io.IOException: Invalid keystore format" whenever I would try to run the android program.  However, if I left the original JKS version of debug.keytool in the default directory where Eclipse created it, then I could use the BKS version of the debug.keytool in the Android program's /resources/raw subfolder and have Android open it and recognize it.  Jim

A: An easy alternative is to use Portecle to generate the BKS:

*

*Download the needed Boucycastle Provider

*Replace bcprov.jar in your Portecle install directory (example: C:\Program Files (x86)\Portecle\bcprov.jar). Same naming is required.

*Restart Portecle and generate your BKS truststore.

More explanations here.

A: I am trying to do SSL connection with certificates, so to support in Android I need to use jks / bks files as trust store.

So generated jks file tried in android SSLSocket connection, But
  throws exception that jks not able to read. So I have to add
  Boncycastle provider to JVM and create bks using jks file

Download the Bouncycastle provider jar file and place under below path:
C:\Program Files\Java\jre1.8.0_191\lib\ext

Update the java.security file by adding provider for the following file
C:\Program Files\Java\jre1.8.0_191\lib\security\java.security

Add the provider
security.provider.12=org.bouncycastle.jce.provider.BouncyCastleProvider

Close command prompt and open execute command to get bks file like below:
keytool -importkeystore -srckeystore <input>.jks -destkeystore <required_bks_file_name>.bks -srcstoretype JKS -deststoretype BKS -srcstorepass <jsk file password> -deststorepass <jsk file password> -provider org.bouncycastle.jce.provider.BouncyCastleProvider

Now you can bks file in your folder.
Thanks


text:
Q: Install MySQLdb with Anaconda I "successfully" installed MySQLdb using:
pip install mysql-python

But when I use the terminal to check, "import MySQLdb" throws this error:

Traceback (most recent call last):
    File "", line 1, in
    File "//anaconda/lib/python2.7/site-packages/MySQLdb/init.py", line 19, in
      import _mysql
  ImportError: dlopen(//anaconda/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib
    Referenced from: //anaconda/lib/python2.7/site-packages/_mysql.so
    Reason: image not found

I'm assuming this is due to some issue with linking, but I don't know what to do.
--- I'm on a Mac. ---

A: MYsql-python is a wrapper around MySQL client libraries. Here, you seem to lack SSL libraries. Try installing libssl (if you're on a Debian/Ubuntu/Mint)
sudo apt-get install libssl1.0.0


text:
Q: No directory is created for Files in form I have a form to send a message to other users. When sending an attachment directory is not created to save.
Error
Warning: chmod(): No such file or directory in C:\xampp\htdocs\_sesiones\validar.php on line 199

Warning: move_uploaded_file(nicogaldo/adjunto_msj/para_11/2014-09-17/mensajeria.php): failed to open stream: No such file or directory in C:\xampp\htdocs\_sesiones\validar.php on line 206

Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php120F.tmp' to 'nicogaldo/adjunto_msj/para_11/2014-09-17/mensajeria.php' in C:\xampp\htdocs\_sesiones\validar.php on line 206

nombre del archivo: nicogaldo/adjunto_msj/para_11/2014-09-17/mensajeria.php
nombre de usuario: nicogaldo

This is the validation of the file to upload:
PHP:
$Mensaje_msj="";
$fecha= date("Y-m-d");
$TamanioMaximo_msj=3000000;

$CarpetaAlojamiento_msj='../updates_msj/'.$_SESSION['user'].'/para_'.$_POST['user'].'/'.$fecha';

//$CarpetaAlojamiento_msj=$_SESSION['user']; //Works fine :S

$NombreArchivoFinal_msj="";

  if (!empty($_FILES['adjunto'])) {
    if($_FILES['adjunto']['size']>$TamanioMaximo) {
      $Mensaje_msj.= 'El adjunto debe pesar menos de 3mb';
    } else {

      if (!is_dir($CarpetaAlojamiento_msj)) {
        mkdir($CarpetaAlojamiento_msj);           #line 199
        chmod($CarpetaAlojamiento_msj, 0777);
      }
    }

    $NombreArchivoFinal_msj="$CarpetaAlojamiento_msj/{$_FILES['adjunto']['name']}";

    if (is_uploaded_file($_FILES['adjunto']['tmp_name'])) {     #line 206
      move_uploaded_file($_FILES['adjunto']['tmp_name'], $NombreArchivoFinal_msj);
    }

    echo "nombre del archivo: ".$NombreArchivoFinal_msj;
    echo "nombre de usuario: ".$_SESSION['user'];

  }

But when I leave $CarpetaAlojamiento_msj=$_SESSION['user']; works well.
Any idea?

A: try mkdir($CarpetaAlojamiento_msj, 0777, true);, true parameter means mkdir recursively.


text:
Q: Locked in Cyrillic boot I can not boot Ubuntu 18.04 and need  manually  do fsck /dev/sda3.
However, once pressed f10 at root my typing alphabet is  changed to Cyrillic.
I do not know what happended.
So I am basically stuck between the need to type fsck command and the fact that I type in Cyrillic.
Is there way to change it to english alphabet?
thanks


text:
Q: Merge records with duplicate ID and combine different data Here is a sample of data from my worksheet. It has been sorted in Column B from smallest to largest to show the duplicate Item Codes (highlighted yellow):

Here is a breakdown of the following columns:

*

*Column A - ID, every ID is unique

*Column B - Item Code, duplicates appear

*Columns C to E - A range of different data, but if two records have the same Item Code (B), the rest of the data (C to E) will remain the same, as seen above

*Columns F to L - Week numbers (52 in a year hence back to 1 in column K) contains numeric values. Despite multiple records could have the same Item Code (B), columns could contain different numeric values (notice the red marks in the above screenshot)

I want to merge these records, based on finding duplicate Item Codes (B), resulting in storing the first ID value (A), merging columns C to E and combing columns F to L. The screenshot below shows my desired output.

As you can see, the records have been combined and merged. Those with a red mark indicate how these numeric values have been added together to show a new value when there are 2 or more records with the same Item Code but have multiple numeric values in the same column. If there is only one value, it merges with the rest to create one row per Item Code.
I have looked online for a long time and all I could find was using Consolidate and using VBA code to combine these records in a format that didn't lead to this desired output, including using formulas.
Thank you!
Edit: The above has been answered. However, below is my original data, I thought the solution for the above question could be easily adjusted and applied to the original data, but I have found no luck with the following code:
Sub ConsolidateItemCodes()

   Dim sh As Worksheet, destSh As Worksheet, lastR As Long, arr, arrH, arrVal, arrfin, arrIt
   Dim i As Long, j As Long, k As Long, dict As Object

   Set sh = Sheets("Sample of Original Data") 'use here the sheet you need processing
   Set destSh = sh.Next 'use here the sheet where to return (now in the next sheet)

   lastR = sh.Range("F" & sh.Rows.Count).End(xlUp).Row
   arrH = sh.Range("A1:CO1").Value2           'the headers
   arr = sh.Range("A2:CO" & lastR).Value2  'place the range in an array for faster iteration/processing
   ReDim arrVal(0 To 36) 'redim the array keeping the values

   'load the dictionary (ItemCodes as unique keys):
   Set dict = CreateObject("Scripting.Dictionary") 'set the dictionary object
   For i = 1 To UBound(arr)
        If Not dict.Exists(arr(i, 6)) Then
            For j = 0 To 36: arrVal(j) = arr(i, j + 36): Next j
            dict.Add arr(i, 6), Array(Array(arr(i, 1), arr(i, 2), arr(i, 3), arr(i, 4), arr(i, 5), arr(i, 7), arr(i, 8), arr(i, 9), arr(i, 10), arr(i, 11), arr(i, 12), arr(i, 13), arr(i, 14), arr(i, 15), arr(i, 16), arr(i, 17), arr(i, 18), arr(i, 19), arr(i, 20), arr(i, 21), arr(i, 22), arr(i, 23), arr(i, 24), arr(i, 25), arr(i, 26), arr(i, 27), arr(i, 28), arr(i, 29), arr(i, 30), arr(i, 31), arr(i, 32), arr(i, 33), arr(i, 34), arr(i, 35)), arrVal)
        Else
            arrIt = dict(arr(i, 6))  'a dictionary item can be adaptet directly, EXCEPT arrays...
            For j = 0 To 36
                arrIt(1)(j) = arrIt(1)(j) + arr(i, j + 36)
            Next j
            dict(arr(i, 6)) = arrIt 'place back the updated jagged array
        End If
   Next i

   'process dictionary content
   ReDim arrfin(1 To dict.Count + 1, 1 To UBound(arr, 6))

   'place the header in the final array:
   For i = 1 To UBound(arrH, 6): arrfin(1, i) = arrH(1, i): Next i

   'extract data from dictionary:
   k = 1
   For j = 0 To dict.Count - 1
        k = k + 1
        arrIt = dict.Items()(j)
        arrfin(k, 1) = arrIt(0)(0): arrfin(k, 2) = arrIt(0)(1): arrfin(k, 3) = arrIt(0)(2): arrfin(k, 4) = arrIt(0)(3): arrfin(k, 5) = arrIt(0)(4): arrfin(k, 6) = dict.keys()(j)
        arrfin(k, 7) = arrIt(0)(5): arrfin(k, 8) = arrIt(0)(6): arrfin(k, 9) = arrIt(0)(7): arrfin(k, 10) = arrIt(0)(8): arrfin(k, 11) = arrIt(0)(9): arrfin(k, 12) = arrIt(0)(10): arrfin(k, 13) = arrIt(0)(11): arrfin(k, 14) = arrIt(0)(12): arrfin(k, 15) = arrIt(0)(13): arrfin(k, 16) = arrIt(0)(14): arrfin(k, 17) = arrIt(0)(15): arrfin(k, 18) = arrIt(0)(16): arrfin(k, 19) = arrIt(0)(17): arrfin(k, 20) = arrIt(0)(18): arrfin(k, 21) = arrIt(0)(19): arrfin(k, 22) = arrIt(0)(20): arrfin(k, 23) = arrIt(0)(21): arrfin(k, 24) = arrIt(0)(22): arrfin(k, 25) = arrIt(0)(23): arrfin(k, 26) = arrIt(0)(24): arrfin(k, 27) = arrIt(0)(25): arrfin(k, 28) = arrIt(0)(26): arrfin(k, 29) = arrIt(0)(27): arrfin(k, 30) = arrIt(0)(28): arrfin(k, 31) = arrIt(0)(29): arrfin(k, 32) = arrIt(0)(30): arrfin(k, 33) = arrIt(0)(31): arrfin(k, 34) = arrIt(0)(32): arrfin(k, 35) = arrIt(0)(33)
        For i = 0 To 36: arrfin(k, i + 36) = arrIt(1)(i): Next i
   Next j

   'drop the processed array content at once:
   With destSh.Range("A1").Resize(k, UBound(arrfin, 6))
        .Value2 = arrfin
        .Rows(1).Font.Bold = True
        .EntireColumn.AutoFit
    End With

    MsgBox "Ready..."
End Sub

Here is a snippet of my original data. As you can see column A is the same, column B (2) above is actually column F (6), column F (6) is actually column AJ (36) and it ends at column CO (93).

And this is my desired output, similar to the above.

A: Please, test the next code. It returns (now) in the next sheet against the processed one, but you can set the destination sheet as you want. As I said in my above comment, it uses arrays and a dictionary and should be very fast. Records can be in any order:
Sub ConsolidateItemCodes()
   Dim sh As Worksheet, destSh As Worksheet, lastR As Long, arr, arrH, arrVal, arrfin, arrIt
   Dim i As Long, j As Long, k As Long, dict As Object

   Set sh = ActiveSheet 'use here the sheet you need processing
   Set destSh = sh.Next 'use here the sheet where to return (now in the next sheet)

   If sh.FilterMode Then sh.ShowAllData 'to show all data in case of filters...

   lastR = sh.Range("B" & sh.rows.count).End(xlUp).row
   arrH = sh.Range("A1:L1").Value2           'the headers
   arr = sh.Range("A2:L" & lastR).Value2  'place the range in an array for faster iteration/processing
   ReDim arrVal(0 To 6) 'redim the array keeping the values

   'load the dictionary (ItemCodes as unique keys):
   Set dict = CreateObject("Scripting.Dictionary") 'set the dictionary object
   For i = 1 To UBound(arr)
        If Not dict.Exists(arr(i, 2)) Then
            For j = 0 To 6: arrVal(j) = arr(i, j + 6): Next j
            dict.Add arr(i, 2), Array(Array(arr(i, 1), arr(i, 3), arr(i, 4), arr(i, 5)), arrVal)
        Else
            arrIt = dict(arr(i, 2))  'a dictionary item can be adaptet directly, EXCEPT arrays...
            For j = 0 To 6
                arrIt(1)(j) = arrIt(1)(j) + arr(i, j + 6)
            Next j
            dict(arr(i, 2)) = arrIt 'place back the updated jagged array
        End If
   Next i

   'process dictionary content
   ReDim arrfin(1 To dict.count + 1, 1 To UBound(arr, 2))

   'place the header in the final array:
   For i = 1 To UBound(arrH, 2): arrfin(1, i) = arrH(1, i): Next i

   'extract data from dictionary:
   k = 1
   For j = 0 To dict.count - 1
        k = k + 1
        arrIt = dict.Items()(j)
        arrfin(k, 1) = arrIt(0)(0): arrfin(k, 2) = dict.keys()(j)
        arrfin(k, 3) = arrIt(0)(1): arrfin(k, 4) = arrIt(0)(2): arrfin(k, 5) = arrIt(0)(3)
        For i = 0 To 6: arrfin(k, i + 6) = arrIt(1)(i): Next i
   Next j

   'drop the processed array content at once:
   With destSh.Range("A1").Resize(k, UBound(arrfin, 2))
        .Value2 = arrfin
        .rows(1).Font.Bold = True
        .EntireColumn.AutoFit
    End With

    MsgBox "Ready..."
End Sub

I tried commenting all code lines, to be easy understood. If something still not clear enough, do not hesitate to ask for clarifications.
Please, send some feedback after testing it.

A: Option Explicit

Sub aggregate()

   Const ITEM_CODE = "F" ' Item Code
   Const WK1 = "AJ" ' start of numeric data

   Dim wb As Workbook, ws As Worksheet, n As Long, c1 As Long, c2 As Long
   Dim c As Long, r As Long, lastrow As Long

   Set wb = ThisWorkbook
   Set ws = wb.Sheets("Sheet1")

   Application.ScreenUpdating = False
   With ws
        lastrow = .Cells(.Rows.Count, ITEM_CODE).End(xlUp).Row
        ' start and end columns
        c1 = .Columns(WK1).Column
        c2 = .UsedRange.Columns.Count + .UsedRange.Column - 1

        ' scan up sheet
        For r = lastrow To 3 Step -1
            ' compare with row above
            If .Cells(r, ITEM_CODE) = .Cells(r - 1, ITEM_CODE) Then
                For c = c1 To c2
                    ' aggregate if not blank
                    If Cells(r, c) <> "" Then
                        .Cells(r - 1, c) = .Cells(r - 1, c) + .Cells(r, c)
                    End If
                Next
                '.Rows(r).Interior.ColorIndex = 3
                .Rows(r).Delete
                n = n + 1
            End If
        Next
   End With
   Application.ScreenUpdating = True
   MsgBox n & " rows deleted", vbInformation

End Sub


text:
Q: IntelliJ Auto build with errors but not errors in editor I'm Using IntelliJ IDEA Ultimate 2019.2 to work on a Java w/gradle project.
When I try to run a JUnit test the Autobuild is triggered and it complains with the following message:

Auto build completed with errors

In the Problems tab I see over 100 erros and when I click on them to investigate I can see that these are not real errors, the editor has no red squiggly anywhere and if I look into specific errors (like java: cannot find symbol) I confirm they are invalid errors.
I've tried "Invalidate Caches / Restart" and "Rebuild Project" with no luck

A: I tried many things, but I think the issue got resolved when I switched the Gradle "Build and run using" setting from Gradle to IntelliJ.


text:
Q: $X \setminus A$ is dense iff for every nonempty open set $U$, $U \setminus A$ is nonempty For the first direction I assume that $X \setminus A$ is dense so that $\mathfrak{cl}(X \setminus A)=X$, let $U$ be a nonempty set if $U \setminus A$ is empty then $U$ is subset from $A$ hence $X \setminus A$ subset from $X \setminus U$ but $X \setminus A$ is subset from $\mathfrak{cl}(X \setminus A)$ so $\mathfrak{cl}(X \setminus A)$ is subset from $X \setminus A$ which contradicts that $X \setminus A$ is dense in $X$ ...
Is this proof correct?
How about the other direction because I worked on it but I can't reach the result ..

A: Your proof is correct: If $U$ is open, with $U \setminus A$ empty, then $A$ contains $U$, so $X \setminus U$ contains $X \setminus A$. But $X \setminus U$ is a closed set, so it contains the closure of $X \setminus A$, too. But we assumed $X \setminus A$ was dense, so this closure is all of $X$. Therefore $X \setminus U$ is all of $X$, so $U$ is empty.
Conversely, suppose that for all non-empty open sets $U$, the set $U \setminus A$ is non-empty. Then no non-empty subset of $A$ is open. Taking complements, no superset of $X \setminus A$ (except for $X \setminus \emptyset = X$) is closed. Therefore, by definition,
$$Cl(X \setminus A) = \bigcap_{F \supset X \setminus A, \\\text{F closed}}F = X$$
as required.

A: Your proof is correct, but it can be made simpler (without using contradiction).
If you set $B=X\setminus A$, then $U\setminus A=U\cap(X\setminus A)=U\cap B$. With this change your statement becomes

$B$ is dense if and only if, for every nonempty open set $U$, $U\cap B$ is not empty.

Suppose $B$ is dense and that $U$ is a nonempty open set and take $x\in U$. Since $B$ is dense, $x\in\operatorname{cl}(B)$, so for every neighborhood $V$ of $x$, $V\cap B\ne\emptyset$. But $U$ is a neighborhood of $x$, so $U\cap B\ne\emptyset$.
Suppose $B$ is not dense. Then there is $x\notin\operatorname{cl}(B)$ and, by definition, there is an open neighborhood $U$ of $x$ (so $U$ is open and nonempty) such that $U\cap B=\emptyset$.


text:
Q: Route traffic from NIC2 to terminate at NIC1 I have a Windows 2000 server with two NICs already installed with separate IPs:

*

*NIC1: 172.14.3.113; No gateway

*NIC2: 10.15.120.22; Gateway: 10.15.120.1

NIC2 is for WAN connectivity, and NIC1 is serving local clients.
NIC1 is already serving local clients. Now for a remote site, I want people to come in and access using NIC2.
Can we route all traffic coming in using NIC2 to NIC1, as everything is working with NIC1 locally.
Can this be done using the windows route command?

A: It's theoretically possible. You'll have to enable packet forwarding on the 2000 server (one guide available here), and then you'll have to add static routes to the 10.15.120.1 router (and possibly further up) to enable packets coming in to find the 172.14.3.x network.
Dare I ask why you can't just address the requests to 10.15.120.22?

A: This is not really an easy problem to solve.
If your application runs over HTTP you can use a Reverse Proxy to do what you want. You set up the Reverse Proxy to listen on 10.15.120.22 and forward all traffic to 172.14.3.113. 172.14.3.113 will then send its traffic back to 10.15.120.22 and 10.15.120.22 (because it's a smart cookie) will send the traffic back to its originator.
The other option is to run NAT on NIC2 and then do a port forward to NIC1
However, we probably need more information about the kind of traffic that you expect to see routed.


text:
Q: SSL Verify Failed error while insatlling Composer on Windows 7 with proxy My error is whenever I try to install Composer using both the GUI and command line I get the same error with SSL verification failing and thus can't connect to HTTPs through my proxy. I am on a Windows 7 machine running XAMPP behind a proxy.
To start I have done my research on this error and have tried all of the solutions on other posts, and I am wondering what I missed.

*

*This one seems to be the same problem as me but no answers. https://stackoverflow.com/questions/52457358/ssl-routinestls-process-server-certificatecertificate-verify-failed-failed-to

*This one looks like it might work but I am on a Windows 7 machine and don't have the option to purge and reinstall my certificates https://stackoverflow.com/questions/53351117/php-composer-https-error-1416f086-certificate-verifying-failed

*This isn't a virtual machine, it is on the native OS so I don't think there is any time synchronization that I need to do. https://stackoverflow.com/questions/53154837/ssl-error-messages-error1416f086ssl-routinestls-process-server-certificatec
The things that I have tried:

*

*Currently using XAMPP for apache, I downloaded and installed latest versions as well as a few previous versions

*I re-downloaded the curl-ca-bundle.crt and updated my  \xampp\apache\bin\curl-ca-bundle.crt to reflect the latest version (~roughly 20kb difference between the one that came with XAMPP and the one I downloaded).

*I manually downloaded the certificate for getcomposer.org and appended it to the end of my curl-ca-bundle.crt. (Yes I am sure that this is the file that PHP/Composer is using to install)

*When I try to install this through command line I get an error saying no such host is known. I figured out that this issue is due to HTTP/HTTPS_PROXY urls not being set. I turned them on and then I get the same error as through the GUI (found below)

*I then when through Composer's site and downloaded the .exe to install, in the installer I have the option to specify proxy (which I did) to get rid of the no sush host, after I specified the proxy I now have the exact same error as the command line.

*Disabling the SSL/TLS for composer. But it still fails when trying to contact any website with https.

GUI:

The Composer installer script was not successful [exit code 1].
OpenSSL failed with a 'certificate verify failed' error. This
  indicates a problem with the Certificate Authority file(s) on your
  system, which may be out of date.
Certificate location [from openssl.cafile ini setting]:
  \xampp\apache\bin\curl-ca-bundle.crt
The php.ini used by your command-line PHP is: C:\xampp\php\php.ini
Script Output: The "https://getcomposer.org/versions" file could not
  be downloaded: SSL operation failed with code 1. OpenSSL Error
  messages: error:1416F086:SSL
  routines:tls_process_server_certificate:certificate verify failed
  failed to open stream: Cannot connect to HTTPS server through proxy

CMD Line:
C:\Users\S0077500\Desktop\Laravel\Attempt 7>php composer.phar diagnose
You are running Composer with SSL/TLS protection disabled.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "https://repo.packagist.org/package
s.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL
Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Composer is configured to disable SSL/TLS protection. This will leave remote HTT
PS requests vulnerable to Man-In-The-Middle attacks.
Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://repo.packagist.org/package
s.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL
Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: Unable to assess the situation
, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipba
ll/1.0.0" file could not be downloaded: SSL operation failed with code 1. OpenSS
L Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy)
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit"
 file could not be downloaded: SSL operation failed with code 1. OpenSSL Error m
essages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify fa
iled
failed to open stream: Cannot connect to HTTPS server through proxy
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version:

  [Composer\Downloader\TransportException]
  The "https://getcomposer.org/versions" file could not be downloaded: SSL op
  eration failed with code 1. OpenSSL Error messages:
  error:1416F086:SSL routines:tls_process_server_certificate:certificate veri
  fy failed
  failed to open stream: Cannot connect to HTTPS server through proxy

diagnose

C:\Users\S0077500\Desktop\Laravel\Attempt 7>

A: I have Windows 10 with xampp 3.0.12 (php5.3). I was not able to install composer. I tried below steps it worked for me.

*

*Download installer script from https://getcomposer.org/installer.

*Save it in a file called as composer-setup.php.

*Open composer-setup.php in your favorite editor.

*Replace all HTTPS to HTTP and save file.

*Execute below 3 steps in command prompt:
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

*Voila! Successfully installed composer, you can run: php composer.phar.
Thanks


text:
Q: Initializing ExpressionTextCtrl i have a given code:
import wx

from application.gui.ctrls.panelCalibration.PanelGridCalibration import PanelGridCalibration
from lib.common.dataStructures.Value import ExpressionValue

class PanelValueCalibration(PanelGridCalibration):
    def __init__(self, parent, defaultValues, changeableSize=False):
        PanelGridCalibration.__init__(self, parent, defaultValues, False)
        self.grid.SetRowLabelSize(0)
        self.grid.SetColLabelSize(0)
        self.grid.SetDimension(1, 1)
        self.grid.Unbind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK)
        wx.CallAfter(self.ExpandCell)

        self.DisableWriteByVariable()

    def ExpandCell(self):
        self.grid.SetColSize(0, self.grid.GetClientSize().x - 20)

    def SetDefaultValues(self, defaultValue):
        pass
        #self.grid.GetTable().SetDefaultValue(0, 0, defaultValue)

    def SetValues(self, value):
        self.grid.GetTable().SetValue(0, 0, value.GetValue())

    def OnGridDimensionChanged(self, oldDimension, newDimension):
        pass

    def GetValues(self):
        return ExpressionValue(self.grid.GetCellValue(0, 0))

    def CheckInput(self):
        if self.GetValues().GetValue() == None:
            self.ShowErrorDialog(_(u"Kein Wert zum Schreiben angegeben!"))
            return False
        return True

as you see, PanelValueCalibration inherits from PanelGridCalibration. However, I want to modify PanelValueCalibration to use a TextCtrl instead of a GridCtrl. I see there is an ExpressionTextCtrl class but I don't know how to import it into my PanelValueCalibration class.
edit:
I already inserted:
from application.gui.ctrls.ExpressionCtrls import ExpressionTextCtrl

but don't know how to define the init correctly:
class PanelValueCalibration(ExpressionTextCtrl):
    def __init__(self, parent, defaultValues, changeableSize=False):
        ExpressionTextCtrl.__init__(self, parent, defaultValues, False)


text:
Q: Vis.js Timeline - How to collapse a group without nesting I'd like to be able to collapse or toggle visibility of specific groups on the timeline by clicking on the group title (or an icon next to it, etc.)
All examples I've seen for accomplishing similar functionality requires using nested groups, and then collapsing the group, but the nested model does not work for our data, and we only want to be able to collapse one at a time.
I have figured how to show a group as collapsed on initialization by setting a className, but I haven't figured out how to toggle the className on the group label + row on the fly.

A: I uses thise functions in order to remove/show all items in a group
    function plannerCloseGroup(groupID){
    // retrieve all items having a property group with value groupID
    var itemsFiltered = items.get({
      filter: function (item) {
        return (item.group == groupID);
      }
    });
    closedItems[groupID] = itemsFiltered;
    items.remove(itemsFiltered);
    $("#plannerMinus_" + groupID).addClass("hidden");
    $("#plannerMinus_" + groupID).removeClass("display");
    $("#plannerPlus_" + groupID).removeClass("hidden");
    $("#plannerPlus_"+ groupID).addClass("display");
}

function plannerOpenGroup(groupID){
    items.update(closedItems[groupID]);
    $("#plannerMinus_" + groupID).addClass("display");
    $("#plannerMinus_" + groupID).removeClass("hidden");
    $("#plannerPlus_" + groupID).removeClass("display");
    $("#plannerPlus_" + groupID).addClass("hidden");
    delete closedItems[groupID];
}

closedItems is a global array
plannerMinus og plannerPlus are icons next to the group name
When I define my groups I have this code in content, where $employeeID also is my groupID
'  '

It then looks like this


text:
Q: Reduce the size of android facebook SDK We are using facebook sdk to login the users to our app. But the SDK is pretty large hence it is increasing our apk size. Since we use only the login feature we do not require other modules of SDK (share, messenger etc). Is there any way we can add only the required features of SDK in the project?

*

*In case of google play services, additional maven artifacts have been added to the Google Repository that contain single domains of functionality.This means that we can include just those portions of Google Play services that your app uses.
dependencies {
    compile 'com.google.android.gms:play-services-ads:6.5.+'
}
(http://googleadsdeveloper.blogspot.in/2015/01/reducing-google-play-services-impact-on.html)

*Even twitter has split it's fabric SDK into smaller modules(Core, Crashlytics, Digits, tweetUI etc) which is really helpful in reducing the size of apk.
(https://docs.fabric.io/android/index.html)
Is similar feature available for facebook SDK as well? Any help is appreciated. Thanks!

A: I see some possible ways :

*

*There are some Facebook sdk alternatives on GitHub like:
https://github.com/greenhalolabs/facebooklogin
https://github.com/sromku/android-simple-facebook
So try to find the best fitted library for your needs

*You can try to use older Facebook library, which would be lighter, but also lack of some functions.
Before you do this point read some articles like this: Facebook authentication without login button

*Finally, try to exclude unnecessary libs like in this example:
dependencies {compile('com.facebook.android:facebook-android-sdk:4.3.0') {
    exclude module: 'support-v4'      }     }


text:
Q: How does Wikipedia's "What links here" work? I recently used Wikipedia's function "What links here" (which is found under the "Toolbox" element in any entry's left menu) and it got me started wondering how this function actually works.
I'm guessing that searching through all the article entries after links isn't very effective, so are all the links stored in a separate database? If so, is this updated when an article is edited or another time?
Thanks.

A: You could think this as a more general problem. If you have a link (or pointer or whatever) from A to B, how can B know that A has a link pointing there?
The answer is to store the information to target location. That is, when  the page A is edited and a link is created to B, at the same time store information about the link source to B (a reverse link). In case of a web page, the reverse link could be written directly into "what links here" page. Just a single write into a static page. No need to perform any searches or database queries.

A: Pseudo code for a simple algorithm that would do it
procedure updateChanges(editedPage):
    for_each(link on editedPage):
        if(link is not to another wikipedia page): continue
        pageToUpdate = open(link):
        if(pageToUpdate->whatLinksHere.contains(editedPage)): continue
        pageToUpdate->whatLinksHere.insert(editedPage)

Sorry I just finished my algorithms class so I have an urge to write pseudo code. In this context, the updateChanges() procedure would be something called during the "update the 'what links here' for other pages" phase that Greg Hewgill referred to.

A: Whenever a page on Wikipedia is edited, it is placed into a background queue that does some further processing. Some of the things that happen there are:

*

*updates to the "what links here" for other pages

*updates to category index pages

*updates to the global cache of existing pages to help render "redlinks" on other pages

This sort of information doesn't need to be updated right away when you hit "Submit", so the background processing queue takes care of it. Sometimes this queue can grow quite large, but usually it's kept under control.
You can find more information about this at Help:Job Queue.

A: The way I would implement is to get all the links after an edit, then store them in a separate table with the key being the current url. Then I could just query the table with the URL the user is currently on and get all the links that have been marked as linking to that page.
It probably wouldn't be as straightforward as that but that's the general, simplified idea. Probably instead of URLs it would be wiser to store page IDs and so on.

A: It would make sense for the "update event" of an article to trigger a links parser as this is the only time an article is going to change. The update event in turn would simply scan for links, and query the db for links that are internal to wikipedia.
I imagine each page has a primary key and a simple association table is created to relate the pages PK to all the other pages that link to it.
Theres likely some additional bits that get added to aid performance on such a large site but that would be the basic mechanics.


text:
Q: Alternate stylesheet switching in both Chrome and Firefox I'm encountering some weird inconsistent behavior between Chromium 53 and Firefox 49 when switching between stylesheets.
My stylesheets are added like this:
<link class="alternate-style" rel="stylesheet" title="Carbon"
      type="text/css" href="assets/css/alt/Carbon.css" />
...

The switcher works like this:
function setStyle(style) {
  $('link.alternate-style')
    .prop('disabled', 'disabled')
    .filter(function() { return this.title == style; })
    .removeAttr('disabled');
}

(setStyle() is called on startup with a default value.)
This worked in Firefox and Chromium without any problems as late as jQuery 2.2.4.
Now I'm trying to upgrade to jQuery 3.1.1.
In Chromium, there's no problem at all - but in Firefox, it won't work after the upgrade. All stylesheets are disabled, and the style-changer won't do anything.
Suspecting that the removeAttr() has changed (jQuery now differentiates between attributes and properties more strictly), I changed setStyle to the following which seemed cleaner in any case:
function setStyle(style) {
  $('link.alternate-style').prop('disabled', function() {
    return this.title != style;
  });
}

Now it works in Firefox, but not in Chromium! The bug is different - the style-switcher works fine, but the initializer is broken and the page will initially be unstyled.
Summary: In 2.2.4, both versions of the code work. In 3.1.1, the old code works in Chromium but not Firefox, while the new code works in Firefox but not Chromium.
By testing, I isolated the part of the code that will work in both browsers:
function setStyle(style) {
  $('link.alternate-style')
  .prop('disabled', true)         // <-- necessary for chromium
  .prop('disabled', function() {
    return this.title != style;
  });
}

That line seems redundant - the property will simply be overridden again. But commenting it out breaks the initialization in Chromium.

A: Update: By testing with the latest dev build of chromium 56, it appears that this is a chromium bug that has since been fixed.


text:
Q: Why is the element of a list of data.frames still a list element and no data.frame? I want to read the CSVs from a folder, subset over all of them and return the subset. However, I have my problems with the apply functions, since I can't access the data the way I want. What would be a good way to do this and what am I not getting here?
#specifiy files in folder with relative path: "data/1.csv" etc.
selected.files <- dir(path = "data", pattern = "*.csv", full.names=TRUE)

#returns list of same length as selected.files, each elemt is a data.frame corresponding to read.csv("1.csv")
selected.frame <- lapply(selected.files, read.csv)

#returns list
class(selected.frame[1])`

Now, I'm not sure how to proceed. I would have expected that I can use an apply function again to access an element of the selected.frame list, treat it as a data.frame and use the subset function on it.

A: Because it is just the subset of the element. Even though it has just one item it is still a list or a data.frame.


text:
Q: How to prevent name mangling of javascript functions in django-pipeline I am using django version 1.82 with django-pipeline. I call a particular javascript function from html by name.
 <form class="navbar-form navbar-right vcenter"
 action="javascript:search();" role="search" id='searchform'>

Unfortunately in the compressed js file, the name of the function is changed and hence the frontend functionality is not workig.  How do I maintain the same name for that function or how do I change the reference to the js function in html?
I have installed yuglify and the settings I use is
PIPELINE_CSS = {
'allstyles': {
    'source_filenames': (
      'css/application.css',
      'feedback/css/feedback-form.css',
    ),
    'output_filename': 'css/nifty.css',
    'extra_context': {
        'media': 'screen,projection',
    },
},
}

PIPELINE_JS = {
'actions': {
    'source_filenames': (
      'js/nifty.js',
      'feedback/js/feedback-form.js',
    ),
    'output_filename': 'js/nifty.js',
}
}
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_DISABLE_WRAPPER = True
PIPELINE_ENABLED=True

A: Are you sure that search() is a global function? To make sure you can assign it to the window variable:
window.search = function() {
    ...
}

A: I'd do it the other way around.
<form ... action="/nojs.html" ... id='searchform'>

and then intercept the submit event on the form.
(function(){
    var sf = document.getElementById('searchform');
    sf.addEventListener('submit', function(ev){
        ev.preventDefault();
        // do here whatever "search()" needs to do
    });
})();

That way you don't need to add anything into the window namespace, are independent of minified function names, and a browser with disabled JS gets a readable error page.


text:
Q: MariaDb Gone Away On Spesefic Row
in my database when select from 2 of 10 tables, in spesefic rows , i give this message :
ERROR 2006 (HY000): MySQL server has gone away

for example whene i try :
select * from records where id=238

every thing is ok , and even this:
select * from records where id=270

is ok.
but when try this one:
select * from records where id=239

return error :

i already search in stackoverflow and google for this and all refrence mention that increace buffer size and...
but i dont think this problem relate to this subjects , its seems that some data is currept the table.
p.s : engine that use is innodb
any clue please

A: MySQL closes itself when a operation tries to read from a corrupted InnoDB table.
This is very annoying but is the only way I know by heart.
Is possible to recover all data in most of times, the procedure is the same for MySQL, MariaDB and XtraDB.
There is a lot of explanation on the official manual https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html.
But, essentially, you need to add an option named innodb_force_recovery on MySQL configuration file, restart MySQL and try to SELECT that corrupted data. This options goes from number 1 to 6, but above 3 you could lose some data.
When you found a number that allow you to make a SELECT on that rows, mysqldump the entire table to recover after.
Depending on table state you'll need to remove the file manually before start MySQL without innodb_force_recovery:
rm /var/lib/mysql/myschema/corrupted_table.ibd

This will cause other problems, but once the database start you'll need to drop the old tablespace, create "the same table" in another database and swap the tablespaces:
USE a;
ALTER TABLE corrupted_table DISCARD TABLESPACE;
CREATE DATABASE b;
-- import the dump inside database b
-- fisically move the "ibd" file from "b" to "a"
-- mv /var/lib/mysql/a/corrupted_table.idb /var/lib/mysql/b/corrupted_table.idb
USE a;
ALTER TABLE corrupted_table IMPORT TABLESPACE;
DROP TABLE b.corrupted_table;


text:
Q: New scene is created from its frame size but it keeps getting smaller each time. Why? I am writing a game in which the user must prevent falling objects (rocks) to pass the button of the screen using some plates, each click make a plate at that position but he can only have 5 plates at each time and clicking on sixth point vanished the first plate while creating a new one.
That was a brief on how my game mechanics work.
Here is the part of my code that counts falling objects(sprites) using physics and if they became more than 10 a game over message will be shown and the code restarts the game, a new game. to have a new game I need to
-(void)didSimulatePhysics
{
    [self enumerateChildNodesWithName:@"rock" usingBlock:^(SKNode *node, BOOL *stop) {
        if (node.position.y < 0)
        {
            ScoreNum++;
            [node removeFromParent];
            score.text = [NSString stringWithFormat:@"%@ %li",ScoreMSG,(long)ScoreNum];
            if (ScoreNum > 10)
            {
                score.fontSize = 40;
                score.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame));
                score.text = @"Game Over!";
                SKScene *spaceshipScene  = [[GameScene alloc] initWithSize:CGRectMake(0, 0,CGRectGetMaxY(self.frame),CGRectGetMaxX(self.frame)).size];
                printf("%f %f",CGRectGetMidX(self.frame),CGRectGetMidX(self.frame));
                SKTransition *doors = [SKTransition doorsOpenVerticalWithDuration:0.25];
                [self.view presentScene:spaceshipScene transition:doors];
                ScoreNum = 0;
            }
        }
    }];
}

GameScene is subclassed from SKScene like this
#import <SpriteKit/SpriteKit.h>
@interface GameScene : SKScene
@end

The code works find but the plates (all of the sprites on the screen) gets squeezed from sides
The following picture shows the results, first time, second time and third time, I needed 10 reputation to include 3 pictures so I had to merge them all into one picture, Here it is.
https://www.imageupload.co.uk/images/2015/08/30/123.png

Sorry, looks like I can not embed an image since I have not enough reputation!
Why each my scene squeezes?

A: Looks like you set a scaleMode in your viewController.viewDidLoad that handles your game scene, nothing wrong with your physics code (in your question).
look for something like this scene.scaleMode = SKSceneScaleModeAspectFill usually SKScenes are automatically scaled based on the screen size of the device and it is upto SKScene to provide you a scene.
Your scenes in your pictures shows that scenes have a complete and full cover but they are scaled.

It is kind of hard to handle sprite size while do not controling scale. I suggest to get ride of every Scale Mode and remark them all and control the scale your self.
  if you are not going to zoom in/out as I believe it is the case in your game you just need to reset the scenes scale to 1 each time after each scene transition.


text:
Q: What would be a better way to code this if then else clause? I have the following code. I'm still a newbie in Ruby on Rails. As you can see I'm repeating myself 4 times.
I tried something like this:
if @property.nil? || @property.status_id == 144 || (@property.status_id <= 16 && current_user.nil?) || (@property.status_id <= 16 && current_user.id != @property.user_id)

But it gives me lots of errors in case @property is nil. Because then @property.status_id cannnot be called since @property is nil.
Anyway, I think an experienced Ruby on Rails coder gets the idea.
  def show
    @property = Property.find(params[:id]) rescue nil
    if @property.nil?
      flash[:error]=t("The_property_was_not_found")
      redirect_to root_path
      return
    end
    if @property.status_id == 144
      flash[:error]=t("The_property_was_not_found")
      redirect_to root_path
      return
    end
    if @property.status_id <= 16 && current_user.nil?
      flash[:error]=t("The_property_was_not_found")
      redirect_to root_path
      return
    end
    if @property.status_id <= 16 && current_user.id != @property.user_id
      flash[:error]=t("The_property_was_not_found")
      redirect_to root_path
      return
    end
    @images = Image.find(:all, :conditions =>{:property_id => params[:id]})
  end

root

A: def show
    @property = Property.find(params[:id]) rescue nil
    if @property.nil? || @property.status_id == 144 || (@property.status_id <= 16 && (current_user.nil? || current_user.id != @property.user_id))
      flash[:error]=t("The_property_was_not_found")
      redirect_to root_path
    else
      @images = Image.find(:all, :conditions =>{:property_id => params[:id]})
    end
  end

I am not familiar with Ruby syntax so this might not really compile, but you get the idea.

A: Is that really the exact code? || short-circuits and a nil value shouldn't be a problem.
@property=nil
if @property.nil? || @property.status_id == 144
   puts @property.class.to_s
end

Outputs
NilClass

A: I think you should approach this by defining the "can show" logic into a straightforward helper method you can call to make a determination rather than cluttering up your show method with all kinds of branches that ultimately make the same action occur.
def can_show_property?(property)
  return false unless (property)

  return false if (property.status_id == 144 or property.status_id > 16)

  return false unless (current_user && current_user.id == property.user_id)

  true
end

def show
  @property = Property.find(params[:id]) rescue nil

  unless (can_show_property?(@property))
    flash[:error]=t("The_property_was_not_found")
    redirect_to root_path
    return
  end

  @images = Image.find(:all, :conditions =>{ :property_id => params[:id] })
end

Having "magic" numbers in your code like 144 does lead to asking why they aren't assigned constants. It's usually a lot easier to understand when clearly labelled MyApp::PROPERTY_LOCKED.

A: You could try this:
def show
begin
  @property = Property.find(params[:id])
  if [144,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0].include?(@property.status_id)
    flash[:error]=t("The_property_was_not_found")
    if current_user && (current_user.id != @property.user_id)
      redirect_to myimmonatie_path
    else
      redirect_to root_path
    end
rescue
  flash[:error]=t("The_property_was_not_found")
  redirect_to root_path
end
@images = Image.find(:all, :conditions =>{:property_id => params[:id]})

end


text:
Q: Fastest way to Find a m x n submatrix in M X N matrix I was thinking of a fast method to look for a submatrix m in a bigger mtrix M.
I also need to identify partial matches.
Couple of approaches I could think of are :

*

*Optimize the normal bruteforce to process only incremental rows and columns.

*May be extend Rabin-karp algorithm to 2-d but not sure how to handle partial matches with it.

I believe this is quite frequently encountered problem in image processing and would appreciate if someone could pour in their inputs or point me to resources/papers on this topic.
EDIT:
Smaller example:
Bigger matrix:
1 2 3 4 5
4 5 6 7 8
9 7 6 5 2
Smaller Matrix:
7 8
5 2
Result: (row: 1 col: 3)
An example of Smaller matrix which qualifies as a partial match at (1, 3):
7 9
5 2
If More than half of pixels match, then it is taken as partial match.
Thanks.

A: I recommend doing an internet search on "2d pattern matching algorithms". You'll get plenty of results. I'll just link the first hit on Google, a paper that presents an algorithm for your problem.
You can also take a look at the citations at the end of the paper to get an idea of other existing algorithms.
The abstract:

An algorithm for searching for a two dimensional m x m pattern in a two dimensional n x n text is presented. It performs on the average less comparisons than the size of the text: n^2/m using m^2 extra space. Basically, it uses multiple string matching on only n/m rows of the text. It runs in at most 2n^2 time and is close to the optimal n^2 time for many patterns. It steadily extends to an alphabet-independent algorithm with a similar worst case. Experimental results are included for a practical version.

A: There are very fast algorithms for this if you are willing to preprocess the matrix and if you have many queries for the same matrix.
Have a look at the papers on Algebraic Databases by the Research group on Multimedia Databases (Prof. Clausen, University of Bonn). Have a look at this paper for example: http://www-mmdb.iai.uni-bonn.de/download/publications/sigir-03.pdf
The basic idea is to generalize inverted list, so they use any kind of algebraic transformation, instead of just shifts in one direction as with ordinary inverted lists.
This means that this approach works whenever the modifications you need to do to the input data can be modelled algebraically. This specifically that queries which are translated in any number of dimensions, rotated, flipped etc can all be retrieved.
The paper is mainly showing this for musical data, since this is their main research interest, but you might be able to find others, which show how to adapt this to image data as well (or you can try to adapt it yourself, if you understand the principle it's quite simple).
Edit:
This idea also works with partial matches, if you define them correctly.

A: There is no way to do this fast if you only ever need to match one small matrix against one big matrix. But if you need to do many small matrices against big matrices, then preprocess the big matrix.
A simple example, exact match, many 3x3 matrices against one giant matrix.
Make a new "match matrix", same size as "big matrix", For each location in big matrix compute a 3x3 hash for each x,y to x+3,y+3 in big matrix. Now you just scan the match matrix for matching hashes.
You can achieve partial matches with specialized hash functions that give the same hash to things that have the same partial matching properties. Tricky.
If you want to speed up further and have memory for it, create a hash table for the match matrix, and lookup the hashes in the hash table.
The 3x3 solution will work for any test matrix 3x3 or larger. You don't need to have a perfect hash method - you need just something that will reject the majority of bad matches, and then do a full match for potential matches in the hash table.

A: I think you cannot just guess where the submatrix is with some approach, but you can optimize your searching.
For example, given a matrix A MxN and a submatrix B mxn, you can do like:
SearchSubMatrix (Matrix A, Matrix B)

answer = (-1, -1)

Loop1:
for i = 0 ... (M-m-1)
|
|   for j = 0 ... (N-n-1)
|   |
|   |   bool found = true
|   |
|   |   if A[i][j] = B[0][0] then
|   |   |
|   |   |   Loop2:
|   |   |   for r = 0 ... (m-1)
|   |   |   |   for s = 0 ... (n-1)
|   |   |   |   |   if B[r][s] != A[r+i][s+j] then
|   |   |   |   |   |   found = false
|   |   |   |   |   |   break Loop2
|   |
|   |   if found then
|   |   |   answer = (i, j)
|   |   |   break Loop1
|
return answer

Doing this, you will reduce your search in the reason of the size of the submatrix.
Matrix         Submatrix         Worst Case:
1 2 3 4           2 4            [1][2][3] 4
4 3 2 1           3 2            [4][3][2] 1
1 3 2 4                          [1][3]{2  4}
4 1 3 2                           4  1 {3  2}

                                 (M-m+1)(N-n+1) = (4-2+1)(4-2+1) = 9

Although this is O(M*N), it will never look M*N times, unless your submatrix has only 1 dimension.


text:
Q: Keep playing sound on macOS even during sleep I'm playing sound using the following code:
if let path = Bundle.main.path(forResource: "mysound", ofType: "wav") {
        do {
            sound = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
            sound.prepareToPlay()
            sound.numberOfLoops = -1
            sound.play()
        } catch {
            print("Could not find file")
        }
}

It is working, however if I close the lid, the device goes to sleep and sound stops.
How can I keep playing sound when the lid is closed?

A: There are two ways to prevent your MacBook from sleeping when the lid is closed:

*

*Use a utility like Fermata.

*Connect an external display.