text:
Q: Columns evaluating to null correction Table 1:
ID   email
A    a@gmail.com

Table 2:
ID   email2        email3   email4
A    a@gmail.com   null     ab@gmail.com

Query:
select T1.ID, T1.email,
case when T1.email<>T2.email2 then T2.email2 end email2,
case when T1.email<>T2.email3 and T2.email2<>T2.email3 then T2.email3 end email3,
case when T1.email<>T2.email4 and T2.email2<>T2.email4 and T2.email3<>T2.email4 then T2.email4 end email4
from t1
left join t2 on t1.id=t2.id

Output:
ID  email         email2   email3   email4
A   a@gmail.com   null     null     null

Expected Output:
ID  email         email2   email3   email4
A   a@gmail.com   null     null     ab@gmail.com

It looks like email4 evaluates to null because email3 is null. I think I understand why as per Why does NULL = NULL evaluate to false in SQL server, but is there an easy way for me to avoid that from happening? The real query is alot more complex and if I add something like isnull(value,'') around every variable in the case statement to avoid comparing to a null value, that can get abit much.
Note that I dont have permission to change ansi_nulls settings and such

A: Because NULL means

I don't know.

So you can try to add check IS NULL in each CASE WHEN columns
 CREATE TABLE Table1(
  ID VARCHAR(50),
  email VARCHAR(50)
);

INSERT INTO Table1 VALUES ('A','a@gmail.com');

CREATE TABLE Table2(
  ID  VARCHAR(50),
  email2 VARCHAR(50),
   email3 VARCHAR(50),
    email4 VARCHAR(50)
);

INSERT INTO Table2 VALUES ('A','a@gmail.com',null,'ab@gmail.com');

Query 1:
select T1.ID, T1.email,
case when T1.email<>T2.email2  then T2.email2 end email2,
case when T1.email<>T2.email3 and T2.email2<>T2.email3 then T2.email3 end email3,
case when (T1.email<>T2.email4 OR T1.email IS NULL) and
            (T2.email2<>T2.email4  OR T2.email2 IS NULL)  and
            (T2.email3<>T2.email4  OR T2.email3 IS NULL)  then T2.email4 end email4
from Table1 t1
left join Table2 t2 on t1.id=t2.id

Results:
| ID |       email | email2 | email3 |       email4 |
|----|-------------|--------|--------|--------------|
|  A | a@gmail.com | (null) | (null) | ab@gmail.com |

A:
"The real query is alot more complex and if I add something like isnull(value,'') around every variable in the case statement to avoid comparing to a null value, that can get abit much." Looking for an easier way than that if possible

You could ISNULL each column once in a derived table, then keep the rest of your query the same:
select T1.ID, T1.email,
case when T1.email<>T2.email2 then T2.email2 end email2,
case when T1.email<>T2.email3 and T2.email2<>T2.email3 then T2.email3 end email3,
case when T1.email<>T2.email4 and T2.email2<>T2.email4 and T2.email3<>T2.email4 then T2.email4 end email4
from t1
left join (SELECT ID,
                  ISNULL(email2,'') email2,
                  ISNULL(email3,'') email3,
                  ISNULL(email4,'') email4
           FROM t2) t2 on t1.id=t2.id


text:
Q: Gcd(f,g)=1 can we express the entire ring of polynomials using f and g? If we have 2 polynomials f and g over a field F and the gcd(f,g)=1 can we represent every polynomial with coefficients in F as a liner combination of f and g?

A: Hint: can you represent $1$ as a linear combination of $f$ and $g$? Can you construct other polynomials from your solution for $1$?

redpajama_set_name: RedPajamaStackExchange


text:
Q: Development resources for IBM WCM/WebSphere I recently started a new position at a company that uses IBM's WebSphere Portal, and it is completely new to me. I was wondering if there was a good resource anyone knew for development techniques using said platform.
Basically what I've been asked to do is create a dynamic newsletter page to speed up the publishing time for a new set of newsletters/articles. I have no idea how to generate dynamic content with WebSphere so that when a new article is published, it updates a landing page with a link to the new article.
Any help at all would be much appreciated!

A: There's a lot of information on the various IBM sites (disclaimer I work for IBM, but not with Portal). This article seems to be relevant.


text:
Q: Is POSIX prescriptive or descriptive? Is POSIX a description of how applications have implemented each specific part of UNIX in the past or is it a prescriptive norm of how UNIX must be implemented ?
If descriptive, only the features that are common to all included implementations would be valid. While any implementation have not implemented a feature, that feature is "undefined".
If prescriptive: On which theoretical framework is it based? Math? C language? Experience?

A: It's prescriptive de jure, but mostly descriptive de facto.
POSIX is a set of specifications that implementations can be matched against, including both implementations that already exist when the document is published and future implementations. So it's prescriptive.
In practice, POSIX started mostly as a common subset of existing implementations. So in this sense, it's mostly descriptive. But POSIX sometimes mandates new behavior. Most commonly, for features that existed in many implementations but with different interfaces (function names, command line options, etc.), POSIX has introduced several functions and utilities, such as pax (a replacement for tar and cpio, which were very different across Unix variants) and various posix_xxx functions. POSIX also introduced new constant and command line options; for example, for ps, "The -A option is equivalent to the BSD -g and the SVID -e. Because the two systems differed, a mnemonic compromise was selected.". The rationale sections often explains why this or that feature was included, often mentioning which implementations already had a feature, or why a choice was made or not made between incompatible implementations.

A: The intention of POSIX is to describe existing behavior and not to break historic behavior (not to make historic UNIX non-compliant) unless the historic behavior could be seen as a definite historic bug already.
The further intention of POSIX is not to introduce own invention. If it turns out that there would be a need for so called own invention (because existing implementations are not useful for a standardization), the ideas from the POSIX committee are discussed with the authors of various UNIX (or program) versions in order to get the best solution. Such a discussion frequently results in new implementations that support the final proposal at the time they are written down already.
There are a few exceptions, POSIX e.g. defined getpgrp() and setpgrp() in a way that is in conflict with the BSD interfaces that existed 10 years earlier already. POSIX defined getline() and fexec() in a way that is completely incompatible with implementations that existed for nearly 30 years before introducing the incompatible interfaces from the GNU libc.
If it turns out that existing implementations do not match, a decision is made which variant is used (or whether a mixture of existing different implementations is introduced) and a posix specific name is introduced. This happened e.g. for the thread interfaces, where posix_xxx() functions have been introduced that are very similar to the previous reference implementation from Roger Faulkner (Sun Microsystems).


text:
Q: Is there an R function for importing a specific portion of a JSON file? RStudio will not load my entire geoJSON file without slowing my computer down. The file contains the precise coordinates needed to draw US zip-code shapes. The entire file is large. I would like to import all the coordinates for one zip-code at a time. The geoJSON file contains properties called GEOID10 and ZCTA5CE10 that correspond with a specific zipcode. Here is a portion of this file:
{
 "type": "FeatureCollection",
 "name": "cb_2017_us_zcta510_500k",
 "crs": {
   "type": "name",
    "properties": {
      "name": "urn:ogc:def:crs:EPSG::4269"
     }
   },
   "features": [
      {
       "type": "Feature",
       "properties": {
       "ZCTA5CE10": "35442",
       "AFFGEOID10": "8600000US35442",
       "GEOID10": "35442",
       "ALAND10": 610213891,
       "AWATER10": 10838694
   },
   "geometry": {
      "type": "MultiPolygon",
      "coordinates": [
        [
          [
            [
              -88.252618,
               32.92675
            ],
            [
              -88.249724,
               32.93242
            ],

The file continues with many more coordinates. The structure is the same for every zip-code in the US. I have been looking into packages such as jsonlite. However, I have limited programming experience. So far, I have written this line of code which would import the entire file into R:
zipcodes <- geojson_read("zipcodes.geojson", what = "sp")

This line freezes my computer. R will upload the entire file on a larger computer, however I would like the code to work on a normal computer. Is there a better way to do this? Can I designate R to upload just the data corresponding to "GEOID10": "35442"? Any help would be great! Thank you!


text:
Q: Var to html div creating list Some info on the issue: I am trying to create a list that fills up with all the issues a person had with their password, I'm sure there are a million ways. However the way I am doing that is by using a var called what (which is defined earlier so that's not the issue) and having it take on the value of the div before it's cleared and then what + my new content is placed in the new div, and each if statement adds on. So if your password is missing everything, then a nice long list should show up.
I had this working before made some changes and now its not working again. Also please note I removed the
 just to trouble shoot the issue. Oh, and what it does now is it runs through all the if statements and displays just the text of the last if statement that was false (so no list is created, however all the text of all the issues flashed quickly till the last one which stays.).
 $("#password").blur(function()
{

  if($('#password').val().length >= 6) {
      passlen = true;
      checkSubmitStatus();}
    else{
    what=$("box1").val();
      passlen= false;

      $("#box1").fadeTo(200,0.1,function() //start fading the messagebox
        {
         $(this).html(what +  'Password must be atleast 6 characters long!').addClass('messageboxerror').fadeTo(900,1);
          });

  }

  if($('#password').val() != $('#username').val()) {
      passuse=true;
      checkSubmitStatus();}
      else{
          passuse= false;
          what=$("#box1").val();

        $("#box1").fadeTo(200,0.1,function() //start fading the messagebox
        {
          $(this).html(what +  'Password must be different from Username!').addClass('messageboxerror').fadeTo(900,1);
          });

  }
  re = /[0-9]/;
  if(re.test($('#password').val())) {
      passnum=true;
      checkSubmitStatus();}
      else{
          passnum= false;
        what=$("#box1").val();

    $("#box1").fadeTo(200,0.1,function() //start fading the messagebox
        {

         $(this).html(what +  'Password must contain at least one number (0-9)!').addClass('messageboxerror').fadeTo(900,1);
          });

  }
  re = /[a-z]/;
  if(re.test($('#password').val())) {
      passlow=true;
      checkSubmitStatus();}
      else{
          passlow= false;
         what=$("#box1").val();

    $("#box1").fadeTo(200,0.1,function() //start fading the messagebox
        {

         $(this).html(what +  'Password must contain at least one lowercase letter (a-z)!').addClass('messageboxerror').fadeTo(900,1);
          });

  }
  re = /[A-Z]/;
  if(re.test($('#password').val())) {
      passup=true;
      checkSubmitStatus();}
      else{
          passup=false;
          what=$("#box1").val();

          $("#box1").fadeTo(200,0.1,function() //start fading the messagebox
        {

         $(this).html(what +  'Password must contain at least one uppercase letter (A-Z)!').addClass('messageboxerror').fadeTo(900,1);
          });

  }

});

A: You can create a
 element and use jQuery's append/appendTo function.
var ul = $("ul");

if( /*password passes criterion*/ ) {
   flag = true;
   checkSubmitStatus();
} else {
   flag = false;
   $("

").html(errormessage).addClass("messageboxerror").appendTo(ul).fadeTo(900,1);
}

/*Repeat for each criterion*/

A: I don't fully know if your question states that you want to provide a full list of validation errors, or only the first one encountered.
If all of them, I agree with Dennis' answer of creating a holding element (such as a  tag) and add
* tags for each validation offense.  As each li is added, it will contain the validation along with a nice user experience fade-in with the .fade(900,1) addition.


text:
Q: How to find the Docker alpine version for a golang tag? I have a Dockerfile with
FROM golang:1.17.3-alpine as builder

How to find out what version of alpine this is?

A: One way to do it:
docker run --rm golang:1.17.3-alpine cat /etc/os-release


text:
Q: Converting CrystalEnterprise.FavoritesFolder to CrystalEnterprise.Folder using SAP BO SDK Hi I m trying to copy a CrystalEnterprise.FavoritesFolder to a backup folder but i am not able to create a backup as it is throwing me and error as follows:
Desktop plugin object CrystalEnterprise.FavoritesFolder is not creatable.

does anyone have any idea as to how to proceed further

A: As the error indicates, you can't create a Favorites folder manually.  Just create a normal (public) folder, and copy the contents of the Favorites folder into it.


text:
Q: how to investigate extremely fast disk usage I just freed 3GB from my hard drive and now, 5 minutes later, I got the warning "you're running on extremely low disk space". How can I find out which program is eating up my disk that fast? Thanks.

A: An excellent way to trace back such problems is Process Explorer, a Task Manager alternative/replacement hosted and endorsed by Microsoft itself.
Another option might be to use a program like WinDirStat to see which file/directory is eating up your disk space.

A: If it is writing 3GB in 5 min, you can open task manager, select the Performance Tab, and press the "Resource Monitor" button.  (assuming Windows 7 or Vista)
On the window that opens, select the Disk tab, and expand both "Processes with Disk Activity" and "Disk Activity".
You can sort by Total, or Write, and you should see what Process is writing to the disk the most.

A: How big is your drive?
Has the 3Gb definitely been used by something?
Take a look at this URL discussing what causes that warning
Link

A: If its not a process thand take that is using up your space, it could be your page file (the file Windows uses for virtual memory, usually sits on the root of whatever drive hosts your operating system). If the page file is choked and can't allocate all the virtual memory space it wants, it will wait for space to clear up at space. You can try reducing your page file size in System properties under 'Virtual Memory' or move the page file to another drive if you have one.


text:
Q: Sensors sampling rate is always too high I'm writing an Android logging application that runs as a background service and logs sensor data.
Here's an example of my code to start logging the Gravity Sensor:
public void StartLogging(int intervalInMilliseconds) {
    mySensorManager.registerListener(this, myGravitySensor, intervalInMilliseconds * 1000); //millisec * 1000 = microsec
}

However, I have a problem: the sample rate I set is completely ignored and the actual one is much, MUCH faster.
For example: even if I set a very slow sample rate of 10000000 microseconds (aka: 10000 milliseconds, or 10 seconds) I actually receive updates about a dozen times every second, which is more than a hundred times faster than I requested!
I read in the documentation that the interval is not meant to be strictly precise, but here we're talking about a difference of at least two orders of magnitude, which is absurd!
I know that I can just compare timestamps and only log, say, one event every 100, but the problem is that I'm trying to minimize power consumption, and I imagine that waking the CPU once every 10 seconds would have quite a different impact on the battery than waking it ten times every second.
I'm also aware that I can pass a fourth parameter that  sets how much time the sensor events can stay in the queue before being delivered, however this doesn't seem to have any noticeable effect either.
Where am I going wrong?

A: It will work in some phones an might not work in others, actually it dependes about the sensor that the phone is using and other factors.
You should not rely on that value and should filter unwanted values depending about your desired rate.
Cheers !!!

A: According to other answers it's simply not possible:
Android - user-defined delay is used in registerListener(). Not working, why?
If you can't make it work with the samplerate parameter, try using the predefined samplerate parameters and see if they make a difference.
If the samplerate is still too high you could use a counter value and only call the event every X samples.

A: While "SensorManager is free to give you more samples than you asked for" is a good answer, it doesn't manage to explain why. I have inferred the following two explanations that may or may not be true across all devices:
If two components request sensor readings at different frequencies, they will both receive data at the highest rate requested, which makes sense from an efficiency point of view depending on the sensor type. Note that this is also true across processes, so a background service for detecting handset shake gestures can influence the shared rate.
Sensor rates can combine in unexpected ways. For instance, the camera reads the accelerometer at a modest 10Hz to determine orientation and the aforementioned shake-gesture-detector might run the gyro at 20Hz. Now a third component that uses TYPE_ROTATION_VECTOR might want to run at SENSOR_DELAY_GAME, which is usually 50Hz. Because this last sensor is (usually) a soft fusion of the accelerometer and the gyro, it appears to demand they both run at the same frequency, but is unable to work out what that should be and gives up and runs at a jaunty 1KHz (on at least one of my devices).


text:
Q: Pygame, is there a way to make "screen layers"? I  am working on a Tank game as a school project and I am trying to make it as user-friendly as possible (with things like customizable keybindings, display settings). However, I don't want the game window to lose it proportions so I figured I would add borders to the sides of the game window in order to support wide screens.
I've attached an imageto illustrate what I'm looking for:

So for this to work, I would need a way to make "screen layers". The base layer is the whole screen with some graphics on the sides added to it and a font displaying score. And then a second layer would be rendered in the middle of the screen which will be the game window and its width and height will be obviously smaller than the base layer.
At the moment, the game is rendered from the top left corner of the screen until all the tiles have been rendered out. So that is why I figured it would be the best to make the tiles render out on a separate surface positioned in the middle of the screen surface.
Would really appreciate some tips on how I can make this possible! :) I don't have that much experience in Classes and pygame, so it would be awesome if you could give a fleshed out description as well! :D

A: Just draw your different stuff on different surfaces.
For example, create a Surface for your game window (let's call it game_surf), and draw your tanks and bullets etc. on that new Surface instead of the pygame main window (which is just another Surface).
# the main window
screen = pygame.display.init()

# just a regular surface
game_surf = pygame.surface.Surface(width, height)

...
# in your main loop
    # or however you draw your sprites
    your_sprite_group.draw(game_surf)

Then blit it onto the screen
screen.blit(game_surf, the_position)

A: Simplest way: Create a group for each 'layer'.
import pygame
front_sprites = pygame.sprite.Group()
middle_sprites = pygame.sprite.Group()
background_sprites = pygame.sprite.Group()

Then, just draw them all onto the screen in the following order:
background_sprites.draw(screen)
middle_sprites.draw(screen)
front_sprites.draw(screen)


text:
Q: Mooc course: Is there a way to get this piece of code to work without the break; at the end? I got this error from running the code without the break; at the end and by searching for it that was a solution i came up with on my own but i was wondering is there a better way to handle it.
import java.util.Scanner;

public class SummanNeliojuuri {

public static void main(String[] args) {
    Scanner lukija = new Scanner(System.in);

    while(true) {
        int luku = Integer.valueOf(lukija.nextLine());
        int luku2 = Integer.valueOf(lukija.nextLine());
        int summa = luku + luku2;
        int neliojuuri = (int) Math.sqrt(summa);
        System.out.println(neliojuuri);
        break; }
    }
}

Just that the code runs without the error. Not sure though that if the error comes up only because im running it through a mooc course "inspector" in netbeans.

A: Aaaah okay that cleared it up. Took the while loop away from it. I assumed the inspection thing in netbeans needed the loop for it for some reason. Also i didnt think that the break was needed here. Thanks a lot all of you! :)
also the error i got was: java.util.NoSuchElementException: No line found
edit: Really thankful for all the help! Was a bit afraid to post something since i knew it was a really "noobie" question. Got rid of the while loop and the break and it works great now!


text:
Q: Дополнительно меню (кнопки) администратора Как сделать чтобы у администратора показывалось в боте дополнительное меню (добавилось к стандартному), а у пользователя показывалось стандартное?
#Стандартное меню:

keyboard = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
keyboard.row(KEYBOARD['FOR_A_LAST'], KEYBOARD['FOR_A_FIRST'])
keyboard.row(KEYBOARD['FOR_A_PHONE'], KEYBOARD['FOR_A_FULL'])
keyboard.row(KEYBOARD['FOR_A_DATAR'], KEYBOARD['DATAR_R'])
keyboard.row(KEYBOARD['FOR_SUBSY'], KEYBOARD['FOR_SUBSN'], KEYBOARD['FOR_A_HELP'])

#Меню администратора:

admin = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
admin.row(KEYBOARD['MESS_DR'], KEYBOARD['MESS'])
admin.row(KEYBOARD['IMPORT'], KEYBOARD['LOGS'])
admin.row(KEYBOARD['ADD_ID'], KEYBOARD['REBOOT']

#Старт

@bot.message_handler(commands=['start'])
def start_handler(message):
    name = message.chat.first_name + ' ' + (message.chat.last_name or '')
    msg = f"Привет {name} . \n"

    if message.chat.id == settings.ADMINS_ID:
        bot.send_message(message.chat.id, text=msg, reply_markup=admin, parse_mode='HTML')

    else:
        bot.send_message(message.chat.id, text=msg, reply_markup=keyboard, parse_mode='HTML')

A: @bot.message_handler(commands=['start'])
def start_handler(message):
    name = message.chat.first_name + ' ' + (message.chat.last_name or '')
    msg = f"Привет {name} . \n"
    keyboard=types.InlineKeyboardMarkup()
    if message.chat.id == settings.ADMINS_ID:
        keyboard.add(types.InlineKeyboardButton(text="admin button"))
    else:
        keyboard.add(types.InlineKeyboardButton(text="userbutton"))

    bot.send_message(message.chat.id, text=msg, reply_markup=keyboard, parse_mode='HTML')


text:
Q: Logging out/back in sometimes freezes after login to blank wallpaper Hi I am running 11.04 on a Dell Inspiron 530
Below I have pasted what hardware I have and some dmesg pasted info
Here is the problem:
When I log out many times I cannot seem to log back in again. It freezes without any panels appearing which I suspect is an issue with gdm?
I usually resort then to alt/print-screen and k to re-reboot and that mostly works and boots back to Unity which then works wonderfully.
I cannot understand why this does not happen when I start the pc up from scratch but only seems to happen on logout-in or sometimes reboot.
I am using only ubuntu on this pc also
Here is print out from lspci
lspci
00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller (rev 02)
00:01.0 PCI bridge: Intel Corporation 82G33/G31/P35/P31 Express PCI Express Root Port (rev 02)
00:19.0 Ethernet controller: Intel Corporation 82562V-2 10/100 Network Connection (rev 02)
00:1a.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 02)
00:1a.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 02)
00:1a.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 02)
00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 92)
00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 port SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
00:1f.5 IDE interface: Intel Corporation 82801I (ICH9 Family) 2 port SATA IDE Controller (rev 02)
01:00.0 VGA compatible controller: ATI Technologies Inc RV610 video device [Radeon HD 2400 PRO]

Here is from lsusb:
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard
Bus 005 Device 002: ID 0461:4d22 Primax Electronics, Ltd
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 003: ID 03f0:7804 Hewlett-Packard DeskJet D1360
Bus 004 Device 002: ID 046d:089d Logitech, Inc. QuickCam E2500 series
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

If it helps also here is the readout from dmesg:
[    5.965964] [drm]   VGA
[    5.965965] [drm]   DDC: 0x7e50 0x7e50 0x7e54 0x7e54 0x7e58 0x7e58 0x7e5c 0x7e5c
[    5.965967] [drm]   Encoders:
[    5.965968] [drm]     CRT2: INTERNAL_KLDSCP_DAC2
[    5.965969] [drm] Connector 2:
[    5.965970] [drm]   DVI-I
[    5.965971] [drm]   HPD1
[    5.965973] [drm]   DDC: 0x7e40 0x7e40 0x7e44 0x7e44 0x7e48 0x7e48 0x7e4c 0x7e4c
[    5.965974] [drm]   Encoders:
[    5.965975] [drm]     CRT1: INTERNAL_KLDSCP_DAC1
[    5.965976] [drm]     DFP1: INTERNAL_LVTM1
[    6.019898] [drm] Internal thermal controller without fan control
[    6.019952] [drm] radeon: power management initialized
[    6.098623] [drm] fb mappable at 0xD0141000
[    6.098625] [drm] vram apper at 0xD0000000
[    6.098626] [drm] size 5324800
[    6.098627] [drm] fb depth is 24
[    6.098629] [drm]    pitch is 5888
[    6.098792] Console: switching to colour frame buffer device 180x56
[    6.098817] fb0: radeondrmfb frame buffer device
[    6.098818] drm: registered panic notifier
[    6.098823] [drm] Initialized radeon 2.8.0 20080528 for 0000:01:00.0 on minor 0
[    6.437588] usbcore: registered new interface driver snd-usb-audio
[    6.533185] HDA Intel 0000:00:1b.0: PCI INT A -> GSI 22 (level, low) -> IRQ 22
[    6.533222] HDA Intel 0000:00:1b.0: irq 43 for MSI/MSI-X
[    6.533242] HDA Intel 0000:00:1b.0: setting latency timer to 64
[    6.608241] type=1400 audit(1305191778.439:2): apparmor="STATUS" operation="profile_load" name="/sbin/dhclient" pid=499 comm="apparmor_parser"
[    6.608870] type=1400 audit(1305191778.439:3): apparmor="STATUS" operation="profile_load" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=499 comm="apparmor_parser"
[    6.609060] type=1400 audit(1305191778.439:4): apparmor="STATUS" operation="profile_replace" name="/sbin/dhclient" pid=447 comm="apparmor_parser"
[    6.609274] type=1400 audit(1305191778.439:5): apparmor="STATUS" operation="profile_load" name="/usr/lib/connman/scripts/dhclient-script" pid=499 comm="apparmor_parser"
[    6.609688] type=1400 audit(1305191778.439:6): apparmor="STATUS" operation="profile_replace" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=447 comm="apparmor_parser"
[    6.610094] type=1400 audit(1305191778.439:7): apparmor="STATUS" operation="profile_replace" name="/usr/lib/connman/scripts/dhclient-script" pid=447 comm="apparmor_parser"
[    6.756553] input: HDA Intel Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input5
[    9.924552] usblp0: USB Bidirectional printer dev 3 if 0 alt 0 proto 2 vid 0x03F0 pid 0x7804
[    9.924903] usbcore: registered new interface driver usblp
[   12.538889] ppdev: user-space parallel port driver
[   12.876847] type=1400 audit(1305191784.707:8): apparmor="STATUS" operation="profile_load" name="/usr/lib/cups/backend/cups-pdf" pid=828 comm="apparmor_parser"
[   12.877582] type=1400 audit(1305191784.707:9): apparmor="STATUS" operation="profile_load" name="/usr/sbin/cupsd" pid=828 comm="apparmor_parser"
[   12.898935] type=1400 audit(1305191784.727:10): apparmor="STATUS" operation="profile_replace" name="/sbin/dhclient" pid=831 comm="apparmor_parser"
[   12.899575] type=1400 audit(1305191784.727:11): apparmor="STATUS" operation="profile_replace" name="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=831 comm="apparmor_parser"
[   12.899975] type=1400 audit(1305191784.727:12): apparmor="STATUS" operation="profile_replace" name="/usr/lib/connman/scripts/dhclient-script" pid=831 comm="apparmor_parser"
[   14.000492] type=1400 audit(1305191785.831:13): apparmor="STATUS" operation="profile_load" name="/usr/share/gdm/guest-session/Xsession" pid=830 comm="apparmor_parser"
[   14.004217] type=1400 audit(1305191785.835:14): apparmor="STATUS" operation="profile_replace" name="/usr/lib/cups/backend/cups-pdf" pid=837 comm="apparmor_parser"
[   14.004956] type=1400 audit(1305191785.835:15): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/cupsd" pid=837 comm="apparmor_parser"
[   14.360859] type=1400 audit(1305191786.191:16): apparmor="STATUS" operation="profile_load" name="/usr/sbin/mysqld-akonadi" pid=838 comm="apparmor_parser"
[   14.361285] type=1400 audit(1305191786.191:17): apparmor="STATUS" operation="profile_load" name="/usr/sbin/mysqld-akonadi///usr/sbin/mysqld" pid=838 comm="apparmor_parser"
[   15.144178] e1000e 0000:00:19.0: irq 41 for MSI/MSI-X
[   15.200046] e1000e 0000:00:19.0: irq 41 for MSI/MSI-X
[   15.200263] ADDRCONF(NETDEV_UP): eth0: link is not ready
[   16.387139] usb 4-2: usbfs: interface 0 claimed by usblp while 'usb' sets config #1
[   16.668752] e1000e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
[   16.668757] e1000e 0000:00:19.0: eth0: 10/100 speed: disabling TSO
[   16.668889] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   20.584348] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro,user_xattr,commit=0
[   26.878702] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro,user_xattr,commit=0
[   27.504006] eth0: no IPv6 routers present
[   65.681147] show_signal_msg: 12 callbacks suppressed
[   65.681152] python[1732]: segfault at 1b0 ip b66c89ef sp bfa2a820 error 4 in libdbus-1.so.3.5.4[b669e000+3b000]
[   72.109525] python[1839]: segfault at 8b32002 ip b74a06bd sp b5d75928 error 4 in libc-2.13.so[b7389000+15a000]
[   74.574963] process `skype' is using obsolete setsockopt SO_BSDCOMPAT
[  440.860838] nautilus[1469]: segfault at 20 ip b6c1dfc2 sp bf8d6ba0 error 4 in libgobject-2.0.so.0.2800.6[b6beb000+45000]
[  468.597037] SysRq : SAK
[  468.597055] SAK: killed process 2320 (Xorg): task_session(p)==tty->session
[  468.597195] SAK: killed process 2320 (Xorg): task_session(p)==tty->session
[  474.533041] SysRq : SAK
[  474.533057] SAK: killed process 2531 (Xorg): task_session(p)==tty->session
[  474.533178] SAK: killed process 2531 (Xorg): task_session(p)==tty->session
[  474.980661] [drm:drm_mode_getfb] *ERROR* invalid framebuffer id
[  480.884016] radeon 0000:01:00.0: GPU lockup CP stall for more than 10052msec
[  480.884020] ------------[ cut here ]------------
[  480.884043] WARNING: at /build/buildd/linux-2.6.38/drivers/gpu/drm/radeon/radeon_fence.c:248 radeon_fence_wait+0x2ea/0x360 [radeon]()
[  480.884046] Hardware name: Inspiron 530
[  480.884049] GPU lockup (waiting for 0x0000A2A4 last fence id 0x0000A29B)
[  480.884051] Modules linked in: binfmt_misc parport_pc ppdev usblp snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_usb_audio snd_pcm snd_hwdep snd_usbmidi_lib snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq gspca_zc3xx snd_timer snd_seq_device gspca_main videodev radeon ttm drm_kms_helper psmouse serio_raw snd soundcore snd_page_alloc dcdbas drm lp i2c_algo_bit parport usbhid hid floppy e1000e
[  480.884083] Pid: 2666, comm: Xorg Not tainted 2.6.38-8-generic-pae #42-Ubuntu
[  480.884086] Call Trace:
[  480.884094]  [<c1058ce2>] ? warn_slowpath_common+0x72/0xa0
[  480.884112]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  480.884130]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  480.884134]  [<c1058db3>] ? warn_slowpath_fmt+0x33/0x40
[  480.884151]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  480.884158]  [<c1076c70>] ? autoremove_wake_function+0x0/0x50
[  480.884175]  [<f88f57c1>] ? radeon_sync_obj_wait+0x11/0x20 [radeon]
[  480.884184]  [<f84ae719>] ? ttm_bo_wait+0xd9/0x170 [ttm]
[  480.884204]  [<f890d8c2>] ? radeon_gem_wait_idle_ioctl+0x82/0xe0 [radeon]
[  480.884218]  [<f8788db1>] ? drm_ioctl+0x1e1/0x470 [drm]
[  480.884241]  [<f890d840>] ? radeon_gem_wait_idle_ioctl+0x0/0xe0 [radeon]
[  480.884247]  [<c1013b00>] ? restore_i387_xstate+0xf0/0x210
[  480.884251]  [<c113251c>] ? rw_verify_area+0x6c/0x130
[  480.884262]  [<f8788bd0>] ? drm_ioctl+0x0/0x470 [drm]
[  480.884267]  [<c1141ecb>] ? do_vfs_ioctl+0x7b/0x2e0
[  480.884270]  [<c1009cde>] ? restore_sigcontext+0xbe/0xe0
[  480.884274]  [<c11421b7>] ? sys_ioctl+0x87/0x90
[  480.884277]  [<c100ab5f>] ? sysenter_do_call+0x12/0x28
[  480.884280] ---[ end trace 448eaf87bbc222a1 ]---
[  480.884287] [drm] Disabling audio support
[  480.885369] radeon 0000:01:00.0: GPU softreset
[  480.885372] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xE57024E0
[  480.885375] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00110103
[  480.885378] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200000C0
[  480.885385] radeon 0000:01:00.0:   R_008020_GRBM_SOFT_RESET=0x00007FEE
[  480.900270] radeon 0000:01:00.0: R_008020_GRBM_SOFT_RESET=0x00000001
[  480.916147] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xA0003030
[  480.916149] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00000003
[  480.916152] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200080C0
[  480.917146] radeon 0000:01:00.0: GPU reset succeed
[  480.920500] radeon 0000:01:00.0: WB enabled
[  480.951456] [drm] ring test succeeded in 1 usecs
[  480.951462] [drm] ib test succeeded in 1 usecs
[  480.951463] [drm] Enabling audio support
[  640.045683] nautilus[2821]: segfault at 20 ip b6b87fc2 sp bfe51e40 error 4 in libgobject-2.0.so.0.2800.6[b6b55000+45000]
[  662.069107] SysRq : SAK
[  662.069139] SAK: killed process 3405 (Xorg): task_session(p)==tty->session
[  662.069301] SAK: killed process 3405 (Xorg): task_session(p)==tty->session
[  662.737841] [drm:drm_mode_getfb] *ERROR* invalid framebuffer id
[  663.636017] radeon 0000:01:00.0: GPU lockup CP stall for more than 10052msec
[  663.636021] ------------[ cut here ]------------
[  663.636045] WARNING: at /build/buildd/linux-2.6.38/drivers/gpu/drm/radeon/radeon_fence.c:248 radeon_fence_wait+0x2ea/0x360 [radeon]()
[  663.636048] Hardware name: Inspiron 530
[  663.636050] GPU lockup (waiting for 0x0000C703 last fence id 0x0000C702)
[  663.636052] Modules linked in: binfmt_misc parport_pc ppdev usblp snd_hda_codec_realtek snd_hda_intel snd_hda_codec snd_usb_audio snd_pcm snd_hwdep snd_usbmidi_lib snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq gspca_zc3xx snd_timer snd_seq_device gspca_main videodev radeon ttm drm_kms_helper psmouse serio_raw snd soundcore snd_page_alloc dcdbas drm lp i2c_algo_bit parport usbhid hid floppy e1000e
[  663.636086] Pid: 3551, comm: compiz Tainted: G        W   2.6.38-8-generic-pae #42-Ubuntu
[  663.636088] Call Trace:
[  663.636097]  [<c1058ce2>] ? warn_slowpath_common+0x72/0xa0
[  663.636114]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  663.636132]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  663.636136]  [<c1058db3>] ? warn_slowpath_fmt+0x33/0x40
[  663.636154]  [<f88f4f3a>] ? radeon_fence_wait+0x2ea/0x360 [radeon]
[  663.636161]  [<c1076c70>] ? autoremove_wake_function+0x0/0x50
[  663.636178]  [<f88f57c1>] ? radeon_sync_obj_wait+0x11/0x20 [radeon]
[  663.636187]  [<f84ae719>] ? ttm_bo_wait+0xd9/0x170 [ttm]
[  663.636210]  [<f890d8c2>] ? radeon_gem_wait_idle_ioctl+0x82/0xe0 [radeon]
[  663.636220]  [<f8788db1>] ? drm_ioctl+0x1e1/0x470 [drm]
[  663.636236]  [<f890d840>] ? radeon_gem_wait_idle_ioctl+0x0/0xe0 [radeon]
[  663.636241]  [<c110bd79>] ? handle_mm_fault+0x109/0x190
[  663.636244]  [<c1534fb0>] ? do_page_fault+0x0/0x490
[  663.636246]  [<c15351df>] ? do_page_fault+0x22f/0x490
[  663.636254]  [<f8788bd0>] ? drm_ioctl+0x0/0x470 [drm]
[  663.636257]  [<c1141ecb>] ? do_vfs_ioctl+0x7b/0x2e0
[  663.636259]  [<c11421b7>] ? sys_ioctl+0x87/0x90
[  663.636262]  [<c100ab5f>] ? sysenter_do_call+0x12/0x28
[  663.636264] ---[ end trace 448eaf87bbc222a2 ]---
[  663.636272] [drm] Disabling audio support
[  663.637335] radeon 0000:01:00.0: GPU softreset
[  663.637337] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xE57024E0
[  663.637340] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00110103
[  663.637342] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200010C0
[  663.637350] radeon 0000:01:00.0:   R_008020_GRBM_SOFT_RESET=0x00007FEE
[  663.652234] radeon 0000:01:00.0: R_008020_GRBM_SOFT_RESET=0x00000001
[  663.668109] radeon 0000:01:00.0:   R_008010_GRBM_STATUS=0xA0003030
[  663.668111] radeon 0000:01:00.0:   R_008014_GRBM_STATUS2=0x00000003
[  663.668113] radeon 0000:01:00.0:   R_000E50_SRBM_STATUS=0x200080C0
[  663.669107] radeon 0000:01:00.0: GPU reset succeed
[  663.672556] radeon 0000:01:00.0: WB enabled
[  663.703517] [drm] ring test succeeded in 1 usecs
[  663.703524] [drm] ib test succeeded in 1 usecs
[  663.703527] [drm] Enabling audio support

Any help appreciated

A: Well I think I found the answer the wrong way though!
I had to mess around with my video driver for the ATI Radeon card so tried ...much against my wishes to install fglrx...last time I did this ..it broke. However I did
sudo apt-get install fglrx and then after that had finished installing and configuring xorg etc I rebooted fine and dandy and kept on rebooting with no stalling so maybe I have fixed it after all.
Can I mark this as solved now?


text:
Q: "that was a classic money handshake" I'm reading the play "Dumb Show" by Joe Penhall. (See on Google Books)
Almost at the beginning of the play one of the characters uses this phrase: classic money handshake. What does it mean?
(Barry and Greg shake hands).

Barry: Hello. You're not a mason. There was nothing funny about your hand shake.
       That was the classic chop from the top. That was a classic money handshake.
      (does it).
      'I'm going to dominate you and take all your money'. And this is a
      showbiz handshake.

What does the classic chop from the top mean?


text:
Q: How can I get the text from a table in HTML? I am trying to scrape data from https://fortnitetracker.com/events/epicgames_S10_FNCS_Week5_NAE. Specifically, I am trying to get the placement and number of points earned by a specific player. I went to the website and found the instance where the specific player ("Nickmercs") was located in the HTML which looked like this:
HTML Text
You can see the "rank" is shown above his name as 56, and the points are shown a few lines below his name which is also 56. I then wrote the following Python 3 program to scrape the data from the website:
import requests

class tracker:

url = "https://fortnitetracker.com/events/epicgames_S10_FNCS_Week5_NAE"

    def getReq(website):
        req = requests.get(website)
        if req:
            return req

    req = getReq(url)
    text = req.text
    index = text.find("nickmercs")
    split = text[index:index+1000]
    print (split)

Running the program resulted in a large portion of the HTML code, but the instance of "Nickmercs" that it found was not the one I was looking for. The one shown in the picture of the HTML code shown above was the actual first instance if the "Nickmercs" string on the page, but for some reason it was not in the req.text / the response for my request. As a result I went back and modified my code to print out where the first instance actually was, and found that the line was different from what was shown in the HTML code picture. The line that was supposed to list the names "Nate Hill, Nickmercs, SypherPK" actually looked like this:
<span :style="{ 'color': '#' + metadata.primary_color }">{{ getPlayerNameList(entry.teamAccountIds, 4) }}</span>

I have little knowledge of how HTML works, so I am wondering if it is possible to fix this problem. It seems to be calling some (what I imagine is a) method called getPlayerNameList() which places the names in the correct spot, but makes it so I can't easily search the names / scrape the data. Is there a way to get around this? Any help is much appreciated!

A: The site is dynamic, thus, you need some way to access the data populated after the page originally loads. One such way is to use selenium:
from selenium import webdriver
from bs4 import BeautifulSoup as soup
d = webdriver.Chrome('/path/to/chromedriver')
d.get('https://fortnitetracker.com/events/epicgames_S10_FNCS_Week5_NAE')
h, *r = [[i.text for i in b.find_all('th' if b.td is None else 'td')] for b in soup(d.page_source, 'html.parser').find('div', {'id':'leaderboard'}).table.find_all('tr')]
new_data = {tuple(b.split(', ')):dict(zip([h[0], *h[2:]], [a[1:-1], *c])) for a, b, *c in r}

Now, to look up a player by name:
data = [b for a, b in new_data.items() if 'Nickmercs' in a][0]

Output:
{'Rank': '56', 'Points': '56 Top 0.373%', 'Matches': '10', 'Wins': '0', 'K/D': '3.50', 'Avg Place': '16.10'}

For your specific target value (Rank):
rank = [b for a, b in new_data.items() if 'Nickmercs' in a][0]['Rank']

Output:
56

A: Data is dynamically loaded from script tags so content is present in response. You can regex out the leaderboard/session info and the accounts info and connect the two via account_id. You find the right account_id based on the player name of interest
import requests, re, json

def get_json(pattern):
    p = re.compile(pattern, re.DOTALL)
    return p.findall(r.text)[0]

r = requests.get('https://fortnitetracker.com/events/epicgames_S10_FNCS_Week5_NAE')
player = 'Nickmercs'
session_info = json.loads(get_json('imp_leaderboard = (.*?);'))
player_info = json.loads(get_json('imp_accounts = (.*?);'))
account_id = [i['accountId'] for i in player_info if i['playerName'] == player][0]
team_info = [i for i in session_info['entries'] if account_id in i['teamId']]
print(team_info)

This gives you all the relevant info. Part of that is shown here:

Specific items:
print(team_info[0]['pointsEarned'])
print(team_info[0]['rank'])

A: You are scraping the HTML along the javascript code and it is not rendered.
For this task you could use computer vision to extract the table from the page.
Otherwise you can use PhantomJS  (https://phantomjs.org/) to scrape the table without using images as it gives you the rendered page.


text:
Q: How can I avoid the generic warning public abstract class Formatter<P, R> {

    public static Object format(Object src, Class<? extends Formatter> formatter) {

        Formatter fmt;
        try {
            fmt = formatter.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }

        return fmt.format(src);  // Unchecked call warning here
    }

    public abstract R format(P src);

}

How can I avoid the generic warning when invoke
fmt.format(src)

The formatter is subclass of Formatter defined like
PhoneFormatter extends Formatter<String, String>

This is the invoke code
if (annotation instanceof LogFormat) {
    LogFormat logFormat = (LogFormat) annotation;
    arg = Formatter.format(arg, logFormat.formatter());
}

-
public class User {

    @LogFormat(formatter = PhoneNumberFormatter.class)
    private String mobile;
}

I don't want to (or say I can't) use any type parameter invoke this method.

A: Make the static method generic as well:
abstract class Formatter <P, R> {
    static <P, R> R format(P src, Class<? extends Formatter <P, R>> formatter) {
        Formatter <P, R> fmt;
        try {
            fmt = formatter.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
        return fmt.format(src);
    }

    abstract R format(P r);
}


text:
Q: What is the command I can enter in the tmux command bar to show the pane numbers? I would like to bind # to show panes numbers because # means number. I found out how to bind # from this question but what's the tmux command for showing panes. I tried show pane-numbers from the docs  because I thought it was a command because a hyphen was included in the description but it turns out that it is just that, a description, and nothing more.

A: The "docs" you linked to is not the official documentation. It looks like a guide that deviates from the tmux standard in the very beginning:

The command 'ctrl-b' is replaced with 'crtl-a' along with some other changes.

Note in this answer I assume the default configuration. In particular I assume the prefix is Ctrl+b.
The real documentation is here: tmux(1) manual page.
The phrase "pane numbers" appears after prefix? as:

C-b q       Display pane numbers

but to know the tmux command for this (without studying the documentation thoroughly) you need to examine the output of list-keys:
tmux list-keys | grep prefix | grep q

The output is:
…
bind-key    -T prefix       q                    display-panes

This way you can learn the tmux command you seek is display-panes. You can verify what it does by running the following command in a shell inside tmux:
tmux display-panes


text:
Q: split string by one of 2 delimiters depending on what is contained in string I am wondering how I can explode a string by either one of 2 delimters as the string I want to split can contain either a comma ',' or a hyphen '-'.
Below code works for the ',' but can't get the '-' and ',' to work at the same time.
Any advise?
   // first possible string
$string = "hello, you";
// second possible string
$string = "hello- you";

//explode function
         list($part1, $part2) = explode(',', $string);

A: Another option is to use preg_split:
$arr = preg_split('/[,-]/', $string);

This has the advantage over the strtok and recursive explode answers by doing all of the looping in C code (so, should be much faster) and allows for the split to be a regular expression, which would be handy if you wanted to also trim the spaces between words:
$arr = preg_split('/\s*[,-]\s*/', $string);

A: $string = "abc,def-g,h,i-lm";

$arr = [strtok($string, ',-')];
while (false !== $token = strtok(',-')) {
    $arr[] = $token;
}

var_dump($arr);

Demo.

A: Just apply explode successively to the string and then the resultant array:
$string = "hello, you - sir";
$temp = explode('-', $string);
$result = array();
foreach ($temp as $piece) {
    $result = array_merge($result, explode(',', $piece));
}

and $result will contain what you are looking for:
Array
(
    [0] => hello
    [1] =>  you
    [2] =>  sir
)

A: Strtok()  will work within the for loop for different delimiters


text:
Q: Parsing XML with class that are uniquely numbered Hey all I have the following code that I am in need of finding the class  in:
Dim nodelist As System.Xml.XmlNodeList = Nothing
Dim doc As New System.Xml.XmlDocument()

doc.LoadXml(tmpData)
nodelist = doc.SelectNodes("//entry/content/sp_0:div/span/sp_0:span")

For Each node As System.Xml.XmlElement In nodelist
   Debug.print(node("OrderID").InnerText)
Next

And the XML looks like this:
<feed
    xmlns:app="http://www.w3.org/2007/app"
    xmlns:thr="http://purl.org/syndication/thread/1.0"
    xmlns:fh="http://purl.org/syndication/history/1.0"
    xmlns:snx="http://www.ibm.com/xmlns/prod/sn"
    xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
    xmlns="http://www.w3.org/2005/Atom">
    <id>2006:feed</id>
    <generator version="5.0.0.0" uri="http://www.ibm.com/xmlns/prod/sn">IBM Connections - Profiles</generator>
    <title type="text">reporting chain for Bill Gates</title>
    <opensearch:itemsPerPage>8</opensearch:itemsPerPage>
    <fh:complete></fh:complete>
    <link
        href="http://..."
        rel="self"
        type="application/atom+xml"></link>
    <entry>
        <id>tag:profiles.ibm.com,2006</id>
        <title type="text">Bill Gates</title>
        <updated>2016-05-11T06:39:54.908Z</updated>
        <category term="profile" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
        <contributor>
            <name>Bill Gates</name>
            <snx:userid>010101</snx:userid>
            <email>Bill_Gates@microsoft.com</email>
            <snx:userState>active</snx:userState>
            <snx:isExternal>false</snx:isExternal>
        </contributor>
        <link
            href="http://..."
            rel="http://www.ibm.com/xmlns/prod/sn/profile-type"
            type="application/profile-type+xml"></link>
        <thr:in-reply-to>
            <app:accept>ref</app:accept>
            <app:accept>tag:profiles.ibm.com,2006</app:accept>
        </thr:in-reply-to>
        <summary type="text">Profile information for Bill Gates</summary>
        <content type="xhtml">
            <sp_0:div
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:sp_0="http://www.w3.org/1999/xhtml">
                <sp_0:span class="vcard">
                    <sp_0:div class="x-groupwareMail" style="display:none"></sp_0:div>
                    <sp_0:div class="org">
                        <sp_0:span class="organization-unit"></sp_0:span>
                    </sp_0:div>
                    <sp_0:div class="role"></sp_0:div>
                    <sp_0:div class="title">Applications Developer/Analyst</sp_0:div>
                    <sp_0:div class="uid">265418</sp_0:div>
                    <sp_0:div class="x-profile-uid">010101</sp_0:div>
                    <sp_0:div class="x-lconn-userid">265418</sp_0:div>
                </sp_0:span>
            </sp_0:div>
        </content>
    </entry>
    <entry>
        etc....
    </entry>
</feed>

I get an error on nodelist = doc.SelectNodes("//entry/content/sp_0:div/span/sp_0:span") saying:

Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

How can I get the internal text 010101 from that class?

A: You will need to use the XmlNamespaceManager class to define the namespaces used in your XPath, and pass this to the SelectNodes method.  In addition, I couldn't get an empty namespace to work for the default namespace (perhaps a limitation with XPath?), so had to define a prefix for that.
Also, your XPath doesn't seem to match your sample XML.  Lets say you wanted to get the value for the <sp_0:div class="x-profile-uid">010101</sp_0:div> element, you would want something like this:
Dim nodelist As System.Xml.XmlNodeList = Nothing
Dim doc As New System.Xml.XmlDocument()

doc.LoadXml(tmpData)

Dim nsmgr = New XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("atom", "http://www.w3.org/2005/Atom")
nsmgr.AddNamespace("sp_0", "http://www.w3.org/1999/xhtml")

nodelist = doc.SelectNodes(
    "//atom:entry/atom:content/sp_0:div/sp_0:span/sp_0:div[@class='x-profile-uid']",
    nsmgr
)

For Each node As System.Xml.XmlElement In nodelist
   Debug.Print(node.InnerText)
Next

Which outputs:
010101

Hopefully you can adapt this to your needs.

A: You should define the namespace "sp_0", the same way you defined the other namespaces (xmlns:app="...") in the root element.
Look at the last line of the element: this is how to define the namespace for SP_0.

    <feed
xmlns:app="http://www.w3.org/2007/app"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xmlns:fh="http://purl.org/syndication/history/1.0"
xmlns:snx="http://www.ibm.com/xmlns/prod/sn"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns="http://www.w3.org/2005/Atom"
sp_0="http://www.w3.org/1999/xhtml">


text:
Q: In WCF is there a way to set ServiceContract Namespace assembly-wide? In WCF land, you can specify a Namespace prefix for anything that has a [DataContract] like so:
[DataContract(Namespace="MyApp")] public class whatever...

However if you wanted to apply a common namespace to ALL data contracts assembly-wide, you can use the ContractNamespaceAttribute:
/* in AssemblyInfo.cs */
[assembly: ContractNamespace("MyApp", ClrNamespace = "MyApp")]

/* in whatever.cs */
[DataContract] public class whatever...

Thats great, works fine. Now over on the ServiceContract side, I can do the same Namespace setup on the service interface:
[ServiceContract(Namespace="MyApp")] public interface whateverService...

But is there something comparable to [assembly: ContractNamespace] that can be used to set the Namespace for all [ServiceContract]s?  I'd really like to avoid having to set it manually for however many services, its nice having it in 1 place for the data contracts.
Since there is an assembly level namespace attribute for the data contracts, i'd hope there is one for the service contracts too...

A: No, you cannot - you have to be very explicit in WCF and you have to explicitly set things like namespaces on each and every ServiceContract. I would probably even do it on each and every DataContract as well - just to be clear about what I am doing.
It's a good thing, though! Being explicit also makes your intentions clear - trust me, in a complex system, that helps !
Marc


text:
Q: Overcoming "No owner defined between domain classes" in Grails many-to-many relationship I was following the "Grails in Action" book in order to create the following scenario.

A map belongs to one or many mapsets. A mapset can contain one or many maps. Both belong to a user.

So, what I did was:
Map.groovy:
static hasMany = [ sets : Mapset ]
static belongsTo = [ user : User, set : Mapset ]

Mapset.groovy:
static hasMany = [ maps : Map ]
static belongsTo = [ user : User ]

User.groovy:
static hasMany = [ maps : Map, sets: Mapset ]

Still, I receive this error when running the app:

Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: No owner defined between domain classes [class at.package.Mapset] and [class at.package.Map] in a many-to-many relationship. Example: static belongsTo = at.package.Map

It doesn't change anything if I write the fully qualified class name for Map.

A: Whoops, this is weird. The following the trick:
In Map.groovy:
static belongsTo = [ User, Mapset ]

I'd probably keep this as an answer instead of deleting the question because there's no reference for this error message on SO yet


text:
Q: Why is the function inside the dictionary executing before they're called I'm trying to make simple code that reads names and put it on a list, what i am intending to do is a series of functions to add names to the list, remove name, find name position etc. so it will have a lot of ifs, to avoid that i tried to use a dictionary to store the functions that will be called, but when i execute the program the functions inside the dictionary are running before i can input the number to execute it
def addName(nameListAux):
    """Returns a list of names

    Args:
        aux str: name that will add to the list list
    """

    name = str(input('Enter a new name: '))

    while name != 'quit':

        nameListAux.append(name)
        print(nameListAux)
        name = str(input('Enter a new name: '))

    print(nameListAux)
    return nameListAux

def searchName(searchedNameList):
    """Search a name on the list

    Args:
        searchedNameList list: list that will search the name

    Returns:
        int: position of the name in the list
    """
    name = str(input('Enter name to be searched: '))

    listLength = (int(len(searchedNameList)) // 2) - 1

    while listLength <= (int(len(searchedNameList) - 1)):
        if name == searchedNameList[listLength]:
            return print('the name is at position', listLength)
        listLength += 1

    listLength = (int(len(searchedNameList)) // 2) - 1

    while listLength >= 0:
        if name == searchedNameList[listLength]:
            return print('the name is at position', listLength)
        listLength -= 1

if __name__ == '__main__':

    nameList = []

    selectionDict = {
        1: addName(nameList),
        2: searchName(nameList),
    }

    while True:
        switch = int(input('''Choose a option:
        1- Add name to list
        2- Search for name in list
        '''))

A: To store a function inside dictionary , you need to store the function name without the bracelet.
So in your case it should be like this :
selection_dict = {1: addName, 2:searchName}

You should have looked more information on google on how to store a function inside a dict. This link will be an useful example for you : Is there a way to store a function in a list or dictionary so that when the index (or key) is called it fires off the stored function?


text:
Q: How to get ad slot by slot name I'm using DFP to show ads on a web page.
Is there any way to refer to particular ad slot by name? e.g. googletag.getSlotByName('abc')
My intension is to refresh ads in particular slots.

A: Yes. The pubads.defineSlot method returns a reference to the slot. This reference can be saved in a variable so you can use it later to refresh it. This would be an example:
googletag.cmd.push(function() {
    var slotABC = googletag.defineSlot("/12345678/SLotABC", [728, 90],
    "div-gpt-ad-1327312723268-0").addService(googletag.pubads());
    googletag.enableServices();
    googletag.display("div-gpt-ad-1327312723268-0");

    //Then you can refer to it and refresh it like this:
    googletag.pubads().refresh([slotABC]);
})

More info: here


text:
Q: How to customize Ubuntu on laptop lid close behavior I would like to learn how to customize the behavior of Ubuntu when the laptop lid closes. I can only guess that a script is run when the laptop lid is closed.
Is there a tutorial/literature explaining what script gets run upon the laptop lid closing / re-opening? I would like to ultimately customize it so I can make my laptop hibernate whenever the lid is closed.
On a longer note, learning which scripts get called, or the hooks into the operating system that allow the OS to be customized for the hardware it runs on is the more substantial goal. I'm using this problem of my laptop not hibernating as a means to learn that.


text:
Q: Twitter embedded for Angular 2 I tried to embed Twitter timeline to my Angular 2 app.
I followed this tutorial https://publish.twitter.com
then I had this
Tweets by TwitterDev

I put a tag into template and put script tag into index.html. This is an example.

<!doctype html>

    <meta charset="utf-8">
    <title>Angular 2 App | ng2-webpack</title>
    <link rel="icon" type="image/x-icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">

    <base href="/">

    <my-app>

loading

        Tweets by TwitterDev

    </my-app>

But it only showed the a tag, no timeline.
Please help me !

A: You should run the twitter widget script after your template was loaded.
I did this:
export class SectionSocialComponent implements AfterViewInit {
    constructor() {}

    ngAfterViewInit () {
            !function(d,s,id){
                var js: any,
                    fjs=d.getElementsByTagName(s)[0],
                    p='https';
                if(!d.getElementById(id)){
                    js=d.createElement(s);
                    js.id=id;
                    js.src=p+"://platform.twitter.com/widgets.js";
                    fjs.parentNode.insertBefore(js,fjs);
                }
            }
            (document,"script","twitter-wjs");
    }
}

And my .html file only contains this:
Tweets by TwitterDev

Maybe this is not the most elegant solution, but worked for me.

A: Load the Twitter's widgets library on the index.html file.

    ....

Puts the twitter reference on your template
Tweets by TwitterDev

Declare twitter var outside the class of your component as suggested by springerkc on comments.
declare var twttr: any;

Load the twitter widgets on AfterViewInit
ngAfterViewInit(): void {
    twttr.widgets.load();
}

I know that this is an old question and maybe there this answer out there, but that is the first place that Google send me.
References:
How do I render new Twitter widget dynamically?
Twitter Developer Documentation

A: I have found a rather simple way of achieving this, it works for Angular 6.
Twitter provides with following code. See here
National Park Tweets - Curated tweets by TwitterDev
It has two tags  and .
You can place the  tag within the  or  section in the index.html of your angular app and  can be placed in the template ( html ) of your desired angular component. It worked like charm.

A: If you go to this website, you can enter your twitter URL and it will generate the code for you.
It will provide you with two lines of code.  The second line of code is a script link to a javascript file that twitter is hosting.  It means that we don't need to execute it in the angular world :D
here is an example:
Tweets by TwitterDev

As Angular strips script tags out of its view, you will need to find a workaround.  One workaround is this answer here.
making the example:
Tweets by TwitterDev

A: you should re-run twitter widgets js file every time routing:

*

*Firstly be sure to import AfterViewInit in your component.
import { Component, OnInit, AfterViewInit } from '@angular/core';

*Use AfterViewInit in your component class.
export class OurNewsComponent implements OnInit, AfterViewInit

*Now try this it will be working fine.
        ngAfterViewInit() {

        // Tweets
        let ngJs: any;
        const ngFjs = document.getElementsByTagName('script')[0];
        const ngP = 'https';

        if (!document.getElementById('twitter-wjs')) {
          ngJs = document.createElement('script');
          ngJs.id = 'twitter-wjs';
          ngJs.src = ngP + '://platform.twitter.com/widgets.js';
          ngFjs.parentNode.insertBefore(ngJs, ngFjs);

        }
      }

A: Best way to integrate any twitter widgets in Angular2
Use https://www.npmjs.com/package/ngx-twitter-widgets
Install package
npm install --save ngx-twitter-widgets

Import NgxTwitterWidgetsModule to NgModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxTwitterWidgetsModule } from "ngx-twitter-widgets";

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxTwitterWidgetsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Use ngx-twitter-timeline tag to your template
<ngx-twitter-timeline
  [source]="{sourceType: 'profile', screenName: 'TwitterDev'}" >
</ngx-twitter-timeline>


text:
Q: Will multiple swap space's be effective? I installed Ubuntu on a 130 ssd and by default it only allocated one GB of swap space. I know swap space should be at least the size of your RAM so I would like to increase it. Instead of resizing I would like to make a new partition on my 1tb drive. I am wondering if this will hurt the performance of the swap space a lot or just a little because the additional space is on a hard drive and not SSD. Or if having multiple locations is a bad idea.

A: In general this highly depends on your use case. E.g. if you do not make use of hibernate to disk (which uses swap to hibernate) you do not need that much amount of swap space and 1GB might be sufficient.
To come back to your question. If you are swapping a lot e.g. because you run low on memory all the time and you have one swap partition on a SSD and the other on a HDD, this will impact performance as the HDD will be the bottleneck in this scenario.
If you just want to add some more swap space for some corner cases to prevent the out-of-memory killer, you could add the swap space on your SSD with a higher priority compared to the swap partition on your HDD. That would result in that the swap on the SSD would get filled first, when the swap area on the SSD is exhausted the swap space on the HDD would be used additionally.
From man 2 swapon.

Swap  pages are allocated from areas in priority order, highest priority first.  For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area.  If two or  more  areas  have the  same  priority,  and  it  is  the  highest priority available, pages are allocated on a round-robin basis between them.

From man swapon:

priority is a value between -1 and 32767.  Higher numbers indicate
higher priority.  See swapon(2) for a full description of swap
priorities.  Add pri=value to the option field of /etc/fstab for use
with swapon -a.  When no priority is defined, it defaults to -1.

To change the default priority of your swap partitions you would have to add/alter your /etc/fstab.
/dev/<swap-ssd> swap swap defaults,pri=1000     0 0
/dev/<swap-hdd> swap swap defaults              0 0


text:
Q: Get Mac logged in user email in Electron Application In Atom Electron desktop application, is there any way to get the logged in user's email address in Mac OS X, So that I can use that email address in the main js file
I have searched in stackoverflow and other resources, but didn't find a way to do that.


text:
Q: Evaluate $\int_0^{\frac{π}{2}}\tan (x)\ln (\sin x)\ln (\cos x)dx$
Evaluate:
  $$I=\int_0^{\frac{π}{2}}\tan (x)\ln (\sin x)\ln (\cos x)dx$$

My ideas is to use the Fourier series of log sin and log cos:
$$\ln (2\sin x)=-\sum_{k=1}^{\infty}\frac{\cos (2kx)}{k}$$
$$\ln (2\cos x)=-\sum_{k=1}^{\infty}\frac{(-1)^{k}\cos (2kx)}{k}$$
But my problem is that I find difficult integrals like:
$$\int\tan (x)\cos (2kx)dx$$
My another idea is:
Use the substation : $y=\tan x$ then $dx=\frac{dy}{1+y^2}$
Then where $x=0 \Rightarrow y=0$ and for $x=\frac{π}{2} \Rightarrow y=\infty$
So:
$$I=\frac{1}{2}\int_0^{\infty}\frac{y\ln \left(\frac{y}{\sqrt{1+y^2}}\right)\ln (1+y^2)}{1+y^2}dy$$
But now I don't know how to complete.

A: $I=\int_0^{\frac{π}{2}}\tan (x)\ln (\sin x)\ln (\cos x)dx$
$=-\int_0^{-\infty}t\ln (\sqrt{1-e^{2t}})dt$
(substituting $\ln(\cos{x}) = t$, so $\tan{x} dx = -dt$, and $\sin{x} = \sqrt{1-\cos^2{x}} = \sqrt{1-e^{2t}}$)
$=-\int_0^{\infty}u\ln (\sqrt{1-e^{-2u}})du$ (Substituting $t = -u$)
$=-\frac{1}{2} \int_0^{\infty}u\ln (1-e^{-2u})du$
$=-\frac{1}{2}\int_0^{\infty}u\sum_{n=1}^{\infty} (-e^{-2nu}/n)du$
$=\int_0^{\infty}\sum_{n=1}^{\infty} (\frac{(2nu)e^{-2nu}}{8n^3})(2ndu)$
$=\sum_{n=1}^{\infty} \frac{1}{8n^3}\int_0^{\infty} ke^{-k} dk$ (Subtituting $2nu = k$, and $\int_0^{\infty} ke^{-k} dk =1 $)
$=\frac{\zeta{(3)}}{8}$

A: $$\int_0^\frac{\pi}{2} \frac{\ln(\sin x)\ln(\cos x)}{\cos x}\sin xdx\overset{\cos x=t}=\int_0^1 \frac{\ln(\sqrt{1-t^2})\ln t}{t}dt\overset{t^2=x}=\frac18 \int_0^1 \frac{\ln(1- x)\ln x}{x}dx$$
$$=\frac18\int_0^1 \left(-\sum_{n=1}^\infty \frac{x^n}{n}\right)\frac{\ln x}{x}dx=-\frac18 \sum_{n=1}^\infty\frac{1}{n}\int_0^1 x^{n-1}\ln xdx=\frac18\sum_{n=1}^\infty \frac{1}{n^3}=\frac{\zeta(3)}{8}$$

A: We can actually use the Beta Function with this one. Here we will address your integral:
\begin{equation}
I = \int_0^\frac{\pi}{2} \tan(x) \ln(\sin(x))\ln(\cos(x))\:dx
\end{equation}
We note that:
\begin{equation}
\tan(x) = \sin(x)\cos^{-1}(x),\:\:\lim_{a \rightarrow 0^+} \frac{d}{da} \sin^a(x) = \ln(\sin(x)),\:\:\lim_{b \rightarrow 0^+} \frac{d}{db} \cos^b(x) = \ln(\cos(x))
\end{equation}
Thus $I$ becomes:
\begin{equation}
I = \int_0^\frac{\pi}{2} \sin(x)\cos^{-1}(x) \cdot \lim_{a \rightarrow 0^+} \frac{d}{da} \sin^a(x) \cdot \lim_{b \rightarrow 0^+} \frac{d}{db} \cos^b(x)\:dx
\end{equation}
By the Dominated Convergence Theorem and  Leibniz's Integral Rule:
\begin{align}
I &= \lim_{a \rightarrow 0^+} \frac{d}{da}  \lim_{b \rightarrow 0^+} \frac{d}{db}  \int_0^\frac{\pi}{2} \sin(x)\cos^{-1}(x) \sin^a(x) \cos^b(x)\:dx \nonumber \\
&= \lim_{(a,b)\rightarrow (0,0)^+} \frac{\partial^2}{\partial a \partial b} \int_0^\frac{\pi}{2} \sin^{a + 1}(x)\cos^{b - 1}(x)\:dx \nonumber \\
&= \lim_{(a,b)\rightarrow (0,0)^+} \frac{\partial^2}{\partial a \partial b} \left[\frac{1}{2}B\left(\frac{a + 2}{2}, \frac{b}{2} \right) \right]
\end{align}
Where $B(\cdot, \cdot)$ is the Beta Function
From here convert to the Gamma Representation, apply the derivatives and the evaluate at $(a,b) = (0,0)$ and you're done!

EDIT - This doesn't work. The Beta Function is undefined for $b = 0$.

A: $$
\begin{aligned}
\int_0^{\frac{\pi}{2}} \tan x \ln (\sin x) \ln (\cos x) d x =&-\frac{1}{2} \int_0^{\frac{\pi}{2}} \ln (\sin x) d\left(\ln ^2(\cos x)\right)\\ \stackrel{IBP}{=}  & \frac{1}{2} \int_0^{\frac{\pi}{2}} \frac{\cos x}{\sin x} \ln ^2(\cos x) d x\\ \stackrel{\cos^2x\mapsto x}{=}  & \frac{1}{16} \int_0^1 \frac{\ln ^2 x}{1-x} d x\\=&\frac{\zeta(3)}{8}
\end{aligned}
$$
for the last integral, please read my post.


text:
Q: Searchview in centre and after focus it goes to app bar in android Hey guys I am learning Searchview in android. I have searchview in centre and when I focus it will go to app bar just like chrome application.

And when focus it will go to app bar

I didn't find any solution. Can someone guide me on this. Thanks

A: I remember a good tutorial regarding transition animation: I think this one
Basically, I'd would need 2 Activities(Fragments) and both have SearchView. When user click on SearchView you would you transition animation to make an affect of moving SearchView from first screen to the second


text:
Q: Create multi-day events with gaps in fullcalendar I am developing a planning solution using fullcalendar.
I am struggling to find a fullcalendar approach for following requirements:
Case: i want to plan an event of 40 hours by dragging an item into fullcalendar
Requirements
The calendar must create an multi-day event, planning maximum 8 hours a day (5 days in total).
The calendar must show the event in day-mode (timegrid) and in month-mode (timeline)
In day mode, the event must show start, lunchbreak and stop , no all-day events.
In timeline (month-view) , the event must be displayed as one draggable event. It should not plan 8hours a day on weekends, but it should continue planning on Monday.
As fullcalendar events are defined by start and stop date, with no fullcalendar functionality to create gaps (non-business hours, lunch breaks, weekends), it seems i would have to split the event in a chain  of communicating events and build a lot of planning logic for dropping and dragging.
Are there any fullcalender best-practices that can help for these requirements?
Any advice on the approach would be very welcome.


text:
Q: Application visibility on google play for app with camera permission Welcome,
I'm trying figure out why my app is not visible for example for samsung galaxy mini 2. This is my configuration
Features 7 features
android.hardware.CAMERA
android.hardware.camera.AUTOFOCUS
android.hardware.LOCATION
android.hardware.location.GPS
android.hardware.screen.LANDSCAPE
android.hardware.screen.PORTRAIT
android.hardware.TOUCHSCREEN

Required permissions 8 permissions
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_NETWORK_STATE
android.permission.CAMERA
android.permission.INTERNET
android.permission.READ_EXTERNAL_STORAGE
android.permission.WAKE_LOCK
android.permission.WRITE_EXTERNAL_STORAGE
com.android.vending.BILLING

I found that this may be the solution but I'm not sure

I will check it but still I want to understand how it works.
Is there any page which based on permissions can tell why specific device is not supported?

A: You're requesting android.hardware.camera.AUTOFOCUS.
The Galaxy Mini 2 review here says;

The camera on the back is only 3 megapixels and there's no auto-focus.


text:
Q: Cannot add database to an Asp.Net application I'm unable to add an mdf database file by right clicking on the project name and clicking on "Add->New Item->SQL Server Database".
It gives me the following error...
**

Connections to SQL Server files
  (*.mdf) require SQL Server Express
  2005 to function properly.  Please
  verify the installation of the
  component or download from the URL:
  http://go.microsoft.com/fwlink/?LinkId=49251

**

*

*I'm using SQL server 2008 enterprise
edition ...but I installed it with
the instance name as SQLEXPRESS since
some applications expect it.

*I've uninstalled SQL SERVER 2005 express

Any ideas why and what I should do to correct this?
Thanks

A: Just specifying the instance name as SQLEXPRESS in the Instance name won't trick the system into thinking that you actually have the express version installed, so our first bullet point would not help.
Your second point says you uninstalled SQL Server 2005 Express, which is the opposite of what you need to do.
Did you ever have the true Express edition?  (Not the Developer edition that installs with Visual Studio, but the actual SQL Server 2005 Express edition downloaded from the link you posted)?
Edit - Added
I see that the link takes you to the 2008 Express edition, not 2005.  I would try going and getting the 2005 install from here instead:
http://www.microsoft.com/express/sql/previous/register.aspx


text:
Q: how to read output of system('ls')? I am doing some file IO with c code. I have a particular pattern in my file. I can verify this by a shell command cat abc.txt | grep abc | wc -l. When I execute the same command using System(), it give proper output, but I have no clue how can I get its output into a variable and compare it in my c code itself.
I tried looking into man pages which suggest using WEXITSTATUS(). This actually returns the status of execution and not output.
F1 !!

A: You don't want system(3) for that. Try popen(3) and friends.

A: What grep and wc are doing are reading the STDIN file handle as part of the pipe |  operator.

A: You can try:
...
pid_t pid = fork();
if(pid == 0){
    int fd = open("output", O_RDWR | O_CREATE);
    close(1);
    (void) dup(fd);  // this will return 1
    system(your_cmd);
    // read output from fd
    // close fd
    // exit
}
else{
...

This will redirect output from command executed by system() to your "output" file.


text:
Q: STL algorithm and (end of) arrays I am new to C++. I was trying using the accumulate algorithm from the numeric library. Consider the following code segment.
int a[3] = {1, 2, 3};
int b = accumulate(a, a + 3, 0);

It turns out that the code segment works and b gets assigned 1+2+3+0=6.
If a was a vector<int> instead of an array, I would call accumulate(a.begin(), a.end(), 0). a.end() would point to one past the the end of a. In the code segment above, a + 3 is analogous to a.end() in that a + 3 also points to one past the end of a. But with the primitive array type, how does the program know that a + 3 is pointing at one past the end of some array?

A: The end iterator is merely used for comparison as a stop marker, it does not matter what it really points to as it will never be dereferenced. The accumulate function will iterate over all elements in the range [a, a+3[ and stop as soon as it encounters the stop marker.
In the C-style array case, the stop marker will be the element one past the end of the array. This would be the same in the std::vector case.


text:
Q: Right way to program in MVC3, appropriate use of partial views I have a view, on the top there's a dropdownlist which basically allows user to select one of the two options.On now the basis of this selection i have to show the content on this page.
Now, what 'd be the right way to go, i should create two partial views and put them in separate divs and on the basis of selection i'd make one of them visible
Or, just have two divs and have my chtml markup inside them and make one of them visible on the basis of user selection.

A: I don't see any reason of creating partial views if they are not required by multiple views, or loaded by ajax call. I would simply use two divs.

A: If you want to use partial views, you could use ajax to load them into a single div containing the content instead of having them both already on the page and hidden.
The jquery call to the controller would look like this:
$("#form").submit(function() {
        $.ajax({
        type: 'POST',
        url: '@Url.Action("PartialViewMethod","ControllerName")',
        data: $(this).serialize(),
        success: function (data) {
            $("#contentDivId").html(data);
        },
        });
}

The controller method would look like this:
public ActionResult PartialViewMethod (string PartialViewName) {
     return PartialView("_" + PartialViewName);
}

Assuming that this is wrapped in a form submitting the name of the partial view you want to return, this would load the html from the partial view into the div with the id contentDivId.


text:
Q: Trying to understand this Can someone please explain the way this python code works. I came across it as a solution to a practice question that requires me to convert the morse code to readable text considering a dictionary containing interpretation of the codes exist:
The code to be converted:
decodeMorse('.... . -.--   .--- ..- -.. .')

The solution:
return ' '.join(''.join(MORSE_CODE[letter] for letter in word.split(' ')) for word in morseCode.strip().split('   '))

I just can't rap my head around the nested join() method solution

A: The equivalent code to
return ' '.join(''.join(MORSE_CODE[letter] for letter in word.split(' ')) for word in morseCode.strip().split('   '))

is the following:
MORSE_CODE = {
  '.-': 'A',
  '-...': 'B',
  #...And so on
}

def decodeMorse(morseCode):
  result = []
  for word in morseCode.strip().split('   '):
    current_word = []
    for letter in word.split(' '):
      current_word.append(MORSE_CODE[letter])
    result.append(''.join(current_word))
  return ' '.join(result)

print(decodeMorse('.... . -.--   .--- ..- -.. .'))

It uses multiple Generator Expressions, which is exactly a list comprehension, but not stored into a list to split the code into words, and each word into letters which is translated into letters and a sentence.
I hope this helps you wrap your head around the code that's been presented to you.


text:
Q: Sorting 2D String Array with BUBBLESORT in java Similar questions have been asked but never about 2D String Arrays, therefore after trying for a long time I couldn't find what I wanted. I'm trying to sort a 2D String Array in java using BubbleSort.
As input, I receive a two-dimensional array (a table) of Strings and the index of the "column" you should sort. I should sort the rows by the values in the indicated column.
You can see the first index as a row index, and the second index as a column index. For example, the following Java array and table correspond with each other:
String[][] table = {
  {"a", "b"},
  {"c", "d"}
};

-
0   1
  +---+---+
0 | a | b |
  +---+---+
1 | c | d |
  +---+---+

To continue on this example, table[0][1] will yield the value "b", since it's the item in row 0 and column 1.
IMPORTANT: I am not allowed to use any sorting algorithm from the Java library, for example Arrays.sort.
This is what I've tried so far:
class Solution {
        public static void stableSort(String[][] table, int column) {
            int i;
            int j;
            String temp = null;
            for (i = 0; i < table.length - 1; i++) {
                for (j = 0; j < table.length - 1 - i; j++) {
                    if (table[i][j].compareTo(table[i][j + 1]) > 0) {
                        temp = table[i][j];
                        table[i][j] = table[i][j + 1];
                        table[i][j + 1] = temp;
                    }
                }
            }
        }
    }

I get an Index out of Bounds error and also it is not working as the test expects a different result in table[0][0]
Thanks for your help.

A: public static String[][] stableSort(String[][] table, int column) {
    int i=0,j=0;
    String[] temp = null;
    boolean swap=true;
    while(swap)
    for (i = 0; i < table.length - 1; i++) {
        swap=false;
        if(table[i][column].compareTo(table[i+1][column]) > 0){
            temp = table[i];
            table[i] = table[i+1];
            table[i+1]=temp;
            swap=true;
        }
    }
    return table;
}

It keeps applying the bubblesort until no more swaps are performed. At that point,the condition while(swap) is no longer satisfied and the method returns.
Tried in a main and it works (if I understand what you meant):
public static void main(String[] args) {
    String[][] table = {
            {"z", "b", "v"},
            {"s", "w", "a"},
            {"r", "c", "h"}
    };

    table = stableSort(table,1);
    for(int i = 0; i < table.length; i++){
        for(int j = 0; j < table[0].length; j++){
            System.out.printf("%5s ", table[i][j]);
        }
        System.out.println();
    }
}

this outputs:
z     b     v
r     c     h
s     w     a

A: EDIT: Working and no errors
If I take your exact sort but add a if statement for the switching of rows, add an exterior loop to run through the 2D array the length times the width and change the for loop control to '<=' then I get the following
   for(int z = 0; z < table.length * table.length; z++) // exterior for loop to run through the loop multiple times
   {
       for (i = 0; i <= table.length - 1; i++) {
           for (j = 0; j <= table.length - 1; j++) {
              if(j == table.length -1 && i == table.length-1) // If we are at the end then we can continue either to the next iteration or to the end of program
                  continue;
              if(j == table.length -1) // If you are ate the end of the row compare to the next row
              {
                   if (table[i][j].compareTo(table[i+1][0]) > 0) {
                       temp = table[i][j];
                       table[i][j] = table[i+1][0];
                       table[i+1][0] = temp;
                   }
              }
              else if (table[i][j].compareTo(table[i][j + 1]) > 0) {
                   temp = table[i][j];
                   table[i][j] = table[i][j + 1];
                   table[i][j + 1] = temp;
              }
           }
       }
   }

I saw what you were trying to do by minimizing the number of checks when you put
table.length - 1 - i

That is good for efficiency but first attempt to get the sorting working. then trim it down to preform better.
Also I don't have a compiler in-front of me so code could have some errors

A: to start, make it a 1d array
or at least 1d indexable
much easier
formula:
x = (int)index/(int)rows
y = index % rows

with that you can use 1 variable index
and index a 2d array
and this is a bubblesort
def sort(self):
    for passnum in range(len(self.array)-1,0,-1):
        for i in range(passnum):
            if self.array[i]>self.array[i+1]:
                temp = self.array[i]
                self.array[i] =  self.array[i+1]
                self.array[i+1] = temp

A: My working solution:
import java.util.Arrays;

public class MySolution {
    public static void stableSort(String[][] table, int column) {
        String[] temp = null;
        int rows = table.length;
        for (int i = 0; i < rows; i++) {
            for (int j = 1; j < (rows - i); j++) {
                if (table[j - 1][column].compareTo(table[j][column]) > 0) {
                    temp = table[j - 1];
                    table[j - 1] = table[j];
                    table[j] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        String[][] table = { { "c", "d" }, { "a", "b" } };
        printTable(table);
        stableSort(table, 1);
        printTable(table);
    }

    private static void printTable(String[][] table) {
        System.out.println("table:");
        for (int i = 0; i < table.length; i++) {
            System.out.println(Arrays.toString(table[i]));
        }
    }
}

some notes for you:

*

*use meaningful names (rows is easier to understand than table.length)

*bubble sort loops were a bit off, there are plenty of examples of how to do it online

*as mentioned, you should start by doing it for 1d array and then "generalize" it

*one big issue you had: using j (which should be the index of the row to compare to) as the column (and ignoring column)

*another big issue is only substituting the element (instead of the rows)

I hope this helps you!
EDIT: I just noticed you've also switched between row and column in your code (in your explanation the first index denotes the row, in your code it seems like the opposite is correct)


text:
Q: Inheritance and methods overriding I am making a collision system in C++ with SFML. I have a base object class with the following methods :
class Object : public sf::CircleShape {
protected:
    bool collision;

    void onCollision();
    void afterCollision();
public:
    bool checkCollision(Object& object);
    bool reactCollision(bool _collision);
};

bool Object::checkCollision(Object& object) {
    //Calcul distance with object and radius
    bool _collision = (distance <= radius)? true : false;

    this->reactCollision(_collision)
    return _collision;
}

bool Object::reactCollision(bool _collision) {
    //If collision state change compare to previous
    if(_collision != collision) {
        if(_collision) {
            this->onCollision();
        }
        else {
            this->afterCollision();
        }

        collision = _collision;
    }
    return _collision;
}

void Object::onCollision() {
    this->setFillColor(sf::Color::Red);
}
void Object::afterCollision() {
    this->setFillColor(sf::Color::White);
}

And then a player class who implement object and overide two methods:
class Player : public Object {
protected:
    void onCollision();
    void afterCollision();
};

void Player::onCollision() {
    this->setFillColor(sf::Color::Magenta);
}
void Player::afterCollision() {
    this->setFillColor(sf::Color::Green);
}

The problem : player use the parent base methods instead of his owns specialized methods. If I implement reactCollision() and checkCollision() in the player class, it's working but that not the goal.
I would like to modify onCollision() in the children's classes of object without implementing the same code from reactCollision() and checkCollision() in the children classes.


text:
Q: Regex in Javascript returning false Regex is returning false for format '(###) ###-####', this regex works fine online with regex testers but not in javascript.
let phoneNumberRegex = new RegExp('^\(\d{3}\)\s\d{3}-\d{4}$');
if (phoneNumberRegex.test(phoneNumberElement.value)) {
   ...
}

Number that is failing is (123) 456-7890, I would like this exact format of number.

A: Backslashes need to be escaped with another backslash in string literals. To avoid this, use a regular expression literal instead of the RegExp constructor.

let phoneNumberRegex = /^\(\d{3}\)\s\d{3}-\d{4}$/;
console.log(phoneNumberRegex.test('(123) 456-7890'));


text:
Q: Will git keep the staged object after unstaging a file As I understand from this answer, each time I stage a file (or part of), git will create an index of the file as blob for including in the next commit.
The question is: will git keep that content after I unstage that file out of the index (as git suggest: git reset HEAD -- file). May be in the form of some dangling object as long as I'm not doing a garbage collect.
Please correct me if I'm wrong

A: Yes, you will have a dangling object.
me@myvm:/scratch/index2  (master)$ git hash-object foo
aff2b43e2799984a7b49aaafdeae5c424f7e4121
me@myvm:/scratch/index2  (master)$ git add foo
me@myvm:/scratch/index2  (master)$ git reset foo
me@myvm:/scratch/index2  (master)$ git fsck
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob aff2b43e2799984a7b49aaafdeae5c424f7e4121
me@myvm:/scratch/index2  (master)$


text:
Q: Forward Jacobian Of Neural Network in Pytorch is Slow I am computing the forward jacobian (derivative of outputs with respect to inputs) of a 2 layer feedforward neural network in pytorch, and my results are correct but relatively slow. Given the nature of the calculation I would expect it to be approximately as fast as a forward pass through the network (or maybe 2-3x as long), but it takes ~12x as long to run an optimization step on this routine (in my test example I just want the jacobian=1 at all points) vs the standard mean squared error so I assume I am doing something in an un-optimal manner. I'm just wondering if anyone knew a faster way to code this. My test network has 2 input nodes, followed by 2 hidden layers of 5 nodes each and an output layer of 2 nodes, and uses tanh activation functions on the hidden layers, with a linear output layer.
The Jacobian calculations are based on the paper The Limitations of Deep Learning in Adversarial Settings which gives a basic recursive definition of the forward derivative (basically you end up multiplying the derivative of your activation functions with the weights and previous partial derivatives of each layer). This is very similar to forward propagation, which is why I would expect it to be faster than it is. Then the determinant of the 2x2 jacobian at the end is pretty straightforward.
Below is the code for the network and the jacobian
class Network(torch.nn.Module):
    def __init__(self):
        super(Network, self).__init__()
        self.h_1_1 = torch.nn.Linear(input_1, hidden_1)
        self.h_1_2 = torch.nn.Linear(hidden_1, hidden_2)
        self.out = torch.nn.Linear(hidden_2, out_1)

    def forward(self, x):
        x = F.tanh(self.h_1_1(x))
        x = F.tanh(self.h_1_2(x))
        x = (self.out(x))
        return x

    def jacobian(self, x):
        a = self.h_1_1.weight
        x = F.tanh(self.h_1_1(x))
        tanh_deriv_tensor = 1 - (x ** 2)
        expanded_deriv = tanh_deriv_tensor.unsqueeze(-1).expand(-1, -1, input_1)
        partials = expanded_deriv * a.expand_as(expanded_deriv)

        a = torch.matmul(self.h_1_2.weight, partials)
        x = F.tanh(self.h_1_2(x))
        tanh_deriv_tensor = 1 - (x ** 2)
        expanded_deriv = tanh_deriv_tensor.unsqueeze(-1).expand(-1, -1, out_1)
        partials = expanded_deriv*a

        partials = torch.matmul(self.out.weight, partials)

        determinant = partials[:, 0, 0] * partials[:, 1, 1] - partials[:, 0, 1] * partials[:, 1, 0]
        return determinant

and here are the two error functions being compared. Note that the first one requires an extra forward call through the network, to get the output values (labeled action) while the second function does not since it works on the input values.
def actor_loss_fcn1(action, target):
    loss = ((action-target)**2).mean()
    return loss

def actor_loss_fcn2(input): # 12x slower
    jacob = model.jacobian(input)
    loss = ((jacob-1)**2).mean()
    return loss

Any insight on this would be greatly appreciated

A: The second calculation of 'a' takes the most time on my machine (cpu).
# Here you increase the size of the matrix with a factor of "input_1"
expanded_deriv = tanh_deriv_tensor.unsqueeze(-1).expand(-1, -1, input_1)
partials = expanded_deriv * a.expand_as(expanded_deriv)

# Here your torch.matmul() needs to handle "input_1" times more computations than in a normal forward call
a = torch.matmul(self.h_1_2.weight, partials)

On my machine the time of computing the Jacobian is roughly the time it takes torch to compute
a = torch.rand(hidden_1, hidden_2)
b = torch.rand(n_inputs, hidden_1, input_1)
%timeit torch.matmul(a,b)

I don't think it is possible to speed this up, computationally wise. Unless you can move from CPU to GPU, because GPU get better on larges matrices.


text:
Q: Jquery insertBefore/insertAfter animation not working I made a simple script that allows users to sort divs using up and down buttons.
jsFiddle: http://jsfiddle.net/dZ6rC/5/
Unfortunately, my attempt to animate the move on mouse click does not cause the tags to be moved.
This is my code:
$('.up').click(function(){
  var previous = $(this).parent().parent().prev('.item');
  $(this).parent().parent().insertBefore(previous).slideUp();
});
$('.down').click(function(){
  var next = $(this).parent().parent().next('.item');
  $(this).parent().parent().insertAfter(next).slideDown();
});

Can someone figure out why the tags don't move?

A: You're not hiding the elements before sliding them down so the effect is not seen:
http://jsfiddle.net/dZ6rC/4/
You can just add .hide before .slideDown.  I think you probably want to improve the animation a bit from there, but just keep this in mind.

A: I am not completely sure what you are trying to accomplish but chaining 3 parent() calls is probably not the best way.
I am guessing this solves your problem:
$('.up').click(function(){
  $(this).parents('.item').slideUp();
});
$('.down').click(function(){
 $(this).parents('.item').slideDown();
});

If I am missing a requirement please update your question.

A: Just add the a sequence of hide and show:
jQuery(html_usr).insertBefore( "#log_row" ).hide().show('blind');


text:
Q: While Loop output data live (VB.net) XML Reader Background Story: I have a huge XML file (about 57 GB and increasing about 250 MB / week) which i need to read through and parse data to a database. So far I've been able to setup a XML reader in a while loop which can read each element at a time and output the data I need. I've also added an element counter and a limit of 600 elements in the loop. This works perfect and I'm able to get the first 600 elements of the total of 8.7 million elements in about 2sec. Then I changed the limit to loop the first 2000 elements and now it had to run for 20 sec. At 3000 elements it took almost 50 sec but the estimate from the first test showed it should have taking only 10 sec.
I've noticed that the while loop waits for the all the elements to run through before it displays it in my application. When I press the button nothing happens until all the data is ready. This is probably why it's getting exponentially slower and slower, as the application has to store each variable somewhere while the loop is active. The intention of the XML reader was to not store all the information in memory at once, but it looks like thats exactly whats it's doing now anyways.
QUESTION: Is there someway i can force the application to output the data to a database after each loop and therefore don't have to store anything in memory?
Here is my XML and the Vb.net code I've modified to my project. I can post my exact code if you need it, but it's very similair:
XML:
<reflection><apis>
<api id="M:Microsoft.VisualBasic.Strings.Mid(System.String,System.Int32)">
  <apidata name="Mid" group="member" subgroup="method" />
  <containers>
    <namespace api="N:Microsoft.VisualBasic" />
    <type api="T:Microsoft.VisualBasic.Strings" ref="true" />
  </containers>
</api>
<api id="M:Microsoft.VisualBasic.Strings.Mid(System.String,System.Int32,System.Int32)">
  <apidata name="Mid" group="member" subgroup="method" />
  <containers>
    <namespace api="N:Microsoft.VisualBasic" />
    <type api="T:Microsoft.VisualBasic.Strings" ref="true" />
  </containers>
</api></apis></reflection>

Button Click:
        Dim reader = Xml.XmlReader.Create("..\..\reflectionData.xml")
    reader.MoveToContent()

    While reader.ReadToFollowing("api")
        Dim api = TryCast(XElement.ReadFrom(reader), XElement)

        If api Is Nothing Then Continue While

        ' Get information from the <api> element.
        Dim ns = api.<containers>.<namespace>.@api
        Dim containingType = api.<containers>.<type>.@api
    End While

    reader.Close()