text:
Q: Shadowed method is not called I have a class which i realized will not always correctly instantiate and as a quick fix, i figured i'd subclass it and shadow a few methods so that the program can continue to run without exploding.  When i run the software, calls to the methods resolve to the base's implementations and not the subclass.  I'm using VB.NET with .NET 2.0.  Here is an example of what i'm trying to do:
Public Class SuperClass

  Public Sub New ()
    Dim type As Type = GetType(SubClass)
    If (Me.GetType() is type) Then
      //nothing
    Else
      //build real object
    EndIf
  End Sub

  Private Shared _Instance As SuperClass
  Public Shared ReadOnly Property Instance() As SuperClass
    Get
      If (_Instance Is Nothing) Then
        Try
          _Instance = New SuperClass()
        Catch ex As Exception
          Dim result As DialogResult = MessageBox.Show(text, caption, MessageBoxButtons.RetryCancel, MessageBoxIcon.Information)
          If (result = DialogResult.Retry) Then
            _Instance = New SuperClass()
            //this will probably cause problems of its own, but i'll cross that bridge later...
          Else
            _Instance = New SubClass()
          End If
        End Try

      End If
      Return _Instance
    End Get
  End Property

  Public Overridable Function MyFunction() As Integer
     Dim somethingReasonable As Integer //do something for real
     Return somethingReasonable
  End Function

End Class

Public Class SubClass
  Inherits SuperClass

  Public Sub New()
    //doesn't do what cause the exception in the first place
  End Sub

  Public Shadows Function MyFunction() As Integer
    //Do something safe
    Return -1
  End Function

End Class

I'm not sure why the base class gets called during runtime.  When i inspect the object in the debugger it is clearly the SubClass type but the SuperClass methods get called.  Access to the object is through the Instance Property.
I'm sure i'm doing something wrong or making some wrong assumption but I can't figure out what.
Thanks,
brian

A: If a method is shadowed rather than overridden, the shadowing methods will not be called when an instance is of subclass type -- the method which will be called is determined based on the compile-time type of the receiver rather than the run-time type.  This is the fundamental difference between shadowing and overriding.


text:
Q: ord() expected string, but int found I'm having problem in the ord() def, my code is given below:
def write(data):
    for block_idx in list(range(0, len(data), 10)):
        chksum = 0
        for byte_idx in list(range(block_idx, 2)):
            chksum += ord(data[byte_idx])

write(b'123')

TypeError: ord() expected string of length 1, but int found

A: You're providing b'123' to the function, which is bytes, that is why when you're trying to get the byte of an specific position you're getting an int. And when you're passing an int to the ord(), the exception is thrown, because:

Given string of length 1, the ord() function returns
an integer representing the Unicode code point of the character when
the argument is a Unicode object, or the value of the byte when the
argument is an 8-bit string.

Use:
chksum += ord(chr(data[byte_idx]))

A: As the Python bytes documentation states:

While bytes literals and representations are based on ASCII text,
bytes objects actually behave like immutable sequences of integers

When b"123"[0] is called it returns an int which is an invalid argument to the builtin ord function.
You don't even need to call ord in this case:
chksum += data[byte_idx]

redpajama_set_name: RedPajamaStackExchange


text:
Q: Filter field domain one2many to many2one I have a one2many field which contains 3 fields with 2 different values, for example.
Here let's say the Zone is a one2many field

Zone A = Car = 3000, Bike = 2000.
Zone B = Car = 2500, Bike = 1500.
Zone C = Car = 2000, Bike = 1000.

and I have many2one fields for the chosen field later (Ex. Car and Bike)
and rate_fields as trigger fields for calculations(a place to store value later)
the point is I want to select the "A" zone, then I select "Car" in many2one fields
the output at the rate field is 3000,
and if I select zone "B" then select "Bike"
the output at the rate field is 1500
if written with code, then the implementation uses filter by domain with domain syntax Multiple Conditions.
can anyone help me to make an example code?
maybe this is a reference but I can't make the appropriate code
Multiple Conditions
In Programming

if a = 5 or (b != 10 and c = 12)

In Open ERP domain filter

['|',('a','=',5),('&',('b','!=',10),('c','=',12))]

https://stackoverflow.com/a/19070664/9228786
Thank you in advance

A: I referenced your other question for some more details, but your questions are both very confusing. As far as I understand, your goal is to choose a Zone, then choose a Vehicle Type. Based on your choices, you want to see the Rate.
Whatever model you want to have the calculation will need a field to choose the Zone, a field to choose the Vehicle Type, and a field to store the Rate.
Your other question's classes are a bit messy, so here's what I suggest.
You'll need a model to track (1) Locations/Zones, (2) Vehicle Types, (3) Rate each Vehicle Type is charged at each Location/Zone, and (4) a model to compute the Rate for the given Vehicle Type at the given Location/Zone.
class ParkingLocation(models.Model):
    _name = 'parking.location'
    _description = 'Parking Zones'

    name = fields.Char(string='Name')

class VehicleType(models.Model):
    _name = 'vehicle.type'
    _description = 'Types of Vehicles'

    name = fields.Char(string='Name')

class ZoneRate(models.Model):
    _name = 'zone.rate'
    _description = 'Define the rate for each Vehicle Type in each Zone'

    location_id = fields.Many2one('parking.location', string='Location', required='True')
    vehicle_type_id = fields.Many2one('vehicle.type', string='Vehicle Type')
    rate = fields.Float('Rate')

class ZoneRateLookup(models.Model):
    _name = 'zone.rate.lookup'
    _description = 'Calculate the rate for the chosen Zone and Vehicle Type'

    location_id = fields.Many2one('parking.location', string='Location', required='True')
    vehicle_type_id = fields.Many2one('vehicle.type', string='Vehicle Type')
    rate = fields.Float('Rate', compute='_compute_rate', store=True, readonly=True)

    @api.multi
    @api.depends('location_id', 'vehicle_type_id')
    def _compute_rate(self):
        rate_lookup_obj = self.env['zone.rate.lookup']
        for zone_rate in self:
            rate = rate_lookup_obj.search([('location_id', '=', zone_rate.location_id.id),
                                                     ('vehicle_type_id', '=', zone_rate.vehicle_type_id.id)])
            if not rate:
                raise ValidationError(_('No Rate found for that Vehicle Type in that Zone!')
            zone_rate.rate = rate.rate


text:
Q: Subgroup of finite index and direct product We consider $\mathbb{Z}_p$ the ring of $p$-adic, and integer $\frac{\mathbb{Z}}{(p-1)\mathbb{Z}} \times \mathbb{Z}_p$, and we would like to find to subgroup $N$ of index $15$ over $\frac{\mathbb{Z}}{(p-1)\mathbb{Z}} \times \mathbb{Z}_p$, or more precisely, just a condition on $p$ to have the existence of such a subgroup.
Actually, as I have the answer, I know that we should prove that :
$\exists r \in \mathbb{N} \quad 15 /p^r(p-1) \quad (*)$
which permits then to conclude, as we assume from the beginning of the exercise that $p<50$.
But I don't succeed to prove $(*)$. Actually, we know that the subgroup of $\mathbb{Z}_p$ of finite index are the $p^r\mathbb{Z}_p$.
But we don't know precisely (or in a simple way) the subgroup of $\frac{\mathbb{Z}}{(p-1)\mathbb{Z}}\times \mathbb{Z}_p$, right ?
So, how to do to find $(*)$ ?
Thank you !

A: Note that every subgroup of $\Bbb Z_p$ of finite index has index a power of $p$.
If $H<\Bbb Z_p$ has finite index then it is open and as such must contain a basic open subgroup $p^r\Bbb Z_p$ for some $r>0$. But then there is a surjection
$$
\frac{\Bbb Z_p}{p^r\Bbb Z_p}\simeq\frac{\Bbb Z}{p^r\Bbb Z}\longrightarrow
\frac{\Bbb Z_p}{H}
$$
and we are done.

More generally, if $H$ is a subgroup of
$\frac{\Bbb Z}{(p-1)\Bbb Z}\times\Bbb Z_p$ of finite index then it has to contain $\{\bar 0\}\times p^r\Bbb Z_p$ for some $r>0$.
Therefore, passing to the quotient, the subgroups $H<\frac{\Bbb Z}{(p-1)\Bbb Z}\times\Bbb Z_p$ of finite index are in one-to-one correspondence with the injective limit of the set of subgroups of
$$
K_r:=\frac{\Bbb Z}{(p-1)\Bbb Z}\times\frac{\Bbb Z_p}{p^r\Bbb Z_p}
\simeq\frac{\Bbb Z}{(p-1)\Bbb Z}\times\frac{\Bbb Z}{p^r\Bbb Z}.
$$
as $r$ varies.
But ${\rm gcd}(p^r,p-1)=1$ so that $K_r$ is actually cyclic of order $p^r(p-1)$ and thus a complete classification follows.


text:
Q: Can't crop JPEG with GIMP 2.8.16 64-bit I have used GIMP for a long time to crop photos. Recently, I have not been able to do this. If I perform the usual procedure (Shift-C, etc.), the file is not cropped. Restarting the program and/or the OS does not help.
I have version 2.8.16 installed on 64-bit Ubuntu (4.4.0-138-generic #164-Ubuntu SMP Tue Oct 2 17:16:02 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux). Plenty of memory (32GB), processor AMD FX(tm)-8350 Eight-Core Processor × 8, graphics GeForce GT 630/PCIe/SSE2.
Any suggestions?


text:
Q: How to run a 30 minute API call in django In my django app, I have a function that is triggered by an action (a republishing action) where after the republish endpoint is hit, that function is triggered to check its status for 30 minutes via another API call. That function is:
timeout = time.time() + 60 * 30
        published_flag = False
    while time.time() < timeout:
                data = requests.get(apiUrl + dist_id).json()
                try:
                    published_flag = data['flags']
                    if published_flag:
                        break
                    else:
                        time.sleep(5)
                        continue
                except KeyError:
                    break

This timeout is 30 minutes and is very long. But 30 minutes is the worst case scenario when the flag status would change. This action can be triggered multiple times (multiple republish buttons can be pressed). The endpoint essentially times out as 30 minutes is too long for an endpoint to work. So I push the data via web sockets to the frontend.
Is there a smarter way to do this?

A: As Enix wrote you should use Celery. But you don't need a lot of workers. Actually never call sleep inside celery tasks. You can just retry it later. So every task will be really short and you need just 1-2 workers.
@app.task(bind=True, max_retries=60*30/5)
def do_whatever(self, dist_id):
    data = requests.get(apiUrl + dist_id).json()
    if 'flags' not in data:
        self.retry(countdown=5)


text:
Q: strcat into char[] I am using argp in a program and it uses a globally defined char doc[] to display information about the program.
Apart from program information, I want to add a GPL notice to this doc.
The GPL notice is defined as a const char * ( but I wouldn't mind changing this) as it is used in a few other places.
Initially I tried this:
static char doc[] = strcat("basic program info", GPLNOTICE);

But this gives:
error: initializer fails to determine size of 'doc'

Then I tried converting to strings:
static char doc[] = (string("basic program info") + string(GPLNOTICE)).c_str()

But that gives the same error
Then I thought maybe making doc a char * would also work
static char *doc = strcat("basic program info", GPLINFO)

...but this crashes with segmentation fault
I tried converting the GPL Notice to a macro definition but couldn't really do anything with that

A: The reason why this line crashes:
strcat("basic program info", GPLINFO)

is because it tries to modify the constant string literal that is stored in read-only memory, which produces undefined behavior. The correct usage of strcat could look like this instead:
static char buf[1024];
strcpy(buf, "basic program info");
strcat(buf, GPLNOTICE);

But since you are programming in c++, you should prefer using std::string instead of C-style strings:
std::string doc("basic program info");
doc += GPLNOTICE;

Also note that it is good practice to read the documentation of functions like these before you use them :)


text:
Q: Run tests in broken project using SBT When doing a serious refactor in a Java Eclipse project I will often break the build, but focus on getting one test to pass at a time.  When running the tests Eclipse warns that the project cannot be compiled, but it will still run the tests it can compile.
Now I'm using SBT and would like to achieve the same thing with 'test-only', but it tries to compile the whole project, fails, and doesn't run the tests.  How can I tell it to just compile the bits it can and run the tests.

A: You should add the following task to your project definition:
import sbt._

class Project(info: ProjectInfo) extends DefaultProject(info) {

  lazy val justTest = testTask(testFrameworks, testClasspath, testCompileConditional.analysis, testOptions)

}

This is the same as the ordinary test task, but has no dependencies attached at the end. If you'd like it to have dependencies, call dependsOn on the testTask(...) expression and provide the tasks you want it to depend on.
testTask(testFrameworks, testClasspath, testCompileConditional.analysis, testOptions).dependsOn(testCompile, copyResources, copyTestResources)


text:
Q: Return custom HTTP_STATUS_CODE while Django login My Django REST API has this class for authentication:
class AuthView(APIView):
      authentication_classes = (BasicAuthentication,)

      def post(self, request, *args, **kwargs):
          login(request, request.user)
          data = {'testkey':'testvalue'}
          return HttpResponse(json.dumps(data), content_type="application/json")

If credentials are correct, I'm getting 200 Status Code (which is fine).
However, for wrong credentials, I want to return a status code other than the default (401) Status Code.

A: HttpResponse takes a status keyword argument, so
HttpResponse(json.dumps(data), content_type="application/json", status=418)

will raise the classic I'm a teapot
Django's http module


text:
Q: Are [-90,-180] and [90,180] theoretically the same point? I'm not an expert in GIS.  To my understanding -180° longitude and +180° longitude are the same, meaning that if I draw two vertical lines on the map along this longitude, they will overlap.
But does this work for latitudes, too? Is -90° latitude equivalent to +90° latitude? If that is the case, as the title says this would mean that -90, -180 and 90, 180 are equivalent, is that correct?

A: No, they are not the same place. +90 would be the North pole, and -90 would be the South pole. For them to be the same place it would need to be on the equator, so 0, 180 = 0, -180
This image might help make it clear

From Geographic Coordinate System - Wikipedia


text:
Q: Bpchar querying in postgres and prisma I have a column in my table which if of type bpchar. Now I am trying to make a match in my application using prisma like this :
await prisma.user.findMany({
   where : {
       sdk_id : {
          contains : search
          mode: 'insensitive'
       }
    }
})

But with no results. Now i am wondering what am i doing wrong here ?


text:
Q: Crowdsale for already minted token bep20 Solidity openzeppelin vs.I don't understand much about places please can someone tell me how I can arrange and execute this crowdsale contract
this is the contract


text:
Q: Get last made move from game boards I have two 2D int arrays that represent game boards. (The initial board and the new board)
Content of the initial board:
013 | 6 0 0 0 4 4 4 4 4 0 0 0 6
012 | 0 0 0 0 0 0 4 0 0 0 0 0 0
011 | 0 0 0 0 0 0 0 0 0 0 0 0 0
010 | 0 0 0 0 0 0 2 0 0 0 0 0 0
009 | 4 0 0 0 0 0 2 0 0 0 0 0 4
008 | 4 0 0 0 0 0 2 0 0 0 0 0 4
007 | 4 4 0 2 2 2 5 2 2 2 0 4 4
006 | 4 0 0 0 0 0 2 0 0 0 0 0 4
005 | 4 0 0 0 0 0 2 0 0 0 0 0 4
004 | 0 0 0 0 0 0 2 0 0 0 0 0 0
003 | 0 0 0 0 0 0 0 0 0 0 0 0 0
002 | 0 0 0 0 0 0 4 0 0 0 0 0 0
001 | 6 0 0 0 4 4 4 4 4 0 0 0 6
      A B C D E F G H I J K L M

Content of the new board (after applying a move):
013 | 6 0 0 0 4 4 4 4 4 0 0 0 6
012 | 0 0 0 0 0 0 4 0 0 0 0 0 0
011 | 0 0 0 0 0 0 0 0 0 0 0 0 0
010 | 0 0 0 0 0 0 2 0 0 0 0 0 0
009 | 4 0 0 0 0 0 2 0 0 0 0 0 4
008 | 4 0 0 0 0 0 2 0 0 0 0 0 4
007 | 4 4 0 2 2 2 5 2 2 2 0 4 4
006 | 4 0 0 0 0 0 2 0 0 0 0 0 4
005 | 4 0 0 0 0 0 2 0 0 0 0 0 4
004 | 0 0 0 0 0 0 2 0 0 0 0 0 0
003 | 0 0 0 0 0 0 0 0 0 0 0 0 0
002 | 0 0 0 0 4 0 4 0 0 0 0 0 0
001 | 6 0 0 0 0 4 4 4 4 0 0 0 6
      A B C D E F G H I J K L M

I wanna compare the two game boards to get the last fetched move. How can I determine the last made move on this board?
As you can see the last made move is: "E1 - E2" -> The pawn "E1" was put in "E2"
Is there a fast way to compare the two to determine this last made move "E1 - E2"
What I have:
    for (int y = 0; y < Board.DIMENSION; y++) {
        for (int x = 0; x < Board.DIMENSION; x++) {
            // Check where not equal
            if (initialBoard.grid[x][y] != newBoard.grid[x][y]) {
                // What to add??
            }
        }
    }

A: Assuming that the user can only make a move over the empty places(0).
You can do something like this:
        for (int y = 0; y < size; y++) {
          for (int x = 0; x < size; x++) {
            // Check where not equal
            if (initialBoard.grid[x][y] != newBoard.grid[x][y] && newBoard.grid[x][y] == 0) {
                // From move
                String from = x +""+ (char)y+65;
            }
            if(initialBoard.grid[x][y] != newBoard.grid[x][y] && newBoard.grid[x][y] != 0) {
                // To move
            }
          }
        }

A: You will need to find two spots where the boards differ. You already seem to have the logic down to find a spot where the game board has changed. Now you need to decide what direction the move occurs in.
To me, it looks like the board going from 0 to 4 means a piece has moved there. So, if the new int is > the old int... we know this is the end location.
Since you've gotten this far, I think you can figure it out with the follow logic: (maybe there are cases in this game I am not aware of - so you will have to check for those cases)
String startPos, endPos;

for (int y = 0; y < Board.DIMENSION; y++) {
  for (int x = 0; x < Board.DIMENSION; x++) {
    // Check where not equal
    if (initialBoard.grid[x][y] != newBoard.grid[x][y]) {
      // if we go from a 0 to a 4, this is the starting position
      if (initialBoard.grid[x][y] < newBoard.grid[x][y]) {
        // translate the location into a position and store it as startPos
      } else {
        // translate the location into a position and store it as endPos
      }
    }
  }
}

System.out.println(startPos + " -> " + endPos); // something like that


text:
Q: Why not refresh the select element from context? I have a simple dropdown.
I'ts refresh the state from localstorage and context.
The context refresh and I can use everywhere in the page except in the select value.
This dropdown have an default value. (HU,EN,,DE,HR) It's not refresh although the state refresh
I'ts stay 'HU'. Although the state changed. The page other parts work properly
I use hooks. Thank you
Here is my codesandbox:
https://codesandbox.io/s/eager-river-t45b3r?file=/src/LanguageDropDown.js
LanguageDropDown.js
import React, { useState, useContext } from "react";
import GlobalContext from "./GlobalContext";
import classes from "./LanguageDropDown.module.css";
export default function LanguageDropDown() {
  const { language, setLanguage } = useContext(GlobalContext);
  console.log(`This is the  language state from context: ${language}`);
  return (

      <select
        className={classes.languageDropDown}
        value={language}
        onChange={(e) => {
          const selectedLanguage = e.target.value;
          console.log(`this is the selected: ${selectedLanguage}`);
          setLanguage(selectedLanguage);
          localStorage.setItem("language", JSON.stringify(selectedLanguage));
        }}
      >
       <option value="hu">HU</option>
        <option value="en">EN</option>
        <option value="de">DE</option>
        <option value="hr">HR</option>
      </select>

Here the good result:{language}

  );
}

ContextWrapper.js
import React, { useState, useEffect } from "react";
import GlobalContext from "./GlobalContext";

export default function ContextWrapper(props) {
  const [language, setLanguage] = useState("");

  useEffect(() => {
    const storageLanguage = localStorage.getItem("language");
    console.log(`this is the storagelanguage: ${storageLanguage}`);
    if (storageLanguage) {
      function setLanguageData() {
        setLanguage(storageLanguage);
      }
      setLanguageData();
    }
  }, [language]);

  return (
    <GlobalContext.Provider
      value={{
        language,
        setLanguage,
      }}
    >
      {props.children}
    </GlobalContext.Provider>
  );
}

A: Try updating your useEffect to following:
useEffect(() => {
    const storageLanguage = localStorage.getItem("language");
    console.log(`this is the storagelanguage: ${storageLanguage}`);
    if (storageLanguage) {
      function setLanguageData() {
        setLanguage(storageLanguage);
      }
      setLanguageData();
    }
  }, []); //Remove the language from here.

Adding [language] to the dependency array executes the useEffect each time language changes in the dropdown. This inturn set the value of the dropdown again.
Keep the dependency array empty in useEffect, lets useEffect execute only once, that solves the issue.

A: The answer provided above did not seem to resolve the issue to me (verified by going to the provided code sandbox and it still not working after making that change).
The issue is in the way that you are saving and parsing the value. You are JSON.stringifying the value when storing it, but you are not JSON.parseing it when retrieving it from localStorage. See this code sandbox for a solution: https://codesandbox.io/s/recursing-tree-7sn98k?file=/src/ContextWrapper.js
Alternatively, you could also not JSON.stringify the value when storing it, but considering that localStorage values must be strings (or will be .toString()'d otherwise) I do believe that the approach of stringifying the values on the way in is more fault-tolerant.


text:
Q: How to get URLs and tab Titles from Edge I have been doing some research and have found nothing current and of use. I am trying to create a program that can get all URLs and their Titles in the currently open tabs on edge. I am guessing this would have to be done using C#, in which I have no experience in. Could someone please create a program that would be able to do this please? I don't mind want language I would just want to have them all stored - preferable in JSON key-value pairs - or even just plain text is fine. can anyone help as I have no experience working with edge :)

A: If you need to get the url and title of all tabs in the current Edge, you can use the System.Windows.Automation api in C#.
Here is a simple demo:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Automation;
using System.Windows.Forms;

namespace ConsoleDemo
{
    class Program
    {
        [DllImport("User32.dll")]
        static extern int SetForegroundWindow(IntPtr point);

        [DllImport("User32")]
        private static extern int ShowWindow(int hwnd, int nCmdShow);

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool GetWindowPlacement(IntPtr hWnd, ref Windowplacement lpwndpl);

        private struct Windowplacement
        {
            public int length;
            public int flags;
            public int showCmd;
            public System.Drawing.Point ptMinPosition;
            public System.Drawing.Point ptMaxPosition;
            public System.Drawing.Rectangle rcNormalPosition;
        }

        public static List<string> GetAndChangeTabUrl()
        {
            Process[] procsEdge = System.Diagnostics.Process.GetProcessesByName("msedge");
            List<string> tabs = new List<string>();
            foreach (Process proc in procsEdge)
            {
                //string name = proc.ProcessName;
                Windowplacement placement = new Windowplacement();
                GetWindowPlacement(proc.MainWindowHandle, ref placement);

                // Check if window is minimized
                if (placement.showCmd == 2)
                {
                    //the window is hidden so we restore it
                    ShowWindow(proc.MainWindowHandle.ToInt32(), 9);
                }

                //Switch Edge tab to the first one
                SetForegroundWindow(proc.MainWindowHandle);
                SendKeys.SendWait("^1");

                if (proc.MainWindowHandle == IntPtr.Zero)
                    continue;

                string TabUrl = string.Empty;
                string TabTitle = string.Empty;
                AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);

                Condition condTabItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
                foreach (AutomationElement tabitem in root.FindAll(TreeScope.Subtree, condTabItem))
                {
                    var SearchBar = root.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar"));
                    TabUrl = (string)SearchBar.GetCurrentPropertyValue(ValuePatternIdentifiers.ValueProperty);
                    TabTitle = tabitem.Current.Name;
                    tabs.Add("URL: " + TabUrl + " ----Title: " + TabTitle);
                    SetForegroundWindow(proc.MainWindowHandle);
                    SendKeys.SendWait("^{TAB}"); // change focus to next tab
                }
            }
            return tabs;
        }

        static void Main(string[] args)
        {
            List<string> result = GetAndChangeTabUrl();
            foreach (var item in result)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
    }
}

And this is the result:


text:
Q: how to know if i should use redux for my application or any other alternative? I am new to react native and mobile development world.
I am developing a mobile application with react native, it's basically an entreprise management app for HR management, storage management, projects and tasks management, clients management, and it contains user authentification with different roles.
The backend and database are already developed.
What are my options to handle data and what are the difference between them ?
I did researches and i am wondering if i should use redux in this application or is there any other alternatives because apparently redux is very hard and i only have 2 months to finish the project

A: I can recommend mobx.
It uses dark magic and can be hard to debug, but it works well most of the time.
Redux is not hard. The concept is rather easy, but it requires too much boilerplate IMHO.

A: From: Mateusz Grzesiukiewicz Book "Hands-On Design Patterns with
React Native" :
Comparing Redux and MobX
This section is highly influenced by Preethi Kasireddy's talk at React Conf
2017. Please spend half an hour and watch it. You can find the talk
at https://www.youtube.com/watch?v=76FRrbY18Bs.

*

*Redux uses plain objects, while MobX wraps objects into Observables.
You may expect me to mention some magic again—no. The brutal truth is that
MobX comes at a cost. It needs to wrap observable data and add some weight to
each single object or each member of a collection. It is fairly easy to look up just
how much data: use console.log to see your observable collection.

*Redux manually tracks updates, whereas MobX automatically tracks updates.

*A Redux state is read-only and can be altered by dispatching an action, while a
MobX state can be altered at any time, sometimes only by using actions exposed
by your Store API. Also, in MobX, actions are not required. You can change state
directly.

*In Redux, a state is typically normalized, or at least this is recommended. In
MobX, your state is denormalized and computed values are nested.

*Stateless and stateful components: here it may seem difficult. Preethi Kasireddy,
in the lecture linked in the preceding information box, mentioned that MobX can
be used with smart components only. To some extent, this is true, but there is no
distinction here from Redux. Both support presentational components, as these
are completely decoupled from state management libraries!

*The learning curve—this is very subjective criteria. Some will find Redux easier,
others will find MobX easier. The popular belief is that MobX is easier to learn.
I'm an exception to this.

*Redux requires more boilerplate. Being more explicit, this is quite
straightforward, but there are libraries that fix this if you don't care. No
references will be provided here, as I recommend educated use.

*Redux is much easier to debug. This comes naturally with single flow and easy
replay of messages. This is where Redux shines. MobX is more old-school here, a
little harder to predict, and not so obvious, even to experienced users.

*Redux wins when it comes to scalability. MobX may pose some maintainability
problems, especially in big projects with a lot of connections and a big domain.

*MobX is concise and shines in small, time-constrained projects. If you go to a
hackathon, consider using MobX. In big, long-term projects, you would need a
more opinionated approach on top of the freedom that MobX gives.

*MobX follows the Flux architecture and does not alter it as much as Redux does.

*Redux leans towards one global store (although can be used with many!), while
MobX is quite flexible with the amount of stores and its examples usually
demonstrate similar thinking to the early ideas of Flux.
While using Redux, you need to learn how to deal with different situations and how to
structure things. When it comes to dealing with side effects especially, you will need to
learn Redux Thunk and possibly Redux Saga, which will be introduced in the following
chapter. In MobX, all of this is magically taken care of behind the scenes, using reactive
streams. In this respect, MobX is opinionated, but takes one responsibility away from you.
While using Redux, you need to learn how to deal with different situations and how to
structure things. When it comes to dealing with side effects especially, you will need to
learn Redux Thunk and possibly Redux Saga. In MobX, all of this is magically taken care of behind the scenes, using reactive
streams. In this respect, MobX is opinionated, but takes one responsibility away from you.
MobX is like system of roads for cars. You create a road map and let people drive. Some
will cause accidents, some will drive carefully. Some roads may be limited to one-way to
restrict traffic a little, or even shaped in a certain way to allow easier reasoning about the
car flow, as in Manhattan. Redux, on the other hand, is like a train. Only one train can move
on a track at a time. If there are a few at the same moment and something is holding up the
one in front, every other train waits behind, just like in a subway station. Sometimes trains
need to transfer people as far as the other side of a continent, and this is also possible. All of
this train flow is governed by one (distributed) agency that plans the movement and puts
restrictions on the train flow.

A: TL;DR You are alone and you have 2 months, go with what you know*.
*In rare cases described below go with Redux.
It very much depends on several points:
Expected live of the app
If you expect the app to be done in 2 months and to never ever look at it again, then Redux or basically any other architecture pattern/library will be mostly a drag, especially for your case as you are a single developer on this project (from what I understand). Architecture is an investment, and from the kind that does not pay back in 2 man/months, maybe in a few man/years.
As you are alone and the deadline is near I would advise you to just go with what you know*. From personal experience in a team of ~20 developers on >250K LOC codebase with very complex state management, we started to see the benefits >5 months after the initial introduction of Redux in the app.
*Except in the cases described below...
BE responses caching and depth of components
Redux solves response caching and props drilling problems (and others but these you might experience the most). In case you have to cache data from the BE while changing screens Redux can help there. As for boilerplate if you use RTK (Redux toolkit: https://redux-toolkit.js.org/) you will write a bit more than without Redux, for the same caching. If you will have a very deep component tree then Redux will simply remove the passing of props and callbacks down the tree, you will use selectors and actions instead which are not passed but just included in the component.
So if there is a big need for caching and/or there will be a lot of props drilling Redux might just pay off in that 2 months (not a high chance but maybe).
Complex state, Complex BE requests, complex error handling
By complex state, I mean something that has at least several states (ex: connected, disconnected, retrying, offline, permission problem, etc.) and non-trivial logic for transition between these states. For example you need to start some user interaction for permissions and the continue from where you left off.
By complex requests I mean at least several endpoints with retries required and maybe passing data from the response of one request to the input of the next. In this case, the state management will be hard and Redux might be a good solution for that. Also, error handling where you do not want to just show an error toast, but to retry on user request or similar might also be a point for Redux (I would not consider error handling alone as enough for going to Redux).


text:
Q: App thinning for custom assets I'm writing a game and i'd love to have multiple asset packages (these are .dat files) for different iOS devices (768p iPad, 1536p iPad, 640p iPhone, 750p iPhones, 1080p iPhones).
Is achievable via App Thinning feature ?
I know unity allows this somehow
https://blogs.unity3d.com/cn/2015/12/28/optimizing-ios-app-size-with-resource-slicing/
I'm using Xamarin, but if its achievable via some command line tools of XCode - thats okay.

A: Short answer is: No, resolution-based segmentation is impossible.
Seems that Apple doesn't allow direct by-resolution segmentation for generic data assets.
You can segment by memory, metal support and device type.
Textures extend this list with scale (1x, 2x, 3x)


text:
Q: How do I get Smartface App Studio? I'm trying to download Smartface App Studio on my PC. Can anyone provide me with an offline installer of Smartface App Studio?

A: Smartface not supporting desktop development anymore. You can develop your projects on Cloud IDE. www.smartface.io


text:
Q: Can't override styles using classes in material-ui I am having a hell of a time trying to understand how to change the styles for a one time use of TextField
The docs really don't make any sense to me
<FormControl>
  <InputLabel
    htmlFor="mobile-number-input"
  >
    Mobile Number
  </InputLabel>
  <Input
    value={this.state.mobileNumber}
    onChange={this.onMobileNumberChange}
    fullWidth
    classes={{
      inkbar: {
        '&:after': {
          backgroundColor: 'white',
        }
      }
    }}
    id="mobile-number-input"
  />
</FormControl><br />

But I get this error
Warning: Material-UI: the key `inkbar` provided to the classes property is not valid for Input.
You need to provide a non empty string instead of: [object Object].

A: You need to override inkbar with the name of another class, not a JSS object.
One way of doing this is to declare your JSS object outside of the component and use the withStyles higher-order component to provide your component with a classes prop that maps the class names defined in JSS to their actual names:
import { withStyles } from 'material-ui/styles';

const styles = {
  inkbarOverride: {
    '&:after': {
      backgroundColor: 'white',
    }
  }
};

const Test = ({ classes }) =>
  <FormControl>
    <InputLabel
      htmlFor="mobile-number-input"
    >
      Mobile Number
    </InputLabel>
    <Input
      value={this.state.mobileNumber}
      onChange={this.onMobileNumberChange}
      fullWidth
      classes={{
        inkbar: classes.inkbarOverride,
      }}
      id="mobile-number-input"
    />
  </FormControl>

export default withStyles(styles)(Test);

Refer to Overriding with classes for more information.


text:
Q: How do you choose an open-source license? I'm a software engineer, not a lawyer, and my university doesn't offer any courses geared toward licensing software. In fact, their law-related courses are lacking (but slowly growing in number). Where can I go to learn about open-source licenses and how to choose them?

A: If you are looking for information regarding free and open source licenses a useful comparison chart: http://en.wikipedia.org/wiki/Comparison_of_free_software_licences

A: You could always just use the best one of all, the WTFPL.  I use this on most of my school projects since they aren't that great anyways.

A: Wikipedia, of course, has basically all the information you would ever need to know. But the hard part is to know where to start. I'd recommend starting off by reading about the Apache License and the GNU GPL, which are two popular sides to the same story, each offering different freedoms to the people associated with the code.
But here it is in a nutshell: Apache License lets anyone do anything with your code, including taking it and using it in a closed source product. It gives whoever is taking the code the freedom to do what they want with it.
The GNU GPL, on the other hand, allows your code only to be used in a project that is also distributed under the GPL. In this case you might write some code and prevent a proprietary company from using your work. Here, you're giving freedom to the code itself that it will always be used for "free" purposes.

A: I'm slightly surprised to see no mention of the Open Source Initiative as a source of information about which open source licences exist.  It probably doesn't do the comparisons, so the other sites are also worth checking.

A: There are lots described here:
http://www.gnu.org/licenses/license-list.html#SoftwareLicenses
The decision of which one to use can be political, but should ultimately be determined by your plans/desires for the software. If you want to ensure it is always free then choose GPL or another "Copyleft" license.  If you don't mind some commercial use, choose another one that's compatible with that.

A: I almost always end up usign MIT or BSD (they're equivalent), since it

*

*Is the most liberal license out there. It just says you're not responsible for any kind of trouble, and optionally forces people to include a copyright notice of your original work in derivatives.

*It allows closed source derivatives, which is something I see as a good thing: companies sometimes don't have the possibility to do their work under the GPL (they may themselves use products or components from a third party with restricted licenses).

That, and the GNU/GPL bunch are generally extremists when you encounter them in the wild.

A: This can create endless discussion, but there is one tenet I would hold to whenever deciding what license to use:  DON'T CREATE A NEW ONE!!
No matter how persuasive your legal guy's arguments that, because no current license exactly meets your project's unique needs, you should write your own, or even just  "slightly modify" an existing one, treat him like a programmer coming to you arguing that he just HAS to use a GOTO statement because nothing else in the language will work.
Other advice:

*

*Choose one which has major usage (see http://freshmeat.net/stats/#license)

*See David A. Wheeler's discussion of why to choose a license compatible with the GPL - http://www.dwheeler.com/essays/gpl-compatible.html.

A: More pragmatic reasons can also influence your choice of license - if you want to use a GPL library, you must use GPL yourself, or if you intend your software to be part of a larger project then you need to look at their requirements.

A: I've recently begun investigating the type of licensing to apply to a rather substantial piece of work.  The number of choices and the content, restrictions (or not) and limitations of all the open-source licenses is bewildering.  I've found a couple good links in the answers posted, but I didn't see anything pointing to the Open Source Initiative's alphabetical list of licenses, so I've included it here.

A: We had a similar dilemma.  At our company we decided invest lots of time on a framework, with the eventual hope of releasing it to the open source community.  The business is built using open source tools (apache, php, etc.), it was time to give back.  We decided on an LGPL/MPL dual license.  That way, we could incorporate fixes/improvements from the community, while still protecting applications (particularly ours) running on top of it from being forced to go open source as well.


text:
Q: Confidence intervals for proportions by svypredmeans() I am trying to obtain the 95% CI for proportions which are actually predictive marginal means, as computed with the survey package for R. I'm including this reproducible example that makes no sense content-wise, but hopefully illustrates well my purpose:
library(survey)
data(api)
dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)

# 1.- marginal means for groups according to a variable
svyglm(I(sch.wide=="Yes") ~ awards+comp.imp, design=dstrat, family=quasipoisson()) %>% svypredmeans(., ~yr.rnd)

# 2.- the confidence intervals I'd like to compute by svyciprop(), in an obviously wrong way
svyby(I(sch.wide=="Yes") ~ awards+comp.imp, ~yr.rnd, design=dstrat, svyciprop, vartype="ci", method="xlogit")

What I can't figure out is how to enter the right arguments into svyciprop(), or if this is even possible. The function svyciprop() takes a single formula, and this does not seem compatible with the way compute predictive marginal means are computed, nor with the output of svypredmeans().
Thanks beforehand for any help!
EDIT Apologies because the code was right, but there was a typo. However, there's a follow-up question: the estimates for the predictive marginal means in step 1 will not match the same estimates in step 2. Can someone shed light on why these differences?

A: Your code does not work for a very simple reason: R is case-sensitive. Change sch.wide=="yes" to sch.wide=="Yes" and it should work.


text:
Q: In TikZ, is it possible to isolate every character of an expression in a node as its own node? I often find myself typing equations into a node of a tikz picture. I then often find that I want to isolate certain characters in the equation and define them as a node.
For instance, consider the following figure.
\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node {$e^{i\pi}+1=0$};
\end{tikzpicture}
\end{document}

I'd like it if in this figure I could define each character e, i, pi, +, 1, =, and 0 as its own node. Is this possible?

A: The \subnode command from tikzmark is designed for this sort of situation.  It fakes a node around text that's inside a \node.  It does need a few compilation runs to settle (it took 3 for this code for me) and you must remember the remember picture key on the tikzpicture.
\documentclass{article}
%\url{https://tex.stackexchange.com/q/582127/86}

\usepackage{tikz}
\usetikzlibrary{tikzmark, arrows.meta}

\begin{document}
\begin{tikzpicture}[>=Latex,remember picture]
  \node (eipi) at (0,0) {\(e^{i\pi}+1=0\)};
\node at (0,-1) {\(\subnode{e}{e}^{\subnode{i}{i}\subnode{pi}{\pi}}+\subnode{one}{1}=\subnode{zero}{0}\)};
\draw[<-] (e) to[out=-90, in=90] ++(-2,-1) node[below] {Base of natural logarithm};
\draw[<-] (i) to[out=135, in=0] ++(-2,1) node[left] {A square root of \(-1\)};
  \draw[<-] (pi) -- ++(0,-2) node[below] {Area of a unit circle};
  \draw[<-] (one) to[out=-45, in=180] ++(2,-1) node[right] {Unity};
\draw[<-] (zero) -- ++(2,0) node[right] {Zilch};
\draw[<-] (eipi) -- ++(0,1) node[above] {An ugly equation};
\end{tikzpicture}
\end{document}


text:
Q: Power factor correction for LED lighting on a generator I'm the electrician for a club that builds an illuminated carnival parade float, and historically we've lit our float using around 10,000 x 40w incandesant lamps powered by a 800kVA 3 phase generator.
Times are changing, and you can no longer buy 40w incandesant lamps easily anymore, and the cost of diesel and generator hire is expensive, so I want to look at using LED lamps instead.
Due to cost, it's really only viable for me to buy very cheap LED B22 lamps from China, with a basic built-in power supply with a poor power factor.
Wiring up a purely resistive system was easy, but I'm struggling to understand and research how to do this correctly without causing a high current in the neutral.
To balance the system, I've heard that I need to either add a resistive dummy load to each phase, or use a power factor correction capacitor, but I don't know how to calculate the size/rating of these.
Can anyone point me in the right direction or explain how to do this?

A: A LED itself is resitance load, while the problem is the rectifier and step down circuit. The cheapest LED lamps use a series capacitor that uses its reactance to increase overall impedance, which means that such lamp will have a cap. phase lag not the inductive as motors or lamps with ballasts.
http://www.ebay.com/gds/LED-Lamps-using-5050-LED-chips-/10000000177064387/g.html
Or the LED lamp can have a small SMPS inside with a transformer, in this situation you will get more a harmonic distortion rather than phase lagging. You should buy one of these first, then see with power meter.
Lastly, LED lamps consume less power than incandescent lamps, so you will have extra current reserve for feeding also the reactive power.
IMO you don't need nothing at all, perhaps a choke or sinusfilter.

A: I found a study that showed various brands of LED bulbs rated 3 to 8 watts with power factors ranging from .48 to .79. If you can find 8 watt LED bulbs with .5 power factor that give equivalent light as your 40 watt incandescents, you would need 16 VA per bulb vs 40 for the incandescents. If you distribute the bulbs equally among the phases, you should not have any difficulty with the neutral currents. You should still have some concern about extra heating in the generator due to harmonics. It is difficult to determine how much the generator should be oversized for harmonics. The generator manufacturer may have a recommendation.
A harmonic filter would both reduce the harmonics and increase the power factor. I don't believe that you should purchase a 3-phase choke and harmonic filter separately. You should be able to get the most effective filter if it is purchased as a package.
Estimating Harmonic Distortion
For estimation purposes, it can be assumed that the power factor of the fundamental current of an LED bulb is 1.0. It can also be assumed that the source voltage is not significantly distorted. Total power factor = Watts / (Voltage X Total RMS current). Total or "true" RMS current is the RMS value of the distorted current waveform. It calculated as the square root of the sum of the squares of the fundamental current plus each of the harmonic currents. You can break that down as Irms = (If^2 + Ih^2)^.5 where If is the fundamental current and Ih is the square root of the sum of the squares of the individual harmonics.
If the voltage, total RMS current and power is known for an LED bulb, the harmonic current and total harmonic current distortion can be calculated as follows:
Only the fundamental current (If) produces power (W). W = V X If X pf. Assuming pf for the fundamental = 1, If = W / V
From Irms = (If^2 + Ih^2)^.5, Ih = (Irms^2 – If^2)^.5
Total harmonic current distortion, THDi = (Ih^2 / If^2)^.5 = Ih / If
The total RMS current and power may be marked on the bulb. If it is not marked it can be measured with an inexpensive power meter like a Kill-A-Watt.
Here is a link to the study mentioned above.

A: We are having the same issues with the harmonics. I calculated total load of 170 kva last year at the start of the year, we had 17,000 lamps on board we pulled 110 kva total  on circuit. it wasn't pushing the generator at all as we had a 250kva set.
The only way I managed to improve power factor was by using motors and variable load heater  which I ran constantly and I left it on when I started the set every time. I based the 3w led at 0.4 pf. The set readings came out 0.85pf.
We found as led are linear loads as well as flourescents, we need non linear loads such as heaters and motors to balance this. But also balancing the phase current as best possible helps. We also used par cans to balance the phases as they only produce resistive loads this way you can protect the generator.

A: You could make it a 1000 bulb, 24 volt DC system, using 4ea 6vdc golf cart batteries wired in series. This would feed 10 branch circuits of 16.7amps with 20amp circuit breakers. Each branch circuit would power 100ea 4watt 500lumen 24vdc LED bulbs, for a total load of 24vdc, 167 amps, 4kW, and a run time of 1 hour.
Make 10ea of these circuits for 10,000 bulbs total. No noisy, smelly generator required. No power factor correction. Just 40kW smooth DC providing the LED equivalent light of 10,000 40watt incandescent bulbs.
Here is one such bulb:

Example product and original source for bulb image above:
4W E26/E27 LED Globe Bulbs G60 27 SMD 5730 500lm Warm White 3000~3500K DC 12 AC 12 AC 24 DC 24V 1pc


text:
Q: Laravel Ajax runs in 500 Internal Server Error although Token is created I made an very simple Ajax in Laravel. I wanted to replace a message in the view after clicking on a button with a message that comes from the controller.
I get an 500 Internal Server Error, i searched and saw that token is often the reason for the error. I added one, but it is still not working. Anyone who had the problem before?

The Message that should be replaced and Button:

This message will be replaced using Ajax.
                Click the button to replace the message.

            <button class="AjaxButton" onclick="getMessage()">Nachricht message</button>

The Controller:
public function ajax(Request $request){
    console.log ('controller');
    $msg = "This is a simple message.";
    return response()->json('msg'->$msg);
}

The Route:
Route::post('/home/ajax','crudController@ajax');

A: laravel comes with axios. axios already include csrf_token in ajax method..
axios.post("{{ route('your_route') }}")
.then(function (response) {
    $("#msg").html(response.data.msg);
})
.catch(function (error) {
    console.log(error);
});

edit
axios.post({{ route ('') }}, {
    firstName: 'Fred',
    lastName: 'Flintstone',
    address : 'Address example'
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});

A: console.log does not exist in PHP.
Remove it and it should work.
Open your .env file and change APP_DEBUG to true (APP_DEBUG=true)
To see more details about the errors.
https://laravel.com/docs/5.5/errors

Also try to change your ajax request to this:
    $.ajax({
        type:'POST',
        url:'/home/ajax',
        data: '_token = <?php echo csrf_token() ?>',
        success: function(response){
            $("#msg").html(response.msg);
        }
    });

And in your Controller change your ajax function to this:
public function ajax(Request $request)
{
    $msg = "This is a simple message.";
    return response()->json(array('msg'=> $msg), 200);
}

There is something wrong with your Laravel setup, normally you should see an error message like this:


text:
Q: Split string column to create new binary columns My data has one column and I am trying to create additional columns with what's after each "/" in the rows. Here are the first few rows of the data:
> dput(mydata)
structure(list(ALL = structure(c(1L, 4L, 4L, 3L, 2L), .Label = c("/
ca/put/sent_1/fe.gr/eq2_on/eq2_off",
"/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL", "/ca/put/sent_1/fe.g
r/eq2_on/eq2_off/cni_at.p3x.4",
"/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov"), class = "factor
")), .Names = "ALL", class = "data.frame", row.names = c(NA,
-5L))

The result should look like this (data frame) with a "1" in the new column if the variable appears in the row and "0" if not:
> dput(Result)
structure(list(ALL = structure(c(1L, 4L, 5L, 3L, 2L), .Label = c("/ca
/put/sent_1/fe.gr/eq2_on/eq2_off",
"/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL", "/ca/put/sent_1/fe.gr/
eq2_on/eq2_off/cni_at.p3x.4",
"/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov", "/ca/put/sent_1fe.
gr/eq2_on/eq2_off/hi.on/hi.ov"
), class = "factor"), ca = c(1L, 1L, 1L, 1L, 1L), put = c(1L,
1L, 1L, 1L, 1L), sent_1 = c(1L, 1L, 1L, 1L, 1L), fe.gr = c(1L,
1L, 1L, 1L, 1L), eq2_on = c(1L, 1L, 1L, 1L, 1L), eq2_off = c(1L,
1L, 1L, 1L, 1L), hi.on = c(0L, 1L, 1L, 0L, 0L), hi.ov = c(0L,
1L, 1L, 0L, 0L), cni_at.p3x.4 = c(0L, 0L, 0L, 1L, 0L), cbr_LBL = c(0L
,
0L, 0L, 0L, 1L)), .Names = c("ALL", "ca", "put", "sent_1", "fe.gr",
"eq2_on", "eq2_off", "hi.on", "hi.ov", "cni_at.p3x.4", "cbr_LBL"
), class = "data.frame", row.names = c(NA, -5L))

I have tried many functions including strsplit and sapply:
sapply(strsplit(as.character(mydata$ALL), "\\/"), "[[", 2) #returns "ca"s only

sapply(strsplit(as.character(mydata$ALL), "\\/"), "[[", 3) #returns "put"s only

There are millions of rows and I'd greatly appreciate anything that is quick and efficient.

A: Using mtabuate from the qdapTools package that I maintain:
library(qdapTools)
mtabulate(strsplit(as.character(dat[[1]]), "/"))

##   V1 ca cbr_LBL cni_at.p3x.4 eq2_off eq2_on fe.gr hi.on hi.ov put sent_1 sent_1fe.gr
## 1  1  1       0            0       1      1     1     0     0   1      1           0
## 2  1  1       0            0       1      1     1     1     1   1      1           0
## 3  1  1       0            0       1      1     0     1     1   1      0           1
## 4  1  1       0            1       1      1     1     0     0   1      1           0
## 5  1  1       1            0       1      1     1     0     0   1      1           0

A: You can use cSplit_e from my "splitstackshape" package:
library(splitstackshape)
cSplit_e(mydata, "ALL", "/", type = "character", fill = 0)
#                                                ALL ALL_ca ALL_cbr_LBL
# 1              /ca/put/sent_1/fe.gr/eq2_on/eq2_off      1           0
# 2  /ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov      1           0
# 3   /ca/put/sent_1fe.gr/eq2_on/eq2_off/hi.on/hi.ov      1           0
# 4 /ca/put/sent_1/fe.gr/eq2_on/eq2_off/cni_at.p3x.4      1           0
# 5      /ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL      1           1
#   ALL_cni_at.p3x.4 ALL_eq2_off ALL_eq2_on ALL_fe.gr ALL_hi.on ALL_hi.ov ALL_put
# 1                0           1          1         1         0         0       1
# 2                0           1          1         1         1         1       1
# 3                0           1          1         0         1         1       1
# 4                1           1          1         1         0         0       1
# 5                0           1          1         1         0         0       1
#   ALL_sent_1 ALL_sent_1fe.gr
# 1          1               0
# 2          1               0
# 3          0               1
# 4          1               0
# 5          1               0

(Note: I think there's a problem in row 3 of your dput which is why it doesn't match your desired output. Notice that the third item in row 3 is "sent_1fe.gr" with no "/" between them.)

A: How about something like this
spt <- strsplit(as.character(mydata$ALL),"/", fixed=T)
do.call(rbind, lapply(lapply(spt, factor, levels=unique(unlist(spt))), table))

which returns
       ca put sent_1 fe.gr eq2_on eq2_off hi.on hi.ov sent_1fe.gr cni_at.p3x.4 cbr_LBL
[1,] 1  1   1      1     1      1       1     0     0           0            0       0
[2,] 1  1   1      1     1      1       1     1     1           0            0       0
[3,] 1  1   1      1     0      1       1     1     1           1            0       0
[4,] 1  1   1      1     1      1       1     0     0           0            1       0
[5,] 1  1   1      1     1      1       1     0     0           0            0       1

A: Other option is to melt the split string in list to long form and then use table
library(reshape2)
as.data.frame.matrix(table(melt(strsplit(as.character(
                                   mydata[[1]]), "/"))[2:1]))[,-1]
#    ca eq2_off eq2_on fe.gr put sent_1 hi.on hi.ov sent_1fe.gr cni_at.p3x.4
#1  1       1      1     1   1      1     0     0           0            0
#2  1       1      1     1   1      1     1     1           0            0
#3  1       1      1     0   1      0     1     1           1            0
#4  1       1      1     1   1      1     0     0           0            1
#5  1       1      1     1   1      1     0     0           0            0
#  cbr_LBL
#1       0
#2       0
#3       0
#4       0
#5       1

A: a tidyverse solution
library(tidyverse)

mydata %>%
  rownames_to_column() %>%
  mutate(key = strsplit(levels(ALL)[ALL],"/"),value=1) %>%
  unnest %>%
  spread(key,value,0) %>%
  select(-rowname)

#   ALL   ca cbr_LBL cni_at.p3x.4 eq2_off eq2_on fe.gr hi.on hi.ov put sent_1
# 1   1 1  1       0            0       1      1     1     0     0   1      1
# 2   4 1  1       0            0       1      1     1     1     1   1      1
# 3   4 1  1       0            0       1      1     1     1     1   1      1
# 4   3 1  1       0            1       1      1     1     0     0   1      1
# 5   2 1  1       1            0       1      1     1     0     0   1      1

data
mydata <- structure(list(ALL = structure(c(1L, 4L, 4L, 3L, 2L), .Label = c(
  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off",
  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL",
  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cni_at.p3x.4",
  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov"), class = "factor
  ")), .Names = "ALL", class = "data.frame", row.names = c(NA,-5L))

A: Having myself similar, but more complex, problem I figured the following functional way that allows to cast in 'one hot' way string seperated character values of a column/s individually as well as categorical variables itself:
oneHotOnText <- function(datatable, columns, seperator=", "){ #argument columns is  character vector or numeric vector
  if(! "data.table" %in% .packages()) if(!require(data.table)) { install.packages("data.table"); library(data.table) }
  if(! "data.table" %in% class(datatable)) TempDT <- as.data.table(datatable) else TempDT <- copy(datatable)
  for(i in TempDT[, columns, with = F]){
    if(class(i) != "character") i <- as.character(i)
    uniqueValues <- unique(unlist(strsplit(unique(i), split=seperator)))
    if(any(uniqueValues %in% names(TempDT))) { print("Value/s of the selected column/s is/are present as variables name/s. Rename it/them.")
                                             rm(TempDT)
                                             break }
    for(j in uniqueValues) TempDT[, (j) := ifelse(grepl(j, i), 1L, 0L)]
  }
  if(exists("TempDT")) return(TempDT)
}

DF = data.frame(
  aColumn=rep(c("f", "b", "c"), 100000),
  xColumn=rep(c("N/W", "W", "R"), 100000),
  yColumn=rep(c("A/B", "A/V", "B/G"), 100000),
  zColumn=rep(20:22, 100000))

str(DF) #factors are present in the data.frame

oneHotOnText(DF, columns = c("aColumn", "xColumn", "yColumn"), seperator="/")[] #applies the function, returns a data.table and prints the result

#        aColumn xColumn yColumn zColumn f b c N W R A B V G
#     1:       f     N/W     A/B      20 1 0 0 1 1 0 1 1 0 0
#     2:       b       W     A/V      21 0 1 0 0 1 0 1 0 1 0
#     3:       c       R     B/G      22 0 0 1 0 0 1 0 1 0 1
#     4:       f     N/W     A/B      20 1 0 0 1 1 0 1 1 0 0
#     5:       b       W     A/V      21 0 1 0 0 1 0 1 0 1 0
#    ---
#299996:       b       W     A/V      21 0 1 0 0 1 0 1 0 1 0
#299997:       c       R     B/G      22 0 0 1 0 0 1 0 1 0 1
#299998:       f     N/W     A/B      20 1 0 0 1 1 0 1 1 0 0
#299999:       b       W     A/V      21 0 1 0 0 1 0 1 0 1 0
#300000:       c       R     B/G      22 0 0 1 0 0 1 0 1 0 1

Similarly it applies to the OP´s problem:
input <- data.frame(ALL = c("/ca/put/sent_1/fe.gr/eq2_on/eq2_off",
                            "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov",
                            "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov",
                            "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cni_at.p3x.4",
                            "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL"
                            ))

oneHotOnText(input, columns = "ALL", seperator = "/")[]

A: Here's a solution that uses dplyr and tidyr (note: I cleaned up what appears to be
an missing / in row three of your sample data):
## Input

input <- structure(
  list(ALL = structure(c(1L, 4L, 5L, 3L, 2L),
       .Label = c("/ca/put/sent_1/fe.gr/eq2_on/eq2_off",
                  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cbr_LBL",
                  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/cni_at.p3x.4",
                  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov",
                  "/ca/put/sent_1/fe.gr/eq2_on/eq2_off/hi.on/hi.ov"),
       class = "factor")),
  .Names = "ALL", class = "data.frame", row.names = c(NA, -5L))

## Solution

require(dplyr)
require(tidyr)
solution <- input  %>%
  mutate(temp = sub("^/", "", ALL)) %>%
  separate(temp,
           c("ca", "put", "sent_1", "fe.gr", "eq2_on", "eq2_off",
             "hi.on", "hi.ov", "cni_at.p3x.4", "cbr_LBL"),
           "/", extra="merge") %>%
  mutate_each(funs(as.numeric(!is.na(.))), -ALL)

A: here is one more tidyverse solution
library(tidyverse)

nn <- max(str_count(df$ALL, "/"), na.rm = T)+1

df %>% mutate(row_id =row_number()) %>%
  select(row_id, everything()) %>%
  separate(ALL, into = paste("tag", 1:nn), sep = "/") %>%
  pivot_longer(cols = paste("tag", 2:nn), names_to = "name", values_to = "val") %>%
  filter(!is.na(val)) %>%
  select(-`tag 1`) %>%
  mutate(new=1) %>%
  #group_by(row_id) %>%
  pivot_wider(id_cols = row_id, names_from = val, values_from = new, values_fill =0)

# A tibble: 5 x 11
  row_id    ca   put sent_1 fe.gr eq2_on eq2_off hi.on hi.ov cni_at.p3x.4
   <int> <dbl> <dbl>  <dbl> <dbl>  <dbl>   <dbl> <dbl> <dbl>        <dbl>
1      1     1     1      1     1      1       1     0     0            0
2      2     1     1      1     1      1       1     1     1            0
3      3     1     1      1     1      1       1     1     1            0
4      4     1     1      1     1      1       1     0     0            1
5      5     1     1      1     1      1       1     0     0            0
# ... with 1 more variable: cbr_LBL <dbl>

A: For multiple columns with commas separate multi-items hot encoding:
library(qdapTools)

#hot-encoding
mtabulate(apply(dataset[3451:3457], 1, function(x) strsplit(x, ",")))

cbind(dataset, mtabulate(strsplit(mydf$Info, ", ")))

A: library(fastDummies)

dummy_cols(df, "ALL", split = "/")


text:
Q: Bar3 plot increase bar thickness I am trying to plot the stacked bar3 plot. How to increases the thickness of the bars? All the bars look flat. I need something like this with thick bars stacked next to each other.

What I got was:

Below is the code and I have also attached the dependency file link Data. Please let me know a solution.
clc; close all; clear;

Z1 = randi([10,500],100,3);
Z2 = randi([10,900],200,3);

class_string = {'Dataset I', 'Dataset II'};

% Plot 3D graph
hFig = figure;
h = bar3(Z1(:, 1), Z1(:, 2:end),'stacked');
hold on;
for j=1:length(h)
  set(h(j),'xdata',get(h(j),'xdata')+2-1);
end
h2 = bar3(Z2(:, 1), Z2(:, 2:end),'stacked');

set(gca, 'PlotBoxAspectRatioMode','auto')
set(gca, 'XTickLabel',class_string, 'XTick', 1:2, 'FontSize', 20, 'LineWidth', 3) %, ...
ylabel ('Image resolution (kilo pixels)')
zlabel ('No.of images')
legend ('High Texture','Low Texture','Location','NorthEast');
hold off
axis tight;


text:
Q: MYSQL Query : How to UNION two table with ORDER BY can anyone help me solve this problem? i've been trying to query this but i keep getting error.
MySQL code:
SELECT * FROM
(

 SELECT BU.*, BD.BOOK_TITLE AS BOOK_TITLE, BD.BOOK_COMPANY AS COMPANY,
     BD.RETURN_DATE AS RETURN
 FROM BOOK_USER BU
 INNER JOIN BOOKING_DETAIL BD ON (BU.USR_ID = BD.USR_ID)

UNION

 SELECT BU.*, "NEW REGISTERED" AS BOOK TITLE, 'RENT-A-BOOK' AS COMPANY,
     BU.REGISTER_DATE AS RETURN
 FROM BOOK_USER BU

) AS BU
GROUP BY BU.USR_ID

The Tables:
BOOK_USER
+---------+----------+---------------+
| USR_ID  | USR_NAME | REGISTER_DATE |
+---------+----------+---------------+
| 1       | john     | 2011-09-20    |
+---------+----------+--------------+
| 2       | jane     | 2011-12-05    |
+---------+----------+--------------+
| 3       | doe      | 2012-02-16    |
+---------+----------+--------------+
| 4       | mary      | 2012-02-02  |
+---------+----------+--------------+

BOOKING_DETAIL
+---------+----------+------------+-----------+--------------+
| BOOK_ID  | USR_ID |  BOOK_TITLE | COMPANY   | RETURN_DATE  |
+----------+--------+-------------+-----------+--------------+
| 1       | 1       | DEAR JOHN   |ABC PVT LMT| 2011-11-01   |
+---------+---------+-------------+-----------+--------------|
| 2       | 1       | LUCKY       |  DEF      | 2012-03-18   |
+---------+---------+-------------+-----------+--------------|
| 3       | 1       | THE RISE    | GHI       | 2012-06-12   |
+---------+---------+-------------+-----------+--------------|
| 4       | 2       | HELLO       |    TIMES  | 2012-01-11   |
+---------+---------+-------------+-----------+--------------|
| 5       | 2       | SHOPAHOLIC  |           | 2012-08-31   |
+---------+---------+-------------+-----------+--------------|
| 6       | 3       | LOST        |           | 2012-06-20   |
+---------+---------+-------------+-----------+--------------|

The result should return the latest RETURN_DATE and SORTED by USR_ID.
eg:

*

*John, THE RISE, GHI,2012-06-12

*Jane,SHOPAHOLIC,RENT-A-BOOK,2012-08-31

*doe, LOST,RENT-A-BOOK,2012-06-20

*mary, NEW REGISTERED,RENT-A-BOOK , 2012-02-02

A: The query constains a subquery which gets the latest RETURN_DATE for each user.
SELECT  a.*, c.BOOK_TITLE, c.RETURN_DATE
FROM    book_user a
        INNER JOIN
        (
            SELECT usr_ID, MAX(return_DATE) maxDate
            FROM booking_detail
            GROUP BY usr_ID
        ) b ON  a.usr_ID = b.usr_ID
        INNER JOIN booking_detail c
            ON  b.usr_ID = c.usr_ID AND
                b.maxDate = c.return_DATE

*

*SQLFiddle Demo
UPDATE
use LEFT JOIN and COALESCE
SELECT  a.USR_ID,
        a.USR_NAME,
        COALESCE(c.BOOK_TITLE,'RENT-A-BOOK') BOOK_TITLE,
        COALESCE(c.RETURN_DATE, a.REGISTER_DATE) RETURN_DATE
FROM    book_user a
        LEFT JOIN
        (
            SELECT usr_ID, MAX(return_DATE) maxDate
            FROM booking_detail
            GROUP BY usr_ID
        ) b ON  a.usr_ID = b.usr_ID
        LEFT JOIN booking_detail c
            ON  b.usr_ID = c.usr_ID AND
                b.maxDate = c.return_DATE

*

*SQLFiddle Demo

A: Try that :
SELECT *
FROM (
    (
        SELECT BU.*, BD.BOOK_TITLE, BD.BOOK_COMPANY AS COMPANY,BD.RETURN_DATE AS RETURN FROM BOOK_USER BU INNER JOIN BOOKING_DETAIL BD ON (BU.USR_ID = BD.USR_ID)
    ) UNION ALL (
        SELECT BU.*, BD.BOOK_TITLE, 'RENT-A-BOOK' AS COMPANY,BD.RETURN_DATE AS RETURN FROM BOOK_USER BU INNER JOIN BOOKING_DETAIL BD ON (BU.USR_ID = BD.USR_ID)
    )
) BU
GROUP BY BU.USR_ID

A: You can directly get the output using following query check the query:
SELECT BU.*, IFNULL(BD.BOOK_TITLE, 'NEW REGISTERED') AS BOOK_TITLE, IFNULL(BD.BOOK_COMPANY, 'RENT-A-BOOK') AS COMPANY,BD.RETURN_DATE AS RETURN
FROM BOOK_USER BU
LEFT JOIN (SELECT * FROM (SELECT USR_ID, BOOK_TITLE, BOOK_COMPANY, RETURN_DATE FROM BOOKING_DETAIL ORDER BY RETURN_DATE DESC) AS A GROUP BY USR_ID) AS BD ON (BU.USR_ID = BD.USR_ID)
ORDER BY BU.USR_ID;


text:
Q: Right click on the touch screen doesn't work On the device is installed through MinimalCD only linux-generic kernel, and some restricted modules, following the steps from Installation/LowMemorySystems with Fluxbox window manager the only installed environment.
The right click and the mouse for the touch screen are working normally.
Tell me please is there any way to enable right click on the touch screen?
Best regards.

A: Easystroke allows gesture-based actions. You can configure it so when you, say, draw a circle, it right-clicks. I find it to work well.
To install it, go to Ubuntu Software and type 'easystroke' into the search bar. You can install it from there.

A: It seems the Linux Kernel after 4.8.6 has nice touch integration added for touchscreens. Of course, your hardware is probably different from the three types mentioned in this answer. I recently booted the Nov. 20 release of Antergos on my Dell Inspiron i5378-2885GRY 13.3" FHD 2-in-1 Laptop. There were a lot of features available that were not there with the 4.4 kernel in 16.04. On the kernel version of the Antergos live USB (It was above 4.8.6. Not sure exactly which version it was.), onscreen scrolling works, zoom in/out works, right clicking, and probably other features I am not aware of yet. When I booted the 16.10 iso with the 4.8.0 kernel more features were available compared to a 16.04 kernel version. It seems the 4.8.0 kernel added support for the Surface 3.  However, using the 4.8.6+ kernel has added the most functionality for me.
How to get the latest kernel is beyond the scope of this answer. You can try installing the 16.10 kernel (probably with partially better results). You could compile the kernel from source. You could use Arch or an Arch based distribution. I however, will plan to install Debian testing Gnome on the new laptop.


text:
Q: Overleaf's autocompile keeps turning off I'm using Overleaf and Mozilla Firefox. I usually leave the autocompile on as I type. However, as I type, Overleaf disables autocompile, the compiled PDF on the viewing pane disappears and is replaced with the message

Sorry, something went wrong and your project could not be compiled.
Please try again in a few moments.

I have to then manually turn on autocompile again. Is there any way to stop this from happening as it happens every few minutes.
Other points:

*

*I'm using a free account.

*The project is not shared and I do not have multiple machines/tabs with Overleaf open.

A: Is your code very heavy and does it contain a lot of images/graphics? In Overleaf you only have one minute to compile for free accounts.
Sometimes when you use TikZ and you are missing ";" it tends to take a long time to compile and after the minute it throws the message you mention.


text:
Q: Highcharts: basic column chart not showing correct color Below is my code to display basic column chart.
$(function () {
 Highcharts.setOptions({
colors: ['#f89422','#8cc641']

});
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Monthly Average Rainfall'
        },
        subtitle: {
            text: 'Source: WorldClimate.com'
        },
        xAxis: {
            categories: [
                'Jan',
                'Feb'
                               ]
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Rainfall (mm)'
            }
        },
        tooltip: {
            headerFormat: '{point.key}
',
            pointFormat: '
{series.name}: 	' +
                '{point.y:.1f} mm
',
            footerFormat: '
',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            colorbypoint: true,
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: [{
            name: 'Tokyo',
            data: [49.9, 71.5]

        }]
    });
});

Though I have given 2 colors in the set options, and colorBypoint: true in plotOptions,
It is showing the same color. Orange.
Any idea? Please refer this fiddle - http://jsfiddle.net/88YSd/

A: The points are showing the same color as they are in the same series.
You can specify indivual point colors like this:
 data: [{y:49.9,color:'#f89422'}, {y:71.5,color:'#8cc641'}]

http://jsfiddle.net/Zhmw2/
An alternative would be to put the two points in separate series
 series: [{
            name: 'Jan',
            data: [49.9]

        },{
            name: 'Feb',
            data: [71.5]

        }

http://jsfiddle.net/H5KmK/


text:
Q: Using a code for an exception. Useful? I am not sure if Exceptions work the same way in each language, but I am using PHP and I was wondering when I'm doing something like this:
if (!$this->connection[0]->query($this->query))
 throw new QueryFailedException($this->connection[0]->error);

Is there a need to supply a code in the second parameter? For example:
if (!$this->connection[0]->query($this->query))
 throw new QueryFailedException($this->connection[0]->error,123);

Now the code is 123... I can't think of a need for this. Is there one? In this case the message contains the query, exception name is QueryFailedException which explains the exception type, the exception itself contains file, line and stack trace, so, I can't think of anything where you could use the code for something useful.

A: If you have an "error source" that works on error codes and you "promote" it to exceptions you can include the actual error code in the exception. a) it does no harm and b) maybe you do not want to have an exception class for each single error code that may or may not occur (and virtually no one cares for in a running system).
Let's take the MySQL server errors as an example. You could create one class for each of those codes
class MySQLException_ER_HASHCHK extends MySQLException
class MySQLException_ER_NISAMCHK extends MySQLException
class MySQLException_ER_NO extends MySQLException
class MySQLException_ER_YES extends MySQLException
class MySQLException_ER_CANT_CREATE_FILE extends MySQLException
class MySQLException_ER_CANT_CREATE_TABLE extends MySQLException
class MySQLException_ER_CANT_CREATE_DB extends MySQLException
class MySQLException_ER_DB_CREATE_EXISTS extends MySQLException
class MySQLException_ER_DB_DROP_EXISTS extends MySQLException
....

but in reality ...who cares? Who's really gonna catch them individually? In almost all cases there will only be a catch(MySQLException $mex) in the app's code and maybe, just maybe it's looking for one specific code where it makes little to no difference for the coder whether there are two catch-blocks or an if/switch block. Now you have a lot of "dead" classes and no one -except the parser- gives a damn about them. (on the other hand "everything worth doing is worth overdoing it")
And even if you do provide some granularity I think it makes little sense to go beyond e.g. having one exception class for each SQLState (does that make sense? sqlstate? don't know, just an example)
class MySQLException_HY000 extends MySQLException
class MySQLException_HY001 extends MySQLException
class MySQLException_XA100 extends MySQLException
class MySQLException_XA102 extends MySQLException

And then again you probably want to include the error code - why lose this information even though/even if your code usually doesn't evaluate it?

A: The error code was a feature used when there was no object oriented language. The only thing that could aid you to understand what went wrong was the error code. In an object oriented language, the object IS your error code.
Unless, in specific cases, more than one thing can throw the exact same error AND they are treated in different ways, drop it.
Also, you would provide much better explanation to whomever is debugging your code if you left a message instead of a meaningless error code, so if you feel like the exception needs more information, fill the Error Message field instead.

A: The error code is a field that can be used to provide more detailed information.  If for example you have two things that can generate the same exception, the code could be used to give more detail.

A: If you can, it is very good to set in an exception code.
That is if you don't change your code to throw different exceptions based on the data you get from your database.
The error code, in OOP is the Exception Class Name itself, so that you can interpret each of them in just one try but with multiple catch clauses.
try {
  // code here
} catch (AccessDeniedException $e) {
 // do something
} catch (Exception $e) {
  // do something else
}


text:
Q: com.sun.deploy.net.jarsigningexception could not verify signing in resource: xalan.jar, 2.7.1 Our JNLP client application contains different JAR's. We sign all these JAR's at build-process. Now, we have one Jar which can not be verified, but only under Windows! (xalan-2.7.1.jar)
If we run the JNLP under windows, we get this exception:
com.sun.deploy.net.JARSigningException: could not verify signing in resource: (http://localhost:8080/server-1.3.11-SNAPSHOT/webstart/xalan.jar, 2.7.1)
    at com.sun.deploy.cache.CacheEntry.writeManifest(Unknown Source)
    at com.sun.deploy.cache.CacheEntry.access$2000(Unknown Source)
    at com.sun.deploy.cache.CacheEntry$9.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.cache.CacheEntry.writeFileToDisk(Unknown Source)
    at com.sun.deploy.cache.Cache.downloadResourceToTempFile(Unknown Source)
    at com.sun.deploy.cache.Cache.downloadResourceToCache(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
    at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Under Linux und Mac it runs perfectly.
I also signed and verified the xalan.jar manually over the jarsigner.exe. Output: "jar verified"
What can be the problem?


text:
Q: Don't include 'Line #' after searching for specific lines in Notepad++ If I search for a specific word in Notepad++ using "Find All in Current Document", the results include "Line #". I need to find a way to stop Notepad++ adding these "Line #" as I only need the actual line content.
For example, if I search for "pizza" lines, the results will be:

Line 2365: pizza
Line 5654: pizza

I don't want it telling me the lines, as they are not important right now.
How can I disable this? Or, is there a way to copy the lines I asked the software to find, ignoring the "Line #"?

A: I don't know if you can disable the linenumbers (my guess is you can't), but in the search result pane you can use block select to copy the lines.
Just put your cursor at the beginning of your first search result and use combinations of  [Alt]+[Shift] and arrow keys to make a selection.
You can then copy only the selection and paste it into a new document.

A: You can simply use the Find Next option. It will highlight the position of the occurrence of the word.

A: Notepad++ has a plugin named Linefilter2:

*

*It has two search modes: normal and regular expressions

*Search results are shown in a new text window whose results don't contain line numbers

You can see the process in the pictures below:

A: You can work around it by copying the lines out of the search result box into a new file, then getting rid of them as follows: search for the regular expression \tLine [\d]*: (with a space after the colon) and replace it with nothing.


text:
Q: How can I make SPService webUrl to query a root site from a subsite? I am running SPServices' GetListItems from a subsite (https://something.sharepoint.com/sites/intranet/op1/) querying a document library in the root (https://something.sharepoint.com/sites/intranet). This is my SPServices code.
$().SPServices(
{
    webUrl         : 'https://something.sharepoint.com/sites/intranet/',
    operation      : "GetListItems",
    async          : true,
    listName       : 'Documents',
    CAMLViewFields : "<ViewFields><FieldRef Name='Title' /><FieldRef Name='EncodedAbsUrl'/></ViewFields>",
    // CAMLQuery      : camlQuery,
    completefunc   : function (xData, Status)
        {
            console.log('doclib_getListItems [xData]', xData);
            console.log('doclib_getListItems [Status]', Status);
        }
});

However I am getting an error "POST https://something.sharepoint.com/sites/intranet/op1/_vti_bin/Lists.asmx 500 (Internal Server Error)". I think it is trying to find the "Documents" list in the subsite but not in the site indicated by the webUrl. Is there a way to force SPServices webUrl to query the root _vti_bin  (https://something.sharepoint.com/sites/intranet/_vti_bin/Lists.asmx) ?

A: The documentation says the parameter is webURL, not webUrl.

GetListItems: [webURL], listName, viewName, CAMLViewFields, CAMLQuery,  CAMLRowLimit, CAMLQueryOptions

Give that a try and see if it helps.


text:
Q: How to link Zlib with Cmake I am trying to link my file with the zlib libray but still get: undefined reference to `deflateInit_'.
I am currently using CLion, have downloaded the zLib file from the homepage and added it into the project. This is how my CmakeLists.txt looks like
cmake_minimum_required(VERSION 3.10) project(GzipTest)

set(CMAKE_CXX_STANDARD 11)

include_directories(ZLIB zlib-1.2.11)

add_executable(GzipTest main.cpp zlib-1.2.11/zlib.h)

And the code (Copying from the zpipe.c):
include "iostream"

include "zlib.h"

include "iostream"

define CHUNK 1639

FILE *fp;

int def(FILE *source, FILE *dest, int level){
    int ret, flush;
    unsigned have;
    z_stream strm;
    unsigned char in[CHUNK];
    unsigned char out[CHUNK];

    // Allocate Deflate state
    strm.zalloc = Z_NULL;
    strm.zfree = Z_NULL;
    strm.opaque = Z_NULL;

    ret = deflateInit(&strm, level);
    if (ret != Z_OK){
        return ret;
    }

}

int main(){
    fp = fopen("inputFile.txt", "r");
    if (fp == nullptr){
        perror("Could not open data");
        exit(EXIT_FAILURE);
    }
    def(fp, fp, 1);
}

What could be missing?
Thanks in advance

A: It seems this old post is getting a lot of traction.
The solutions to linking zlib with CMake are either:

*

*To download zlib, if on Linux with
 sudo apt-get install zlib1g-dev

and then following what Matthieu proprosed.

*Or download zlib like in 1 and do:
 add_executable(my_executable main.cpp)
 target_link_libraries(my_executable z)

*Or just download zlib from their homepage: https://zlib.net/, then save it in a 'deps' folder. Modify the CMakeList in the zlib folder with
 set(ZLIB_DEPS_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)

and in the main CMakeList, do
 add_executable(my_executable main.cpp)
 add_subdirectory(deps)
 include_directories(my_executable ${ZLIB_DEPS_DIR})
 target_link_libraries(my_executable zlib)

A: You have to link against zlib.
If you used:
find_package(ZLIB)

Then you should have:
target_link_libraries(GzipTest ZLIB::ZLIB)

Also don't add the headers to your source files:
add_executable(GzipTest main.cpp)


text:
Q: Starting and ending functions in javascript I am playing around with a short little code to see if I can get a function going while the user has their mouse down and then end it when they bring their mouse up. For this example I am trying to increment a number that I am displaying on the screen as the user moves their mouse while holding the button down. I want it to freeze and stop once they release the button, however the counter just resets and the count continues from 0 even though the button is not being pressed...
function dragInit(state, e) {
    var i = 0;
    $(document).on("mousemove", function() {
        if (state) {
            i+=1;
            $('#debug').text(i); //Show the value in a div
        }
    });
}

$(document).ready(function() {

$(document).on(
    {mousedown: function(e) {
        var state = true;
        dragInit(e, state);
    },
    mouseup: function(e) {
        var state = false;
        dragInit(e, state);
    }
    });
});

As an aside, is there a way I can display whether a variable is true or false onscreen? When I try it just says [object Object].

A: There are a lot of mistakes in your code. I suggest you to read more basic concepts before starting to use jQuery.
The order of the parameters passed to dragInit() is wrong on both mouseup and mousedown event bindings.
The reason your counter is restarting is because your variable i is local, so it exists only during the function context it is declared in.
You are making the same mistake with the state variable, but in this case it is completely unnecessary to declare it.
Consider making your counter a global (even though it is not a good practice).
I can't provide you code because I am answering from my phone. A solution would be create a mousemove event that checkes whether the mouse button is pressed before incrementing your counter.
Hope I helped

A: You could do something like this:
function dragInit() {
    $(document).on("mousemove", function () {
        if (eventState.state) {
            eventState.count += 1;
            $('#debug').text(eventState.count); //Show the value in a div
        }
    });
}

// Create an object to track event variables
var eventState = {
    count:0, //replaces your previous 'i' variable
    state: false //keeps track of mouseup or mousedown
};

$(document).ready(function () {

    $(document).on({
        mousedown: function (e) {
            eventState.state = true;
            dragInit(); //don't need to pass anything anymore
        },
        mouseup: function (e) {
            eventState.state = false;
            dragInit(); //don't need to pass anything anymore
        }
    });
});

jsFiddle
Or keep everything together as one object
var dragInit = function () {
    var count = 0;
    var state = false;
    var action = function () {
        $(document).on("mousemove", function () {
            if (state) {
                count += 1;
                $('#debug').text(count); //Show the value in a div
            }
        })
    };

    $(document).on({
        mousedown: function (e) {
            state = true;
            action(); //don't need to pass anything anymore
        },
        mouseup: function (e) {
            state = false;
            action(); //don't need to pass anything anymore
        }
    });
}

$(document).ready(function () {
    var obj = new dragInit();
});

jsFiddle 2
Example in response to comment
jsFiddle: This shows why the following code snippets differ in execution.
// Works
$(document).on("mousemove", function () {
    if (state) {

    }
})

// Doesn't
if (state) {
    $(document).on("mousemove", function () {

    });
}

A: Less code, You just need this.
Use jquery on and Off to turn on and off mousemove event.
Counter Reset http://jsfiddle.net/kRtEk/
$(document).ready(function () {
    var i = 0;
    $(document).on({
        mousedown: function (e) {

            $(document).on("mousemove", function () {

                $('#debug').text(i++); //Show the value in a div
            });

        },
        mouseup: function (e) {
            i = 0;
            $('#debug').text(i);
            $(document).off("mousemove");
        }
    });
});

W/O Reset http://jsfiddle.net/gumwj/
$(document).ready(function () {
    var i = 0;
    $(document).on({
        mousedown: function (e) {
             $(document).on("mousemove", function () {
                 $('#debug').text(i++); //Show the value in a div
            });

        },
        mouseup: function (e) {
            $(document).off("mousemove");
        }
    });
});

WithNoCounter http://jsfiddle.net/F3ESx/
$(document).ready(function () {

    $(document).on({
        mousedown: function (e) {
             $(document).on("mousemove", function () {
              $('#debug').data('idx',parseInt($('#debug').data('idx')|0)+1).text($('#debug').data('idx')); //Show the value in a div
            });

        },
        mouseup: function (e) {
            $(document).off("mousemove");
        }
    });
});

A: Assuming you are married to Jquery (nothing wrong with that) - check out and consider entirely re-thinking your approach leveraging the ".one()"  (http://api.jquery.com/one/) method.
edit: and if that taste doesn't sit well - familiarize yourself with the "deferred" object (http://api.jquery.com/category/deferred-object/)
lots of ways to approach this via jquery - what you decide in the end depends on what you really intend to do with this.


text:
Q: How to contain a Sqlalchemy query into a Python variable? I have 12 if/else statements in my codes, each one will query with Sqlalchemy differently like below:
if condition1:
  query1 = s.query(Invoice).filter(Invoice.trading_partner_name==trading_partner_name).all()

elif condition2:
  query2 = s.query(Invoice).filter(...).all()

elif condition3:
  query3 = s.query(Invoice).filter(...).all()

elif condition 4... and so on

and then I want to display each of the query above with the code (or similar code to this one) below:
             for data in query1:
                [a few other very long codes]

I can put the codes above after each query results in each if/else statement, but that would make my codes very long and redundant. I tried to create a variable that I hoped to hold the value of each query:
query_variable = 0

then I tried to set this variable to each query variable in each if/else statement like below:
if condition1:
  query1 = s.query(Invoice).filter(Invoice.trading_partner_name==trading_partner_name).all()
  query_variable = query1

elif condition2:
  query2 = s.query(Invoice).filter(...).all()
  query_variable = query2

elif condition3:
  query3 = s.query(Invoice).filter(...).all()
  query_variable = query3

elif condition 4... and so on

and then I tried substitute the query_all variable above into the loop of the long codes like below:
            for data in query_variable:
                [a few other very long codes]

However, it didn't work. When I run to code to query data from query_variable, I got the error below:
 TypeError: 'int' object is not iterable

I tried to find answers on StackOverflow, but I couldn't...
If you knows how to fix this problem/ or the answer to "how to contain a Sqlalchemy query into a Python variable?", pls help me!
I would greatly appreciate your help!

A: Okay, thanks a lot to @Epsi95, my problem was because I was testing some of my conditions is not met. To hold a sqlalchemy query, you can do the same as I did, and it works:)


text:
Q: Approximating nice functions with wild ones Let $X$ and $Y$ be toplogical spaces, and call a function $f:X\to Y$ wild if the preimage $f^{-1}(\{y\})$ is dense in $X$ for every $y\in Y$ -- or, equivalently, if the image of every nonempty open subset of $X$ is all of $Y$.
Can every function $X\to Y$ be approximated pointwise by wild functions?
For $\mathbb Q\to\mathbb Q$ the answer is yes -- if we want to approximate $f$, then select a surjection $h:\mathbb Z\to \mathbb Q$, and approximate $f$ by
$$ f_n(x) = \begin{cases} h(\lfloor \tan q \rfloor) & \text{if }x=(2p+1)2^{-q}\text{ for }p,q\in\mathbb Z, q>n \\
f(x) & \text{otherwise} \end{cases} $$
For $\mathbb Q\to\mathbb R$ the answer is no for the trivial reason that there are no wild functions.
For $\mathbb R\to\mathbb R$, we can extend the construction for $\mathbb Q\to\mathbb Q$, if only a Vitali set $A$ exists:
$$ f_n(x) = \begin{cases} a+h(\lfloor \tan q \rfloor) & \text{if }x=a+(2p+1)2^{-q}\text{ for }a\in A, p,q\in\mathbb Z, q>n \\
f(x) & \text{otherwise} \end{cases} $$

Question: Is the answer still yes for $\mathbb R\to\mathbb R$ if we don't have enough choice to construct a Vitali set?

Wild functions $\mathbb R\to\mathbb R$ exist no matter whether we have choice or not -- such as Conway's base-13 function -- but it is not obvious that there will be enough of them to be dense in $\mathbb R^{\mathbb R}$ under pointwise convergence.

(Inspired by this question.)

A: Sleeping on it helps. :-)
A sufficient conditions for wild functions to be dense is that there exists one wild function $X\to\mathbb N\times Y$. Calling this function $g$, we can approximate any $f$ by
$$ f_n(x) = \begin{cases} y &\text{when }g(x)=\langle k,y\rangle\text{ with }k>n \\ f(x) &\text{otherwise} \end{cases} $$
In the $\mathbb R\to\mathbb R$ case we can manufacture a suitable $g$ given a wild function $h:\mathbb R\to\mathbb R$, such as Conway's base-13 function:
$$ g(x) = \begin{cases} \langle 0,0\rangle &\text{if }h(x)\text{ is an odd multiple of }\pi/2 \\
\langle \lfloor h(x)/\pi \rfloor, \tan(h(x))\rangle &\text{otherwise} \end{cases}$$
This same construction works whenever we have a wild $X\to Y$ and a surjection $Y\to\mathbb N\times Y$.

We see that the topology of $Y$ doesn't really matter. The only case where the topology on $Y$ can matter is if $Y$ and $\mathbb N\times Y$ are not equipotent, which requires $Y$ to be finite (boring case) or the Axiom of Choice to fail.


text:
Q: Interpreting Quantified Predicate Formulas Does $\forall x (P(x) \rightarrow Q(x))$ mean that $(P(x) \rightarrow Q(x))$ is true for all truth assignments to $x$ or does it mean that  $P(x)$ and $Q(x)$ can be true or false depending on the truth assignment to $x$?

A: I think it should come with a domain for $x$.
With a domain for $x$, if this statement is true, it means "For every $x$ in the domain, if $P(x)$ is true, then $Q(x)$ is true; if $P(x)$ is false, then $Q(x)$ is false".
The statement is false $iff$ there exists $x$ such that $P(x)$ is true but $Q(x)$ is false.

A: Formulas of first-order (or predicate) logic, like :

$∀x(P(x)→Q(x))$

are interpeted not with truth assignments, but through an interpretation $\mathcal M$, made of :

*

*a (not empty) set of objects, called the domain of the interpretation; call it $M$

*a suitable reference for every constant of the language (if any)

*an assignement to each predicate letter of the language of a relation on $M$ of the suitable arity; i.e. if the predicate letter $P$ (as in our example) is monadic (i.e.has only one argument: arity = $1$) then we assign to it a subset $P^M$ of M (it will be the set of objects of the domain for which $P$ holds); if $R$ is a binary relation (a predicate with arity = $2$) then we assign to it a sucset $R^M$ of $M \times M$; and so on.

Consider now the language of arithmetic, with an individual constant : $\overline 0$, a function symbol $S$ for the successor function and a binary relation : $<$ for less than.
We interpret it in the domain $\mathbb N$ of natural numbers, with the obvious interpretation for the above symbols.
Consider now the formula :

$\forall x(x = \overline 0)$.

Intuitively, we expect that it will be true in $\mathbb N$ if, substituting to the individual variable the name for an object in the domain $\mathbb N$, we obtain a true formula, and this will happen with all numbers, i.e. for every object in the domain.
Consider a formula $A(x)$ with only $x$ free; we call an instance of it a formula $A[t/x]$ obtained from $A(x)$ putting the closed term $t$ (i.e. a "name" of an object) in place of $x$.
Assume that we have a name for every number (for every object in $\mathbb N$); we use $\overline k$ as name for the number $k$.
Now it's done !

The formula $\forall x (x = \overline 0)$ is true in $\mathbb N$ iff every instance : $(x = \overline 0)[\overline k/x]$ is true in $\mathbb N$.

With $0$ as $k$, we have that $(x = \overline 0)[\overline 0/x]$ is simply : $\overline 0 = \overline 0$ wich is true.
But with $1$ as $k$, we have that $(x = \overline 0)[\overline 1/x]$ is : $\overline 1 = \overline 0$ wich is obviously false.
Thus, having found an instance of $x = \overline 0$ which is false, we may conclude that (as expected) :

$\forall x (x = \overline 0)$ is false in $\mathbb N$.

Now, what about

$∀x(P(x)→Q(x))$ ?

First of all, we have to choose a domain $M$ for our interpretation $\mathcal M$.
Second, we have to assign to the predicate letters $P$ and $Q$ two subset of the domain $M$, $P^M$ and $Q^M$ respectively.
Having done this, we have that the above formula will be true in $\mathcal M$ iff for every $a \in M$, if $\overline a$ is the name of $a$, the formula $(P(x)→Q(x))[\overline a/x]$ is true in $\mathcal M$.
In other terms,

$∀x(P(x)→Q(x))$ is true in the interpretation $\mathcal M$ iff for every $a \in M$, $(P(\overline a)→Q(\overline a))$ is true in it.


text:
Q: Problem assigning probabilities in sample function I have generated a bunch of variables through the following :
max_no=10
list2env(setNames(as.list(c(0.2, 0.25,0.15, 0.1, 0.1, 0.05, 0.03, 0.06, 0.03, 0.02, 0.01)), paste0("proportion", 0:max_no)), envir = .GlobalEnv)

These generate objects like "proportion0", "proportion1",..., "proportion10" with values 0.2, 0.25.... etc.
I want to plug these proportion values as a vector of probabilities into the sample function like the following:
sample(seq.int(0, max_no, 1), size=10000, replace=TRUE, prob=c(paste0("proportion", 0:max_no)))

But I get the error message: Error in sample.int(length(x), size, replace, prob) : NA in probability vector
What would be a simple way of feeding in the probabilities?

A: I am not sure what is the use-case for this but you can use mget and unlist
sample(seq.int(0, max_no, 1), size=10000, replace=TRUE,
       prob=unlist(mget(c(paste0("proportion", 0:max_no)))))

Why not pass probability directly instead of storing each number in a different variable?
sample(seq.int(0, max_no, 1), size=10000, replace=TRUE,
       prob=c(0.2, 0.25,0.15, 0.1, 0.1, 0.05, 0.03, 0.06, 0.03, 0.02, 0.01))