text:
Q: Sort hash by value and key (in that order) I'm looking for a nice way to sort a hash in Perl by value first and by key afterwards.
Example:
 my %userids = (
  williams => "Marketing",
  smith    => "Research",
  johnson  => "Research",
  jones    => "Marketing",
  brown    => "Marketing",
  davis    => "Research"
);

Output:
Marketing: brown
Marketing: jones
Marketing: williams
Research: davis
Research: johnson
Research: smith

Please note that value was the first sorting level. Second sorting level is key. Any idea how to do this in an elegant and high-performance way? Thanks!

A: I would like to add one more thing, use \L sequence in sorting.
From Perlfaq4: How do I sort a hash (optionally by value instead of key)?
To make our report order case-insensitive, we use the \L sequence in a double-quoted string to make everything lowercase. The sort() block then compares the lowercased values to determine in which order to put the keys.
foreach (sort { $userids{$a} cmp $userids{$b} or "\L$a" cmp "\L$b" )  {
    print "$_: $userids{$_}\n";
}

Output :
brown: Marketing
jones: Marketing
williams: Marketing
davis: Research
Johnson: Research # here 'J'ohnson, J is in uppercase(taking assumption), come as fifth record
smith: Research

2.
foreach (sort { $userids{$a} cmp $userids{$b} or $a cmp $b )  {
    print "$_: $userids{$_}\n";
}

Output:
brown: Marketing
jones: Marketing
williams: Marketing
Johnson: Research # here it shifted to fourth record
davis: Research
smith: Research

A: Good reference: http://www.misc-perl-info.com/perl-sort.html#shv
#!/usr/bin/perl

my %userids = (
    williams => "Marketing",
    smith    => "Research",
    johnson  => "Research",
    jones    => "Marketing",
    brown    => "Marketing",
    davis    => "Research"
);

foreach (sort { ($userids{$a} cmp $userids{$b}) || ($a cmp $b) } keys %userids)
{
    print "$_: $userids{$_}\n";
}


text:
Q: Прекратить бесконечный цикл после нажатия Enter while 0 == 0:
    a = 1
    a = input()
    if a == 1:
        print('some text')
    else:
        break

Цикл должен выполняться безпрерывно пока я не нажму Enter.
Как убрать прерывания на ввод input() или сделать ввод не обязательным.

A: я же вам уже отвечал. Если, что-то не понятно, то спросите - что не понятно.
a = 1
while a:
    a = input('\nВводите что-нибудь, выход `Enter`: ')
    print('some text ->`{}`'.format(a))

redpajama_set_name: RedPajamaStackExchange


text:
Q: flash actionscript countdown date difference returns NaN I am creating a simple countdown timer where the dates are being read from a text file. The dates are in the nanoseconds format. When it goes to calculate the difference between the 2 dates the result is showing up as NaN.
I tried trace(isNaN(currenttime)) and trace(isNaN(targettime)) and they both return false. However when I do the same on timeleft I am getting false meaning it is not a valid date format. Here is my code.
Appreciate your help in advance.
//Loads variables from external file called data.txt
//yr2016 - April 18 2016 - 1460952000000
//yr2017 - April 18 2017 - 1492488000000
//yr2018 - April 17 2018 - 1523976000000
//yr2019 - April 15 2019 - 1555300800000
//yr2020 - April 15 2020 - 1586923200000
//yr2021 - April 15 2021 - 1618459200000
//yr2022 - April 15 2022 - 1649995200000

this.onEnterFrame = function() {

loadvariablesnum("data.txt",0);

var today:Date = new Date();
var currentyear = today.getFullYear();
var currenttime = today.getTime();

switch(currentyear) {
    case 2016:
    var targetdate:Date = new Date(yr2016);
    var targettime = targetdate.getTime();
    break;

    case 2017:
    var targetdate:Date = new Date(yr2017);
    var targettime = targetdate.getTime();
    break;

    case 2018:
    var targetdate:Date = new Date(yr2018);
    var targettime = targetdate.getTime();
    break;

    case 2019:
    var targetdate:Date = new Date(yr2019);
    var targettime = targetdate.getTime();
    break;

    case 2020:
    var targetdate:Date = new Date(yr2020);
    var targettime = targetdate.getTime();
    break;

    case 2021:
    var targetdate:Date = new Date(yr2021);
    var targettime = targetdate.getTime();
    break;

    case 2022:
    var targetdate:Date = new Date(yr2022);
    var targettime = targetdate.getTime();
    break;
}

    var timeLeft = targetTime - currentTime;

    var sec = Math.floor(timeLeft/1000);
    var min = Math.floor(sec/60);
    var hrs = Math.floor(min/60);
    var days = Math.floor(hrs/24);
    sec = String (sec % 60);
    if (sec.length < 2) {
        sec = "0" + sec;
    }
    min = String (min % 60);
    if (min.length < 2) {
        min = "0" + min;
    }
    hrs = String (hrs % 24);
    if (hrs.length < 2) {
        hrs = "0" + hrs;
    }
    days = String(days);

    var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
    time_txt.text = counter;
}


text:
Q: Retrieve saved ticket details using square connect API I have been experimenting with square connect API.
Square recently introduced Saved "tickets" which allowed tickets to be printed and modified before actually charging customers.
When ticket is being saved. Is there a way I can retrieved contents of the saved tickets using connect-API?
It does not notify through web hook nor I can retrieve the list anywhere.
Thank you in advance!!!

A: There is currently no way to do this through the Connect API.


text:
Q: Install persistent Ubuntu Lucid Lynx on 16 GB pen Drive I am using Windows XP and I want to install Ubuntu 10.04 LTS Lucid Lynx on my 16 GB pen drive. I have a live Ubuntu disc. I want my install to be persistent so that whatever changes I make are preserved. I do not want to alter my MBR but I want to able to boot fro my pen drive through BIOS.

A: It works. I use a Jaunty install on a 16GB drive.
I dont expect Lucid to be any problem -- will be shifting to it shortly myself.
Ubuntu Wiki: LiveUsbPendrivePersistent

Update: I completed one 8GB flash drive install of Lucid yesterday.
Some points to remember,

*

*With Lucid, you can use the System, Administration menu
to install after booting with the LiveCD

*Remember to select the Advanced button after setting up your flash drive partition as root -- you must select the flash drive device (probably /dev/sdb) to write the MBR.
That way you wont kill the normal boot sequence of your machine.

*

*You can then plug the USB on any USB Bootable machine to boot into your Ubuntu system

*I usually tap the BIOS Boot Menu key at machine startup to manually select booting through the USB with such a bootable Ubuntu flash

*You can also have an extra data partition on the 16GB drive
(Ubuntu footprint will usually not exceed 10GB even after you install several additional things).

*

*If you make a partition that you might want to use as data space on a Windows machine,
it will be accessible only if its the first partition.

*So, use gparted to make a vfat or fat32 primary (of say 6GB),
then, mark the rest as logical and create your root partition (and a swap if you wish)

*Install Ubuntu in this logical root partition.

*You can mount the 6GB space from Ubuntu and still use the key as a 6GB drive on Windows (when you have not booted through it)

*

*Imagine the Possibilities!

*It would be wise to keep backing up any data you have on the flash drive
to a more permanent storage regularly
This will protect you from loss or damage of the tiny Ubuntu OS you can carry around with you

A: Of course, BACKUP, BACKUP and BACKUP first and foremost !!!!
I installed Ubuntu Lucid Lynx on a 16GB memory stick with no major issue. However, there is ONE thing that you need to be extremely careful about. At the very last window before confirming and going ahead, you need to click on the advanced button, to change the location of the master boot record for the startup. By default, it will install itself on /dev/sda, or /dev/hda, depending on your hard disk. This is your main booting hard disk, and it will screw up your hard disk. Make sure it is instead installed on the USB stick device, which should be something /dev/sdb, or /dev/sdc.
I would also recommend that you have NO other USB storage device on your computer at that time, and if you can temporarily disconnect your hard disk, it is even safer.
I screwed up two hard disks with this, once with JoliCloud, and once with Ubuntu 10.04.
I would also recommend that you have no swap partition. Such partition is accessed a lot and your memory stick has a finite number of writes it can sustain before becoming defective. If this is only to experiment with Ubuntu before doing the big move, don't worry. If you want to have it permanently on the stick for portable use, remove the swap partition, expanding the main partition instead.
But otherwise, it works like a charm.

A: If your BIOS supports disabling and enabling SATA and IDE ports, you don't have to worry about accidently overwriting your current MBR. Just disable them first.


text:
Q: ActionView::Template::Error (The asset "bootstrap.min.js" is not present in the asset pipeline.): I am coding a simple platform with Rails. I have deploy it in Heroku. Whe i test it local, it works, but in Heroku i have this error: ActionView::Template::Error (The asset "bootstrap.min.js" is not present in the asset pipeline.): :(
I have tried everything, but the error doesn't go. What do you think? What could i make? Thank you for your help!
PD:
My assets.rb file:
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# CSS
Rails.application.config.assets.precompile += %w( bootstrap.min.css )
Rails.application.config.assets.precompile += %w( icons.scss )
Rails.application.config.assets.precompile += %w( main.css )
Rails.application.config.assets.precompile += %w( responsive.css )

# JS
Rails.application.config.assets.precompile += %w( app.js common.js home2.js )
Rails.application.config.assets.precompile += %w( jquery-2.1.3.js )
Rails.application.config.assets.precompile += %w( bootstrap.min.js )

# Fuentes
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "fonts")

A: I just add these lines to application.js:
//= require bootstrap.min
//= require jquery-2.1.3
//= require app
//= require common
//= require home2

and i delete the direct references to the files in the index.html.erb


text:
Q: Adding references in beamer slides I am adding references in slides created using beamer.Following the post in this link
I made a few modifications. The line that appears in the footnote stops in the middle of the frame. How do we extend it until the end of the frame/ how to remove the line?
\documentclass[xcolor={table,dvipsnames,usenames}]{beamer}
\begin{filecontents}{\jobname.bib}
@book{Saussure1995,
    Author = {Ferdinand de Saussure},
    Origyear = {1916},
    Publisher = {Payot},
    Title = {Cours de Linguistique G{\'e}n{\'e}rale},
    Year = {1995}}

@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}

\end{filecontents}
\usepackage{natbib}
\usepackage{bibentry}
\bibliographystyle{apalike}
\usepackage{chngcntr}
\usepackage{subcaption}
\counterwithin*{footnote}{page}
\newcommand\footcite[1]{\footnote{\bibentry{#1}}\label{\thepage:#1}}
\newcommand\secondcite[1]{\textsuperscript{\ref{\thepage:#1}}}
\usepackage{graphicx}
\graphicspath{ {image/} }
\begin{document}
\nobibliography{\jobname}
\subsection{frame 6}
\begin{frame}{}
\begin{figure}[ht]
  \centering
  \begin{subfigure}{\linewidth}
    \centering\includegraphics[width=4cm]{rabbit.png}
  \end{subfigure}%
  \begin{subfigure}{\linewidth}
    \centering\includegraphics[width=4cm]{rabbit.png}\footcite{Saussure1995}
  \end{subfigure}
\end{figure}
\begin{figure}
\includegraphics[scale=0.6]{image/image.png}
\caption{Steps }
\end{figure}
\end{frame}
\end{document}

Edit1: Also, for images how do we directly include the reference at the footnote without displaying the reference number next to the image.

Edit2: The size of the font in the footnote appears big. I tried reducing the size using \tiny \footcite{Saussure1995}. But this isn't reducing the font size. Any suggestions?
Edit3:Here is the code without \subcaption and without figure
\documentclass[xcolor={table,dvipsnames,usenames}]{beamer}
\begin{filecontents}{\jobname.bib}
@book{Saussure1995,
    Author = {Ferdinand de Saussure},
    Origyear = {1916},
    Publisher = {Payot},
    Title = {Cours de Linguistique G{\'e}n{\'e}rale},
    Year = {1995}}

@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}

\end{filecontents}
\usepackage{natbib}
\usepackage{bibentry}
\bibliographystyle{apalike}
\usepackage{chngcntr}

\counterwithin*{footnote}{page}
\newcommand\footcite[1]{\footnote{\bibentry{#1}}\label{\thepage:#1}}
\newcommand\secondcite[1]{\textsuperscript{\ref{\thepage:#1}}}
\usepackage{graphicx}
\graphicspath{ {image/} }
\begin{document}
\nobibliography{\jobname}
\subsection{frame 6}
\begin{frame}{}
\includegraphics[width=.47\textwidth]{rabbit.png}\hfill
\includegraphics[width=.47\textwidth]{rabbit.png}\footcite{Saussure1995}
\vfill
\includegraphics[width=\textwidth,height=50pt]{image.png}
\includegraphics[scale=0.6]{image/image.png}
\caption{Steps }
\end{frame}
\end{document}

Edit5:
\documentclass[xcolor={table,dvipsnames,usenames}]{beamer}
\begin{filecontents}{\jobname.bib}

@article{aguiree2013idf,
  title={IDF diabetes atlas},
  author={Aguiree, Florencia and Brown, Alex and Cho, Nam Ho and Dahlquist, Gisela and Dodd, Sheree and Dunning, Trisha and Hirst, Michael and Hwang, Christopher and Magliano, Dianna and Patterson, Chris and others},
  year={2013},
  publisher={International Diabetes Federation}
}

\end{filecontents}
\usepackage{natbib}
\usepackage{bibentry}
\bibliographystyle{apalike}

\begin{document}
\nobibliography{\jobname}
\subsection{frame 6}
\begin{frame}{}
\begin{figure}
\includegraphics[width=.47\textwidth]{image/rabbit.png}\hfill
\includegraphics[width=.47\textwidth]{image/rabbit.png}
\vfill
\includegraphics[width=\textwidth,height=50pt]{example-image}
\caption{Steps}
\end{figure}
\vfill
\footnotesize Image credit: \bibentry{aguiree2013idf}
\end{frame}
\end{document}

 An error is displayed while compiling the above, citation not found.

A: Instead of trying to remove the footnoterule and the footnotemark, why not manually placing the reference at the bottom of the frame?
Off-topic: but you cannot use \caption outside of a figure or table environment.
\documentclass[xcolor={table,dvipsnames,usenames}]{beamer}
\begin{filecontents*}{\jobname.bib}

@article{aguiree2013idf,
  title={IDF diabetes atlas},
  author={Aguiree, Florencia and Brown, Alex and Cho, Nam Ho and Dahlquist, Gisela and Dodd, Sheree and Dunning, Trisha and Hirst, Michael and Hwang, Christopher and Magliano, Dianna and Patterson, Chris and others},
  year={2013},
  publisher={International Diabetes Federation}
}

\end{filecontents*}
\usepackage{natbib}
\usepackage{bibentry}
\bibliographystyle{apalike}

\begin{document}
\nobibliography{\jobname}
\subsection{frame 6}
\begin{frame}{}
\begin{figure}
\includegraphics[width=.47\textwidth]{rabbit.png}\hfill
\includegraphics[width=.47\textwidth]{rabbit.png}
\vfill
\includegraphics[width=\textwidth,height=50pt]{example-image}
\caption{Steps}
\end{figure}
\vfill
\footnotesize Image credit: \bibentry{aguiree2013idf}
\end{frame}
\end{document}


text:
Q: how to fix Warning: A non-numeric value encountered in this specefic line of code this are codes which might have problem ' how I can solve it?

<a href="<?php the_permalink(); ?>" title="<?php echo wp_strip_all_tags(get_the_title()); ?>">

<?php echo wp_strip_all_tags(get_the_title()); ?>


text:
Q: How to add line breaks to the specialties section of your LinkedIn profile How can we create line breaks in a way that they are respected by LinkedIn?
I'm using a Unix system (OS X).
I found this answer, but I think there has to be a way of doing it without running a Live CD.

A: If some people are reporting that it works on Linux, it's likely to be caused by the different line endings used by Windows.
At the end of a line:

*

*Windows uses carriage return, line feed (CRLF, \r\n)

*Linux uses line feed (LF, \n)

*Mac uses carriage return (CR, \r)

These are leftovers from ye olden days of computing, which, if you're really interested in it, you can read more about on Wikipedia's newline article.
Anyway, if you use a more powerful text editor on your Windows computer, many will have the option of converting line-breaks to the different styles. Just off the top of my head, Notepad++ and Komodo Edit are two free editors which can do this.

A: I give nickf's answer as valid as I found it very useful. However, keep in mind what Jil McElroy says (in the link I originally posted).

Be sure to review your Specialties in
  the "View My Profile" tab. For some
  reason, the "Edit my profile" tab does
  not format line breaks correctly.


text:
Q: My background service gets killed and restarted with long wait despite being busy There are many threads with similar issues and recommendations to fix. I've tried all and none works for my case except putting the service in foreground, which I do not want to do so far.
I cannot post a comment to existing threads as I don't have enough reputations and I want to question, so can't answer. This is the only choice to bring my question and look for some expert's opinions and recommendations.
Existing threads with similar issues discussed,
Time taken for Android Service to restart after being forcibly killed
Background Service getting killed in android
Android: Scheduling restart of crashed service with HUGE delay?
MY PROBLEM:
I've a service that starts at boot time (listening to intent BOOT_COMPLETED)
I start a thread that does interaction with other service through a socket and is interrupted when the service is killed (onDestroy).
Using Wifi on phone, my service is never killed by android and it works as expected.
If I switch to 3G only (At&T SIM), My service gets killed approx. after 1800 seconds (30 minutes) and scheduled to be restarted in approx. 3600 sec (1 hour). All this time the thread that service started is doing SQLLite calls and interacting with this other service.
Android thinks my service has been idle for 1800+ seconds and will kill its with long restart time.
Questions:

*

*What do I need to do to tell Android ActivityManager that my service is doing work using a thread it spun, so it should not be killed. Happens only on 3G.

*How to reduce the timer to under 20 seconds. 1 hour is just too long.
I did used AsyncTask to spin other thread that loops for ever sleeping 1 second, but still my service gets killed.

*How Android behavior changes when using 3G versus Wifi in determining which service to kill?

A: I found that android does not support long running background services. So my service that needed to keep communicating with other services, will get killed especially on 3G/4G when network bandwidth is more restricted.
I switched back to foreground mode, works fine now. I'll still like to hear if there's a way to avoid the foreground mode on 3G/4G.


text:
Q: Windows error: "'Enable-WindowsOptionalFeature' is not recognized" I am attempting to install the Windows Subsystem for Linux on my Windows 7 machine, following the instructions shown in this documentation.
The first step there says to run the command
> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

However, my machine does not recognize the Enable-WindowsOptionalFeature command.
PS C:\> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature : The term 'Enable-WindowsOptionalFeature' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Enable-WindowsOptionalFeature:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

*

*Why does my machine not recognize the Enable-WindowsOptionalFeature

*How can I proceed to install the Windows Subsystem for Linux?

A:
How can I proceed to install the Windows Subsystem for Linux?

The optional Windows feature, Windows Subsystem for Linux, cannot be enabled on Windows 7.  What you want is not possible.

*

*Windows 10 Installation Guide

Why does my machine not recognize the Enable-WindowsOptionalFeature

Enable-WindowsOptionalFeature is a Windows 8+ only command.  The PowerShell cmdlet just uses the DISM module to add/remove Windows Features, in order to do that it requires the version of DISM that comes with Windows 8+, the cmdlet Enable-WindowsOptionalFeature cannot be used on a Windows 7 machine.

This topic lists the Windows PowerShell modules included with Windows
  Server 2016 and Windows 10. The Windows PowerShell modules in the list
  support automating the features of those versions of the Windows
  operating system and provide links to the cmdlet references for each
  module. These modules enable you to use Windows PowerShell to
  administer, maintain, configure, and develop new features for Windows
  Server 2016 and Windows 10.

*

*Windows 10 and Windows Server 2016


text:
Q: Meteor can't find template that is defined 4 lines later This code:
//hello.js

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';

import './hello.html';

Template.hello.onCreated(function helloOnCreated() {
 // counter starts at 0
 this.counter = new ReactiveVar(0);
});

Template.hello.helpers({
 counter() {
   return Template.instance().counter.get();
 },
});

Template.hello.events({
 'click button'(event, instance) {
   // increment the counter when button is clicked
   instance.counter.set(instance.counter.get() + 1);
 },
});

Welcome to Meteor!

  {{> hello}}
  {{> info}}

<template name="hello">
  <button>Click Me</button>

You've pressed the button {{counter}} times.

</template>

<template name="info">

Learn Meteor!

Do the Tutorial

Follow the Guide

Read the Docs

Discussions

</template>

Returns this error:
Error: No such template: hello
    at lookup.js:189
    at Blaze.View.<anonymous> (spacebars-runtime.js:32)
    at view.js:199
    at Function.Template._withTemplateInstanceFunc (template.js:465)
    at view.js:197
    at Object.Blaze._withCurrentView (view.js:538)
    at viewAutorun (view.js:196)
    at Tracker.Computation._compute (tracker.js:311)
    at new Tracker.Computation (tracker.js:201)
    at Object.Tracker.autorun (tracker.js:576)

To prevent this for getting absurdly long, here is the GitHub repo if needed.
In the tutorial the template comes after the call. But for some reason, it won't on my page. If I move the templates above the call, it works, but not after. I'm not sure what I'm doing wrong.
Here is the directory structure as requested. I've just started this project, and hello is the only page at the moment.

A: You should also add a comment to the top of each file which merely indicates the working directory.
I assume the first snippet of code is the contents of hello.js and the second snippet to be the content of main.html. I also assume that you are NOT showing us the contents of hello.html.
If all these are true, I can see that you are importing hello.html into hello.js BUT you are ALSO referencing hello.html WITHIN main.html. I assume your error is Meteor being confused as to which is the right reference, and grabbing the wrong one.
Clean code tends to separate Meteor templates into their own directories and files anyways. I'd get rid of them from main.html.
UPDATE:
I think your issue is in your main.js, or rather, your routing file.
For starters, it's bad JS practise to import in the middle of the code. Good practise is:
1) Import all absolute paths
2) Add a spacing
3) Import all relative paths
4) Never import after that
Take a good look @ BlazeLayout.render which you have added to your project, but haven't used. Attempting to just brazenly import the JS file is never going to work. You need to pass arguments to the render method, which include the template you desire to render.


text:
Q: Find all irreducible representations $\pi$ of G and matrices $\pi$(x) and $\pi$(y) with respect to suitable basis Here is the information I have:

*

*G is the group of order 21

*it is generated by two elements $x$ and $y$

*$x^7=y^3=e$

*$xy=yx^2$

I want to do two things:

*

*Construct all irreducible representations of G

*Write down, for each $\pi$  the matrices $\pi$(x) and $\pi$(y) (with respect to suitable basis)

My idea:
First find the 1-dimensional relresentations and consider dimensions of the others but I am finding it very difficult to make progess on this.

A: Initially looking at this over the complex numbers is easier. A few fundamental theorems (which I suppose you have seen in your class) are:

*

*The number of representations is the number of conjugacy classes.

*The sum of the degrees squared is the group order and the degrees divide the group order

*The number of 1-dimensional representations is the index of the derived subgroup.

*Permutation representations are induced trivial representations.

With this the following approach (not all details are spelled out) will get you the representations:
Your group has (explicit calculations....) 5 conjugacy classes (with representatives $1,x,y,x^3,y^2$) and derived subgroup (generated by $x$) of order 7. So there are 5 irreducible representations, of degrees $1,1,1,3,3$.
The 1-domensional representations simply need to map $x$ trivially and $y$ to a 3-rd root of unity.
To get the other ones, note that the group has a faithful transitive permutation representation (on the cosets of $<y>$) of degree 7: $x\mapsto (1,2,3,4,5,6,7)$, $y\mapsto (2,3,5)(4,7,6)$. The point stabilizer has 3 orbits, so it is the sum of 3 irreducible representations, one of which is the trivial one.
The trivial representation is on the submodule spanned by $(1,1,1,1,1,1,1)$. The quotient module (for the permutation module) gives you a 6-dimensional real representation that is the sum of two complex conjugate 3-dimensional ones. If you only want real representations you are done. If you want complex 3-dimensional representations I would try to induce up a nontrivial 1-dimensional representation of $<x>$.


text:
Q: Exploding multiple dict columns and concatenating with original Pandas data frame I export a Postgres SQL query to create a Pandas data frame df similar to the following:
df = pd.DataFrame({
    'employee_id' : [123, 456, 789],
    'country_code' : ['US', 'CAN', 'MEX'],
    'sales' : [{'foo': 2, 'bar': 0, 'baz': 1},
               {'foo': 3, 'bar': 1, 'baz': 2},
               {'foo': 7, 'bar': 0, 'baz': 4}],
    'expenses' : [{'red': 1, 'white': 0, 'blue': 3},
               {'red': 1, 'white': 0, 'blue': 1},
               {'red': 2, 'white': 2, 'blue': 2}]
})

df

    employee_id   country_code      sales                             expenses
0   123           US                {'foo': 2, 'bar': 0, 'baz': 1}    {'red': 1, 'white': 0, 'blue': 3}
1   456           CAN               {'foo': 3, 'bar': 1, 'baz': 2}    {'red': 1, 'white': 0, 'blue': 1}
2   789           MEX               {'foo': 7, 'bar': 0, 'baz': 4}    {'red': 2, 'white': 2, 'blue': 2}

I would like to be able to explode both the sales and expenses columns so that their keys are separate columns.  Currently, I'm only able to explode one of these columns, as follows:
df = pd.json_normalize(df['sales'])
df
    foo bar baz
0   2   0   1
1   3   1   2
2   7   0   4

I'm not able to pass a list of columns to pd.json.normalize().
Questions:

*

*How do I explode both the sales and expenses columns?

*After exploding both columns, how do I add back the other two columns (employee_id and country_code) from the original data frame?

The desired output is:
    employee_id   country_code   foo   bar   baz   red   white   blue
0   123           US             2     0     1     1     0       3
1   456           CAN            3     1     2     1     0       1
2   789           MEX            7     0     4     2     2       2

Thank you!

A: You may use concat along axis=1 with json_normalize:
json_cols = ['sales','expenses']
result = pd.concat([pd.json_normalize(df[col]) for col in json_cols],axis=1)
result = pd.concat([df.drop(json_cols,axis=1),result],axis=1)

Output:
result
    employee_id country_code    foo bar baz red white   blue
0   123         US               2   0   1   1   0       3
1   456         CAN              3   1   2   1   0       1
2   789         MEX              7   0   4   2   2       2

A: If you want to modify the original dataframe, a variant would be:
cols = ['sales', 'expenses']

df = pd.concat([df]+[pd.json_normalize(df.pop(c)) for c in cols], axis=1)

output:
   employee_id country_code  foo  bar  baz  red  white  blue
0          123           US    2    0    1    1      0     3
1          456          CAN    3    1    2    1      0     1
2          789          MEX    7    0    4    2      2     2

A:    df.join(df.sales.apply(pd.Series))
    .join(df.expenses.apply(pd.Series))
    .drop(['sales','expenses'],axis=1)

       employee_id country_code  foo  bar  baz  red  white  blue
    0          123           US    2    0    1    1      0     3
    1          456          CAN    3    1    2    1      0     1
    2          789          MEX    7    0    4    2      2     2


text:
Q: Divide every row in a matrix by corresponding row in vector Imagine I have the following matrix:
mat <- read.table(text="
   0 25  7 25  9 20 26 26 22 19 22 25
  25  0 21 43 23 37 43 43 41 33 36 46
   7 21  0 21 22 20 22 37 35 32 35 45
  25 43 21  0 26 35 43 43 38 33 37 49
   9 23 22 26  0 21 24 23 24 19 22 31
  20 37 20 35 21  0 34 34 39 39 43 51
  26 43 22 43 24 34  0 44 36 33 37 48
  26 43 37 43 23 34 44  0 50 47 51 77
  22 41 35 38 24 39 36 50  0 47 50 78
  19 33 32 33 19 39 33 47 47  0 73 79
  22 36 35 37 22 43 37 51 50 73  0 87
  25 46 45 49 31 51 48 77 78 79 87  0
", header=F)

mat <- as.matrix(mat)

I want to compute a specific network density measure which is defined as:

where Z_ijk is the number of co-occurrences between team members i and  j , and max(Z_ijk) is the maximum number of co-occurrences that team member i  has with any other member of team k. N_k is the number of members on the team.
To get the maximum value in each row, I did the following:
max_values <- apply(mat, 1, max)

> max_values
 1  2  3  4  5  6  7  8  9 10 11 12
26 46 45 49 31 51 48 77 78 79 87 87

I thought I could divide the matrix by max_values using sweep:
sweep(mat, 1, max_values, FUN = '/')

But it does not yield the intended output.  Any thoughts?
The expected output would be: divide every value in row 1 by 26, every value in row 2 by 46, and so on.

A: We can do this by dividing with rowMaxs (from matrixStats)
library(matrixStats)
mat/rowMaxs(mat)


text:
Q: Not possible to install anything on Ubuntu 18.04 LTS It's not possible to install anything on my Ubuntu 18.04 LTS. When I run
sudo apt-get upgrade

I get:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 wine32:i386 : Depends: libwine:i386 (= 3.0-1ubuntu1) but it is not installed
 wine64 : Depends: libwine (= 3.0-1ubuntu1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

When I run
sudo  apt --fix-broken install

I get the error-messages after a while:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  fonts-wine libwine libwine:i386
The following NEW packages will be installed:
  fonts-wine libwine libwine:i386
0 upgraded, 3 newly installed, 0 to remove and 10 not upgraded.
15 not fully installed or removed.
Need to get 0 B/39,9 MB of archives.
After this operation, 375 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 373690 files and directories currently installed.)
Preparing to unpack .../libwine_3.0-1ubuntu1_amd64.deb ...
Unpacking libwine:amd64 (3.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libwine_3.0-1ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/wine/acledit.dll.so', which is also in package wine1.8-amd64 1:1.8.0-0ubuntu1~ubuntu15.10.1~ppa1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../libwine_3.0-1ubuntu1_i386.deb ...
Unpacking libwine:i386 (3.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libwine_3.0-1ubuntu1_i386.deb (--unpack):
 trying to overwrite '/usr/lib/i386-linux-gnu/wine/acledit.dll.so', which is also in package wine1.8-i386:i386 1:1.8.0-0ubuntu1~ubuntu15.10.1~ppa1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../fonts-wine_3.0-1ubuntu1_all.deb ...
Unpacking fonts-wine (3.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/fonts-wine_3.0-1ubuntu1_all.deb (--unpack):
 trying to overwrite '/usr/share/wine/fonts/coue1255.fon', which is also in package wine1.8 1:1.8.0-0ubuntu1~ubuntu15.10.1~ppa1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libwine_3.0-1ubuntu1_amd64.deb
 /var/cache/apt/archives/libwine_3.0-1ubuntu1_i386.deb
 /var/cache/apt/archives/fonts-wine_3.0-1ubuntu1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

So something about wine....
Do you have any suggestions?

A: This seems similar problem as this one. It refers to another package, but the output error is the same trying to overwrite file, which is also in…
The solution here is to (force) remove the package that causes the error, directly with dpkg . The problematic package is mentioned after the which is also in <package to be removed>
In your case wine1.8-amd64 , wine1.8-i386 and wine1.8
The following commands should do the trick:
sudo dpkg -P wine1.8
sudo dpkg -P wine1.8-amd64
sudo dpkg -P wine1.8-i386

Then run again
sudo apt-get install -f

and dpkg should now be able to configure the packages correctly.
If for some reason above commands won't work, then use the --force-all option. Dangerous option as it can break things, but it is there for a reason.
sudo dpkg -P --force-all wine1.8
sudo dpkg -P --force-all wine1.8-amd64
sudo dpkg -P --force-all wine1.8-i386

Also, if you still have any PPA about wine enabled, please disable it or completely remove it.


text:
Q: How to boot Ubuntu after installing Windows using BootCamp I have had the need to create a working Ubuntu 64-bit and Windows 7 pro 64-bit dual booting system of late and decided my  Macbook Pro 8.2 15". I had previously removed the Mac OS X from it as it was having issues so I formatted the whole HD and had Windows 7 running on it without troubles (bootcamp 4, 5, 5.1).
I ended up making a mistake and wiping everything during the installation of the Ubuntu partition (after shrinking the Windows one and partitioning it... I didn't realize that the "Erase and Install Ubuntu" toggle performed the erase IMMEDIATELY!)
After installing successfully Ubuntu 14.04 LTS 64-bit I installed Windows 7 in the remaining unpartitioned space. Once done so upon boot the computer boots only in W7 and the Startup Manager accessed from holding the alt / option key upon booting only recognizes the presence of one hard drive and not the various bootable partition. When clicked it will simply boot in Windows.
Now I understand this is because windows does not recognize ext4 and that I should boot in the linux (GRUB?) partition as it can deal with both ext4 and NTFS, however the Startup Manager also doesn't recognize the two boot partitions which means I am stuck booting in windows 7 at this moment.
This guides states I would need to get Ubuntu to EFI-boot using rEFInd which would be installed through the Mac partition, though the article says it was a necessary thing for 32-bit; is it still for 64-bit as it was running great?
What would you recommend doing to achieve the dual boot? Should I install a temp version of OSX to follow the guide?
These were the partitions I made when installing Ubuntu, do I need other ones?

*

*A reserved for bios 1 MB

*swap 6 GB

*/ 100 GB ext4

*/media/shared 30 GB fat32 (there was no ntfs in the list strangely enough)

*The rest was left unpartitioned

I didn't make a /home partition.
The installation went perfectly for Ubuntu. It started up wonderfully and working great. I proceeded to install windows and had to create the windows partition in the shared partition by extending it to 300 GB because it wouldn't allow me to create one in the remaining free allocated space (commands grayed out)

A: You might want to try out this software EasyBCD on windows. Its a recommendation only but it helped me when I faced the same situation as yours.
After that you might want to run boot - repair when you get to boot in Ubuntu and then remove EasyBCD.
Here are the detailed instructions:

*

*Download EasyBCD from here

*Install EasyBCD in your Windows Partition.

*Now, run EasyBCD as an administrator.

*Next, click on "Add New Entry".

*Next, Click on 'Linux/BSD" under "Operating Systems" then select "GRUB 2" under "Type:", type a name according to your choice and click "Add Entry".

*Now, click on "Edit Boot Menu".

*Now, according to your OS priority select your OS and press the up button and set it "Default - Yes" by ticking in the appropriate box.

And finally "Save Settings" and reboot. You will get the menu for your linux and on pressing enter you will get the GRUB menu to your linux OS.


text:
Q: Eigen segfaults with AVX on Ivy Bridge when using `std::vector` of fixed-size matrices I'm wondering if this is a known issue; if not, has anyone experienced this, and has anyone managed to find a fix?
I'm building a numerical computation code using Eigen 3.3.4 using GCC 6.4 on Fedora 25 on a Core i7-3700. My proc/cpuinfo says I should have AVX. I've tried two builds. Build 1:
g++ -std=c++14 -O3 -m64 -mavx

and build 2:
g++ -std=c++14 -O3 -m64 -msse4.2

Build 2 runs fine. But when I try build 1, I get segfaults in the Zero function for a square fixed-size matrix as well as in the inverse() method. I'll appreciate any pointers as to what might be going on.
EDIT: I forgot one very important detail: I was actually using a std::vector of fixed-size Eigen matrices.

A: The fact that I was using a std::vector of fixed-size matrices was the key. Thanks very much for the request for a minimal example, @rex. While preparing the example, I found out the following.
For certain large input sizes (of the std::vector containing the matrices), Eigen throws a runtime error, which led me to this site. Following the instructions there fixed the issue.
Essentially, std::vector with its standard allocator seems to mess with Eigen's alignment requirements for vectorization of fixed-size array operations. Using Eigen's provided aligned_allocator fixes the issue.


text:
Q: PlainRoute Redirect / onEnter not triggered navigating from child to parent route I'm using the alternate syntax to define my routes using PlainRoute. It's recommended to use the onEnter lifecycle event to trigger a redirect. However, due to the way onEnter currently behaves (or at least how I understand it behaving), it's not triggered when navigating from a child route to a parent route. For example, if you navigate from /profile/foo to /profile, onEnter will not be triggered.
Let's look at some code:
export default {
  path: 'projects',
  onEnter (next, replace) {
    console.log('1st level deep!')
    if (next.routes.length <= 2) {
      replace('/foo')
    }
  },
  childRoutes: [
    {
      path: ':project',
      onEnter (_, replace) {
        console.log('2nd level deep!')
      },
      component: ProjectComponent
    }
  ]
}

The parent's onEnter will not be triggered and the redirect won't be able to occur. Does anyone know of a way to trigger onEnter that I'm not aware of? react-router-redux picks up and broadcasts a location change, but I'd rather rely on react-router. Thanks for your time!


text:
Q: How to install msbuild on CentOs I want to install msbuild on CentOS to run project.sln files. What are the commands for installing the same. I tried to install using "didstopia/msbuild" docker image but could not succeed.

A: Install the dotnet sdk for centOS.
You will be able to run msbuild files with the command dotnet msbuild or even just dotnet.


text:
Q: @ModelAttribute populate form field from request param instead of backing form My problem is:
@ModelAttribute populate form field from request param instead of form DTO if request param and form field has same name.
Example: I have form with input filed called name:
<input type="text" name="name" />

Given form with value name=John,
If I submit form (web method POST) using url:
http://localhost:8080/user/?name=Michael
I will have query param and form field that has same name.
What I expect is: name field should be populated from Form Field, not query params.
MyForm.java
public class MyForm {
    private String name;
    private Boolean isMale;
    private Byte status;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Boolean getIsMale() {
        return isMale;
    }
    public void setIsMale(Boolean isMale) {
        this.isMale = isMale;
    }
    public Byte getStatus() {
        return status;
    }
    public void setStatus(Byte status) {
        this.status = status;
    }
}

MyController.java
@Controller
@RequestMapping("/user")
public class UserController {
  @RequestMapping(value = "/", method = RequestMethod.POST)
  public String index(
        Model model,
        @ModelAttribute("form") MyForm form,
        BindingResult bindingResult) {
    String name = form.getName(); //this contains value from form: Michael
    Boolean isMale = form.getIsMale(); //this contains value from query parameter: true
    Byte status= form.getStatus(); //this contains value from form: 1
    return "views/index";
}

When I submit the form with values:
name = Michael
isMale = false
status = 1

using url with query params:
http://localhost:8080/user/?isMale=true

then isMale will contains value true, that populate from query param.
What I expects is, isMale should contains false that populate from Form Field.
How to solve this problem...?

A: You should use @RequestBody annotation instead of @ModelAttribute if you want just the request body (which contains your form data) to populate your Java object
(as a side note, its bad design to pass the same parameter name in both your query string as well as in your form data. Do refactor, if possible)


text:
Q: Active thread count in cluster less than kafka topic partitions in Apache Nifi I am using ConsumeKafka in Apache Nifi to consume data from a kafka topic with 15 partitions. ConsumeKafka processor has concurrency of 18 (6 nodes * 3 concurrent task/node )

Total threads running on cluster below : 10

I was expecting total threads=15 as i have 15 partitions on my kafka topic.
I see 15 unique consumer-IDs as well. How is nifi allocating threads in this case ?


text:
Q: MATLAB - Eval function and printing many plots The variable is a 32x8x40940 double matrix. Here's an example of what I want to accomplish:
plot(squeeze(variableName(1,1,:)))
plot(squeeze(variableName(1,2,:)))
plot(squeeze(variableName(1,3,:)))

... repeat in a loop
plot(squeeze(variableName(2,1,:)))

... repeat the sequence above
except that I want to save the plots instead of just generating all of them. I also want them in image form (e.g. png) for I can organize them using another software that I have.
The following eval function was an example that I was given, but the documentation is lacking examples for me to use in this case. I want to have it automatically save the plots to a specific area in my directory.
eval( [ 'print( ''-dpng'', ''..\folder\another_Folder_', num2str( var ), '.png'')' ] );
% 'var' being iteration number within loop

Any ideas?

A: As a general rule, you should avoid using eval for a myriad of security, readability, and general good coding reasons reasons.
Notes here, here, and here
If you want to do save the looped figures, consider using the saveas function in Matlab. From the help,
x = [2 4 7 2 4 5 2 5 1 4];
bar(x);
saveas(gcf,'Barchart.png')

The gcf is the current figure that is open in matlab.
In your case, once you write a loop, you can assign these to an array or some other data structure before using the saveas command. You can also append the counter to the filename (make sure to convert the integer to a string so that strcat doesn't fail.
y[loopcounter]=plot(squeeze(variableName(1,1,:)))
saveas(y[loopcounter],strcat('file',str(loopcounter),'.extension_format'))


text:
Q: What does the preserve keyword do in xkb config files I want to know what the preserve keyword does in the xkb_types section of a custom xkb keymap.
Here is an example from an existing config file:
type "FOUR_LEVEL_SEMIALPHABETIC" {
    modifiers= Shift+Lock+LevelThree;
    map[Shift]= Level2;
    map[Lock]= Level2;
    map[LevelThree]= Level3;
    map[Shift+LevelThree]= Level4;
    map[Lock+LevelThree]= Level3;
    preserve[Lock+LevelThree]= Lock;
    map[Shift+Lock+LevelThree]= Level4;
    preserve[Shift+Lock+LevelThree]= Lock;
    level_name[Level1]= "Base";
    level_name[Level2]= "Shift";
    level_name[Level3]= "Alt Base";
    level_name[Level4]= "Shift Alt";
};

I am interested in these two lines:
    preserve[Lock+LevelThree]= Lock;
    preserve[Shift+Lock+LevelThree]= Lock;

Unfortunately neither the Archwiki, which has a very good xkb config guide, nor the official website of xkb (which does not have much information in general) seem to have any information about this.

A: XFree86 documents it in How to further enhance XKB configuration; Defining new layouts. Copying the relevant fragment for the benefit of the reader,

Usually, all modifiers introduced in modifiers=<list of modifiers> list are used for shift level calculation and then discarded. Sometimes this is not desirable. If you want to use a modifier for shift level calculation but you don't want to discard it, you may list in preserve[<combination of modifiers>]=<list of modifiers>. That means, for a given combination all listed modifiers will be preserved. If the Lock modifier is preserved then the resulting symbol is passed to internal capitalization routine regardless whether it has been used for a shift level calculation or not.


text:
Q: I can't close menu when click AM trying to have to actions on a nav menu (open and close)
this is my code :
Here, i can open the item and hide it when i click outside BUT I need also to close the item when i click on the link .menu-item-has-children > a

var click_item = function() {
$('.menu-item-has-children > a').on('click', function() {
  var EltToToggle = $(this).next('.sub-menu');

  if ($(this).attr('href') === "#") {
    event.preventDefault();
  }

  if ($(this).attr('aria-expanded') === "true") {
    console.log("ppppp");
    $(this).attr('aria-expanded', false);
    $(this).removeClass('is-opened');
    EltToToggle.removeClass('show');
    console.log("click true")
  } else if ($(this).attr('aria-expanded') === "false") {
    $(this).attr('aria-expanded', true);
    $(this).addClass('is-opened');
    EltToToggle.addClass('show');
    console.log("click false")
  }
});
}
click_item();

$(document).mouseup(function(e) {
    var sub_menu = $(".sub-menu");

    // If the target of the click isn't the sub_menu
    if (!sub_menu.is(e.target) && sub_menu.has(e.target).length === 0) {
      sub_menu.removeClass('show');
      $(".menu-item-has-children > a").attr('aria-expanded', false);
      $(".menu-item-has-children > a").removeClass('is-opened');
      console.log("ok")
    }
    click_item();
  });
.menu {
  display: flex;
}

li {
  margin: 10px;
}

.sub-menu {
  display: none;
  position: absolute;
  top: auto;
  left: 50%;
  -webkit-transform: translate(-50%, 2rem);
  transform: translate(-50%, 2rem);
  padding: 1rem 0;
  background-color: #fff;
  border-radius: .6rem;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, .1);
}

.show {
  display: block!important;
}
.menu-item-has-children>a {
position: relative
}

.menu-item-has-children>a:after {
    top: 2rem;
    right: 1.5rem;
}

.menu-item-has-children>a:after {
    content: "\f077";
    font-family: FontAwesome!important;
    font-style: normal;
    font-weight: 400;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    font-size: inherit;
    display: inline-block;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-alt: "";
    speak: none;
    right: 1.6rem;
    top: 2.3rem;
    font-size: 1rem;
    transition: -webkit-transform .25s ease;
    transition: transform .25s ease;
    transition: transform .25s ease,-webkit-transform .25s ease;
}
.menu-item-has-children>a:after {
    top: 2rem;
    right: 1.5rem;
}
 .menu-item-has-children>a[aria-expanded=true]:after {
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

                               Item 1

                                [Current] Lvl2. Children 1

                                Lvl2. Children 2 with long text lorem ipsum

                                Link 2

                                Lvl3. Children 1

                                [Current] Lvl3. Children 2 with long text lorem ipsum

                                [_blank] Lvl3. Children 3

                                [_blank] Lvl2. Children 4

                                Link 2

                                [Current] Lvl2. Children 1

                                Lvl2. Children 2 with long text lorem ipsum

                                Lvl2. Children 3 with children

                                Lvl3. Children 1

                                [Current] Lvl3. Children 2 with long text lorem ipsum

                                [_blank] Lvl3. Children 3

                                [_blank] Lvl2. Children 4

A: Try to hide/show your navigation bar using css class, that will be easy and effective way to manage it.
Also replace $(document).mouseup with $(document).click, you just need clicking event, so I recommend to avoid using mouseup in such scenarios.
You can do something like this:

$(document).ready(function() {

  $(document).click(function(event) {
    var clickover = $(event.target);
    // if the user click outside navbar
    if (!clickover.hasClass("navbar")) {
      $(".navbar").removeClass("in");
    }
  });

});
.navbar.in {
  background: red;
  width: 100px;
  height: 100%;
  position: absolute;
}
<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Demo Test</title>

Click outside the navbar and it'll be closed. This is just a DEMO that can help you understand how to hide/show elements by clicking events.

A: Here is a solution
If there are no submenus, close all parent uls with class show
I also converted the if to a toggle

$('.menu-item-has-children  a').on('click', function() {
  var EltToToggle = $(this).next('.sub-menu');

  if ($(this).attr('href') === "#") {
    event.preventDefault();
  }
  const expanded = $(this).attr('aria-expanded') === "true"

  $(this).attr('aria-expanded',    !expanded);
  $(this).toggleClass('is-opened', !expanded);
  EltToToggle.toggleClass('show',  !expanded);

  if (EltToToggle.length === 0) {
      $(this).parents("ul,show").toggleClass("show",false)
  }

});

$(document).mouseup(function(e) {
  var sub_menu = $(".sub-menu");

  // If the target of the click isn't the sub_menu
  if (!sub_menu.is(e.target) && sub_menu.has(e.target).length === 0) {
    sub_menu.removeClass('show');
    $(".menu-item-has-children > a").attr('aria-expanded', false);
    $(".menu-item-has-children > a").removeClass('is-opened');
    console.log("ok")
  }
});
.menu {
  display: flex;
}

li {
  margin: 10px;
}

.sub-menu {
  display: none;
  position: absolute;
  top: auto;
  left: 50%;
  -webkit-transform: translate(-50%, 2rem);
  transform: translate(-50%, 2rem);
  padding: 1rem 0;
  background-color: #fff;
  border-radius: .6rem;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, .1);
}

.show {
  display: block!important;
}

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

                               Item 1

                                [Current] Lvl2. Children 1

                                Lvl2. Children 2 with long text lorem ipsum

                                Link 2

                                Lvl3. Children 1

                                [Current] Lvl3. Children 2 with long text lorem ipsum

                                [_blank] Lvl3. Children 3

                                [_blank] Lvl2. Children 4

                                Link 2

                                [Current] Lvl2. Children 1

                                Lvl2. Children 2 with long text lorem ipsum

                                Lvl2. Children 3 with children

                                Lvl3. Children 1

                                [Current] Lvl3. Children 2 with long text lorem ipsum

                                [_blank] Lvl3. Children 3

                                [_blank] Lvl2. Children 4

A: try this
   $(document).ready(function(){
  $("*").click(function(){
    $(".menu-item-has-children > a").removeClass('is-opened');
  });
});


text:
Q: Find all the idempotent elements of $\Bbb Z[i]/(5)$. I need to find all the idempotent elements of $\mathbb{Z}[i]/(5)$. The four idempotent elements are $3+i$, $3-i$, $0$, and $1$, but the solution I have does not explain how these elements were found. I understand the definition of idempotent elements ($e^2=e$) and know how to confirm that these elements are idempotent elements. The trivial solutions are obvious, but I have no idea how to go about finding the nontrivial $3+i$ and $3-i$ solutions.
If anyone could help me understand how $3+i$ and $3-i$ were found and if possible why they along with $0$ and $1$ are the only solutions I would greatly appreciate it. Thanks in advance.

A: You don't find them if you already know them. You simply show the computation. The ring $\mathbb{Z}[i]/(5)$ basically works like computation with integers and i, but every time you see a 5 or a multiple of 5 you can make it zero. For instance, $(2-3i)^2 = 4 - 12i - 9 = -5 - 12i = -2i = 3i$. Note that in the last equation, I was allowed to change the number by a multiple of 5. You'll probably need to use a fact like that in the calculation.
As far as how they found those particular solutions, a typical element of the ring looks like $a + bi$. So $(a+bi)^2 = a^2 + b^2 + 2abi$. If this is idempotent, then in the ring $\mathbb{Z}/(5)$ we must have $a,b$ such that $a^2 + b^2 = a$ and $2ab = b$. If $b$ is not zero, then $2a = 1$, and so $a = 3$. (This is because $6 = 1$.) Then we know $3^2 + b^2 = 3$, so $b^2 = 1$ and we have $b = \pm 1$. If $b$ is zero, then we need $a^2 = a$, which has only solutions $a = 0,1$.

A: Here's one possible way, which is mostly algebraic: consider $e=a+bi$.
In order for $e$ to be idempotent, we must have $e^2-e \equiv 0 \mod 5$ (using $\mod 5$ in the loose sense in that the components of $e^2-e$ must be divisible by $5$).
Then this means that $(a+bi)^2-(a+bi) = (a^2-a-b^2) + i(2ab-b)$ must have its real and imaginary parts divisible by $5$, or that $a^2-a -b^2 \equiv 0 \mod 5$ and $2ab-b \equiv0 \mod 5$.

*

*Case 1: $b \equiv 0 \mod 5$

Then clearly the second equation is satisfied, and we're left with $a^2-a \equiv 0 \mod 5 \implies a \equiv 0, 1 \mod 5$. Then our solution is either $e=0+0i$ or $e=1+0i$.

*

*Case 2: $b \not\equiv 0 \mod 5$

Then clearly we may cancel $b$ from the second equation (as it possesses an inverse modulo $5$), leaving us with $2a-1 \equiv 0 \mod 5 \implies a \equiv 3 \mod 5$. Going to the first equation yields $1 \equiv b^2 \mod 5 \implies b \equiv \pm 1 \mod 5$. Then our solution is either $e=3+i$ or $e=3-i$.
This should account for all the solutions, which matches with the answers you obtained.

A: Take $\;a+bi\in\Bbb Z[i]\;$, then
$$(a+bi)^2+(5)=a+bi+(5)\iff (a^2-b^2-a)+b(2a-1)\in (5)$$
We have that either
$$5\mid b\;\;\wedge\;\;5\mid (a^2-a)\iff a=0\pmod 5\;\;\vee\;\;a=1\pmod 5$$
or else
$$5\mid (2a-1)\iff a=3\pmod 5\;\;\wedge\;\;5\mid(a^2-a-b^2)\iff b=\pm 1\pmod 5$$
In the first case we get $\;0+(5)=(5)\;,\;\;1+(5)\;$, and in the second one we get $\;(3\pm i)+(5)\;$ , just as you mention.


text:
Q: Php Syntax Unexpected Sytax Error I want to write like this in php. How can i express samely into php?
$test = '{"longUrl": "http://www.yahoo.com"}';

Thanks.

A: If you want to write actual PHP code to make a new object (assuming your example is JSON), there's no literal/shortcut syntax in PHP for that; you have to make a new stdClass object and set its variables manually:
$test = new stdClass;
$test->longUrl = "http://www.yahoo.com";

If you are comfortable writing JSON inside a string, as you are doing in your example, simply feed that into json_decode() and you have yourself a stdClass object:
$test = json_decode('{"longUrl": "http://www.yahoo.com"}');

A: $test = array("longUrl" => "http://www.yahoo.com");

>echo $test['longUrl']
http://www.yahoo.com


text:
Q: Copied SSH key from PC A doesn't work on PC B I've created an SSH key (on PC A) to access my GitHub repo (works correctly). Then I copied this key to PC B. For some reason, I can't access the repo from the PC B even if the public and private keys are the same.
Cloning into 'repo'...
sign_and_send_pubkey: signing failed for RSA "/home/milano/.ssh/github-futilestudio" from agent: agent refused operation
sign_and_send_pubkey: signing failed for RSA "milano@milano-lenovo" from agent: agent refused operation
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What's the reason behind that?
EDIT
Could the reason be the signature at the end of the SSH key?
milano@milano-lenovo

which is obviously a name of the PC A.

A:
Could the reason be the signature at the end of the SSH key?

No, that part is ignored.
Do copy, to be sure, the public key as well as the private one.
Or, ideally, generate a new one dedicated to the second machine (since copying private keys is not the best practice)

*

*If a ssh -Tv git@github.com does show you the right private key is considered, check for a difference in environment variable (type set in a CMD). In particular, make sure you don't have GIT_SSH set to Windows 10 openSSH.
Type where ssh to make sure Git is using the same openSSH on both machines.

*If a ssh -Tv git@github.com does show you the right private key is not considered, check if on your first machine you have a %USERPROFILE%\.ssh\config, which should then be replicated on the second one.


text:
Q: Pandas dropna function is returning original dataframe despite me setting a threshold. How may I resolve this? Not sure why dropna() isn't working... 'data' is a preset pandas dataframe with 5 named columns with all values like integers or NA
Part of my project is to ask the user to input their own threshold by the way
threshold = input("What is your threshold for NAs in a given row?")
try:
   num = int(threshold)
except:
   print("Please enter a number or leave blank")
   if num < 0:
      print("Please enter a positive integer")
   elif num >= 0:
      data = data.dropna(axis = 0, thresh=num, inplace=True)
      print(data)

return data

A: Given the indentation in your code, the only place where you actually end up running dropna is in the except: block if int(threshold) fails. :) That's why you always just return the original data.
You're missing the except: block's else: block:
threshold = input("What is your threshold for NAs in a given row?")
try:
    num = int(threshold)
except:
    print("Please enter a number or leave blank")
else:  # <- this!
    if num < 0:
        print("Please enter a positive integer")
    else:
        data = data.dropna(axis=0, thresh=num, inplace=True)
        print(data)

return data

Of course it would be better to just fail altogether and not return unmodified data.
def input_positive_integer(prompt):
    while True:
        try:
            threshold = int(input(prompt))
            assert threshold > 0
            return threshold
        except Exception:
            print("Invalid input.")

threshold = input_positive_integer("What is your threshold for NAs in a given row?")
data.dropna(axis=0, thresh=threshold, inplace=True)  # inplace modification


text:
Q: Download and save a file using php (keeping original filename) I'm trying to download and save files like this (http://www.example.com/bajar.php?id=420633&u=7) but keeping the original filename.
I've already searched and found this code:
file_put_contents('test.rar', file_get_contents('http://www.example.com/bajar.php?id=420633&u=7');

But in this case I have to put the filename 'test.rar' manually, how can I do the same obtaining the original filename?
Many thanks!

A: Here's an adaptation of the thread I linked to that should work for your case. The regex is looking for the last '/' and then returning everything after it.
<?php
function get_real($url) {
    $headers = get_headers($url);
    foreach($headers as $header) {
        if (strpos(strtolower($header),'location:') !== false) {
            return preg_replace('~.*/(.*)~', '$1', $header);
        }
    }
}
echo get_real('http://www.example.com/bajar.php?id=420633&u=7');
?>


text:
Q: How to create triangle-shaped list using list comprehension? What would be the easiest way to create a list in the following format:
[[0],
 [0,0],
 [0,0,0],
 [0,0],
 [0]]

This would be for n=3, so the question is mostly how to reverse the iterating variable that denotes the amount of elements per list.
The following list comprehension for example:
[[0]*(i+1) for i in range(3)]

Would create:
[[0],
 [0,0],
 [0,0,0]]

Is there a nifty way to accomplish what I want?

A: A nifty way is
[[0]*(i+1) for i in range(3)] + [[0]*(i+1) for i in range(2)][::-1]

i.e. doing the same thing twice, but with one less row, then flipping it around with a reverse slice [::-1].
And to package this into a neat pair of functions,
def half_triangle(n):
   return [[0]*(i+1) for i in range(n)]

def triangle(n):
   return half_triangle(n) + half_triangle(n - 1)[::-1]

>>> pprint(triangle(5))
[[0],
 [0, 0],
 [0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0],
 [0, 0],
 [0]]
>>>

A: One simple way would be to put an inline if operator in
the left-side expression of your list-comprehension, to
transform the  i delivered by the for part on the
side you want:
[[0]*((i+1) if i < 3 else (5 - i)) for i in range(5)]

However, this is hard to read and error prone, due
to having to think about the various "+1" and "-1"
involved, and having to hardcode the maximum
size in three different points. Having to type a number
depending on your desired size in three places is
solvable with a variable, tough:
max_size = 10
[[0]*((i+1) if i < max_size else (max_size * 2 - 1  - i)) for i in range(max_size * 2 - 1)]

And with max_size = 10:
Out[6]:
[[0],
 [0, 0],
 [0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0],
 [0, 0],
 [0]]

However, this solution does nothing to let the code more readable,
or easier to deal with the "+1" and "-1" for the edgecases.
A cleaner and more idiomatic solution is to use an
specialized "generator":
range in Python is a special builtin that returns an object
that is "iterable".
If you as simply as create anofo ther "iterable" that will return the
sizes you want, you just plug it in place of the range inside your expression.
In Python, one of the easiest way of creating an iterable is creating a "generator function". Which is simply a function that instead of using return, uses the yield keyword to supply partial results to another context - in this example, the for statement inside the comprehension.
And since we are writing a function body, then the easiest and more readable way to create the triangle pattern is to have a for that will increase the size, and another for that will decrease the size after that one - both of these make plain use of the "range" to get a linear pattern:
In code, that is just:
def triangle(max_size):
    for i in range(1, max_size + 1):
        yield i
    for i in range(max_size - 1, 0, -1):
        yield i

And then you use triangle instead of range for super-easy-to-read-and-maintain code:
In [8]: [[0] * i for i in triangle(10)]
Out[8]:
[[0],
 [0, 0],
 [0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0, 0],
 [0, 0, 0, 0, 0],
 [0, 0, 0, 0],
 [0, 0, 0],
 [0, 0],
 [0]]

A: You can use reversed() to reverse a range. So, for a maximum length n, you can use:
[[0]*(i+1) for i in list(range(n))+list(reversed(range(n-1)))]

A: There is a nifty way using the abs function:
>>> n = 3
>>> [[0] * (n - abs(n - i)) for i in range(1, 2*n)]
[[0],
 [0, 0],
 [0, 0, 0],
 [0, 0],
 [0]]


text:
Q: Is there any English equivalent to the Portuguese proverb "days of plenty, nothing's eve?" Days of plenty, nothing's eves (in Portuguese dias de muito, vésperas de nada) means your days of plenty are eves of days of nothing, i.e. you alternate between splashing out and hardship, usually because you spend excessively when you have money. The saying is used as a comment on, or warning against this.
I've looked into this other question, which focus on wasting time or money and regretting it later. I wonder whether there is any saying that more closely conveys the idea of alternating between relative luxury and belt tightening. While the situations you use days of plenty, nothing's eves to comment on may involve wasting money, it is not necessarily so. Take the following examples (fill the blank with a suitable saying):

They splash out as soon as they get their paycheck, and then they can hardly afford bare necessities for the rest of the month. You know, ____________
The city council spent nearly all its culture budget on free concerts in the first four months of the year, and now there won't be any more significant events this year. You know, ____________

Especially in the second example, the city council and many among the public may think the money was well spent. But others, while agreeing the events were worth the money, would prefer the events more evenly spaced out throughout the year, and use the proverb to criticize the council's policy.
You can off course use the saying to criticize waste of money:

He inherited quite a lot of money from his parents, but he's frittered it all away, and now he doesn't even have a house of his own. You know, _________________

A: Both "boom-or/and-bust and "{either} feast or famine" are pretty literal translations of your idiom, with "feast/boom" meaning "days of plenty" and "famine/bust" standing for "days of nothing."
Although "boom-or-bust" is mostly used for describing the ups and downs of whole economies and industries, I think it, and especially "famine-or-feast," would work well in your first two examples of people or governments quickly blowing through their limited budgets, resulting in them having either too many/sufficient resources or too little or no resources.

Boom-and-bust
   adjective
  1.    characteristic of a period of economic prosperity followed by a depression.
  Also, boom-or-bust
feast-or-famine
  adjective
  1.characterized by alternating, extremely high and low degrees of prosperity, success, volume of business, etc.: "artists who lead a
  feast-or-famine life."

(definitions from  'Dictionary/com'  and "The Free Dictionary,' respectively)
As for your third example, I'd probably go either with any of the other good answers so far that capture the alternating feel of your proverb ('rich today, poor tomorrow'/'ebb & flow'/'ups & downs') or with the good one that, although lacking perhaps the alternation, talks of the nearly-inevitable consequences of "fools [having] money."
My own late entry for your third example (and it might also fit with the first two) would also be one that doesn't directly capture the notion of alternating fortunes:

burn a hole in/through {somebody's}
  pocket
  If money is burning a hole in your pocket, you are very eager to
  spend it.
  (from 'Cambridge Dictionaries Online')

You know, all that money just burned a hole right through his pocket. What a shame.

A: I'd suggest, the wheel of fortune is always in motion and rich today, poor tomorrow

People's fortunes are constantly changing - somebody who has good luck one year may have bad luck the next, and vice versa. It seemed that nothing could go wrong, but the wheel of fortune is forever in motion, and disaster struck the following day. The proverb was first recorded in 1748 in Papers of Benjamin Franklin. The Facts on Files Dictionary of Proverbs

fortune is fickle might also fit the bill. Ngram

A: 1) what goes around comes around from OD:

proverb: The consequences of one's actions will have to be dealt with eventually.

A couple more suggestions :
2) Ebb and flow from TFD

... You know, their bank balance ebbs and flows like the tide.
... You know, that's the type of ebb and flow that event goers have to endure.

3) Or on similar vein, ups and downs  from reference.com.

rises and falls of fortune; good and bad times: Every business has its ups and downs.

A: If someone spends money extravagantly without  any forethought, only to regret later, the I'd say
A fool and his money are soon parted

something that you say which means that stupid people spend money without thinking about it enough

[The Free Dictionary]
Usage

The city council spent nearly all its culture budget on free concerts in the first four months of the year, and now there won't be any more significant events this year. You know, fools and their money are soon parted.

Or

He inherited quite a lot of money from his parents, but he's frittered it all away, and now he doesn't even have a house of his own. You know, a fool and his money are soon parted

A: Consider the old saying:

What a difference a day makes!

If you refer to a future turn of events, another idiom is:

"There is no telling what tomorrow will bring."


text:
Q: how to combine ranges v3 transform, join and cycle? I'm trying to generate an infinite range of integers using range-v3 library. My goal is to have {0,0,0,1,1,1,2,2,2,0,0,0,1,1,1 ...}.
I would like the number of times each number is repeated to be variable also. without this limitation, I can do this, and it works fine.
const std::vector<std::vector<int>> repvec = { {0,0,0},{1,1,1},{2,2,2} };
auto joinedVec = repvec | ranges::view::join;
auto infiniteVec = joinedVec | ranges::view::cycle;

But if I want the variable number of repetition, I can't make it compile:
int nbRep = 3;
const std::vector<int> origVec = { 0, 1, 2 };
auto repVec = origVec | ranges::view::transform( [nbRep] (const int &x) {
    return ranges::view::repeat(x) | ranges::views::take(nbRep);
});
auto joinedVec = repVec | ranges::view::join;
auto infiniteVec = joinedVec | ranges::view::cycle;

I'm not sure if it is a limitation of the ranges library or if I'm doing something wrong.

A: I don't really see the reason why would you do:
ranges::view::repeat(x) | ranges::views::take(nbRep)

instead of just:
ranges::view::repeat_n(nbRep)

The solution is quite simple:
auto generate_range(const std::vector<int>& original, const std::size_t reps) {
    using namespace ranges;

    auto rng = original | views::transform([reps](const auto arg) {
        return views::repeat_n(arg, reps);
    });

    return rng | views::cycle | views::join;
}

We first create a range of ranges based on the original vector - we transform its elements into ranges of repeated elements. We end up with a range, which elements are ranges consisting of repeated values. Based on your example, we have:
rng = [[0, 0, 0], [1, 1, 1], [2, 2, 2]]

Now we just need to cycle all the elements. We end up with:
rng | cycle = [[0, 0, 0], [1, 1, 1], [2, 2, 2], [0, 0, 0], [1, 1, 1], ...]

Last thing we need to do is to join them:
rng | cycle | join = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, ...]

Full example:
#include <iostream>
#include <range/v3/all.hpp>
#include <vector>

auto generate_range(const std::vector<int>& original, const std::size_t reps) {
    using namespace ranges;

    auto rng = original | views::transform([reps](const auto arg) {
        return views::repeat_n(arg, reps);
    });

    return rng | views::cycle | views::join;
}

int main() {
    using namespace ranges;

    const std::vector<int> original = {0, 1, 2};
    const int reps = 3;

    for (const auto r : generate_range(original, reps) | ranges::views::take(15)) {
        std::cout << r << ' ';
    }
}

which prints: 0 0 0 1 1 1 2 2 2 0 0 0 1 1 1.


text:
Q: Windows 10 x:Bind to SelectedItem I'm trying to port/adopt my Windows RT app to WIndows10 and I'm trying out the new bindings x:Bind.
So far I'm able to bind to my ViewModel properties and other Viewelements. But now I'm trying to bind the text of a TextBox to a SelectedItem of a GridView.
In classic binding I'm doing it like that.
<TextBox x:Name="tb_textgroup"
                             Grid.Row="1"
                             PlaceholderText="Change Groupname"
                             Text="{Binding UpdateSourceTrigger=PropertyChanged,
                                    ElementName=gv_textgroup,
                                    Mode=TwoWay,Path=SelectedItem.bezeich}"
                             IsEnabled="{Binding UpdateSourceTrigger=PropertyChanged,
                                       ElementName=gv_textgroup,
                                       Mode=TwoWay,Path=SelectedItem.edit_activated}"
                             Margin="20,10,20,0"
                             />

I was trying it with

*

*Text="{x:Bind gv_textgroup.SelectedItem.bezeich, Mode=TwoWay}"

*Text="{x:Bind textgroup[gv_textgroup.SelectedIndex].bezeich, Mode=TwoWay}"

*

*where textgroup is my viewmodelclass with all the elements

But None of it worked... any ideas?
And can someone explain me what to do with "DependencyProperty". I watched the viedo from "build 2015" and have the sample codes. But it's saying nothing to me... I'm quite a newbie...
Many thanks for your help

A: You cannot use x:Bind on the SelectedItem of a GridView. This is because the SelectedItem is an object, so it can be anything. x:Bind needs to have actual classes/interfaces. x:Bind does not use reflection to find properties like Binding does.
You can accomplish this by x:Bind the SelectedItem of the GridView to your view model and then x:Bind to that from the TextBlock. I'm not sure this would really help performance as much as you would like.
public class ViewModel
{
    public MyItem SelectedItem { get; set; } //fire prop changed
}

<GridView SelectedItem="{x:Bind SelectedItem, mode=Twoway}"/>
<TextBlock Text="{x:Bind ViewModel.SelectedItem.bezeich}"

A: I'm not sure why this works, but if you create an object-to-object converter, x:Bind works for two-way conversion on any SelectedItem.
public class NoopConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, string language)
    {
        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, string language)
    {
        return value;
    }
}

And you can use it like this:
<ListView ItemsSource="{x:Bind ViewModel.Items}"
         SelectedItem="{x:Bind ViewModel.SelectedItem, Mode=TwoWay, Converter={StaticResource NoopConverter}}"
         ...

Special thanks to runceel for his public samples.
He explains it here in Japanese.


text:
Q: Highchart and php Hi guys i m trying to pass value from my php to highchart dataset but its not working help needed.
<?php $count2=$decode[nextPage][totalResults];
    echo("<input type=hidden name=aaqib value=".$count.">");
?>

<!DOCTYPE HTML>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>

Hi guys i m trying to pass value from my php to highchart dataset but its not working help needed.
i need to use value of J and K in data so that they are shown in highcharts

A: Store your php vars into a js vars and then pass to highcharts.
Fix the following too.
echo('<input type="hidden" name="aaqib" value="{$count}"/>');
Update according to this comment.
series: [{
    data: [[j,k]]
}]

Tthis demo should help you.

A: why are you echoing the input above your doctype declaration? I think that belongs inside your body. And you should also '-signs around the attribute values in you echo. something like this:
<?php $count2=$decode[nextPage][totalResults];
    echo("<input type='hidden' name='aaqib' value='$count'>");
?>

Some browsers might threat this correctly, but it's actualy invalid html


text:
Q: to display data depending on option choosen from dropdown I am a begginer in programming, I have php code and I want to display some data from mysql database depending on the option selected from the dropdown menu and here is the select menu:

<select name="category"class="form-control1"  required="required">
          <option value="">--report category--</option>
          <option value="rbNumber"  >RB report & range of date</option>
          <option value="policeStationID" >Police station report & range of date</option>
          <option value="zone"  >zone report & range of date</option>
          <option value="region" >region report & range of date</option>

     </select>
    &nbsp&nbsp
 <input type="date" name="date1" required="required">&nbsp&nbsp
 <input type="date" name="date2" required="required">&nbsp&nbsp
 <input type="submit" name="submit" value="search Report">
</form>

I want,  when I select rb report option then the query to be executed and select the corresponding data and display it.

A: What you are looking for can't be done in pure php. What you need is to use AJAX, here is example thread answering similar case:
Fire AJAX when value selected from dropdown


text:
Q: Seeking help manuerving JSON files in CloudWatch Log Insight I have a question on using CloudWatch Log Insights when it comes to JSON files.
I am trying to include two log streams in one query for CloudWatch Logs Insights where I would want to focus on "level" to find errors:
Here is my code:
filter @logStream = 'ingest-23j23d3-daf4343ff3, ingest-2fdfd434d-dsa32434d'
 | fields @message, @timestamp
 | parse @message '"level": "*"' as level
 | filter level == "error"

Here is an example of the JSON:
{
    "message": "Could not delete old file cache entries: rimraf: callback function required",
    "level": "error"
}

How can I incorporate more than one @logStream in my query. Also, can anyone direct me to maneuvering the JSON file for future use. I would greatly appreciate it.

A: I was able to fix the issue I had. Since I had no knowledge of Regex, I had to go into it's documentation and also AWS's and find ways of displaying my data:
filter level = "error" | filter strcontains(@logStream, 'ingest-')
 | fields @timestamp, @message, level

I was able to filter my levels (which were debug, info, and error) to only show error. From here, I filtered ALL my logstreams beginning with ingest to find the error logs. I hope this helps anybody out in need of answers.


text:
Q: How to make an application like JConsole? I want to make an application like JConsole. Is it possible? If yes, what are the changes need to done at JVM level? I am planning to use Spring-Boot. As per my knowledge, JMX is enabled by default. Do I need to configure anything extra in my Spring-Boot app in order to access the JMXBeans which are exposed by default?
Here I'm not trying to expose any MBean instead I'm trying to access those beans which are already exposed by JVM. How to achieve it?

A: JConsole is a JMX compliant monitoring and management application. The architecture is quite simple. It's a client-server architecture. Where the client is the Remote application (Example JConsole or the one that you want to build) and the server is the JMX Agent. In your case, you want to build your own client which is possible.

I want to make an application like JConsole. Is it possible?

Yes, it is possible.

If yes, what are the changes need to done at JVM level?

What do you mean by changes at JVM level? You are simply creating a client application that connects to the server (JMX Agent) using a certain protocol. Remote  Method Invocation (RMI) is the protocol used by JConsole for the connection to the JMX Agent. If you want to use RMI for communication, you don't have to do anything on the server side. But if you want to use some other protocol for communication, you can define your own Protocol adapter.

As per my knowledge, JMX is enabled by default.

As of Java SE 6 it is. But you can only monitor it locally. For connection from a remote machine, you need to define an RMI port to start listening for incoming connections.

Here I'm not trying to expose any MBean instead I'm trying to access those beans which are already exposed by JVM. How to achieve it?

Please check out the example from this link - Mimicking Out-of-the-Box Management Using the JMX Remote API. It shows you how to create a simple client application that connects to a remote JMX agent and access the MBeans. This should guide you in the right direction.


text:
Q: CSS sprite image not found HTML, The image is just blank like the image is not found. It still resizes though.  Why is this? I have tried with imgur and local image in image folder at website problemo is still not solved.
.sprite {
  background-image: url(https://i.imgur.com/q0b68yh.png);
  background-repeat: no-repeat;
  display: block;
}

.sprite-fast_img {
  width: 85px;
  height: 88px;
  background-position: -5px -5px;
}

.sprite-github {
  width: 30px;
  height: 30px;
  background-position: -100px -5px;
}

.sprite-gmail {
  width: 30px;
  height: 30px;
  background-position: -100px -45px;
}

.sprite-linkedin {
  width: 30px;
  height: 30px;
  background-position: -100px -85px;
}

.sprite-secure_img {
  width: 85px;
  height: 88px;
  background-position: -140px -5px;
}

.sprite-stackoverflow {
  width: 30px;
  height: 30px;
  background-position: -5px -103px;
}

.sprite-tumblr {
  width: 30px;
  height: 30px;
  background-position: -45px -103px;
}

.sprite-twitter {
  width: 30px;
  height: 30px;
  background-position: -140px -103px;
}

Thank you for the help & best wishes.

A: I think your div is missing the sprite class:

.sprite {
    background-image: url(https://i.imgur.com/q0b68yh.png);
    background-repeat: no-repeat;
    display: block;
}

.sprite-fast_img {
    width: 85px;
    height: 88px;
    background-position: -5px -5px;
}

.sprite-github {
    width: 30px;
    height: 30px;
    background-position: -100px -5px;
}

.sprite-gmail {
    width: 30px;
    height: 30px;
    background-position: -100px -45px;
}

.sprite-linkedin {
    width: 30px;
    height: 30px;
    background-position: -100px -85px;
}

.sprite-secure_img {
    width: 85px;
    height: 88px;
    background-position: -140px -5px;
}

.sprite-stackoverflow {
    width: 30px;
    height: 30px;
    background-position: -5px -103px;
}

.sprite-tumblr {
    width: 30px;
    height: 30px;
    background-position: -45px -103px;
}

.sprite-twitter {
    width: 30px;
    height: 30px;
    background-position: -140px -103px;
}

A: When you make a sprite, the main class is where you put the sprite image and bg definitions. After that you need to create subclass to show the part of sprite you need.
In your code you not defined the subclasses for each icon you need, you just created a new class for each icon but that classes not have conection whit the main class. You need to create the main class sprite and subclasses as sprite.your-icon and when you call the sprite you will call

    .sprite {
        background-image: url(https://i.imgur.com/q0b68yh.png);
        background-repeat: no-repeat;
        display: block;
    }

    .sprite.fast_img {
        width: 85px;
        height: 88px;
        background-position: -5px -5px;
    }

    .sprite.github {
        width: 30px;
        height: 30px;
        background-position: -100px -5px;
    }

    .sprite.gmail {
        width: 30px;
        height: 30px;
        background-position: -100px -45px;
    }

    .sprite.linkedin {
        width: 30px;
        height: 30px;
        background-position: -100px -85px;
    }

    .sprite.secure_img {
        width: 85px;
        height: 88px;
        background-position: -140px -5px;
    }

    .sprite.stackoverflow {
        width: 30px;
        height: 30px;
        background-position: -5px -103px;
    }

    .sprite.tumblr {
        width: 30px;
        height: 30px;
        background-position: -45px -103px;
    }

    .sprite.twitter {
        width: 30px;
        height: 30px;
        background-position: -140px -103px;
    }


text:
Q: Install VirtualBox Headless only I want to install VirtualBox on a fresh debian box without having to install an X-Server.
How can that be done ?

A: VirtualBox (both OSE as well as the free binary version) can be installed without X.
when running VMs you can run the VirtualBox X client over X11 although its not much fun unless you have a really fast network, but you can start your VMs headless using VBoxHeadless and then connect to them over the network via VRDP to get a console (useful for installations) or just using SSH.
VirtualBox is very good about that - everything you want to do can be managed using command line tools, even feeding keyboard input.

A: I don't have access to a Debian box right this moment, but I just checked on an Ubuntu box, and the dependencies for the virtualbox-ose package do not seem to include X.  They do include several libraries for X.
So my first stab at an answer for you is to simply try: apt-get install virtualbox-ose
Here is a guide with lots of help for managing a headless VirtualBox:
http://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-2.0-on-a-headless-ubuntu-8.04-server
If you have trouble doing what you want with VirtualBox you might also look into other virtualization systems such as Xen.
Good luck.

A: yes, also phpvirtualbox is what you can use for managing them.
with it, installing client will become much easier and you can do in-browser remote desktop.

*

*for debian box, you will firstly install some packages via apt-get
apt-get install libaudio2 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libllvm2.9 libmng1 libqt4-dbus libqt4-declarative libqt4-network libqt4-opengl libqt4-script libqt4-sql libqt4-sql-mysql libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 libxmu6 libxxf86vm1 qdbus

*install lamp server

*install phpvirtualbox by download and extraction

*add a vbox user and create /etc/default/virtualbox  http://code.google.com/p/phpvirtualbox/wiki/vboxwebServiceConfigLinux

*edit vbox config.php file, (username and pass)

You will proabably also install virtualbox extension pack by example:
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack

After that, start all the service or do a reboot! Any questions, commet below


text:
Q: Transient component is registered as transient but implements idisposable I use Simple injector but somehow i get error as stated in subject. I tried many things before i decided to post this question for instance this is not working for me. I get the following exception when I call Validate:
Validation error message:

The configuration is invalid. The following diagnostic warnings were reported:
-[Disposable Transient Component] AlbumsController is registered as transient, but implements IDisposable.
-[Disposable Transient Component] ArtistsController is registered as transient, but implements IDisposable.
-[Disposable Transient Component] HomeController is registered as transient, but implements IDisposable.
See the Error property for detailed information about the warnings. Please see https://simpleinjector.org/diagnostics how to fix problems and how to suppress individual warnings.

Application_Start
protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);

    container = new Container();
    container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
    container.Register<IRepository<Artist>, ArtistRepository>(Lifestyle.Scoped);
    container.Register<IRepository<Album>, AlbumRepository>(Lifestyle.Scoped);
    container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
    container.Verify();
    DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
}

I tried to add Lifestyle.Scoped to my registrations as follows:
container.Register<IRepository<Artist>, ArtistRepository>(Lifestyle.Scoped);
container.Register<IRepository<Album>, AlbumRepository>(Lifestyle.Scoped);

Controllers:
Note: Repositories implement IDisposable.
public class HomeController : Controller
{
    ...
}

public class AlbumsController : Controller
{
    readonly IRepository<Album> _repository;

    public AlbumsController(IRepository<Album> repository)
    {
        _repository = repository;
    }

    ...
}

Other details:

*

*My controllers do not override the protected virtual void Dispose(bool) method.

*I'm using Simple Injector v4.4.0

*I'm using the web integration packages v3.2.7

A: Based on the supplied demo project I was indeed able to reproduce the issue.
The problem is in the referenced packages:
<package id="SimpleInjector" version="4.4.0" targetFramework="net46" />
<package id="SimpleInjector.Integration.Web" version="3.2.7" targetFramework="net46" />
<package id="SimpleInjector.Integration.Web.Mvc" version="3.2.7" targetFramework="net46" />

As you can see the packages for MVC are from another major branch.
If you update everything to 4.4.0 your problem goes away.
Apart from this, the error message is not telling you to implement IDisposable in your repositories. SimpleInjector, and any other tool for that matter, is not able to decide this for you.
You should decide for yourself if you need that. If you would also inject the DbContext, which is best practice anyway, there is no need to implement IDisposable at all in your repository assuming the current implementations won't change much.


text:
Q: Windows Azure not generating aspx files I setup my first Azure Cloude Service as well as Web Role. When I build and then publish application I can only see bin directory with all my dlls. I don't have any folders or aspx files.
\ProjectName.CloudService\bin\Debug\ProjectName.CloudService.csx\roles\Web\bin
How can I compile other files.

A: Are the .aspx files actually added to the Visual Studio project?  (Visual Studio only copies the files it knows about.)  If you don't see them in the treeview for the project, click the button at the top that shows files not part of the project, and then right-click and "include in project" on the files you're missing.
If that doesn't work, you might consider heading over to the MSDN forum for Windows Azure: http://social.msdn.microsoft.com/forums/en-us/windowsazure/threads and asking there.

A: If you look in your Cloud Service project folder, you won't find the aspx files, dlls, etc.  The Cloud Service project folder will only contain your configuration files and eventually your packaged Azure deployment files. You'll want to look in bin\Debug\ folder under your Web Role (ASP.NET) project.