text:
Q: What's missing from this strategy of choosing which C# collection to use? Here's my strategy for choosing which C# collection type to use:

*

*if number of items in collection is fixed, then use an array, e.g.:
string[] directions = new string[] { "north", "south", "east", "west" };

*otherwise always use List<T>

*unless of course you need a more specialized collection, e.g. Stack<T>, Queue<T>, or Dictionary<TKey, TValue>

*but never use ArrayList anymore
Based on your experience, what is missing from this strategy?

A: Your rules work fine.
In addition:

*

*Always perfer generic (or specialized) collections over ungeneric (object-based) ones.

*Use HashSet<T> if you want to check for mere existence instead of key-value-mappings (which is represented through Dictionary).

*In case of dictionaries, consider the use of ordered maps (SortedList<...>, SortedDictionary<...>) if ordering seems important.

*Use linked lists if you have remove/insert operations in the middle.

and of course the most important one:

*

*Never export concrete collection types: Always use the most general interface, which is - in the most cases - IList<T> or IEnumerable<T>.

A: I'd say that in the majority of cases, even if I knew the number of items in a collection, I'd use List, simply for the number of utility functions it provides and compatibility with LINQ.
Hashmaps are an important use case, for when you would want faster access to items within the collection.

A: You can also use Collection<T> if you plan to override add/remove/clear methods in an inherited class because there are virtual methods.


text:
Q: Unreliable iPad car connection cable I own a 2008 Scion (made by Toyota) which has a built-in port for connecting iPod/iPhone/iPad to the car's stereo for audio and remote control. I purchased the recommended adapter cable which connects the car's console to the the 30-pin connector on my iPad 3. (Link to interface cable PT546-21062 by Toyota)
After a week or so, it started losing the connection if the iPad moved, so I started sliding the iPad between the seat and the center console to keep it still. This worked as long as I didn't bump it.
Starting this week, going around a turn has been enough to cause the connection to completely fail even when the iPad is held in place. I've noticed the end of the adapter plugged into the iPad easily wiggles back to front.
How can I be sure the problem is the cable and not my iPad?
I can still connect the iPad to my computer using the 30-pin to USB cable that came with my iPad, but that only uses 5 or 6 of the 30-pins the cable supports. I also unscrewed the console in the car and checked that the internal wiring there is all solid.
What would be the best way to try to fix this? Are there 30-pin extension cables that have more sturdy connectors that would lock into the port on my iPad better?
Is this something I could get help with at the Apple Store or would they not help since the adapter is made by Toyota rather than Apple?

A: After testing with a friend's iPhone I replaced the cable an it is working now. The connection feels tighter than the old one did even when it was new, so the old one may have just been defective.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Javascript add new row with  then remove at the last row I have simple question regarding table row.
Below is the example:

var data = ['A', 'B', 'C', 'D', 'E'];

for(var i=0; i<data.length; i++) {
  var element = `
    ${i}

  `;

  console.log(element);
}

The result from console.log is:
0

1

2

3

4

Now I need at the last row 4
 no need this
. It should be like this 4	.
Is there any trick to handle it?

A: You can try this:

for(let i=0; i<data.length; i++) {
  let element = `<td>${i}</td>`;
  if (i !== data.length-1) {
    element += "
";
  }
  console.log(element);
}


text:
Q: Background service running but not functioning properly in kitkat devices What I have
A background service that changes the wallpaper of a device automatically from a few selected images. It runs perfectly fine on lolipop and post lolipop devices. But the problem arises when I try it on a kitkat device. The service stays alive but doesn't function as I can't see the wallpapers changing.
How do I know the service is alive?
On a kitkat device, when I go to Settings->Apps->Running. It shows 1 service running for my app and since it is the only service I have implemented in the whole app, I am sure that the service is alive. Moreover, greenify shows that the service is still running.
What the service is supposed to do
Users can download images which get stored in a specific folder. When the user sets the interval after which the wallpaper should change and clicks on a button to start it, the background service is started which derives the bitmap from those previously downloaded images and sets them as wallpaper after specified intervals.
The manifest declaration for the service
<service android:name=".AutomaticWallpaperChanger" android:enabled="true" android:exported="false"/>

Code for the service:
public class AutomaticWallpaperChanger  extends Service {
// constant
public static long NOTIFY_INTERVAL;
Boolean shuffle;
int wallpaper;
SharedPreferences mySharedPreferences;
SharedPreferences.Editor editor;

// run on another Thread to avoid crash
private Handler mHandler = new Handler();
// timer handling
private Timer mTimer = null;

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d("onstart gallery dialog","called");
    editor.putBoolean("service not running",false).commit();
    return START_STICKY;
}

@Override
public void onCreate() {
    // cancel if already existed
    if (mTimer != null) {
        mTimer.cancel();
    } else {
        // recreate new
        mTimer = new Timer();
    }
    mySharedPreferences = getApplicationContext().getSharedPreferences("preferences", Activity.MODE_PRIVATE);
    editor= mySharedPreferences.edit();
    AutomaticWallpaperChanger.NOTIFY_INTERVAL=mySharedPreferences.getInt("interval",3600);//3600*1000)*1000;
    AutomaticWallpaperChanger.NOTIFY_INTERVAL*=1000;
    // schedule task
    mTimer.scheduleAtFixedRate(new TimeDisplayTimerTask(), 0, NOTIFY_INTERVAL);
}

class TimeDisplayTimerTask extends TimerTask {

    @Override
    public void run() {
        Log.d("timer","Running");
        // run on another thread
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                //Toast.makeText(getApplicationContext(),
                        //"running",
                       // Toast.LENGTH_SHORT).show();
                // display toast
                AsyncTask asyncTask= new AsyncTask() {
                    @Override
                    protected Object doInBackground(Object[] objects) {
                        File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "WallR"+ File.separator + "Gallery");
                        if(folder.exists()) {
                            File[] listOfFiles = folder.listFiles();
                            shuffle = mySharedPreferences.getBoolean("checked", false);
                            Log.d("shuffle", String.valueOf(shuffle));
                            if (shuffle != true) {

                                if (listOfFiles.length != 0) {
                                    wallpaper = mySharedPreferences.getInt("wallpaper", 0);
                                    wallpaper++;
                                    editor.putInt("wallpaper", wallpaper);
                                    editor.commit();
                                    if (wallpaper >= listOfFiles.length) {
                                        wallpaper = 0;
                                        editor.putInt("wallpaper", wallpaper);
                                        editor.commit();
                                    }
                                    Log.d("wallpaperr number", String.valueOf(wallpaper));
                                    Bitmap bitmap = BitmapFactory.decodeFile(listOfFiles[wallpaper].getPath());
                                    WallpaperManager mWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
                                    try {
                                        mWallpaperManager.setBitmap(bitmap);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    bitmap.recycle();
                                }
                            }
                            else {
                                if (listOfFiles.length != 0) {
                                    wallpaper = mySharedPreferences.getInt("wallpaper", 0);
                                    wallpaper++;
                                    editor.putInt("wallpaper", wallpaper);
                                    editor.commit();
                                    if (wallpaper >= listOfFiles.length) {
                                        wallpaper = 0;
                                        editor.putInt("wallpaper", wallpaper);
                                        editor.commit();
                                    }
                                    shuffleArray(listOfFiles);
                                    Log.d("wallpaperr number", String.valueOf(wallpaper));
                                    Bitmap bitmap = BitmapFactory.decodeFile(listOfFiles[wallpaper].getPath());
                                    WallpaperManager mWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
                                    try {
                                        mWallpaperManager.setBitmap(bitmap);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                    bitmap.recycle();
                                }
                            }
                        }
                        return null;
                    }
                };
                asyncTask.execute();

            }

        });
    }
    void shuffleArray(File[] ar)
    {
        // If running on Java 6 or older, use `new Random()` on RHS here
        Random rnd = new Random();
        for (int i = ar.length - 1; i > 0; i--)
        {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            File a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;
        }
    }

}

@Override
public void onDestroy() {
        editor.putBoolean("service not running", true).commit();
        mTimer.cancel();
        mTimer.purge();

}

}

My observations
The service runs perfectly fine for lollipop, marshmallow and nougat devices. But for kitkat devices, it runs as long as the app is open. After I swipe the app out of the recent apps, the service stays alive but doesn't change the wallpaper anymore.


text:
Q: Regex reset capture groups I have tried alterations using '|' but seems to be impossible to first parse map if possible, if not, just parse the value as a whole, but keeping the capture group as no 1/2, tried with branch reset group but didn't manage that way either. Any suggestions are welcome.
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Scratch {

  public static void main(String[] args) {

    final Pattern outerKeyPattern = Pattern.compile("([A-Z]+)\\((.*)\\)", Pattern.MULTILINE);
    final Pattern innerPattern = Pattern.compile("([A-Z]+)\\((.*?)\\)");

    // There will always be a value in the outer,
    // but sometimes it's an inner map, i.e only need to solve this case, no other exeptions

    String input = """
      VALUE(123)
      OUTERVALUE(INNERVALUE(123)OTHERVALUE(456))
      """;

    Map<String, Map<String, String>> outer = new HashMap<>();
    Matcher matcher = outerKeyPattern.matcher(input);
    while (matcher.find()) {
      String key = matcher.group(1);
      String value = matcher.group(2);
      Matcher valueMatcher = innerPattern.matcher(value);
      Map<String, String> innerMap = new HashMap<>();
      while (valueMatcher.find()) {
        innerMap.put(valueMatcher.group(1), valueMatcher.group(2));
      }
      outer.put(key, innerMap);
    }

    System.out.println(outer);
  }
}

yields output:
{VALUE={}, OUTERVALUE={INNERVALUE=123, OTHERVALUE=456}}

I need to parse value also as key for the inner map and it's value as null:
{VALUE={123=}, OUTERVALUE={INNERVALUE=123, OTHERVALUE=456}}

A: Since you seem to process your data line by line and the comment in your snippet indicates that your data is well formed, you could first extract the whole content of the outter braces and then check if the value contains any nested key-value pairs. With some modifications to your regex, something like below might be what you are looking for:
public static void main(final String[] args) {

    Pattern outerPattern = Pattern.compile("([A-Z]+)\\((.*)\\)");
    Pattern innerPattern = Pattern.compile("([A-Z]+)\\(([^()]*)\\)");

    String input = """
            VALUE(123)
            OUTERVALUE(INNERVALUE(123)OTHERVALUE(456))
            """;

    Map<String, Map<String, String>> outer = new HashMap<>();

    input.lines().forEach(line -> {
        Matcher matcher = outerPattern.matcher(line);
        matcher.find();

        String key   = matcher.group(1);
        String value = matcher.group(2);

        Map<String, String> innerMap = new HashMap<>();

        if (!innerPattern.asPredicate().test(value)) {       //check if value doesn't contain any nested key-value-pairs
            innerMap.put(value, "");
        } else {
            Matcher valueMatcher = innerPattern.matcher(value);
            while (valueMatcher.find()) {
                innerMap.put(valueMatcher.group(1), valueMatcher.group(2));
            }
        }
        outer.put(key, innerMap);
    });

    System.out.println(outer);
}


text:
Q: Configure Apache Mass Virtual Hosts to different directories Our server is running Apache on port 9000 (because IIS is at 80) and we have the following configuration (vhosts.conf) to access our sites:
NameVirtualHost *:9000
UseCanonicalName Off

<VirtualHost *:9000>
    ServerAlias %1.ourserver
    VirtualDocumentRoot D:/oursites/%1
    VirtualScriptAlias D:/oursites/%1
</VirtualHost>

So we can open the browser and access by http://someclient.ourserver:9000/. So far so good.
Now we are installing a new server, where Apache will run on port 80, but we need that one specific site to have the VirtualDocumentRoot to a different drive/directory. We tried something like this (with no success):
NameVirtualHost *:80
UseCanonicalName Off

<VirtualHost specificsite.ourdomain.com:80>
    ServerAlias specificsite.ourdomain.com
    VirtualDocumentRoot C:/specificsite
    VirtualScriptAlias C:/specificsite
</VirtualHost>

<VirtualHost *:80>
    ServerAlias %1.ourserver
    VirtualDocumentRoot D:/oursites/%1
    VirtualScriptAlias D:/oursites/%1
</VirtualHost>

When we test, the result is that, accessing http://specificsite.ourdomain.com/ on browser, Apache tries to "redirect" to D:/oursites/specificsite, which is not correct.
Accessing http://someclient.ourserver/ Apache redirects correctly to D:/oursites/someclient.
So what am I missing? Looks like I am forgetting a little detail that is resulting in all requests falling at the second VirtualHost.
More info:

*

*Running Xampp 1.7.7 on

*Windows Server 2008 R2 with

*Two entries on DNS management: one for the *.ourserver and another for the specificsite.ourdomain.com;

*The reason of using specificsite.ourdomain.com is that our clients can access this specific site that is hosted on our server.

Thanks in advance for any help!

A: Two issues:

*

*ServerAlias doesn't support the same variables as VirtualDocumentRoot - that vhost's alias is set to literally %1.ourserver.

*Your declaration of the new vhost doesn't match the NameVirtualHost directive, so it's not being checked when a request comes in on that host/port combination.  It's using DNS to find the address to bind to, so the fact that it didn't knock the dynamic vhost offline means that your server's probably behind a NAT.

Try this:
NameVirtualHost *:80

# Put this one's configuration first, so that it's the default.
<VirtualHost *:80>
    # Add a ServerName directive so that it doesn't guess - it can be anything
    ServerName dynamic.filler.name
    ServerAlias *.ourserver
    VirtualDocumentRoot D:/oursites/%1
    VirtualScriptAlias D:/oursites/%1
</VirtualHost>

<VirtualHost *:80>
    ServerName specificsite.ourdomain.com
    VirtualDocumentRoot C:/specificsite
    VirtualScriptAlias C:/specificsite
</VirtualHost>


text:
Q: Android:How to make Radio button non changable by user? I have a RadioGroup with two radio button's in it. And based on some internal calculation's I am selecting one of them. I want to make them non changeable by the user from UI.

A: In your layout file set android:enabled="false"
Just like this
<RadioButton
    android:id="@+id/radioButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:enabled="false"/>

A: RadioButton btn=(RadioButton)findviewById(R.id.yourButtonIdInRadioGroup);
btn.setEnabled(false);


text:
Q: MailApp not sending with large number of recipients My code takes an input of emails that looks like this:

email1@gmail.com, email2@gmail.com, email3@gmail.com ...

and tries to send them an email using the following code.

function sendEmail(form) {

  var ss = SpreadsheetApp.getActive();
  var body = form.body;
  var bcc = form.bccfield;
  var cc = form.ccfield;
  var to = form.tofield;
  var subject = form.subject;
   var eHandle = ss.getSheetByName("Email Handling");
  var sig = eHandle.getRange(10, 2).getValue();
  var img = eHandle.getRange(11, 2).getValue();
  var sigImage = '';

MailApp.sendEmail({
    to: to,
  cc: cc,
  bcc: bcc,
    subject: subject,

  htmlBody: body.replace(/\n/g, '
') + sig + sigImage});
  }

It seemed to always be working but now I'm trying to send to a class list of parents (about 55 at a time) and it just doesn't send anything (the code doesn't even finish). I am GSuite for Education so I should have a limit of over 1,000 recipients per day.
I'm pretty sure the only difference which now causes a problem is the number of recipients.

A: You are not allowed to sent an email to more than 50 recipients at a time.
Number of recipients per email is part of Quotas for Google Services.
You are only allowed to sent an email with a maximum number of 50 recipients.

An obvious workaround would be to split the recipients into two or more (depending upon the number of recipients) different emails so this hard limitation won't be violated.


text:
Q: Convert List of dictionary to dictionary input
values = [{'name': 'mike', 'age': '20'}, {'name': 'tom', 'age': 34}, {'name': 'kate', 'age': 99}]

output expected
output
values = {{'name': 'mike', 'age': '20'}, {'name': 'tom', 'age': 34}, {'name': 'kate', 'age': 99}}

A: The output you wanted has a set containing dictionaries. Since sets cannot hold dictionaries, we can convert the dictionary into tuples, and then we will use a set to hold these tuples.
For example, if we have:
values = [{'name': 'mike', 'age': '20'}, {'name': 'tom', 'age': 34}, {'name': 'kate', 'age': 99}]

We can do:
{i for dict in values for i in dict.items()}

This results to:
{('age', '20'),
 ('age', 34),
 ('age', 99),
 ('name', 'kate'),
 ('name', 'mike'),
 ('name', 'tom')}


text:
Q: Weak convergence and trace operator Suppose that $u_j\rightharpoonup u$ in $W^{1,p}(\Omega)$ (notice the weak convergence), with $\Omega\subset \mathbb{R}^3$ regular enough. Let $v_j=Tu_j$, and $v=Tu$, where $T:W^{1,p}(\Omega)\to L^p(\partial \Omega)$ is the trace operator. Can I claim one of the following?

*

*$v_j\rightharpoonup v$ in $W^{1-\frac{1}{p},p}(\partial \Omega)$

*$v_j\to v$ in $L^p(\partial \Omega)$

In my case $p=4/3$, so I think the first implies the second. But what I really need is simply the second one.
Edit: the fractional exponent for the trace Sobole space is $1-\dfrac{1}{p}$, not $\dfrac{1}{2}$ (unless $p=2$, obviously).
Edit 2: I read somewhere (can't find the link/reference now) that a valid norm for for traces is
$$
\|u\|_{W^{1-1/p,p}(\partial \Omega)} := \underset{Tv=u}{\inf} \|v\|_{W^{1,p}(\Omega)}.
$$
It looks to me like a legit norm, and with this characterization, we have that $T$, as an operator from $W^{1,p}(\Omega)$ onto $W^{1-1/p,p}(\partial\Omega)$ is continuous, with norm $1$. If this is correct, then, as Jose said in a comment, 1. would be true.


text:
Q: UI's in Sharepoint Our web team has been asked to build some user interfaces in Sharepoint.  The UI's would primarily be forms that would need to write to a  SQL Server database.
Is ASP.NET the best way to do this?  If so what's the best way to integrate the ASP.NET application into Sharepoint?

A: You have 4 options:
1. Build web parts
2. build user controls , and use smart part to display them.
3. use infopath
4. host the asp.net in an iframe (page viewer web part).

I would go with building web parts, however user controls and smart part are probably quicker, and quickest still is infopath, but infopath wont use the page layouts or master pages that you specify.
if the web app has already been developed then youre looking at option 4, if its not already developed then I would suggest 1 or 2 which gives you the flexibility of reusing the controls elsewhere in the site as well as utilising the sharepoint metadata.

A: Another option: Create your own aspx page, and refer to the default SharePoint master page.  Upload it with a feature.  This is better than web parts if you want control over the whole page, not just a web part zone.  Web parts are better when you want to make it easy for power users to configure functionality and placement.
Application pages are appropriate for system and administration pages, because once copied to the layouts folder, they're available on all your webs.  They also have a nice permission model, through inheritance from the LayoutsPageBase class, so you can easily restrict access to some users.  But I wouldn't use this for regular users pages, ie. functionality that is part of the application itself.

A: You can also build SharePoint "application pages" to do this.  This is a decent way to migrate existing pages from the ASP.NET world into a SharePoint app.
IMO, the best decision of all of these reasonable recommendations would depend on the specific functionality you're planning to implement.

A: I would combine 1 and 2 of Mauro's answer.  Wrap up your user control in your own web part.

A: Or you could use data views in Sharepoint to connect to the backend

A: Option 2 from Mauro is the quickest and most flexible way. If you use smart part, you just have to focus on developing regular ASP.NET user controls.

A: If you have MOSS Enterprise, you might want to check out the BDC. There are also some 3rd part web parts that you might check out that will do some of the work for you.

A: The easiest way to construct UI in SharePoint is by creating a UserControl and then creating your own WebPart and in it using LoadControl to load your UserControl...
Then to have a really responsive app (shameless plug - I'm a developer at Ra-Ajax) you could also use something like Ra-Ajax to get Ajax functionality which should work seamlessly together with SharePoint...
The complete solution would look something like this;
public class MyWebPart : WebPart
{
   protected override OnInit(EventArgs e)
   {
      EnsureChildControls();
      base.OnInit(e);
   }

   override void CreateChildControls()
   {
      LoadControl("SomeUserControlAtSomePath.ascx");
      base.CreateChildControls();
   }
}


text:
Q: Take input from the user and pass on to the scpi commands I am writing this script:
def main():
    rc = RemoteControl()

    # To Check if HCCU is responding to SCPI commands
    scpi_command = r'*IDN?'
    debug('Calling SendSCPICommandToHCCU:', scpi_command)
    result = rc.SendSCPICommandToHCCU(scpi_command)
    debug('Result:', result)

    scpi_command = r'setup:ports:recall "SISO_NR"'
    debug('Calling SendSCPICommandToHCCU:', scpi_command)
    result = rc.SendSCPICommandToHCCU(scpi_command)
    debug('Result:', result)

now in scpi_command I am passing a recall command to recall a profile which is a string("SISO_NR"). I want to modify this script in such a way that my script asks the user for the input of the string here. How can I do it?

A: To get an user input in python use input
Example:
command = input('Provide a command:')
print(command)

More infos: https://www.w3schools.com/python/ref_func_input.asp


text:
Q: Image display Black on moving seekbar I am displaying an image in image view and apply some color filters, here is my code
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_2);

    SeekBarTxt=(TextView)findViewById(R.id.value_txt);
    iv=(ImageView)findViewById(R.id.img_vw1);

    sb_red = (SeekBar)findViewById(R.id.seek_bar1);
    sb_green = (SeekBar)findViewById(R.id.seek_bar_green);
    sb_blue = (SeekBar)findViewById(R.id.seek_bar_blue);

    sb_red.setOnSeekBarChangeListener(colorBarChangeListener);
    sb_green.setOnSeekBarChangeListener(colorBarChangeListener);
    sb_blue.setOnSeekBarChangeListener(colorBarChangeListener);

    setColorFilter(iv);
}

OnSeekBarChangeListener colorBarChangeListener=new OnSeekBarChangeListener() {

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        // TODO Auto-generated method stub
        seekBar.setSecondaryProgress(seekBar.getProgress());
        //SeekBarTxt.setText("ended tracking touch");
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        // TODO Auto-generated method stub
        //SeekBarTxt.setText("starting to track touch");
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        // TODO Auto-generated method stub
        //SeekBarTxt.setText(Integer.toString(progress)+"%");
        setColorFilter(iv);
    }
};

private void setColorFilter(ImageView iv)
{

    float redValue,greenValue,blueValue;

    if(sb_red.getProgress()!=0 || sb_green.getProgress()!=0 || sb_blue.getProgress()!=0)
    {
        redValue = ((float)sb_red.getProgress())/255;
        greenValue = ((float)sb_green.getProgress())/255;
        blueValue = ((float)sb_blue.getProgress())/255;
    }
    else
    {
        redValue = 1;
        greenValue = 1;
        blueValue = 1;
    }

     float[] colorMatrix = {
               redValue, 0, 0, 0, 0,  //red
               0, greenValue, 0, 0, 0, //green
               0, 0, blueValue, 0, 0,  //blue
               0, 0, 0, 1, 0    //alpha
         };

    SeekBarTxt.setText(redValue+"%");
    ColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);

    iv.setColorFilter(colorFilter);
}

now my problem is when i slide the seekbar little image immediatly gets black,
 i want to apply color effect slowly slowly on image. how can i acheive this.
Kindly help!


text:
Q: retreiving checkbox data along with the textbox data when a check box is checked I am M.Boopalan
I am trying to retrieve the textbox data which is disabled when corresponding checkbox is checked.
 Note : That textbox and checkbox are in a particular card div. The cards are more than 5.
front end : HTML and EJS
Back end : nodejs (express)
Thanks in advance.

  <input type="text" value="<%= res[j].d_name %>" name="<%= res[j].d_name %>" disabled>

Type of Variety :  <%= res[j].category %>

   <input type="checkbox" value="<%= res[j].price %>" name="itemPrice">
   INR : Rs.<%= res[j].price %>


text:
Q: Issue with Ansible Check and Diff Mode I was going thru this post (https://blog.networktocode.com/post/generating-diff-with-ansible/) where its mentioned that we can use check and diff mode together. I am trying to use that for gold config audit (audit pre decided config against what is present on device) for Cisco and Extreme devices. Below is my playbook –
# task to audit & heal ntp configuration
- name: Set NTP template
  ios_config:
     src: "{{domain}}_{{ansible_network_os}}_ntp.cfg"
     match: line
  register: ntp_result

Below is my template -
ntp server 10.19.70.1

Ansible highlighting that it is going to change the config. Below is what result I am getting. Surprisingly I am not getting any config diff.
"ntp_result": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python"
        },
        "changed": true,
        "commands": [
            "configure ntp server add x.x.x.x"
        ],
        "failed": false,
        "updates": [
            "configure ntp server add x.x.x.x"
        ],
        "warnings": [
            "unable to perform diff against running-config due to check mode"
        ]
    }

Why I am not getting config diff? Any idea what is wrong?

A: This is a limitation of the module: you can only combine check with diff using the diff_against options of startup and intended, but not running.
corresponding Ansible source here:
        if module.params['diff_against'] == 'running':
            if module.check_mode:
                module.warn("unable to perform diff against running-config due to check mode")


text:
Q: Angular service array empty I am trying to store JSON's data in a shared array within a service. The problem is that every time I want to update the service's array with some new content (e.g. new JSON), I need to first clear the array and after that the array remains empty, instead of loading new data.
My service looks like this:
.service('jsonTest',
    function() {
      var json = [];

      function storeJson(file) {
        json=[];
        json.push(file);
      }
      return {
        storeJson: storeJson,
        showJson: json
      }
    });

As you can see, I am cleaning the array each time before loading new data with
json = [];

But then it still remains empty after loading new stuff.
What am I doing wrong here?
You can check that example here: http://plnkr.co/edit/tN9WvNminw1uLpThWPvu?p=preview
The service is in app.js and is being used in MainCtrl (main.js) and ProductCtrl (product.js).
Any advice please?

A: You're not watching json and updating showJson each time it's changed. You need to do something like:
.service('jsonTest', function() {
  var json = {
    showJson: [],
    storeJson: function(file) {
      json.showJson=[];
      json.showJson.push(file);
    }
  };

  return json;
});

Because json is a local variable, when you set it equal to [] inside storeJson, it's using a new memory location, i.e. it's not a reference variable, so showJson is not automatically updated. If you were clearing the existing array (maybe by .pop until there are no elements left), it would work, but since you're assigning a new empty array, it doesn't.
Alternatively, you could also make showJson a function that returns json. That would also work.
.service('jsonTest', function() {
  var json = [];

  function storeJson(file) {
    json=[];
    json.push(file);
  }
  function showJson() {
    return json;
  }
  return {
    storeJson: storeJson,
    showJson: showJson
  }
});

A: i think you should be using an empty object rather than an array.
.service('jsonTest', function() {
    var json = {};
    return {
        set: function(val){
            json = val;
        },
        get: function(){
            return json;
        }
    };
});

Updated you're Plunker

A: Perhaps, a better structure is to move $http calls to service itself, so its truly a service. Tben inject the service into MainCtrl.
So, you can invoke service (lets call it 'myAppService') like:
 .controller('MainCtrl', ['$scope', '$log', 'myAppService',
    function ($scope, $log, myAppService) {

       $scope.getData = function(filepath) {
          // do something with results ie. store etc.
          var fileOrPromise = myAppService.get(filepath);
       };
 ]);

and a service/factory:
 .factory('myAppService', ['$http', '$q', '$window',
    function($http, $q, $window) {
      return {
          get: function(filepath) {
             return _goGetFile(filepath);
          },
          // do something else
      };
    }
  ]);

Here is some references to design and best practices:

*

*johnpapa

*scotch.io
Hope this helps.


text:
Q: Counting null rows and columns in a n*n matrix I'm trying to solve the following problem:

Write the function null(A) which, given a matrix of integers A (list of lists), of size n * n, counts the number of null rows and columns (that is, with all elements equal to zero). The result should be a list with 2 elements: number of null rows and number of null columns.

Could anyone suggest a solution please? I've been blocked in this question for a while, it is probably very easy but I can't seem to solve it.
I'm in an introductory Python class, so the solution should be simple (no packages needed).
Thank you so much in advance!

A: I would suggest that you get familiar with "for x in y" code, to see how it works.
For example, if you have a list, you can access every item of the list:
example_list = ['a', 4, 'g']

for x in example_list:
    print(x)

Output:
a
4
g

instead of x, you can type anything, it doesn't matter, but whatever you write there, will be a local variable containing the value of every item in the list, one at a time (so, if you write "for item in example_list", be sure to print(item))
In the case of a 2d_list, every item will be a list itself, so...
2d_example_list = [[1, 2, 3], ['a', 'b', 'c'], ['Never', 'Gonna', 'Give', 'You', 'Up']]

for item in 2d_example_list:
    print(item)

Output:
[1, 2, 3]
['a', 'b', 'c']
['Never', 'Gonna', 'Give', 'You', 'Up']

You can also nest two "for" loops to access every item of every list.
I think this is enough for you to be able to find the answer to your problem, good luck! :)

A: You may enter a matrix of your choice. The null() function traverses each row and checks if the maximum value of the row is 0 - if it's true, means all values are 0. Then, it transposes the matrix and follows the same convention to check each column. Increments values when finds a null column or row.
import numpy as np

def null(array):
    rowCounter = 0
    columnCounter = 0
    for row in array:
        if (max(row) == 0):
            rowCounter += 1

    array = array.transpose()
    for row in array:
        if (max(row) == 0):
            columnCounter += 1

    return rowCounter, columnCounter

array = np.array([[0,0,0,0], [1,1,1,0], [2,2,2,0], [0,0,0,0]])

print(array)

print("Number of null rows and columns:" + str(null(array)))


text:
Q: Differential Equations: Say whether the equation has bounded solutions at $x = 0$ Its been forever since I've done Diff EQ and I can't remember how to go about solving this problem:
Say whether the equation has bounded solutions at $x = 0$ and whether all solutions are bounded:
$$
(x^2 + x^3)u'' + (x + x^2)u' + u = 0
$$
Any guidance would be greatly appreciated.


text:
Q: Why is there an escape velocity? I've been trying for days, but I just can't understand why escape velocities exist. I've searched the web and even this site, and although I've read many explanations, I haven't been able to truly understand them. Most of the explanations I've seen involve calculus; I only know very little calculus. Could somebody provide a more intuitive explanation?
Here's what I know & understand:

*

*Escape velocity is the speed at which the kinetic energy equals the gravitational potential energy of an object

*Escape velocity isn't the same as orbital velocity, a satellite never reaches escape velocity, escape velocity is only an initial velocity. And all the other common misconceptions.

What I do not understand, is why an object that has reached escape velocity will never return back to the planet it was launched from. To help you understand where I'm stuck, here's a short "proof":

*

*Our whole universe consists of only two bodies. A teapot of mass m, and a planet of mass M. M is many million times larger than m, so the gravitational force acting on the planet is trivial.

*We launch the teapot from the planet, giving it an initial velocity U (relative to the planet). U > escape velocity for that particular planet.

*Now, the only force acting on the body (teapot) is the gravitational force from the planet, resulting in a negative acceleration (relative to the planet). The  force, and therefore the resulting deceleration, will be decreasing quadratically as distance increases. The negative acceleration will get very close to, but never quite reach, zero.

*Therefore, the speed of the teapot will never stop decreasing. The teapot will keep decelerating forever.

*We conclude that at some point, the speed of the teapot will reach zero. The teapot will then fall back to the planet, even though U was greater than the escape velocity.

I suspect that my implication (4) => (5) is false. Somebody please explain why, using as little Calculus as possible. Could this be similar to the Achilles and the Tortoise paradox?
Thanks in advance!

A: 5 does not follow from 4.  I'll use only the time derivative to show this.  For a simple counter-example to 5, consider an exponentially decaying velocity:
$v = V_0e^{-\alpha t}$
Clearly, the speed asymptotically approaches zero.  What is the acceleration?
$a = -\alpha V_0e^{-\alpha t}$
So, even though there is always a non-zero deceleration, i.e., the object decelerates forever, the speed never reaches zero.
Now consider an object with the following velocity:
$v = V_\infty + V_0e^{-\alpha t}$
Again, the object decelerates forever and yet, the speed approaches a constant, non-zero value.

A: Here is a beautiful mathematical explanation The Problem of Escape Velocity [1]
In short, the height at which the speed of teapot will become zero, is very very large (~ infinity). Hence the bodies which leave the earth with escape velocity don't return, even though gravity might still act on them.
[1] Calculus: An Intuitive and Physical Approach (Second Edition)
 By Morris Kline

A: Velocity equation of a body thrown straight up from Earth surface:
$v^2(h)=(v_o^2 – v_e^2)+v_e^2\frac{R}{h}$
where
$v_o$  - initial velocity, $v_e$  - escape velocity, $R$ - Earth radius, $h$ - distance from  Earth center $(h>R)$
1) If  $v_o<v_e$ then there is  $h$ at which $v=0$:
$\large {h_{max}=R\frac{v_e^2}{v_e^2-v_o^2}}$
2) If  $v_o=v_e$ then $v>0$ at any $h$:
$v^2(h)=v_e^2\frac{R}{h}$
3) If  $v_o=2v_e$ then $v$ can't be less then $\sqrt3\;v_e$:
$v^2(h)=3v_e^2+v_e^2\frac{R}{h}$

P.S. Initial velocity equation can be easily derived from the equation of energy conservation
$\large {\frac{mv_o^2}{2}-\frac{GMm}{R}=\frac{mv^2}{2}-\frac{GMm}{h}}$
and formula of escape velocity:
$\large {v_e=\sqrt{\frac{2GM}{R}}}$

A: I don't know if it will help you, but what you are missing is the basic insight of calculus if you want. This lack of understanding generated paradoxes since the time of the Greeks. See "Achilles and the tortoise" on Wikipedia.
The basic point is that you can sum an infinite number of "intervals" (real numbers) and obtain a finite result.
For example if you sum $\frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \cdots$ you get 1 (perfectly finite).
The idea is the same with the deceleration. Deceleration reduces the velocity a little bit in a certain time interval, than you are farther away, deceleration becomes smaller and reduces the velocity again but a little less then before, etc. The point is the the sum of all the small reductions of velocity is finite and if this sum is smaller than the initial velocity the velocity will never reach zero and the teapot will always be flying farther away never coming back.
For example if the initial velocity is 2 and the deceleration reduces the velocity in little steps like this $2 -\frac{1}{2} -\frac{1}{4} -\frac{1}{8} -\frac{1}{16}\cdots$ the final velocity is $2-1=1$, still positive! If it started with velocity less than $1$, the velocity would become negative and the teapot will fall back on the planet. I hope it helps your intuition, but study calculus, it is useful ;)

A: I will be assuming only that you know about energy conservation and, in particular, the formula for the teapot's energy $$E= \frac{1}{2} m v^2 -\frac{ G M m}{r}$$ where $v$ is the speed and $r$ is the distance from the teapot to the centre of the Earth.
We know this is constant. Consider an arbitrarily large distance $r$; if we can solve for $v$, i.e if $v^2>0$ given the energy and masses, then the teapot can  reach this distance and, with nothing to stop it, will reach greater and greater distances. Since $\frac{ G M m}{r}$ tends to zero as $r$ increases without bound the condition is that $E>0$ in order for the teapot to escape. Fixing $r=R_{earth}$ and setting $E=0$---as this is the threshold for escape--- allows us to solve for the escape velocity at the surface of the Earth.
By this reasoning you can think of $E$ as the "kinetic energy at infinity": if the teapot still has some left then it can actually reach it.

A: Every field has a boundary condition in which it is valid . The region of field there is always energy stored . To overcome this energy we need some external energy (may be mechanical) . So this can happen only when there is external fore acting on the body which will change the KE of the body , helping the body to go out of the field and hence some velocity is present i.e. known as escape velocity .


text:
Q: I am unable to make a http call while running my ionic v4 app in browser I want to run my Ionic 4 app in browser and make a http post request. The request is sent, when the app is running on a mobile device but it doesn't work in the browser.
 this.http.post(
    url,
    {
        "req": 2,
        "userId": username,
        "password": password,
        "orgId": 1,
        "device_id": "",
        "device_type": "android",
        "regd_id": "",
        "build_type": "production"
    },
    { 'Content-Type': 'application/json'}
    ).then(async data => {
        //some logic
    }).catch(error => {
        //Error Handling
    });
});

A: if you are using the plugin cordova-plugin-advanced-http
and used the code:
import { HTTP } from '@ionic-native/http/ngx';

It not posible running this on browser because is a function that use native http of device, the same browser say that on console.

If you want to use on browser need to use:
import { HttpClient } from '@angular/common/http';

If you want to run the app in parallel (mobile/browser) need to import both plugin and use the plugin Platform and use the code to use the correspondent:
this.platform.is("ios" || "android" || "desktop")
I'm not sure about the platform names that return the plugin but do test to know it.

I hope I've helped :)


text:
Q: Exceptions being mishandled between Serilog Http sink and reading in http controller endpoint by LogEventReader So for my job I need to funnel logs from all our services to a logging api. I decided to use the Serilog.Sinks.Http v8.0.0 to send logs to a asp api service. The configuration of the the services that send to the api are as follows:
LoggerConfiguration config = new LoggerConfiguration()
            .MinimumLevel.ControlledBy(loggingLevelSwitch)
            .Enrich.FromLogContext()
            .Enrich.WithExceptionDetails()
            .Enrich.WithMachineName()
            .Enrich.WithEnvironmentName()
            .WithPdxProperties()
            .WriteTo.Http(logAddress, period: TimeSpan.FromMilliseconds(500), textFormatter: new CompactTextFormatter(), queueLimitBytes: null)
            .WriteTo.Console();

The controller endpoint is as show below:
[HttpPost]
public void Post([FromBody] LogEvents body)
{
    _logger.LogInformation($"Received batch of {LogFields.COUNT_NUM} log events.", body.Events.Length);
    foreach (JObject jsonEvent in body.Events)
    {
        LogEvent logEvent = LogEventReader.ReadFromJObject(jsonEvent);
        Serilog.Log.Write(logEvent);
    }
}

When I get a log event with an exception in it the jsonEvent will look as follows when converted to json:
    {
   "@t":"2022-09-01T13:42:41.467405Z",
   "@mt":"Unhandled exception.",
   "@l":"Error",
   "@x":"MassTransit.SendException: Exception of type 'MassTransit.SendException' was thrown.\r\n   at Program.<Main>$(String[] args) in C:\\Users\\hostname\\Documents\\Github\\Solution\\Dotnet.Project\\Program.cs:line 73",
   "ExceptionDetail":{
      "HResult":-2146233088,
      "Message":"Exception of type 'MassTransit.SendException' was thrown.",
      "Source":"Project.Source",
      "TargetSite":"Void MoveNext()",
      "MessageType":null,
      "Uri":null,
      "Type":"MassTransit.SendException"
   },
   "MachineName":"MACHINE",
   "EnvironmentName":"Development",
   "PdxAppName":"job-woopwoop",
   "PdxClientGroup":"default",
   "PdxAppType":"woop"
}

Now this is where I run into difficulty. When the reader gets the json object and turns it into a LogEvent I lose valuable information and it turns into this:
{
   "Timestamp":"2022-09-01T13:42:41.467405+00:00",
   "Level":4,
   "MessageTemplate":{
      "Text":"Unhandled exception.",
      "Tokens":[
         {
            "Length":20,
            "Text":"Unhandled exception.",
            "StartIndex":0
         }
      ]
   },
   "Properties":{
      "ExceptionDetail":{
         "TypeTag":null,
         "Properties":[
            {
               "Name":"HResult",
               "Value":{
                  "Value":-2146233088
               }
            },
            {
               "Name":"Message",
               "Value":{
                  "Value":"Exception of type 'MassTransit.SendException' was thrown."
               }
            },
            {
               "Name":"Source",
               "Value":{
                  "Value":"Project.Source"
               }
            },
            {
               "Name":"TargetSite",
               "Value":{
                  "Value":"Void MoveNext()"
               }
            },
            {
               "Name":"MessageType",
               "Value":{
                  "Value":null
               }
            },
            {
               "Name":"Uri",
               "Value":{
                  "Value":null
               }
            },
            {
               "Name":"Type",
               "Value":{
                  "Value":"MassTransit.SendException"
               }
            }
         ]
      },
      "MachineName":{
         "Value":"MACHINE"
      },
      "EnvironmentName":{
         "Value":"Development"
      },
      "PdxAppName":{
         "Value":"job-woopwoop"
      },
      "PdxClientGroup":{
         "Value":"default"
      },
      "PdxAppType":{
         "Value":"woop"
      }
   },
   "Exception":{
      "Message":"This exception type provides ToString() access to details only.",
      "Data":{

      },
      "InnerException":null,
      "HelpLink":null,
      "Source":null,
      "HResult":-2146233088,
      "StackTrace":null
   }
}

How can I make it so that the exception object doesnt have the "This exception type provides ToString() access to details only." message and has the correct properties populated like the stack trace?


text:
Q: UITableView inside a UICollectionView: can't set value I have a UICollectionView with 4 UICollectionViewCells. Each cell contains a UITableView with a varying number of cells.
I have an array from which I need to pass a value (depending on the indexPath) into the cell. My problem is that it always gives me nil when I try to do this.
So for example I have this array:
let arrayOfStrings = ["test1", "test2", "test3", "test4"]

I have this code in my collection view's cellForItemAt method:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "testCollectionViewCell", for: indexPath) as! TestCollectionViewCell

    cell.myString = arrayOfStrings[indexPath.row]

    cell.label.text = "This text is set."
    return cell
}

The cell's label is set properly, but when I try to print myString in the cell's table view's cellForRowAt method it always returns nil.
I need the string because I plan to manipulate the table views depending on the string passed in.
So why is this happening and what can be done?

A: You can try like this
extension HomeViewController : UITableViewDelegate, UITableViewDataSource {
   func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  return 4
   }

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

  if indexPath.row == 0 {
    let cell = tableView.dequeueReusableCell(withIdentifier: "DealTableViewCell", for: indexPath) as! DealTableViewCell
    cell.DealCollectionView.dataSource = self
    cell.DealCollectionView.delegate = self
    cell.DealCollectionView.tag = 10101
    return cell
} else if indexPath.row == 1 {
    let cell = tableView.dequeueReusableCell(withIdentifier: "BusinessTableViewCell", for: indexPath) as! BusinessTableViewCell
    cell.BusinessCollectionView.dataSource = self
    cell.BusinessCollectionView.delegate = self
    cell.BusinessCollectionView.tag = 10102
    return cell
} else if indexPath.row == 2 {
    let cell = tableView.dequeueReusableCell(withIdentifier: "FilterTableViewCell", for: indexPath) as! FilterTableViewCell
    cell.FilterCollectionView.dataSource = self
    cell.FilterCollectionView.delegate = self
    cell.FilterCollectionView.tag = 10103
    return cell
} else {
    let cell = tableView.dequeueReusableCell(withIdentifier: "ComboTableViewCell", for: indexPath) as! ComboTableViewCell
    cell.ComboCollectionView.dataSource = self
    cell.ComboCollectionView.delegate = self
    cell.ComboCollectionView.tag = 10104
    return cell
   }
  }
}

Add the collection view to each tableview cell and set delegate in tableview cell
   extension HomeViewController : UICollectionViewDelegate, UICollectionViewDataSource {

  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  if collectionView.tag == 10101 {
    return 3
  } else if collectionView.tag == 10102 {
    return 3
  } else if collectionView.tag == 10103 {
    return 3
  } else if collectionView.tag == 10104 {
    return 3
 }
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    if collectionView.tag == 10101 {
    let cell = collectionView.dequeueReusableCell(withIdentifier: "DealCollectionViewCell", for: indexPath) as! DealCollectionViewCell

    return cell
} else if collectionView.tag == 10102 {
    let cell = collectionView.dequeueReusableCell(withIdentifier: "BusinessCollectionViewCell", for: indexPath) as! BusinessCollectionViewCell

    return cell
} else if collectionView.tag == 10103 {
    let cell = collectionView.dequeueReusableCell(withIdentifier: "FilterCollectionViewCell", for: indexPath) as! FilterCollectionViewCell

    return cell
} else if collectionView.tag == 10104 {
    let cell = collectionView.dequeueReusableCell(withIdentifier: "ComboCollectionViewCell", for: indexPath) as! ComboCollectionViewCell

    return cell
}

return UICollectionViewCell()
}
}

For reload the collectionView in use
if let cell = self.tableView.cellForRow(at: IndexPath(row: i, section: 0)) as?
tableViewCell {
  cell.collectionView.reloadData()
 }


text:
Q: Understanding segment group, bus, device and function numbers from SMBIOS Objective
I'm trying to programmatically find out on which physical slot a particular PCIe device is connected.  The premise is that I have the PCI-ID of a card that is surely occupying a slot, and the solution would be finding out which one.
Note that I'm only interested in working on the PCI Express bus, although the device identification/enumeration process I think is the same as the old PCI.
Attempt
The SMBIOS contains information about the motherboard slots available.  It is possible to examine this information from the linux command line:
$ sudo dmidecode -t slot
# dmidecode 2.11
SMBIOS 2.7 present.

Handle 0x003A, DMI type 9, 17 bytes
System Slot Information
    Designation: PCIEX16_1
    Type: x16 PCI Express x16
    Current Usage: In Use
    Length: Short
    ID: 1
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:03:02.0

Handle 0x003B, DMI type 9, 17 bytes
System Slot Information
    Designation: PCIEX16_2
    Type: x8 PCI Express x8
    Current Usage: In Use
    Length: Short
    ID: 2
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:04:02.2

Handle 0x003C, DMI type 9, 17 bytes
System Slot Information
    Designation: PCIEX16_3
    Type: x16 PCI Express x16
    Current Usage: In Use
    Length: Short
    ID: 3
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:05:03.0

However, I can't find any device in the PCI bus (lspci) that has a PCI ID of 0000:03:02.0, 0000:04:02.2 or 0000:05:03.0.  What I know by manual inspection is the following:

*

*Card 0000:03:00.0 is in the first slot.  The PCI bridge appears to be 0000:00:02.0

*Card 0000:04:00.0 is in the second slot.  The PCI bridge appears to be 0000:00:02.2

*Card 0000:05:00.0 is in the third slot.  The PCI bridge appears to be 0000:00:03.0
So a pattern emerges here.  From the SMBIOS structure, the bus number is the one given to the card that is plugged in but the device/function numbers are the same as the corresponding PCI bridge.
Is this pattern just a coincidence in my motherboard or there is a rationale behind?  It is an Asus motherboard, with an AMI BIOS.  I've read that some BIOSes do not provide accurate information about their slots so I would like to know how much generality I can achieve.
Any hint or pointer to reference documentation is also greatly appreciated.

A: You may find the lspci command helpful.  Here's a sample output:
# lspci -v -t
-[0000:00]-+-00.0  Intel Corporation 5500 I/O Hub to ESI Port
           +-01.0-[01]--+-00.0  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           |            \-00.1  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           +-03.0-[02]--+-00.0  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           |            \-00.1  Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet
           +-07.0-[04]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-09.0-[05]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-14.0  Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers
           +-14.1  Intel Corporation 7500/5520/5500/X58 I/O Hub GPIO and Scratch Pad Registers
           +-14.2  Intel Corporation 7500/5520/5500/X58 I/O Hub Control Status and RAS Registers
           +-1a.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4
           +-1a.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5
           +-1a.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2
           +-1c.0-[03]----00.0  LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator]
           +-1d.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1
           +-1d.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2
           +-1d.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1
           +-1e.0-[06]----03.0  Matrox Electronics Systems Ltd. MGA G200eW WPCM450
           +-1f.0  Intel Corporation 82801IB (ICH9) LPC Interface Controller
           \-1f.2  Intel Corporation 82801IB (ICH9) 2 port SATA Controller [IDE mode]


text:
Q: Program doesn't copy files properly It just copies the first letter of the file name and file type is .file instead of the real one.
The program can be used to sort and copy files into different directories (years and quarters) according to their LastWriteTime.
void sort(std::string quartal, const char * c_pfad, SYSTEMTIME datum, WIN32_FIND_DATA *wfd_p){
            year = datum.wYear;
            str_year =  patch::to_string(year);             // convert

            year_path = dir + str_year + "\\";  // C:\\Pictures\\2015\\

            CreateDirectory(convert(year_path), NULL);                              // year-dir

            quartal_path = year_path + quartal; // C:\\Pictures\\2015\\Erstes Quartal\\

            CreateDirectory(convert(quartal_path), NULL);                               // quarter-dir

            ziel = quartal_path + *wfd_p->cFileName;

            CopyFile( c_pfad, convert(ziel), false );

}

void schleife(const char* file){
WIN32_FIND_DATA wfd;
HANDLE fHandle = FindFirstFile(file,&wfd);

do
{
    // Neither . nor ..  (subdirectories)
    if (!( (wfd.cFileName[0]=='.') && ( (wfd.cFileName[1]=='.' && wfd.cFileName[2]==0) || wfd.cFileName[1]==0 ) ))
    {
        if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {

              findDirGes = findDirGes.substr (0, findDirGes.size()-1) + wfd.cFileName + "\\*";
              schleife(convert(findDirGes));                             // no file but directory

        }
        else
        {
           pfad = findDirGes.substr (0, findDirGes.size()-1) + wfd.cFileName;

          WIN32_FILE_ATTRIBUTE_DATA dateidaten;

          GetFileAttributesEx(convert(pfad), GetFileExInfoStandard, &dateidaten);
          // cprintf("\n %d", dateidaten.ftLastWriteTime);

          FILETIME test = dateidaten.ftLastWriteTime;
          // cprintf("\n %d", test);
          SYSTEMTIME datum;

          FileTimeToSystemTime(&test, &datum);

        switch (datum.wMonth){
        case 1:
        case 2:
        case 3:
            sort("Erstes Quartal\\", convert(pfad), datum, &wfd );
            break;
        case 4:
        case 5:
        case 6:
            sort("Zweites Quartal\\", convert(pfad), datum, &wfd );
            break;
        case 7:
        case 8:
        case 9:
            sort("Drittes Quartal\\", convert(pfad), datum, &wfd );
            break;
        case 10:
        case 11:
        case 12:
            sort("Viertes Quartal\\", convert(pfad), datum, &wfd );
            break;
  }

        }
    }
}
while (FindNextFile(fHandle,&wfd));
FindClose(fHandle);
}

*The problem of the program is that it goes through all the files in the directory you typed in and if it comes to another directory it sorts and copies the files perfectly but after that it doesn't continue with the files (or directories) in the directory above.
Thanks for your help.

A: Using only one global variable WIN32_FIND_DATA wfd; for all the recursive calls is an error. Use a separate local variable each time you need to recurse.
void schleife(const char* file)
{
    WIN32_FIND_DATA wfd; // local variable
    HANDLE fHandle = FindFirstFile(file, &wfd);
    do
    {
        ...
        schleife(convert(findDirGes)); // recursive call
        ...
    }
    while (FindNextFile(fHandle, &wfd));
    FindClose(fHandle);
}


text:
Q: What are idioms that are antonymous to "don't skimp on"? The idiom "don't skimp on" means don't be shy and put as much as necessary. I am now wondering if there are idioms that mean the opposite of that. I am sure there are many, but it's hard to look for idioms since you can't look them up on a dictionary unless you know them.
For example:

Please, don't skimp on the butter. It's good stuff!

A: You could say:
"Go easy on the ..."
"Light on the ..."
"Don't over-do it on ..."
"Be sparing with ..."
"Don't get carried away with the ..."
"Take it easy with the ..."
"Be judicious with ..."
"Use a light touch with the ..."
or even the simple, "Not too much ..."

A: We are unlikely to use the antonym in the imperative form. We don't tell people to "use less than is needed".
There are plenty of ways to describe someone using less of something

He was scrimping (and saving)
  He was being frugal
  He was stingy
  He was mean with the butter
  He was being careful with the butter.

These have a different nuance.  Being "frugal" and "careful" are generally positive. Being mean or stingy are negative.

A: Please give me  [just adjectives]
-  just a little butter.
- a tad of butter.
- just a dab of butter.
- just a teeny bit of butter.
Actual idioms:
Please go light on the butter. To go light on butter or cream or sugar. Anything you add to food or drink.
Please don't overdo it on the butter. [not too much, same as above]
Please hold off on the butter. [not any]


text:
Q: "parameter `'a` is never used" error when 'a is used in type parameter bound use std::iter::Iterator;

trait ListTerm<'a> {
    type Iter: Iterator<Item = &'a u32>;
    fn iter(&'a self) -> Self::Iter;
}

enum TermValue<'a, LT>
where
    LT: ListTerm<'a> + Sized + 'a,
{
    Str(LT),
}

error[E0392]: parameter `'a` is never used
 --> src/main.rs:8:16
  |
8 | enum TermValue<'a, LT>
  |                ^^ unused type parameter
  |
  = help: consider removing `'a` or using a marker such as `std::marker::PhantomData`

'a clearly is being used. Is this a bug, or are parametric enums just not really finished? rustc --explain E0392 recommends the use of PhantomData<&'a _>, but I don't think there's any opportunity to do that in my use case.

A: DK. answered how to circumvent the issue (by using PhantomData as suggested), and hinted that the issue was that 'a was unused in the definition, but why would the compiler care about that?
'a is a lifetime marker. It is used by the borrow-checker to identify the relationship between the lifetime of different objects, as well as their borrow status.
When borrowing an object, you may borrow it either mutably (&mut T) or immutably (&T), and in accordance with the Mutability XOR Aliasing principle underpinning Rust's memory safety it changes everything:

*

*You can have multiple concurrent &T

*You can only have a single &mut T, and it excludes concurrent &T
When you parameterize your struct or enum with 'a, you announce your intention to borrow something whose lifetime will be some 'a. You do not, however, announce whether you will be borrowing mutably or immutably, and this detail is critical.
The compiler, therefore, will peer at the internals of your data type and check whether you use a mutable or immutable reference to deduce, by itself, which kind of borrow will occur when you use the data type.
And here, because 'a is unused, it cannot find any such use and therefore cannot compile your code.

It is arguable whether the compiler peering inside the data type is a good thing or not, since changing the internals of this data type (from &T to &mut T) could lead to compilation failures without changing the type interface.
It is important, thus, to remember that how you use the generic parameters (owning, borrowing mutably or borrowing immutably) is NOT an implementation detail.

A: If you aren't using an associated type (like <LT as ListTerm<'a>>::Iter) in the enum definition, you probably don't need to make 'a a parameter at all.
I assume you want the LT: ListTerm<'a> bound so that you can write one or more fns or an impl that uses LT as a ListTerm. In which case, you can easily parameterize the type with just <LT>, and put the 'a generic and trait bound only on the items that require it:
trait ListTerm<'a> {
    type Iter: Iterator<Item = &'a u32>;
    fn iter(&'a self) -> Self::Iter;
}

enum TermValue<LT> {  // no 'a parameter here...
    Str(LT),
}

impl<'a, LT> TermValue<LT>  // ... just here
where
    LT: ListTerm<'a>,
{
    fn iter(&'a self) -> LT::Iter {
        match *self {
            TermValue::Str(ref term) => term.iter(),
        }
    }
}

Some standard library types like std::collections::HashMap<K, V> do this: the K: Hash + Eq bound isn't on the type itself. Alternatively, you could have a where clause on each method where the bound is needed. The difference between a where clause on an impl and one on a fn is not significant unless you're implementing a trait (see this question).
The main reason for using PhantomData is that you want to express some constraint that the compiler can't figure out by itself. You don't need PhantomData to express "Any TermData<LT> is only valid as long as its contained LT is valid", because the compiler already enforces that (by "peering inside" the type, as in Matthieu's answer).

A:
'a clearly is being used.

Not as far as the compiler is concerned.  All it cares about is that all of your generic parameters are used somewhere in the body of the struct or enum.  Constraints do not count.
What you might want is to use a higher-ranked lifetime bound:
enum TermValue<LT>
where
    for<'a> LT: 'a + ListTerm<'a> + Sized,
{
    Str(LT),
}

In other situations, you might want to use PhantomData to indicate that you want a type to act as though it uses the parameter:
use std::marker::PhantomData;

struct Thing<'a> {
    // Causes the type to function *as though* it has a `&'a ()` field,
    // despite not *actually* having one.
    _marker: PhantomData<&'a ()>,
}

And just to be clear: you can use PhantomData in an enum; put it in one of the variants:
enum TermValue<'a, LT>
where
    LT: 'a + ListTerm<'a> + Sized,
{
    Str(LT, PhantomData<&'a ()>),
}


text:
Q: Calling Barcodescanner from another class, cant retrieve the data? I'm trying to open the barcode scanner from class "Partynallen" with a button placed in "NewViewController". I can get the barcode to open and scan stuff, but the image freezes and no result is being passed. What could i possibly be doing wrong?
Appreciate any help provided, thanks in advance.
import AVFoundation
import QRCodeReader
import Alamofire

class Partynallen: UIViewController, QRCodeReaderViewControllerDelegate {

    lazy var readerVC: QRCodeReaderViewController = {
    let builder = QRCodeReaderViewControllerBuilder {
    //change object to scan and the initial position of the camera
        $0.reader = QRCodeReader(metadataObjectTypes: [.qr, .ean13], captureDevicePosition: .back)
    // Configure the view controller (optional)
    $0.showTorchButton = true
    $0.showSwitchCameraButton = false
    $0.showCancelButton = true
    $0.showOverlayView = true //shows the square area of the QRCode Scanner
        $0.rectOfInterest = CGRect(x: 0, y: 0, width: 1, height: 1)
    }
    return QRCodeReaderViewController(builder: builder)
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        readerVC.delegate = self
    }

    func reader(_ reader: QRCodeReaderViewController, didScanResult result: QRCodeReaderResult) {
    //code to be added
        reader.stopScanning()
        //print(result)
        //print(result.value)
        //barcode = result.value
       //Apifetch(code: "URL")
        dismiss(animated: true, completion: nil)
    }

    func readerDidCancel(_ reader: QRCodeReaderViewController) {
    //code to be added
        reader.stopScanning()
        dismiss(animated: true, completion: nil)
    }

}

class NewViewController: UIViewController {

    let partynallen= Partynallen()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        partynallen.readerVC.delegate = partynallen.self // DONT KNOW IF THIS IS CORRECT?
    }

        @IBAction func scan(_ sender: UIButton) {

            partynallen.readerVC.modalPresentationStyle = .formSheet
            present(partynallen.readerVC, animated: true)
    }

}


text:
Q: Creating subdomains in Amazon EC2 How can I create subdomains on Amazon EC2?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
Thanks

A: Depends on your server software. But as you mention httpd.conf, chances are good that you run Apache on a Linux distribution. If that's the case then yes, adding a virtual host is enough. Here is one way of doing it:

*

*Purchase a domain. If you have one, skip this, we'll take example.com for this example.

*Find the external IP or DNS for your EC2 instance. You probably want to associate an Elastic IP to your instance, otherwise the IP of your instance will change on reboots.

*Create a DNS record for your domain, for instance a CNAME record to point to your Elastic IP/DNS name:
subdomain.example.com => ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com

*Make sure your httpd.conf contains a line to allow virtual hosts:
NameVirtualHost *:80

*Create a virtual host directive:
httpd.conf:
<VirtualHost *:80>
  ServerName subdomain.example.com
  ServerAdmin webmaster@subdomain.example.com

  DocumentRoot /var/www/example.com/subdomain

  <Directory /var/www/example.com/subdomain>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

  ErrorLog /var/log/apache2/subdomain.example.com.error.log
  LogLevel warn
  CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>

6. Restart Apache
/etc/init.d/apache2 restart


text:
Q: PHP - How to get year, month, day from time string Given the following timestring:
$str = '2000-11-29';

$php_date = getdate( $str );
echo '
';
print_r ($php_date);
echo '
';

How to get the year/month/day in PHP?
[seconds] => 20
[minutes] => 33
[hours] => 18
[mday] => 31
[wday] => 3
[mon] => 12
[year] => 1969
[yday] => 364
[weekday] => Wednesday
[month] => December
[0] => 2000

I don't know why I get 1969 for year.
Thank you

A: You can use strtotime to parse a time string, and pass the resulting timestamp to getdate (or use date to format your time).
$str = '2000-11-29';

if (($timestamp = strtotime($str)) !== false)
{
  $php_date = getdate($timestamp);
  // or if you want to output a date in year/month/day format:
  $date = date("Y/m/d", $timestamp); // see the date manual page for format options
}
else
{
  echo 'invalid timestamp!';
}

Note that strtotime will return false if the time string is invalid or can't be parsed. When the timestamp you're trying to parse is invalid, you end up with the 1969-12-31 date you encountered before.

A: Using the object-oriented programming style, you can do this with DateTime class
$dateFormat = 'Y-m-d';
$stringDate = '2000-11-29';
$date = DateTime::createFromFormat($dateFormat, $stringDate);

Then, you can decompose your date using the format() method
$year = $date->format('Y'); // returns a string

If you prefer the numeric format, instead of the string format, you can use the intval() function
$year = intval($date->format('Y')); // returns an integer

Here some formats that you can use

*

*Y A full numeric representation of a year, 4 digits

*m Month of the year, 2 digits with leading zeros

*d Day of the month, 2 digits with leading zeros

*H 24-hour format of an hour, 2 digits with leading zeros

*i Minutes, 2 digits with leading zeros

*s Seconds, 2 digits with leading zeros

Here the entire list of the formats that you can use : http://php.net/manual/en/function.date.php

A: PHP - How to get year, month, day from time string
$dateValue = strtotime($q);

$yr = date("Y", $dateValue) ." ";
$mon = date("m", $dateValue)." ";
$date = date("d", $dateValue);

A: Update: Forgot to add semicolon at end of first line, try this:
<?php
$str = "2010-08-29"; // Missed semicolon here
$time = strtotime($str);

// You can now use date() functions with $time, like
$weekday = date("l", $time); // Wednesday or whatever date it is
?>

Hopefully that will get you going!

A: PHP - we can get year, month, day from time string in many formats.
$dateFromDb = '2021-2-6 13:15:19';

if (($timestamp = strtotime($dateFromDb)) !== false) {
    // auto format full time
    $php_date = getdate($timestamp);
    echo '
';
    foreach($php_date as $key =>$value){
        echo $key.'='.$value.'
';
    }

    // manually format time
    echo'-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
';
    echo '4 digit year =            '.date("Y", $timestamp).'
';
    echo '2 digit year =            '.date("y", $timestamp).'
';
    echo 'Month =                   '.date("m", $timestamp).'
';
    echo 'Day =                     '.date("d", $timestamp).'
';
    echo 'Time in 24 Hours Format = '.date("H", $timestamp).'
';
    echo 'Time in 12 Hours Format = '.date("h", $timestamp).'
';
    echo 'Minutes =                 '.date("i", $timestamp).'
';
    echo 'Seconds =                 '.date("s", $timestamp).'
';
    echo '-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
';
    // and we can combine format also.
    // and we can add '/' or ':' between year,month,days or anything we want.
    echo 'Time =  ' .date("H:i:s" ,$timestamp).'
';
    echo 'Date =  ' .date("d/m/Y" ,$timestamp).'
';

    } else {
        echo 'invalid date format.';
    }


text:
Q: Twilio adding custom attributes from studio into flex agent info bar I am using a "send to flex node" in my twilio studio application.
In this node I am passing:
{"verified": "{{flow.variables.verified}}", "accountid": "{{flow.variables.accountid}}"}

I have created a sample plugin but how can I modify it so that the existing agent info tab also displays those two parameters ? Maybe under CUSTOMER CONTEXT or in its own container?
I understand that they will need to be used as follows in the code :
${task.attributes.verified} and ${task.attributes.accountid}

Many thanks

A: You want to create a component that uses the task context so that it has access to the task object as one of its props. You can then add that component to the task info panel.
For example, here's an account component that displays the attributes you want:
import React from "react";
import { withTaskContext } from "@twilio/flex-ui";

function AccountComponent({ task }) {
  return

${task.attributes.verified} and ${task.attributes.accountid}

;
}

export default withTaskContext(AccountComponent);

Then, in your main plugin file, within the init function, add the component to the task info panel. Using sortOrder: -1 will place it at the top of the component.
import React from "react";
import { FlexPlugin } from "flex-plugin";
import AccountComponent from "./components/AccountComponent";

const PLUGIN_NAME = "FlexTaskInfoPlugin";

export default class FlexTaskInfoPlugin extends FlexPlugin {
  constructor() {
    super(PLUGIN_NAME);
  }

  init(flex, manager) {
    flex.TaskInfoPanel.Content.add(
      <AccountComponent key="account-component"></CustomerName>,
      { sortOrder: -1 }
    );
  }
}


text:
Q: Organizing an object to create keys when needed and/or push different attribute to value pair array The data structure that I am trying to achieve would look as so :
I would like the list_id to become a key in a object, and hold all the id's of the items that have the matching list id.
var lists = { (list_id)1 : [1, 2, 3]
              (list_id)2 : [4, 5, 6]
              (list_id)3 : [7, 8, 9]
              (list_id)4 : [10, 11, 12] };

this object is created from a json data structure that looks like this:
    let json = [{ id: 1, list_id: 1 }, { id: 2, list_id: 1 },
                {id: 3, list_id: 1 }, {id: 4, list_id: 2 },
                {id: 5, list_id: 2 }, {id: 6, list_id: 2 },
                {id: 7, list_id: 3 }, {id: 8, list_id: 3 },
                {id: 9, list_id: 3 }, {id: 10, list_id: 4  },
                {id: 11, list_id: 4 }, {id: 12, list_id: 4 }]

I can make an object that holds all the list_id's as keys but am getting stumped on pushing the actions_id into the value pair array with the matching list id.
 let listAll = {};

 json.forEach(function(lista, index, listb) {
   listAll[lista.list_id] = [];

   if ( listAll[lista.list_id] === lista.list_id){

      listAll[lista.list_id].push(lista.id)

    } else {

      listAll[lista.list_id] = [lista.id];

    }
});

My goal is to have and object that contains a key for every list_id currently avaliable from the actions.
Then add every action that contains the matching list_id into a value pair array.
the current output of this code is
{ '1': [ 3 ], '2': [ 6 ], '3': [ 9 ], '4': [ 12 ] }

which does not contain all numbers, each array should contain 3 numbers.

A: An alternative is using the function reduce to group the objects by a specific key = ['list_id', list_id].join('').

let json = [{ id: 1, list_id: 1 }, { id: 2, list_id: 1 },                 {id: 3, list_id: 1 }, {id: 4, list_id: 2 },                {id: 5, list_id: 2 }, {id: 6, list_id: 2 },                {id: 7, list_id: 3 }, {id: 8, list_id: 3 },                {id: 9, list_id: 3 }, {id: 10, list_id: 4  },                {id: 11, list_id: 4 }, {id: 12, list_id: 4 }],
    result = json.reduce((a, {id, list_id}) => {
      let key = ['list_id', list_id].join(''); // For example: this is creating ['list_id', 1] to list_id1
      (a[key] || (a[key] = [])).push(id);
      return a;
    }, Object.create(null)/*This is only to create an object without prototype -> {}*/);

console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }

A: Why don't you try hasOwnProperty instead?
var listAll = {};
json.forEach(function(list, index) {
  if (listAll.hasOwnProperty(list.list_id)) {
    listAll[list.list_id].push(list.id);
  }else {
    listAll[list.list_id] = [list.id];
  }
});
console.log(listAll);


text:
Q: Does dedicated maintenance work hamper a programmer's career? The majority of my work over the last three years has largely been around maintaining legacy systems that needed patching up or the occasional revamp before being sold again.
I understand the critical role dedicated maintenance programmers have to play in companies with a large number of projects and limited developers on hand.
But as I judge my current career progress and look at my peers; contractors and corporate developers alike; I do feel as if I am lagging far behind since I've gained a great deal of breadth in terms of the areas I've touched but not much depth.
I've begun to address this by starting a blog, working on my own little git-hub projects and rescheduling my life to have time to do personal coding after work on a regular basis.
I feel that were I to interview at other companies to escape maintenance work I would have to represent myself as being quite junior in skill level since I would not have the depth of level of knowledge required of a person with three years experience focused on a particular path in feature development would. So half my current work experience would count for naught in the long run.
But this leads me to my main questions, apologies if this feels too centered around my personal dilemma,:
Do dedicated maintenance programming roles end up being detrimental to an early career?
Are other programmers right to avoid roles like these?
Does doing this line of work lock you into doing similar tasks unless you're prepared to start over as a junior?

A:
Do dedicated maintenance programming roles end up being detrimental to an early career? Are other programmers right to avoid roles like these? Does doing this line of work lock you into doing similar tasks unless you're prepared to start over as a junior?

First up, you should know that you're considered a junior for quite a while. You may get arbitrary promotions because you're good and this is the only way to give you a decent payrise, but you'll still be considered a junior as you head on to your next job.
Second, if I'm hiring someone with 2-4 years' experience, I don't really care whether their work was purely maintenance. If you've spent 10 years in maintenance and I'm hiring for a greenfields project, I may have questions but, for the first few years, I honestly kind of expect it.
On the other hand, if I'm hiring someone who has NEVER worked in maintenance, I'm going to be more suspicious. I've had many candidates for jobs who have spent their first 4 years skipping from one "good" job to another and every single one has learned nothing about what makes for maintainable code. And, make no mistake, if I'm hiring for a greenfields project I intend to stick with, I don't care whether YOU are going to maintain the code, I care that you know how to leave it maintainable for future developers.
These other programmers you mention, who avoid jobs like these, generally avoid them because they're less fun, not because it hinders their career.
Finally, you should know that a very large percentage (I would conservatively guess at about 80%) of software development jobs are more than 50% maintenance.
So, to cut through all that and answer your question: No, I don't think it's going to hinder your career. Unless you stay there for far too long. The common rule of thumb is "once you start feeling like you're getting the same year of experience every year, it's time to go." If you feel, each year, like you're a better developer than you were last year, you're fine (and that goes for me, 20 years into my career, as much as you).

A:
Do dedicated maintenance programming roles end up being detrimental to an early career?

More often than not - YES, assuming:

*

*that career here means expertise in many different technical skills.

*that you spend more than X years there, where X is enough to "set" your ways of thinking.

*that you don't do anything aside.

*that "dedicated maintainer" (see EDIT, below) means you don't code to maintain as well as code new things, but that you almost always code to maintain or even work on a project in maintenance mode - no new features, required least changes in code to fix the bug.

This doesn't mean that is always the case.
People maintaining software rarely are encouraged (see EDIT, below) to do research, rarely can plug in new library or DB and spend few days finding out how it works. It's (usually) a steady job that requires minimal changes to existing code base and thus "shapes" the way you approach problems later on. I can name quite a few companies that have a policy for maintaining software that explicitly states "less changes in the code = better", despite bad things this can bring.

Are other programmers right to avoid roles like these?

I know very good maintainers who like their jobs and wouldn't want to apply for something else precisely because it's comfortable where they are. Not everybody likes to learn new things every now and then. So - avoid or look for it depending on your preferences.

Does doing this line of work lock you into doing similar tasks unless you're prepared to start over as a junior?

More often than not - YES. Because you already have experience doing that, because you already "know the ropes" etc. But shift is definitely possible and can happen without applying for a junior position. You already started doing things aside, keep at it! That's actually very worthwhile and can shrink the 'skill gap' you noticed.

EDIT: Dan has pointed out (very rightly), that maintenance tasks can often be done WITH research. That is true. I've changed the answer above in two places to better address this.
Such tasks surely COULD be done this way and if they are - great! However AFAIK most DEDICATED maintainers of LEGACY systems have policies or management expectations and deadlines that - again, more often than not - coerce them into solving the problem with least changes possible.
Often the pressure is high enough that even if you can do it this way, you may not want to. Especially if it's not YOUR code: without theory (as per Ryle and Naur) behind it you risk damaging more than you fix.
Nevertheless it should be noted: I don't have hard global data, I speak from my own experience - I worked in a situation as OP, I recruited people with 4 - 10 years of experience as maintainers, I talked to many maintainers and I know people working as dedicated maintainers. Not just people who code new things but also code to maintains a project - dedicated maintainers, who's only job is to do bugs and patches and not even one new feature, because it's old project and it's now only in "maintenance mode".

A: In any job, the experience you get is specific to what you are doing, which limits your range of possibilities when applying for other jobs based on that experience.  It isn't specific to maintenance.  I think other questions are more relevant than whether something is maintenance or new software development:

*

*How widespread are the specific technologies you are working with?  If you are maintaining something that is obsolete and rarely used elsewhere, then that would limit your future career opportunities (but so would developing new software for a system/platform/technology that is not widely used).

*How does your current work equip you for the work you want to do in the future?  Maintenance work, as you pointed out, is important and will always be around.  There is nothing wrong with having a career focused on this type of programming; there will always be lots of possibilities for system maintainers.  But maybe it is not what you want to do.  It is a concern if your current work is not preparing you for what you are interested in.

However, I would not be too worried.  One thing you say is:

I've gained a great deal of breadth in terms of the areas I've touched
  but not much depth.

Don't think of this as a problem, because it can be used to your advantage.  Having broad experience means there is a wide range of things to which you can say "yes, I have done that."  Lots of jobs ask for experience in several different technologies and tasks.  You would likely have an advantage over a developer who has very deep experience in one technology.
Furthermore, lots of jobs involve a mixture of maintenance and new development.  If you wanted to do more new development, you could use your existing maintenance experience to transition into a mixed role that will give you more development experience.
In conclusion, your resume is probably better than you think it is.  A lot of it will come down to how well you analyze the strengths of your experience, and then communicate those strengths in the application and interview process.

A:
I would have to represent myself as being quite junior in skill level since I would not have the depth of level of knowledge required of a person with three years experience focused on a particular path in feature development would

Correct. You would not be able to say "3 years experience designing systems from scratch using X, Y, and Z", you'd have to say "3 years experience MAINTAINING systems from scratch using X, Y, and Z" unless you want to out right lie on your CV.

I feel that were I to interview at other companies to escape maintenance work I would have to represent myself as being quite junior in skill level since I would not have the depth of level of knowledge required of a person with three years experience focused on a particular path in feature development would

If you want to say "I design and build systems from scratch" then yes, you would have to class yourself as junior.
What is quite common in IT, (and I'm not saying this is what you are doing) is for people to assume that because they have been working for X years, they have X years experience and after {indeterminate number of years} they should be considered a Senior {Widget} developer.
Now, don't get me wrong, there is nothing wrong with maintenance work, everybody has to do it at some time or another, but what you have realised is that being stuck doing that for too long will likely make it hard for you to get away from that role in the future. This often goes hand in hand with being "stuck" not learning newer technologies/tools/methods.
Ideally, you want a mix of "new" system work and legacy work.
On a positive note, you presumably have seen a lot of different architectures (good and bad), different approaches, how bad decisions can make the legacy programmers work much harder later down the line. These are all positives than can be accentuated.
Good luck!

A: Looking at this from a different angle, I think selling yourself as an expert in maintenance is a marketable opportunity.
As an owner of a software company that has multiple projects on the go, one of the biggest risks I have to minimise is developers who jump ship, and the subsequent maintenance of their code.
So assuming you're capable of growing passionate about maintenance work (which I would guess to be the case since you're prepared to blog about your experience), if you came to me offering your services as a maintenance guru - guaranteeing to polish all of my developers' various projects by refactoring, optimising and documenting their code for long-term maintainability - and you had a track record to back up your guarantee, I'd hire you in a flash.
My advice would be to give this a proper try. Position yourself as a maintenance expert and cultivate your blog. You may be on to something.


text:
Q: How can a bootable partition be created for Windows installation media on an external HDD? Now I'm not talking about a backup image or creating a partition that holds the entire OS to boot from, just to clarify. What I'm asking for is taking the Windows installation media, plopping that onto a partition on an external HDD, then plugging that HDD into another computer and having the ability to boot onto that partition from a BIOS menu. Is there a good way to go about this? I've seen quite a lot of tutorials out there for manipulating the Windows install media, so I hope this should be relatively easy. Any help is greatly appreciated!

A: You can create a simple FAT32 partition on that USB drive - size 8 GB (so you can accommodate images bigger than 4 GB)
Then mount the source ISO and copy ALL files (admin mode) to the created partition on USB.
Then you run
bootsect /nt60 z: /force /mbr

where z: is your partition on USB drive.
Check with "Disk Management" or diskpart.exe that the USB partition is marked as active and mark it as active if it is'nt.
Now you should be able to boot from this USB drive either BIOS or UEFI way on any computer.


text:
Q: Windows application and Spy++ I am unable to figure out why I can use Spy++ to get handle, window class etc of some windows application. For example, iexplore.exe, it just doesn't work on url text box or any text, edit box area if any in the page loaded; there are also windows application I get only the outer layer's properties whereas its internal buttons, textbox or combox are inaccessible. In these applications what should I do to reach them ? Thank you :)

A: These programs use windowless controls.
Instead of using standard Windows controls, they draw and process everything themselves within one giant container.


text:
Q: Protractor exited with error code 100 when run config.js A few days ago, my protractor was working fine. But yesterday when I tried to run the same tests, I got:
E/launcher - Error: Error: Cannot find module 'jasmine-reporters'
Require stack:
- D:\Repos\POS\config\config_c80_checkScreen.js
- C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\configParser.js
- C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\launcher.js
- C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\cli.js
- C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\bin\protractor
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
   at Function.Module._load (internal/modules/cjs/loader.js:686:27)
   at Module.require (internal/modules/cjs/loader.js:848:19)
   at require (internal/modules/cjs/helpers.js:74:18)
   at onPrepare (D:\Repos\POS\config\config_c80_checkScreen.js:62:28)
   at C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\util.js:46:49
   at Function.promise (C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:682:9)
   at Object.runFilenameOrFn_ (C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\util.js:38:16)
   at C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\built\runner.js:98:27
   at _fulfilled (C:\Users\ingridd\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
Closing report
[11:03:30] E/launcher - Process exited with error code 100

On my project folder, I have the protractor-jasmine2-screenshot-reporter folder as you can see on the screenshot
jasmine2 folder
Please see where the ENV var is located
env var
The last thing I tried was to update the web driver and install the latest protractor. But I still get the same error.
Any suggestion is appreciated.

A: Error 100 is RUNNERS_FAILED_EXIT_CODE which is because there is an unexpected error. The error looks like you are missing the jasmine-reporters. npm install -S jasmine-reporters should fix it.


text:
Q: Creation of a Custom Data Entry I would like to know if it's possible to create a custom data entry that pulls in data via an external database hosted in heroku. Will it be opening an API on my side? or would i be posting on a scheduled basis to a specific API in SFMC?
As of now, majority of the answers has been to pull in data via existing data extensions. And if so, am i able to replicate the functionality of how Salesforce Data Entries work?
My current connection is SFDC <-> Marketing Cloud Connect <-> SFMC

A: You would need to make calls to the Journey Builder API from your side in a similar way to the fashion CRM Flows make calls to the Journey Builder Events API for Salesforce Data entry events. The actual Salesforce events make use of an undocumented batch endpoint interaction-experimental/v1/batchcontactevents which is very similar, but allows you to fire multiple events in a single call.
If you have some means of configuring triggers in your Heroku DB somewhat like the Flows defined by the Salesforce Data UI in Journey Builder, it's possible extend Journey Builder, see a Sample Entry Event and UI. Not trivial and you may find it easier to just to fire regular API Events from Heroku.


text:
Q: take no of neighbours from the given index of list. what is the best practice or effiecient performance for given solution? I want to take (c=3) number of elements from the given index (idx) of (a_list) list.
Input:
a_list = [1,2,3,4,5,6,7,8,9,10]
idx = 4
c = 3        # no of neighbours to take

Output:
[2,3,4,6,7,8]
Solution 1: Append forward and backward elemnts through separate loops.
def get_result(a_list, idx, c):

  for i in range(1,c+1):
    result.append(a_list[idx - i])

  for i in range(1,c+1):
    result.append(a_list[idx + i])

  return result

Solution 2: Make two separate list for forward and backward elements with one for loop and merge.
def get_result(a_list, idx, c):
  forward_list, backward_list = [],[]

  for i in range(1,c+1):
    forward_list.append(a_list[idx - i])
    backward_list.append(a_list[idx + i])

  result = [forward_list, backward_list]
  return result

A: It would be better to use slices and not use loops to construct the result manually:
def get_result(a_list, idx, c):
    return a_list[idx-c:idx] + a_list[idx+1:idx+c+1]

>>> get_result([1,2,3,4,5,6,7,8,9,10], 4, 3)
[2, 3, 4, 6, 7, 8]

After all, your use case is exactly what slices are for: extract a contiguous [or at least regular] subsequence of a sequence.
Since idx-c might turn out to be negative, you might add some logic to cover that case, e.g. you could use
a_list[max(0, idx-c):idx]

for the first summand.


text:
Q: selenium doesnt display all of webpage I am working on a scraper that will search through an employee's page on bluepages (an internal IBM website), and get employee name, department, and download a copy of their resume. unfortunately, when i run open the web-page with selenium, it only loads the top part of the page, and nothing else. I have tried switching into Iframes, as well as waiting for elements to load. when opening the site in Firefox, all parts of the page open up immediately, and don't require a button press.
Any help would be greatly appreciated


text:
Q: How to hide tr tag in a table if the td has NIL value using JavaScript/JQuery? I am currently having problem hiding tr tag if the td tag has NIL value using javascript, below is the code for table and it occurs as the 3rd table as i am currently developing an chrome extension and that matters so as to target it.
Here is what i tried in jquery but i need to do this in javascript:
$('tr').each(function(){
    var tr = $(this);
    if (tr.find('td:eq(0)').text()=="NIL"
        && tr.find('td:eq(1)').text()=="NIL"
        && tr.find('td:eq(2)').text()=="NIL"
    ) tr.addClass('hidden');
});

Here is the table code:

                Assignments

                NIL

                NIL

                NIL

                NIL

                NIL

A: This is what you want:

$("table td:contains('NIL')").closest("tr").css("color", "red");

/* ABOVE HERE IS JUST FOR DEMO CHANGING OF COLOR
   BUT USE FOLLOWING TO HIDE
$("table td:contains('NIL')").closest("tr").hide();
*/

      Assignments

      NIL

      NIL

      NIL

      NIL

      NIL

      Not a " N I L"

Update:

$("table table table td:contains('NIL')").closest("tr").css("color", "red");

/* ABOVE HERE IS JUST FOR DEMO CHANGING OF COLOR
   BUT USE FOLLOWING TO HIDE
$("table td:contains('NIL')").closest("tr").hide();
*/
table {
  border: 1px solid #000;
}

                  Assignments

                  NIL

                  NIL

                  NIL

                  NIL

                  NIL

                  Not a " N I L"

          Second Table

    First Table


text:
Q: Cannot Read Layers in Unity3d Camera Culling Mask I am using Unity 5.5 on Ubuntu 16.10. I have a camera culling mask with a specific set of layers.
However, in the Unity editor interface, the culling mask dropdown does not display checks next to the layers I have selected. As a result, when I have too many layers selected, the field reads Mixed ..., and I can not see which layers I set the mask to use.
When I log camera.cullingMask, I get a strange integer I can not comprehend. How can I programmatically see which layers I selected in a culling mask?

A: I have the same problem on Ubuntu and no solution for the check-mark-bug.
However, I'll try to explain the strange integer that you get from the property. It is a bit field, where each layer is assigned a value:
Layer name       | Layer Number | Mask value
Builtin Layer 0  |            0 | 1 << 0 =     1
Builtin Layer 1  |            1 | 1 << 1 =     2
Builtin Layer 2  |            2 | 1 << 2 =     4
Builtin Layer 3  |            3 | 1 << 3 =     8
Builtin Layer 4  |            4 | 1 << 4 =    16
Builtin Layer 5  |            5 | 1 << 5 =    32
Builtin Layer 6  |            6 | 1 << 6 =    64
Builtin Layer 7  |            7 | 1 << 7 =   128
User Layer 1 / 8 |            8 | 1 << 8 =   256
User Layer 2 / 9 |            9 | 1 << 9 =   512
...

(It seems that User Layer names may start at 1 or at 8 depending on the Unity version)
You can combine these values, for example Builtin Layer 5and User Layer 9 would result in 1 << 5 | 1 << 9 = 2^5 | 2^9 = 32 | 512 = 32 + 512 = 544.
Read more about Layer masks in the documentation.