Appropriate $\sigma$-field for collection of closed sets

Question: Let $(C,\mathcal{F})$ be the set of continous functions $[0,\infty)\to\mathbb{R}$ with the corresponding product $\sigma$-field. Let $Z(f) = \{x\geq0: f(x)=0\}$. Let $\mu$ denote the Lebesgue measure. Denote the collection of closed subsets of $[0,\infty)$ by $D$. Define
$$ A = \{f\in C: \mu(Z(f))=0\}.$$
I'm interested in understanding the measure-theoretic footing of the statement:

Brownian motion has a zero set of measure 0, almost surely.

If I've interpreted this right, the statement makes sense if $A\in\mathcal{F}$. How do we show that $A\in\mathcal{F}$?
What would be even nicer is if would could find a $\sigma$-field $\mathcal{G}$ on $D$ such that the following holds, with $Z$ and $\mu$ measurable:
$$(C,\mathcal{F})\to^Z (D,\mathcal{G})\to^\mu (\mathbb{R}^+,\mathcal{B}),$$
where $\mathcal{B}$ is the Borel $\sigma$-field on $\mathbb{R}^+$. This would answer the question of whether $A\in\mathcal{F}$, since the composition of measurable functions is measurable. This is suggested in these notes.
Thanks!
Edit:
By product $\sigma$-field $\mathcal{F}$ on $C$, I mean the smallest $\sigma$-field on $C$ such that, for each $x\geq 0$, the projection map $\pi_x:f\mapsto f(x)$ is measurable. (This definition.)
Answer: The product $\sigma$-field on the set of continuous functions is not particularly useful, since no path is measurable in that $\sigma$-field.
If you look at the problem on a compact interval only, you can take the usual sup-norm and the generated Borel $\sigma$-field. With this norm, the evaluation $e:\mathcal{C}\times[a,b]\to\mathbb{R}$ given by $e(f,x)=f(x)$ is continuous and hence measurable. Therefore, the set $Z=e^{-1}\big(\{0\}\big)$ is measurable. If this set has measure zero, we can conlude by Fubini's theorem that for almost all paths, the set of zeros has Lebesgue measure zero.
Now, if you endow the set $\mathcal{C}$ with the $\sigma$-field generated by the Borel $\sigma$-fields on $C_{[n,n+1]}$ for $n=0,1,\ldots$, you can apply the previous result to conclude again that the set of zeros of almost all paths has Lebesgue measure zero.
Comment: @MichaelGreinecker: The indicator of the irrationals is not in $C$.  We are only defining a $\sigma$-field on $C$ so certainly $C$ is measurable.
Comment: Sorry Michael. I was unclear using the term product $\sigma$-field. I've edited my post to clarify exactly which $\sigma$-field I mean. Paths should now be measurable.
Comment: @BenDerrett I is quite clear what you mean by product $\sigma$-field, but there is no sample path $f$ such that $\{f\}$ is measurable in the product $\sigma$-field.
Comment: Thanks. What about this: Let $f$ be the element of $C$ which is identically $0$. Then we have $\{f\}=\cap_{q\in\mathbb{Q}^+}\pi_q^{-1}(0)\in\mathcal{F}$.
Comment: @BenDerrett No. The indicator function of the positive irrationals is also in the intersection. The product $\sigma$-field doesn't contain just continuous functions and the set of continuous functions is not a measurable subset.
Comment: @BenDerrett: In fact, both you and Michael are talking about the same $\sigma$-field.  But either way, the essential point is that the measurability of the set $A$ comes from Fubini's theorem.
Comment: @NateEldredge I seen now. In that case, the linke given is misleading. Ben uses the trace on $\mathcal{C}$, which does coincide with the Borel $\sigma$-algebra from the topology of uniform convergence.


How to resolve "@Url cannot be used with @PUT URL (parameter #1)"

Question: I want to use @PUT and @Url together, but it throws an IllegalArgumentException

Edit
@PUT
fun editPost(
    @Url() url: String = "xxxx/threads/{tid}",
    @Path("tid") postId:Long,
    @Body x: X
)

Comment: can you add your code
Comment: There is no context to this question
Comment: @PUT
    fun editPost(@Url() url: String = "xxxx/threads/{tid}",@Path("tid") postId:Long,@Body x: X)
Comment: Taht is my code
Comment: @Zero Ok, I have edited your answer and upvoted it because that is a valuable question which people will need an answer too. Make sure to format your questions well and be specific. As Milan as mentioned, always add your code if you can. I am now providing an explanation as to why you had this issue, take a look at my answer
Comment: @Zero How did you solved this problem ? Facing same issue. Could you please help me on this
Answer: This answer is based on the assumption of you using Retrofit Library to make a API call. If that's not the case, my apologies and let me know so I can modify/remove the answer.
From what I've researched, you've probably implemented your interface method like the following:
@PUT("")
Call...

With this call, you should encounter java.lang.IllegalArgumentException: Missing either @GET URL or @Url parameteras you've not provided the addition parameter which is needed to complete the API call.
Therefore, you must keep the base URL in the mainActivity where you'll be making the call and route of the API within the bracket of the interface
@PUT("user/id")

or if you want to keep it blank as original, you must use @PUT(".") as this will declare that your final URL is the same as the Base URL provided in the mainActivity.
Answer: You were very close...
@PUT("xxxx/threads/{tid}"
fun editPost(
    @Path("tid") postId: Long,
    @Body x: X
)

Comment: @Zero this will solve your issue - let me know if you have any questions


I'm having trouble embedding HSQLDB into a simple Java (Eclipse) project

Question: After reading up on some options (sqlite, derby etc...), I've decided to throw down with HSQLDB. I've downloaded it, read up on it and followed a 'hello world' type intro to it, and am now stuck.
I believe that you have to put the hsqldb.jar file in the src folder, so I did exactly that. Then I made a reference to the package with Eclipse by going into Run -> Run Configurations, then going into the Classpath tab, then clicking User Entries, then add External Jar, and selecting hsqldb.jar.
I get this :

java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver

Here's my code :
package mysqlite;

import java.sql.*;

public class myclass {
    public static void main(String[] args) {
        try {
            Class.forName("org.hsqldb.jdbcDriver");

            String url = "jdbc:hsqldb:db";
            String user = "aUser";
            String password = "";

            Connection conn = DriverManager.getConnection(url, user, password);
        }
        catch(Exception e) {
            System.out.println(e.toString());
        }
    }
}

I understand it's unable to find a class, but I thought that was what the hsqldb.jar provided.
Comment: ignore the package name lol, this started as an investigation into sqlite.
Comment: 2nd comment : upon going back into the classpath area, under user entries, the jar I referenced is no longer listed.
Comment: Nevermind, figured it out. Turns out my question boils down to 'how do you include a jar file properly in Eclipse'. I found the answer here http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29 Funny how typing out the question really helps you realize where you went wrong. Leaving this all here in case anyone else might need it.
Answer: No, you do not have to put it into src folder. src is for source files (*.java). You have to add this jar into your classpath:  click on project properties, choose "Java build path", select tab "Libraries" and add the jar here.
The jar can be stored anywhere in your file system. Sometimes people create lib directory under project home and put all 3rd party dependencies there.
Comment: Tried it that way too, works well. I think part of my confusion is / was classpath vs buildpath.
Comment: @jason , if it works well, you can accept his answer.
Answer: Try putting the .jar here:
<YOUR_JAVA_HOME>\jre\lib\ext

Comment: Im curious how that would play out when you go to distribute the program. Would you need to provide the jar separately with your app? Or does it get somehow bundled with your app? What if you have multiple unrelated projects and you store numerous unrelated .jars in there? So much more experimenting to do...
Comment: This needs a downvote actually, you will find out why eventually
Comment: You would be better off putting the .jar in your classpath as @AlexR instructed... Putting it here is just a quick and dirty way to do it that worked for me when I was playing around with a database recently.


Nemo keyboard shortcuts overwritten

Question: I read a lot about how you can make Nemo your standard file browser in Ubuntu 14.04. I managed to install it and most of the standard actions are performed by Nemo and no longer by nautilus - as it should be. But there is one thing I cannot manage to do:
I cannot make Nemo to accept my keyboard shortcuts, which I declared in ~/.gnome2/accels/nemo. It seems like this file gets overwritten when I restart Nemo. What I want to achieve is that I can open a Terminal in the currently openend directory. What I tried was editing the line ; (gtk_accel_path "<Actions>/DirViewActions/OpenInTerminal" "<Primary><Alt>z") in the file ~/.gnome2/accels/nemo. However, any changes are lost after the next start of nemo.
Thanks a lot!
EDIT: I am stupid. If you remove the ; in front of the line  ; (gtk_accel_path "<Actions>/DirViewActions/OpenInTerminal" "<Primary><Alt>z") everything works. Sorry for the foolish question.
Comment: If you found solution please post your own answer for helping to other users.
Answer: Found an answer by myself:
If you remove the ; in front of the line  ; (gtk_accel_path "<Actions>/DirViewActions/OpenInTerminal" "<Primary><Alt>z") everything works. Sorry for the foolish question.

Nemo keyboard shortcuts overwritten


How do i run a perl script (possible missing dependencies)

Question: I'm trying to use this little script because my cat loves walking on my keyboard.
http://linux.softpedia.com/get/Utilities/Lock-keyboard-for-Baby-23745.shtml
I just installed Ubuntu16.04 and don't have a lot of experience.
So i figured i would use the terminal to navigate to the folder i downloaded the script into and then do
perl scriptname.pl

Which outputs this:
Can't locate Gtk2.pm in @INC (you may need to install the Gtk2 module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at keylock.pl line 128.
BEGIN failed--compilation aborted at keylock.pl line 128.

It seems like a missing dependency but i can't figure out what to install.
sudo apt-get install gtk2.0
sudo apt-get install build-essential libgtk2.0-dev
sudo apt-get update

will only tell me they are installed and up to date.
What can i do?
Answer: You need Perl interface to Gtk2, it should exist as libgtk2-perl.
Comment: Yep that worked. Thank you!  /solved


How can I create a custom bazel build rule that uses the runfiles path of another rule?

Question: I'm trying to create a custom build rule to build a pip package from a py_binary output. To create my pip package I want to invoke a shell script. The shell script builds a pip package by creating a zip file from the runfiles of the py_binary output.
For example suppose I have
py_binary(
    name = "some_binary",
    srcs = ["some_binary.py"],
    srcs_version = "PY2AND3",
)

Building this rule produces
bazel-bin/some_binary.runfiles

I would now like to create a custom build rule that will invoke my shell script with the location bazel-bin/some_binary.runfiles
I tried creating a macro
def build_pip_package(
    name, py_binary=None, setup_file=None):
  """Create a pip package from a py_binary.

  The source file should be a text file with python formatting i.e.

  Args:
    name: Name for the rule.
    py_binary: Build rule producing the py_binary
    setup_file: Build rule producing the setup.py file to use to produce
      the package.
  """
  output= "somefile"
  native.genrule(
      name=name,
      outs=[output],
      cmd="echo $(location //:build_pip_package_script) "
      + "--py_runfiles_path=$(locations %s)" % py_binary
      + " --setup_file=$(location %s) " % setup_file,
      tools=["//:build_pip_package_script"],
      srcs=[setup_file, py_binary])

This ends up invoking my shell script with
bazel-out/local-fastbuild/bin/some_binary/model_train some_binary.py

How can I invoke my script with the location of the runfiles directory corresponding to the some_binary target.
Answer: If you put the py_binary in the tools attribute instead of srcs bazel will include the runfiles tree. You can access it via "$(location %s).runfiles" % py_binary


How to change a file inside a .exe in python?

Question: I've made a nsis installer for my application and want to change one of the files inside the installer .exe. Is there a way to open the installer and change one of the files inside, similar to ZipFile?
The reason for doing this is I want to add a unique token so I can later identify which user has downloaded the app. Generating a new installer from scratch with the token inside would be too slow.
Comment: [What have you tried so far?](https://meta.stackoverflow.com/q/261592) I would read through the NSIS documentation and find out how to do it that way.
Answer: No, you cannot change files inside the installer.
What you can do however is to append some text to the end of the exe on the server and then read it in the installer.
If you have a lot of data, you can append it in a .cab file and use the CabX plug-in (CabX::FromSelf).
Comment: Thanks, the first idea worked perfectly.


Logger is not working for biz-talk solution completely

Question: I am facing one strange issue in my project.There is one solution say S1.Inside that solution there is one biztalk project say P1 and one helper library project.Inside that helper library project we have  one class file for creating log.
Now there is one more solution say S2 .Inside this solution we have two more biztalk projects. say P2 and P3 respectively These biztalk project have reference to that previous project as well as the helper library.
Now the issue is i am able to create log for P2 project but not for the P3 project.
Can anyone please guide me why this is happening??
Thanxs in Advance.
Comment: Debug the project P3 to see if the log shapes are hit. Check the event viewer to see if you have some exception there. Without more detail is impossible that we can help you.
Comment: One thing i observed is that in Biztalk Admin console for this P3 project ideally it should show dependencies for helper library project but it is not showing that and i am not getting why this is happening
Answer: I guess your are logging to the same file. If so, the best solution is to write to different files. An other option is to use a different locking model on the log file.
This example shows how to configure the appender to use the minimal locking model that allows multiple processes to write to the same file.
<appender name="FileAppender" type="log4net.Appender.FileAppender">
    <file value="${TMP}\log-file.txt" />
    <appendToFile value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
</appender>

This example shows how to configure the appender to use the "inter process" locking model. Be sure all loggers are using the same locking model.
<appender name="FileAppender" type="log4net.Appender.FileAppender">
    <file value="${TMP}\log-file.txt" />
    <appendToFile value="true" />
    <lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    </layout>
</appender>

Comment: One thing i observed is that in Biztalk Admin console for this P3 project ideally it should show dependencies for helper library project but it is not showing that and i am not getting why this is happening


Question about upper central series of a group

Question: I am trying to figure out nilpotent groups, and it says that a group $G$ is nilpotent if there is a non-negative integers $c$ such that $Z^c(G) = G$.
Now an upper central series is something like $Z^0(G) \leq Z^1(G) \leq Z^2(G) \leq \ldots$ where $Z^0(G) = 1$ and $Z^1(G) = Z(G)$. But it doesn't say what $Z^2(G)$ is, it just says that $Z^2(G) / Z^1(G) = Z(G / Z^1 G)$. Since $G / Z^1(G)$ is a group whose elements are sets, $Z^2(G) / Z^1(G)$ will also be a set whose elements are sets. How do you solve for $Z^2(G)$, if you want to check if $Z^2(G) = G$?
Comment: But you have exactly what $Z_2(G)$ is! It is uniquely defined by the property $Z_2(G)/Z(G) = G/Z(G)$.
Comment: I didn't say that $Z_2(G)$ was equal to $Z_2(G)/Z(G)$. I said $Z_2(G)/Z(G) = Z(G/Z(G))$ (which is what you wrote anyway! And that does define $Z_2(G)$. I guess you want a definition that looks like $Z_2(G) = \{ g \in G \mid {\rm some\ property\ of}\ g \}$. You can do that yourself!
Comment: @DerekHolt But $Z_2(G)$ should be a set with elements of $G$. $Z_2(G)/Z(G)$ is a set with elements that are sets (and those sets contain elements of $G$). So $Z_2(G)$ can't be equal to $Z_2(G)/Z(G)$. Maybe I don't understand what "uniquely defined" means (I thought it means "equal to").
Answer: Consider the group $Z(G/Z(G))$. Then it is a subgroup of the factor group $G/Z(G)$, say $H/Z(G)$. Therefore $H$ is a subgroup of $G$ containing $Z(G)$. Now we write $H = Z_2(G)$. For example, consider the dihedral group $G = D_8$. You can check that $|Z(G)|=2$. Now $G/Z(G)$ is a group of order $4$ and in particular is abelian. Therefore $$G/Z(G) = Z(G/Z(G)) = Z_2(G) /Z(G).$$ Hence we have $G = Z_2(G)$ and $G$ is of class 2.
Comment: Every group of order $p^2$ where $p$ is a prime number is abelian.
Comment: In this example $|G| =8$ and $|Z(G)|=2$. So $G/Z(G)$ is of order $4$.
Comment: You should prove in general that, if $H/N = L/N$  then $H = L$.
Comment: How do you know $G/Z(G)$ is an abelian group of order $4$?
Comment: Sorry, I meant how do you know it is a group of order $4$ in the first place
Comment: Ok, I think I understand that part. But in our definition, it says $G$ is nilpotent with nilpotency degree of $2$ if $Z_2(G) = G$. I don't really see how do you got from $G/Z(G) = Z_2(G)/Z(G)$ to $G = Z_2(G)$, but in practice do we just check every $Z_c(G)/Z(G)$ until we find one that is equal to $G/(Z)G$?
Answer: Read this link it may help you
https://en.wikipedia.org/wiki/Central_series


xxd usage (change magic byte to JPEG)

Question: I create a simple test file like this:
$ cat > test
blah

Now I run vi, and then :%!xxd to edit first bytes with FFD8 FF
00000000: ffd8 ffe0 0a                             blah.

and the I run :%!xxd -r.
file gives me NOT jpeg:
$ file test
test: Unicode text, UTF-8 text

And if I manage to get hexdump:
$ xxd test
00000000: c3bf c398 c3bf c3a0 0a                   .........

What am I doing wrong with xxd?
Thank you
Answer: When opening the file with vi, please make sure to say:
LC_ALL=C vi test

then edit and save the file with the shown procedure.

xxd usage (change magic byte to JPEG)


XPages - show image contained with email in xpage document

Question: I am working on an internal helpdesk. Emails address to the helpdesk appear in a Notes View, and I can open the document in XPages and see the text. But it won't show any inserted images within the text.
I can list the attachments as external links (courtesy of http://techdriveactive.blogspot.co.uk/2012/11/open-attachments-in-xpage-in-client.html) but I can't seem to get a handle on the images.
Any ideas ??
Comment: have a look at the source code. Does it show the href tags? Where do they point? Eventually some onLoad() JS can fix that.
Answer: One way around that challenge is to use a Dojo ContentPane. It has a href attribute that can point to a different url. You then can point it to the content rendered by the classic engine:
<code>      href="someview/docid/Body?OpenField"
</code>
Note: this won't work in XPiNC
Comment: Wow, so simple when you know how. Thank you thank you thank you
Answer: To you HelpDeskOpenDoc.xsp XPage add a Rich Text control and bind it to the Rich Text Field with the images and other rich content ...
<code><xp:inputRichText id="inputRichText1" value="#{document1.Body}"></xp:inputRichText>
</code>


Effect of !important declaration when sizing (fonts) with rem

Question: UPDATE: Please note that I am seeing this issue only in Chrome (latest version). Everything seems to be fine in Firefox.
By definition:

The rem unit is relative to the root—or the —element. That means
  that we can define a single font size on the  element and define
  all rem units to be a percentage of that.

Let me explain my situation with an example...
Relevant CSS:
html {
    font-size: 87.5%;
}

body {
    font-size: 17px;
    font-size: 1.21428571rem;
}

code {
    font-size: 14px !important;
    font-size: 1rem !important;
}

I am using the !important declaration to override the font-size of inline code.
The thing is, I noticed that the font-size of code blocks is much smaller than 14px, most probably 12px. But if I remove the !important declaration and set the font-size on a specific code element (styling a specific inline code element), the fonts-size is nice and fine at what appears to be 14px.
Does you have any idea as to how !important declarations may affect sizing in rem's? (Especially considering in my case.)
Answer: First off !important is lazy coding and dangerous to maintainability. It's toxic and breaks the nature of CSS (the Cascading portion). Avoid it at all costs.
Second:
code {
    font-size: 14px !important;
    font-size: 1rem !important;
}

Might as well be written:
code {
    font-size: 1rem !important;
}

The second rule overrides the first (again, the Cascading nature of CSS)
rem stands for root em, which is the font-size of the top level element (i.e., html)
and what your rule is saying 1 x the em of the html element, with is 87.5% of the browser default.
EDIT:
Your
 tags have a font-size of 100% inherited from the parent element which is eventually inherited from body and body has a 1.2142857rem which is roughly 17px This is why you're seeing a difference in font sizes, which is also exacerbated by the the difference of monospace and sans serif fonts.
Comment: **(1)** I have to use `!important` because I am overriding the style of `.entry-content code` in default stylesheet with `code` in my child theme's (WordPress) stylesheet. I don't want to touch the parent stylesheet. If I modify `.entry-content code` I'd have to modify numerous others.
Comment: **(2)** `font-size: 14px !important;` is for older browsers. Even IE8 doesn't support `rem` I am told.
Comment: You don't *have* to use `!important` if you refactored your css to have better specificity you wouldn't need it. Also check my edit for a detailed description of what's going on.
Comment: The point I don't understand is, why does `1.2142857rem`, that is the font-size set on `body`, `p` or any other element, matter? The font-size of `code` (1rem) should be governed by that of `html` (87.5%). 1rem should always be equal to 14px (as long as the browser's default is 16px)... am I wrong? (also, I can confirm that the issue persists in the latest version of Chrome — everything's fine in Firefox)
Comment: hmm... no. The issue persists in Firefox as well, it's just not as visible as in Chrome.
Comment: I can confirm with Firebug that the computed value is 14px as expected on Firefox 14.
Comment: @BoltClock Yep. You are right. Everything's fine in Firefox. The slight difference I saw was due to the line-height difference in the two pages. Thanks!
Comment: Sorry I'm seeing it now, I thought you were talking about the inline `code` tag. This has to be a bug in Chrome, it seems to be using the `body` as the root em when inside the `pre` tag. If you remove the code the rem on the pre tag is correct.
Comment: However, if I set the `pre` tag to use 1rem it seems to fix the issue.
http://jsfiddle.net/E9Eu9/ http://jsfiddle.net/E9Eu9/1/
Comment: Thanks for your time, after working on it for hours, I finally realized what was causing the problem. Please see my answer below.
Answer: Okay, the issue was with (1) font-family not defined for code and pre blocks, which meant Chrome and other webkit browsers chose some monospace font that appears smaller (2) line-height was smaller (almost equal to the font-size).
Fixing these two has solved the problem.
I have no idea why Chrome Dev Tools Web Inspector's "Computed Style" shows 11px as the font-size (also applies to any webkit browser, including Safari). I can confirm that it's showing the wrong value because by changing the font to Arial I could easily tell that it's 14px.
Also, after setting the font-family on code and pre blocks, Chrome now shows the correct computed font-size value.


How to compare every value from a column from one df with every value from a column of another df in R? dfs with different row numbers

Question: Which box fits in which basket by also taking into consideration the priority of the boxes and baskets?
df.boxes has the following columns:
boxID - the name of the box
boxX - the size of the box in the X dimension
boxY - the size of the box in the Y dimension
importance - which box should be assigned to a basket first. like a priority -  555 most important (with the highest priority), 111 least important (with the lowest priority)
df.basket has the following columns:
basketID - the name of the basket
basketX - the size of the basket in the X dimension
basketY - the size of the basket in the Y dimension
priorityOfSelection - which basket should be first filled with a box.  1 - highest priority, 7 - lowest priority
for example, box1  doesn't fit in the basket with the highest priority, a.k.a basket 1, so it moves down to the next basket with priorityOfSelection "2" and stores its name in a new column "boxes" of df.basket.
I have a though, first I order the two data frames based on their "importance", "priorotyOfSelection" and compare the size of the boxes to the size of the basket and if there is a match I assign the name of the box to the corresponding basket. In this order of thinking I am trying to create nested for-loop - unsuccessfully, as you may see.
Could anyone point out what and where I do wrong or direct me to an alternative approach, that would be also highly appreciated?
reprex
 df.boxes <-structure(list(boxID = c("box 1", "box 2", "box 3", "box 4", "box 5"),
                                  boxX = c(600,450, 400, 350, 200),
                                  boxY = c(600, 400, 450, 500, 300),
                                  importance = c(555, 444, 333, 222, 111)
                                  ), class = "data.frame", row.names = c(NA, -5L))

df.basket <- structure(list(basketID = c("basket 1", "basket 2", "basket 3","basket 4", "basket 5", "basket 6", "basket 8"),
                            basketX = c(500,650, 500,200, 450, 500,300),
                            basketY = c(450,650, 500,300,450,500, 300),
                            priorityOfSelection = c(1, 2, 3, 4, 5,6,7)
                            ), class = "data.frame", row.names = c(NA, -7L))

attempt:
for (i in 1:nrow(df.boxes)){
  for(j in 1:nrow(df.basket)){
  df.basket$box[j] <- ifelse((df.boxes$boxX[i] <= df.basket$basketX[j] | df.boxes$boxY[i] <= df.basket$basketX[j]) & (df.boxes$boxX[i] <= df.basket$basketY[j] | df.boxes$boxY[i] <= df.basket$basketY[j]),
                                df.boxes$boxID[i], "none")
  }
}

desired output:

Thank you very much for your time!
Comment: That's caused by it overwriting. If you set the box column to 0's then add that as a condition so it wont overwrite anything it should fix it.`df.basket[,"box"]<-0
for (i in 1:nrow(df.boxes)){
  df.basket[which(df.basket$basketX>=df.boxes[i,"boxX"] & df.basket$basketY>=df.boxes[i,"boxY"] & df.basket$box==0)[1], "box"]<-df.boxes[i,"boxID"]
}
` This gives me the same results as your example. It gives 0 instead of none for unused baskets, but you could easily change that if you want. This is getting to be pretty close to what @AllanCameron suggested.
Comment: You could use something like this to determine which baskets a box will fit in and then since they are in order of priority just take the first one that it will fit in. `which(df.basket[,"basketX"]>df.boxes[2,"boxX"] & df.basket[,"basketY"]>df.boxes[2,"boxY"])[1]`
Comment: This works to automate it. The problem being that it overwrites baskets that have already been used.  `for (i in 1:nrow(df.boxes)){
  df.basket[which(df.basket$basketX>df.boxes[i,"boxX"] & df.basket$basketY>df.boxes[i,"boxY"])[1], "box"]<-df.boxes[i,"boxID"]
}`
Comment: thank you for writing! When I run your code individually(from the first comment) it works correct up to the third box and the automated version gives me false assignment of boxes to baskets.
Comment: yes, indeed, thank you @Tanner33, I get the expected result now! :)
Answer: If you set up an extra column in df.boxes to record whether the box has been "used" or not, you can do it this way:
df.basket$box <- character(nrow(df.basket))
df.boxes$used <- logical(nrow(df.boxes))

for(i in sort(df.basket$priorityOfSelection))
{
  fits <- which(df.boxes$boxX <= df.basket$basketX[i] &
                df.boxes$boxY <= df.basket$basketY[i] &
                df.boxes$used == FALSE)

  df.basket$box[which(df.basket$priorityOfSelection == i)] <-
    paste("box", fits[which.max(df.boxes$importance[fits])])
  df.boxes$used[fits[which.max(df.boxes$importance[fits])]] <- TRUE
}

df.basket$box[df.basket$box == "box "] <- "none"

df.basket
#>   basketID basketX basketY priorityOfSelection   box
#> 1 basket 1     500     450                   1 box 2
#> 2 basket 2     650     650                   2 box 1
#> 3 basket 3     500     500                   3 box 3
#> 4 basket 4     200     300                   4 box 5
#> 5 basket 5     450     450                   5  none
#> 6 basket 6     500     500                   6 box 4
#> 7 basket 8     300     300                   7  none

Created on 2020-03-09 by the reprex package (v0.3.0)
Comment: wow, thank you! it seems easy and yet it is not! One thing though, it is possible to rotate the box inside the basket. I extended your `fits` vector:  `fits <- which(((df.boxes$boxX <= df.basket$basketX[i] | df.boxes$boxX <= df.basket$basketY[i] ) & (df.boxes$boxY <= df.basket$basketX[i]| df.boxes$boxY <= df.basket$basketY[i])) & df.boxes$used == FALSE)`
and so far it still gives the same result as yours and as the desired one :) Thank you very much! All the best, -
Comment: Be careful with the "or" statements. The way you have it written a box fits in a basket as long as one side of the basket is longer than both sides of the box. You need something more like (x <= x "and" y <= y "or" x <= y "and" y <= x).
Comment: `fits <- which(((df.boxes$boxX <= df.basket$basketX[i] & df.boxes$boxY <= df.basket$basketY[i] ) | (df.boxes$boxY <= df.basket$basketX[i] & df.boxes$boxX <= df.basket$basketY[i])) & df.boxes$used == FALSE)`
Answer: Just for fun a late submission with "pure for looping" and if's with no extra columns.
Under the assumption that what you are basically trying to achieve is pushing the boxes from top to bottom into the (priority ordered) baskets (list)
df.basket$box <- NA
for (i in seq.int(df.boxes$boxID)){
  for (j in seq.int(df.basket$basketID)){
    if(is.na(df.basket$box[j])){
        if (all( c(df.basket$basketX[j], df.basket$basketY[j]) -
                 c(df.boxes$boxX[i], df.boxes$boxY[i]) >= 0)){
            df.basket$box[j] <- df.boxes$boxID[i]
  break
        }
    }
  }
}
df.basket$box[is.na(df.basket$box)] <- "none"
df.basket

    basketID basketX basketY priorityOfSelection   box
1 basket 1     500     450                   1 box 2
2 basket 2     650     650                   2 box 1
3 basket 3     500     500                   3 box 3
4 basket 4     200     300                   4 box 5
5 basket 5     450     450                   5  none
6 basket 6     500     500                   6 box 4
7 basket 8     300     300                   7  none

For sure not as elegant as  the solution by '@Allan Cameron' but also a possible approach, if you wanna grasp the for loop approach you started out with in your own attempt a bit better.
Comment: It is so nice to see my initial approach developed in a way to give the desired output. It may be just the first two lines of code but still, there is a nested for-loop :) Thank you very much!


Need One Result to Be Found Using A Different WHERE. A SELECT within a SELECT?

Question: I have this query:
SELECT a.WEEK_ID, a.QUANTITY, a.PRICE AS expenseTotal,
b.ID, b.COMMENCE, b.USER_ID,b.*,
c.ID AS userid, c.NAME, c.LAST_NAME
from b_sale_basket a
INNER JOIN b_report_week b ON a.WEEK_ID = b.ID
INNER JOIN b_user c ON b.USER_ID = c.ID
WHERE a.ORDER_ID = $ID AND a.PRODUCT_ID = 316

You will see this section on the top line:
a.PRICE AS expenseTotal

I am wanting a.PRICE to be found WHERE a.PRODUCT_ID = 317 NOT 316 as it currently is.
I have tried to do a SELECT statement within a SELECT:
  SELECT a.WEEK_ID, a.QUANTITY,
 (SELECT PRICE FROM b_sale_basket WHERE PRODUCT_ID = 317 AND ORDER_ID = $ID) AS expenseTotal,
  b.ID, b.COMMENCE, b.USER_ID,b.*,
  c.ID AS userid, c.NAME, c.LAST_NAME from b_sale_basket a
  INNER JOIN b_report_week b ON a.WEEK_ID = b.ID
  INNER JOIN b_user c ON b.USER_ID = c.ID
  WHERE a.ORDER_ID = $ID AND a.PRODUCT_ID = 316

But that's not worked.  Please could somebody point me in the right direction?
Comment: You really couldn't be more cryptic in your wording.
Comment: Really sorry, I will try and reword it.
Comment: Is `php` code really relevant for this question? Why not just focus on the `SQL` query? Can you clean up the unnecessary stuff from the Q?
Comment: You have too many end paranthesis in the second SQL statement.
Comment: I'm confused, why cant you just change it to 317? And why is it 316?
Comment: I am using it in a while loop within PHP and it returns the relevant rows, I need to use $row['expenseTotal'] as a variable within the row.
Comment: why not do a SUM() on all products and remove PRODUCT_ID = 317 from the sub select?
Answer: You need to add another JOIN
Something like:
SELECT a.WEEK_ID, a.QUANTITY,
 d.PRICE AS expenseTotal,
  b.ID, b.COMMENCE, b.USER_ID,b.*,
  c.ID AS userid, c.NAME, c.LAST_NAME
  FROM b_sale_basket a
  INNER JOIN b_report_week b ON a.WEEK_ID = b.ID
  INNER JOIN b_user c ON b.USER_ID = c.ID
  INNER JOIN b_sales_basket d ON d.ORDER_ID = a.ORDER_ID AND d.PRODUCT_ID = 317
  WHERE a.ORDER_ID = $ID AND a.PRODUCT_ID = 316

Comment: Unfortunately this doesn't return anything.  I see what you're trying to do but it just doesn't show any result.
Comment: well, that's why I said 'like' this. Just play around with it and I'm sure you'll get what youre looking for, I just went with your sub select.
If ORDER_ID is your primary key then of course it won't return anything since its impossible for one row to have two values for PRODUCT_ID


Summing in mysql previous row with current

Question: Need help to make query.
I have table like this:
kli, akt, mes

'2', '2',  '201209'

'2', '2',  '201210'

'3', '3',  '201211'

And I need a result table:
kli, akt, mes

'2', '2',  '201209'

'4', '4',  '201210'

'7', '7',  '201211'

result tables sum by field mes, current and all previous rows
Answer: try the below query
SELECT SUM(b.kli),SUM(b.akt),a.mes FROM tableName a INNER JOIN tableName b ON a.mes >= b.mes GROUP BY a.mes


BCM 4312 LP-PHY card doesn't detect any wireless networks

Question: I installed ubuntu 12.04 on my dell inspiron with BCM4312 802.11/b/g (LP_PHY) wlan card,installation was followed by errors about missing firmware so to fix it i installed firmware-b43-lpphy-installer,after that it detects my wlan card but it doesn't detect any wireless networks
it's using b43-pci-bridge,however it detects few wireless networks with wl driver sometimes but wifi switch does't respond then and card is working well with windows7
I even followed these instructions to install firmware provided by broadcom but no
success and now i have no idea what could be the problem and how to fix it
Comment: Have you followed my guide in http://askubuntu.com/questions/55868/how-to-install-broadcom-wireless-drivers
Comment: yes i followed the  your link @Luis but no luck..  as i told above it's not working at all with b43 and acting strange with wl that is wifi switch stops working,it detects some wireless networks for a while and then that too disappears later
Comment: @user2007060 Please, respond to the Luis request, so we can know if your problem was solved or not. Thanks!
Answer: Work in progress ..
Solves driver issue, but not in repeatable, stable manner.
Note: I have already tried all suggestions in: Installing Broadcom Wireless Drivers

Typically, after initial install of Ubuntu 12.04.4 LTS (latest update) you will get an error message briefly on screen suggesting the wireless card's firmware is out of date.
In other words:
dmesg | grep -e b43 -e Broadcom
returns: (or very similar)
[    8.091376] b43-phy0: Broadcom 4312 WLAN found (core revision 15)
[    8.136098] b43-phy0: Found PHY: Analog 6, Type 5 (LP), Revision 1
[    8.161222] Broadcom 43xx driver loaded [ Features: PNL ]
[    8.188507] b43-phy0 ERROR: Firmware file "b43/ucode15.fw" not found
[    8.188512] b43-phy0 ERROR: Firmware file "b43-open/ucode15.fw" not found
[    8.188516] b43-phy0 ERROR: You must go to http://wireless.kernel.org/en/users/Drivers/b43#devicefirmware and download the correct firmware for this driver version. Please carefully read all instructions on this website.

You need to install Non-Free drivers, then restart driver:
sudo apt-get install linux-firmware-nonfree
sudo modprobe -r b43 && sudo modprobe b43
Check the status:
dmesg | grep -e b43 -e Broadcom
should return: (or very similar)
[  306.159033] b43-phy0: Broadcom 4312 WLAN found (core revision 15)
[  306.200170] b43-phy0: Found PHY: Analog 6, Type 5 (LP), Revision 1
[  306.224407] Broadcom 43xx driver loaded [ Features: PNL ]
[  306.628157] b43-phy0: Loading firmware version 666.2 (2011-02-23 01:15:07)

Note 1: If you instead did a full update (sudo apt-get update && sudo apt-get upgrade) to 12.04.4, this may change the b43 firmware loaded to 2008 (which is not the latest).
Note 2: IMHO, this step is required to support the BCM4312-LP card, regardless of what driver you end up using.
The BCM4312-LP card should now be working ..
Try shutting down, removing power and Ethernet cable, waiting a full 20 seconds, and re-starting laptop/netbook ..
Check the status:
dmesg | grep -e b43 -e Broadcom
should return: (or very similar)
[  438.442062] eth1: Broadcom BCM4315 802.11 Hybrid Wireless Controller 22.214.171.124 (r326264)

OR
[    7.663552] eth1: Broadcom BCM4315 802.11 Hybrid Wireless Controller 18.104.22.168 (r326264)
[  187.909055] Broadcom 43xx driver loaded [ Features: PNL ]

Remove any soft/hard kill flags
sudo rfkill unblock all
I have tried ALL the following:

Loading the Broadcom STA driver (from icon, on top bar)
This (of course) crashed before completing install. However, once it attempts to install, the driver problem is resolved.
Manually running 'Additional Drivers', to load STA driver
So far, always crashes, stalls, or fail to load ..
Manaually running 'Additional Drivers, from command line
jockey-gtk
So far, either stalls or eventually loads ..

Will keep you updated ..

Feb-27:
No useful update.
I have used these steps 5-6 times successfully, but not fully repeatable ..


C++ perfect shuffle logical error, I cant seem to fix it?

Question: The code is supposed to  performs perfect shuffle on an array of integers.A perfect
shuffle is a sequence obtained by interleaving its first half with the second half, always
moving the middle card to the front. For example, the perfect shuffle of
{1,2,3,4,5,6,7,8,9,10} is {6,1,7,2,8,3,9,4,10,5}.The problem withh my code is that it doesnt display the desired output instead it shows sum random numbers.Thank you in advance
Here is the code:
<code>#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    int userArray[25], a[20], b[20];
    int i, sizeofarray, half, j, m;

    A: cout << "Enter SIZE of even numbers: ";
    cin >> sizeofarray;
    if (sizeofarray % 2 != 0)
    {
        cout << "Wrong Input!!,you should enter an even size (2,4,...)";
        system("PAUSE");
        system("CLS");
        goto A;
    }
    cout << "Enter  numbers:  \n";
    for (i = 0; i < sizeofarray; i++)
    {
        cin >> userArray[i];
    }

    // for(i=0;i<sizeofarray;i++)
    //{

    half = sizeofarray / 2;
    cout << "The perfect shuffle is: \n";
    for (j = 0; j <= half; j++)
    {
        a[j] = userArray[j];
        cout << a[j];
    }
    for (m = half; m <= sizeofarray; m++)
    {
        b[m] = userArray[m];
        cout << b[m];
    }

//}

    return 0;
}
</code>
Comment: `m<=sizeofarray` is wrong. And you print `userArray[half]` twice. And you probably want to print some spaces between numbers, to make it clear which number is which.
Comment: I used to arrays to get the first half and second half
Comment: You should not output a and b separately to shuffle the way you show.
Comment: ok will try ,thank you.But why is m<=sizeofarray wrong
Comment: Array indices are 0 .. size -1 so a for loop condition for that will be < size because array[size] is one past the end of the array.
Comment: @NaodTadele You read into your array `sizeofarray` numbers, which means you can only read indices from `0` to `sizeofarray - 1` and the rest of array values is unititiazlized (i.e. random numbers). And better make sure user never enters `sizeofarray` bigger than `25`.
Comment: your right, thanks
Comment: that makes sense
Comment: Re: "always moving the middle card to the front" -- FWIW, that's an **in shuffle**, because the top card goes into the deck. When the top card stays on top it's an **out shuffle**. Both are perfect shuffles. If I remember correctly, 8 perfect out shuffles will restore a 52-card deck to its original order, but it takes 52 in shuffles to do the same.
Answer: For debugging reasons, you should separe the process of writing a user input and writing the algorithm itself. Because testing with testcases written in the code can save you a lot of time.
I would write the shuffle algorithm like this : (edit)
<code>  for(int i = 0; i < half; i++) {
    shuffledArray[i*2+1] = arr[i];
    shuffledArray[i*2] = arr[i+half];
  }
</code>
This example assumes that your output (shuffled) array is called shuffleArray, the input array called arr, and that you have an integer variable called size.
It will work only with binary shuffle. If you want to shuffle by 3 or 4, it may be a bit different.
Comment: really ,i cant seem to find the problem
Comment: Yes indexes were reversed. It's ok now.
Comment: Did you understand how ?
since i will iterate from 0 to 4, i*2 will be 0,2,4,6,8
And i*2+1 will be 1,3,5,7,9
We have our indexes like that. Just need to pick the right value for each then.


How do I determine if an application is built by Electron or not?

Question: How do I determine if an application is built by Electron or not?
Could I always find specific file or binary on Electron apps?
Please give me some advice, thanks.
Comment: You can try to import some specific electron compoenent like `import { ipcRenderer } from 'electron'`
Answer: There are a few "non-futureproof" ways to check if an app was built on Electron and they vary depending of the OS.
You will need to go in your application folder (for example Applications for macOS, Program Files for Windows or /usr/share for Linux...
Here are some examples of the files/directory you may find in your application folder:
 Linux / Win32
These two OS have basically the same structure, so it's pretty easy to check what you want

locales/
resources/
blink_image_resources_200_percent.pak
chrome_100_percent.pak
chrome_200_percent.pak
content_resources_200_percent.pak
content_shell.pak
icudtl.dat
vkswiftshader.dll
vkswiftshader_icd.json

There are also some files like

libffmpeg.so / ffmpeg.dll
libnode.so / node.dll

depending of the OS you're on.
 macOS
It's a bit more complicated here. You might need to check the Info.plist file to see if there is any reference to Electron.
As unseen_damage said, you can also check in [app folder]/Contents/Resources if there is an app.asar as .asar files are specifically created for Electron.

Anyway, all those files may see their names changes someday, so don't consider them as a reliable way to check if "any" app is built on Electron, it's more of a manual way to check it.
Comment: For MacOS:
1. Right click .app file
2. Click "Show Package Contents"
3. Navigate into Contents
4. Navigate into Frameworks
5. Check if there's a Electron Framework.framework file
Resource: https://cameronnokes.com/blog/how-to-know-if-a-desktop-app-uses-electron/
Answer: MacOs
To find all Electron apps by finding the .asar file on your mac, use this.

open Terminal
run this command
find /Applications -name '*.asar' -print
Comment: Complementary to my comment below: `find /Applications -type f -name "*Electron Framework*"` gives me the same list of Applications, so good as a double check!
Answer: MAC:
open a terminal type cd /Applications, then, change directory (cd) into the name of the application you want to check. For example, if it is iTunes, you would do the following /Applications/iTunes.app/Contents/Resources. If you see an app.asar file, or something similar with the .asar suffix, it is most likely an Electron App.
Windows:
Open up the program files directory of the application you are wondering about, and check the file folder for any file with .asar suffix. This can be done via the search, terminal, etc.
Bottom line- Electron apps, when packaged, are bundled into an asar file, and you can search for this file extension to see if the program was built with electron.
Documentation- http://electron.atom.io/docs/tutorial/application-packaging/
Answer: macOS
You can also run the following terminal command:
find /Applications -name "*Electron Framework*" | cut -d/ -f3 | sort -u | cut -d. -f1

This will output an alphabetized and cleaned up list of just the application names.
Source: https://talk.macpowerusers.com/t/why-the-dislike-of-electron-apps/20697/20
Comment: Gives me the same list of Applications as `find /Applications -name '*.asar' -print`, so good as a double check!


how to interpret postgres timezon

Question: I am working on resolving a timezone issue and just want to understand how to interpret the timezone if I have got it right

2018-01-04 22:31:23.1+00

date time.1+00 ..any simple explanation on how can I know which time zone is this ?
Comment: +00 is GMT / Zulu etc. i.e. no offset.
Comment: what does .1 refer to?
Comment: fractional seconds.
Answer: 2018-01-04 22:31:23.1+00

Year:   2018
Month:  01     (January)
Day:    04

Hour:   22     (10pm)
Minute: 31
Second: 23.1   (.1 is one-tenth of a second)

Offset: +00    (hours East of GMT)

Note, you cannot determine which time zone this is in - only the offset from UTC/GMT applicable at that timestamp.
Since multiple time zones can use UTC+00, you don't know which of those time zones it is in.  It might just be in UTC, but it might be in Atlantic/Reykjavik, or Africa/Casablanca.  One uses UTC year round, the other switches between UTC and UTC+1.  There are others as well.
Comment: Note that PostgreSQL doesn't store a timestamp with timezone WITH the timezone. It converts it to UTC THEN stores it. So once you've stored it, the TZ offset is lost. It then applies a new offset based on what the client timezone is.
Comment: very clean. Thanks!
Comment: so how would I know this information - Atlantic/Reykjavik, or Africa/Casablanca from above timezone
Comment: You can't.  A time zone and an offset are two different things.

how to interpret postgres timezon


Where can I find GRUB bootloader script before the system started up?

Question: Where can I find GRUB bootloader script before the system is started up? I'm running on VBox V4.3.12 r93733.
Comment: What do you mean "bootloader script"? The actual code? The config data? Where the bootloader is on the hard drive?
Comment: When we first started up the machine, it will prompt us to choose 'Ubuntu' or 'Advanced options for Ubuntu' or 'Memory test' and so on from GNU GRUB. I'd like to know where is this GRUB script file actually stored onto before it's started up?
Comment: So the config file that gives the boot menu options?
Comment: You may say so.
Answer: If I understood you right, you want the location of the bootloader config file that you can manually edit.
There are a few different locations where these files are stored.

Main config: /etc/default/grub <-- This is the one you really want to edit. OK to play.
Grub config files: /etc/grub.d <-- Custom boot entries. Semi-OK to play.
Various other things: /boot <-- Don't play with things in this dir.

The file that is ACTUALLY read by GRUB2 is stored somewhere on the "boot" partition (EFI, boo!) and/or the empty sectors at the beginning of the hard drive (Legacy, yay!). [I think]
Comment: If I understand it correctly, these files in /etc/default/,/etc/grub.d, /boot will only be readable once /boot and / have been mounted which is after vmlinuz kernel and initrd have been successfully loaded. My doubt is that even before /boot and / are mounted where is this GNU GRUB script file residing, where we can see GNU GRUB menu to choose 'Ubuntu' or 'Advanced options for Ubuntu' or 'Memory test' and so on from GNU GRUB menu?
Comment: @navorser Bottom part of answer
Comment: @navorser The original Grub, now called 'Grub Legacy' had a menu file that was easy to edit. Ubuntu uses the current incarnation of Grub, Grub2. It spreads the pieces out and is significantly more complex. It does not have a single menu file.
Comment: When I checked the script of GNU GRUB Menu before executing any bootup menu, I found that it's the same script as its /boot/grub/grub.cfg
Comment: Thanks to Mew and ben. I am wondering where does this script from the quote come from since partition of the storage on the machine haven't been mounted yet?"setparams 'Ubuntu'

 recordfail
 load_video
 gfxmode $linux_gfx_mode
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='hd0,msdos1'
 if [X$feature_platform_search_hint = xy ]; then
   search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1\
 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  7b31bb31-630f-42bb\
-b091-00503d5e2deb
 else
   search --no-floppy --fs-uuid --set=root 7b31bb31-630f-42bb-b09\
1-00503d5e2deb
 fi"
Comment: @navorser Like I said, I think it is stored in the MBR or the EFI-Boot partition on the hard drive.
Answer: ---Grub 2 Files & Options
  Grub 2 is modular and these files are loaded as necessary by the grub bootloader.

  The Grub 2 user-configurable settings are contained mainly in /etc/default/grub and the files in /etc/grub.d. When update-grub is executed the results are input into the /boot/grub/grub.cfg file.

      x /boot/grub/grub.cfg

            - This is the main Grub 2 file. This file contains the Grub menu information but unlike Grub Legacy's menu.lst file, grub.cfg is not meant to be edited.

                  + grub.cfg is automatcially generated when "update-grub" is executed:

                  + Each section (### BEGIN) is clearly delineated and references the file in the /etc/grub.d folder from which the information was generated.

                  + grub.cfg is updated by running the "update-grub2" or "update-grub" command as root.

                  + By default, and whenever the "update-grub2" command is executed, this file is made "read-only". This is in keeping with the intent that the file should not be edited manually. If you must edit this file, instructions are provided in Section 2.

            - Sample grub.cfg including Windows and one manual entry (41_srcd):

              Code:

              #
              # DO NOT EDIT THIS FILE
              #
              # It is automatically generated by /usr/sbin/grub-mkconfig using templates
              # from /etc/grub.d and settings from /etc/default/grub
              #

              ### BEGIN /etc/grub.d/00_header ###
              load_env
              set default="0"
              if [ ${prev_saved_entry} ]; then
                saved_entry=${prev_saved_entry}
                save_env saved_entry
                prev_saved_entry=
                save_env prev_saved_entry
              fi
              insmod ext2
              set root=(hd0,1)
              search --no-floppy --fs-uuid --set 7ebcfe33-6914-42ec-9d2e-0859f7396925
              if loadfont /usr/share/grub/unicode.pf2 ; then
                set gfxmode=640x480
                insmod gfxterm
                insmod vbe
                if terminal_output gfxterm ; then true ; else
                  # For backward compatibility with versions of terminal.mod that don't
                  # understand terminal_output
                  terminal gfxterm
                fi
              fi
              if [ ${recordfail} = 1 ]; then
                set timeout=-1
              else
                set timeout=10
              fi
              ### END /etc/grub.d/00_header ###

              ### BEGIN /etc/grub.d/10_linux ###
              menuentry "Ubuntu, Linux 2.6.31-12-generic" {
                      recordfail=1
                      save_env recordfail
                  set quiet=1
                  insmod ext2
                  set root=(hd0,1)
                  search --no-floppy --fs-uuid --set 7ebcfe33-6914-42ec-9d2e-0859f7396933
                  linux    /boot/vmlinuz-2.6.31-12-generic root=UUID=7ebcfe33-6914-42ec-9d2e-0859f7396933 ro   quiet splash
                  initrd    /boot/initrd.img-2.6.31-12-generic
              }
              menuentry "Ubuntu, Linux 2.6.31-12-generic (recovery mode)" {
                      recordfail=1
                      save_env recordfail
                  insmod ext2
                  set root=(hd0,1)
                  search --no-floppy --fs-uuid --set 7ebcfe33-6914-42ec-9d2e-0859f7396933
                  linux    /boot/vmlinuz-2.6.31-12-generic root=UUID=7ebcfe33-6914-42ec-9d2e-0859f7396933 ro single
                  initrd    /boot/initrd.img-2.6.31-12-generic
              }
              menuentry "Ubuntu, Linux 2.6.31-11-generic" {
                      recordfail=1
                      save_env recordfail
                  set quiet=1
                  insmod ext2
                  set root=(hd0,1)
                  search --no-floppy --fs-uuid --set 7ebcfe33-6914-42ec-9d2e-0859f7396933
                  linux    /boot/vmlinuz-2.6.31-11-generic root=UUID=7ebcfe33-6914-42ec-9d2e-0859f7396933 ro   quiet splash
                  initrd    /boot/initrd.img-2.6.31-11-generic
              }
              menuentry "Ubuntu, Linux 2.6.31-11-generic (recovery mode)" {
                      recordfail=1
                      save_env recordfail
                  insmod ext2
                  set root=(hd0,1)
                  search --no-floppy --fs-uuid --set 7ebcfe33-6914-42ec-9d2e-0859f7396933
                  linux    /boot/vmlinuz-2.6.31-11-generic root=UUID=7ebcfe33-6914-42ec-9d2e-0859f7396933 ro single
                  initrd    /boot/initrd.img-2.6.31-11-generic
              }
              ### END /etc/grub.d/10_linux ###

              ### END /etc/grub.d/20_memtest86+ ###

              ### BEGIN /etc/grub.d/30_os-prober ###
              menuentry "Microsoft Windows XP Home Edition (on /dev/sda1)" {
                  set root=(hd0,1)
                  chainloader +1
              }
              ### END /etc/grub.d/30_os-prober ###

              ### BEGIN /etc/grub.d/40_custom ###
              menuentry "Jaunty 2.6.28-15-custom" {
                  saved_entry=${chosen}
                  save_env saved_entry
                  set root=(hd0,8)
                  linux    /boot/vmlinuz-2.6.28-15-custom root=UUID=48e03255-22b3-488b-ae7e-9dbe4e2beac7 ro  quiet splash
                  initrd    /boot/initrd.img-2.6.28-15-custom
              }
              menuentry "SystemRescue" {
                  saved_entry=${chosen}
                  save_env saved_entry
                      set root=(hd0,6)
                      linux   /sysrcd/rescuecd subdir=sysrcd setkmap=us
                      initrd  /sysrcd/initram.igz
              }
              ### END /etc/grub.d/40_custom ###

      x /etc/default/grub

            - This file contains information formerly contained in the upper section of Grub Legacy's menu.lst and items contained on the end of the kernel line. The items in this file can be edited by a user with administrator (root) privileges.

              Quote:
              # If you change this file, run 'update-grub' afterwards to update
              # /boot/grub/grub.cfg.

              GRUB_DEFAULT=0
              #GRUB_HIDDEN_TIMEOUT=0
              GRUB_HIDDEN_TIMEOUT_QUIET=true
              GRUB_TIMEOUT="3"
              GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
              GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
              GRUB_CMDLINE_LINUX=""

              # Uncomment to disable graphical terminal (grub-pc only)
              #GRUB_TERMINAL=console

              # The resolution used on graphical terminal
              # note that you can use only modes which your graphic card supports via VBE
              # you can see them in real GRUB with the command `vbeinfo'
              #GRUB_GFXMODE=640x480

              # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
              #GRUB_DISABLE_LINUX_UUID=true

              # Uncomment to disable generation of recovery mode menu entrys

            - A few bugs still exist in the hidden menu feature. Hiding the menu, even with the correct "TIMEOUT" settings in /etc/default/grub may not work as described.

            - GRUB_DEFAULT - Sets the default menu entry. Entries may be numeric or "saved"

                  + GRUB_DEFAULT=0 - Sets the default menu entry by menu position. As Grub Legacy, the first "menuentry" in grub.cfg is 0, the second is 1, etc.

                  + GRUB_DEFAULT=saved - Sets the default menu entry with whatever was selected last. If the menu is displayed during boot, the last entry selected will be highlighted. If no action is taken, this selection will be booted at the end of the timeout or if the menu is hidden.

                        # grub-set-default is enabled when this value is set to saved. You can quickly change the default OS/kernel with this command.

                              * The format is "sudo grub-set-default X, with X being the menuentry position (starting with 0 as the first entry) or the exact menu string. Examples: sudo grub-set-default 3 or sudo grub-set-default "Ubuntu, Linux 2.6.31-14-generic"

                              * To obtain the existing menuentry choice number (starting from 0) or the menuentry "string", run "grep menuentry /boot/grub/grub.cfg"

                  + GRUB_DEFAULT="xxxx" - An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter. Example: GRUB_DEFAULT="Ubuntu, Linux 2.6.31-9-generic"

                  + For an example of how to enable the "saved" option with a custom menu, see the "Custom User Entries" section.

            - GRUB_TIMEOUT=5 - No change from Grub Legacy. This is the number of seconds before the default entry is automatically booted.

                  + Setting this value to -1 will cause the menu to display until the user makes a selection.

                  + To display the menu on each boot use a value of 1 or higher.

                  + This command defers to the GRUB_HIDDEN_TIMEOUT command. If the hidden display is interrupted by a key press, the GRUB_TIMEOUT counter begins its countdown.

                  + In addition to editing the file as root, you can also run the following commands the check and change the default timeout value. The first checks the existing timeout, the second replaces the value. Replace T with the new value.

                  Code:

                    cat /etc/default/grub | grep 'GRUB_TIMEOUT='   # Checks current TIMEOUT value.
                    sudo sed 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=T/g' -i /etc/default/grub  # Change TIMEOUT value. Replace T with new value.

            - GRUB_HIDDEN_TIMEOUT=0

                  + The menu will be hidden unless a # symbol is present at the beginning of this line. ( # GRUB_HIDDEN_TIMEOUT=0 )

                  + The setting may depend on the presence of other operating systems.

                        # Another OS Detected: The menu will be displayed. ( The line will begin with a # symbol. )

                        According to some of the GRUB 2 developers, in Ubuntu the menu will not be hidden any time there are other OSs found by os-prober, regardless of this setting. This is in keeping with the Ubuntu Team's goal towards booting: https://wiki.ubuntu.com/DesktopExper...pec#Bootloader

                        # No other OS Detected: The menu will be hidden.

                  + For integers greater than 0, the system will pause, but not display the menu, for the entered number of seconds.

                  + 0 The menu will not be displayed. There will be no delay. When this entry is set to 0:

                        # The user may force displaying the menu as the computer boots by holding down the SHIFT key.

                        # During boot, the system will check the SHIFT key status. If it cannot determine the key status, a short delay will enable the user to display the menu by pressing the ESC key.

                  + If enabled, the splash screen designated in 05_debian_theme will be displayed. This setting hides the menu only.

            - GRUB_HIDDEN_TIMEOUT_QUIET=true

                  + true - No countdown is displayed. The screen will be blank.

                  + false - A counter will display on a blank screen for the duration of the GRUB_HIDDEN_TIMEOUT value.

            - GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
                  + Determines the descriptive name in the menu entry. (Ubuntu, Xubuntu, Debian, etc.)

            - GRUB_CMDLINE_LINUX

              If it exists, this line imports any entries to the end of the 'linux' command line (Grub Legacy's "kernel" line) for both normal and recovery modes. This is similar to the "altoptions" line in menu.lst

            - GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
              This line imports any entries to the end of the 'linux' line (Grub Legacy's "kernel" line). The entries are appended to the end of the normal mode only. This is similar to the "defoptions" line in menu.lst. For a black screen with boot processes displayed in text, remove "quiet splash". To see the grub splash image plus a condensed text output, use "splash". This line is where other instructions, such as "acpi=off" are placed.

            - #GRUB_TERMINAL=console

              Uncomment to disable graphical terminal (grub-pc only). This can be useful if the user plans on spending a lot of time in the GRUB 2 command line mode. Scrolling and screen responsiveness will be greatly speeded up.

            - #GRUB_DISABLE_LINUX_UUID=true

              Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

            - #GRUB_GFXMODE=640x480

              You can add this line and remove the # symbol to make it active. This entry sets the resolution of the graphical menu (the menu text size). It provides resolutions supported by the user's graphics card (e.g. 640x480, 800x600, 1280x1024, etc). The setting applies only to the boot menu text.

            - From the GRUB 2 menu you can display available resolutions by typing "c" and then at the "grub>" prompt type "vbeinfo"

            - GRUB_DISABLE_LINUX_RECOVERY=true

              Add or uncomment this line to prevent "Recovery" mode kernel options from appearing in the menu. If you want a "Recovery" option for only one kernel, make a special entry in /etc/grub/40_custom.

            - GRUB_DISABLE_OS_PROBER="true" - Enables/disables the os-prober check of other partitions for operating systems, including Windows, Linux, OSX and Hurd.

      x /etc/grub.d/

            - The files in this folder are read during execution of "update-grub" or "update-grub2" commands. The contents are imported into /boot/grub/grub.cfg

              The order of the entries in the grub menu is based on the order of the file names. File named with a starting numeral are run before those beginning with a letter. The order the files are run determines the menu order in grub.cfg.
              Custom entries can be added to the "40_custom" file or in a newly created file.

              Any file created must be executable in order to be included in the grub.cfg file during the "update-grub2" command.
                  + 00_header
                  + 05_debian_theme: Set background and text colors, themes
                  + 10_hurd Locates Hurd kernels
                  + 10_linux Locates Linux kernels based on results of the "lsb_release" command.
                  + 20_memtest86+: If the file /boot/memtest86+.bin exists, it is included as a menu item.
                  + 30_os-prober: Searches for Linux and OS's on other partitions and includes them in the menu.
                  + 40_custom: A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the "update-grub2" command. This and any other custom file must be made executable to allow importation into grub.cfg.

---Adding Entries to Grub 2
  Menu entries can be added to grub.cfg automatically or manually.

      x Automatically.

            - When "update-grub" or "update-grub2" is executed, Grub 2 will search for linux kernels and other Operating Systems. What and where is looks is based on the files contained in /etc/grub.d folder.
                  + 10_linux searches for installed linux kernels on the same partition.
                  + 30_os-prober searches for other operating systems.

      x Custom User Entries (/etc/grub.d/40_custom).

            - Entries to grub.cfg can be manually inserted by creating a file in the /etc/grub.d folder.
                  + The name of the file determines the order in the menu. 30_os-prober entries will be placed before 40_custom entries, which will be placed before 50_my-sample entries.
                  + Any created file must be made executable. This can be done as root by running "sudo chmod +x /etc/grub.d/filename".
                  + The files in the /etc/grub.d folder will be read and the contents included in grub.cfg when the "update-grub2" command is executed as root.

            - A sample entry. This file creates a menu item for running the SystemRescueCD (previously installed) from a partition created on sda10. Folders and files must have been copied to the correct location in accordance with the SystemRescueCD if you wish to actually use this entry.
                  +

                    #!/bin/sh
                    exec tail -n +3 $0
                    # This file provides an easy way to add custom menu entries. Simply type the
                    # menu entries you want to add after this comment. Be careful not to change
                    # the 'exec tail' line above.

                    echo "Adding SystemRescueCD" >&2
                    menuentry "System Rescue CD" {
                    set root=(hd0,10)
                    linux /sysrcd/rescuecd subdir=sysrcd setkmap=us
                    initrd /sysrcd/initram.igz
                    }

                  + Note the new partition naming convention. Devices start counting from "0" as done previously. sda is designated as "hd0", sdb is "hd1", etc. However the first partition is now designated as sda1. Counting partitions does not start with "0". sda5 is "5".
                  + The line 'echo "Adding SystemRescueCD" >&2' is not required. Including it in the file allows this line to be seen in the terminal when "update-grub2" is executed. It provides visual feedback that the entry has been found and entered. The entry, if in the correct format, will be inserted in grug.cfg whether or not this line is included in the file.

            - Tip: If you want to have your custom entries at the top of the menu (say you want custom titles), create a new file and name it "07_xxxx". Since the files in /etc/grub.d/ are read sequentially, those in "07_custom" will be placed before those of "10_linux". I recommend not naming a custom menu file lower than 06 so that any theme run from 05_debian_theme is allowed to run before any custom menu is created. After creating the file, run sudo update-grub and then check the value of "DEFAULT" in /etc/default/grub. If it doesn't point to the correct menuentry, change the value of DEFAULT to the correct menuentry value.

            - Omitting memtest86+: To prevent "memtest86+" entries in your Grub 2 menu, remove the "executable" bit from /etc/grub.d/20_memtest86+. You can do this via a file browser by selecting "Properties (right click), Permissions", or via the command line:

              sudo chmod -x /etc/grub.d/20_memtest86+

            - Omitting Recovery Mode entries: The file /etc/grub.d/10_linux was recently updated to include a check for recovery mode options. Edit /etc/default/grub and add or change this line:

              GRUB_DISABLE_LINUX_RECOVERY=true
              If you have an older version of /etc/grub.d/10_linux and the above does not work after updating grub, you can prevent "Recovery mode" entries in your Grub 2 menu, by editing /etc/grub.d/10_linux. If there are no conditional "if" statements concerning the recovery mode, place a comment symbol (#) in front of the following lines (at approximately line 146) of the old file:

              # linux_entry "${OS}, Linux ${version} (recovery mode)" \
              # "single ${GRUB_CMDLINE_LINUX}"
              If you wish to retain one "Recovery mode" entry for insurance, you can add an entry to /etc/grub.d/40_custom which will appear at the bottom of your grub menu.

            - Building a Totally Customized Menu: Ok, admit you are a control freak and you want to see only what you build yourself - customized titles, no "memtest86+" and no extra kernels. Here is how you do it:
                  + Run sudo update-grub to get the current available kernels.
                  + Copy the desired "menuentry" listings from /boot/grub/grub.cfg to /etc/grub.d/40_custom The entry begins with the line starting with "menuentry" and ends with a line containing "}".
                  + Add any other "menuentry" items you wish to see on the boot menu.
                  + Edit the titles of the "menuentry" line if desired (between the quotation symbols). Do not change the lines following the "menuentry" line. Each entry should start with a "menuentry" line and end with a "}" on the last line.
                  + Remove the executable bit from /etc/grub.d/10_linux, /etc/grub.d/20_memtest86+ and /etc/grub.d/30_os-prober
                    Removing the executable bit from any file in /etc/grub.d will exclude the file from being included in grub updates.

                    sudo chmod -x /etc/grub.d/10_linux /etc/grub.d/20_memtest86+ /etc/grub.d/30_os-prober

                  + Run "sudo update-grub"
                  + The updated /boot/grub/grub.cfg file should now contain only sections for "00_header", "05_debian_theme" and "40_custom".
                  + The grub.cfg file will not be updated with the addition of a new kernel. To add a new kernel, make "10_linux" executable, run "sudo update-grub" to refresh the available kernels, and repeat these instructions.

            - Incorporating the DEFAULT=save Option: In order to enable the "saved default" option with which Grub 2 preselects the last successfully-used option at boot, the "DEFAULT=save" option must be entered in /etc/default/grub and the 40_custom file must be modified. An example of a 40_custom file follows:
                  +

                    #! /bin/sh -e

                    prefix=/usr
                    exec_prefix=${prefix}
                    libdir=${exec_prefix}/lib
                    . ${libdir}/grub/grub-mkconfig_lib
                    echo "Adding SystemRescueCD & Custom Kernel" >&2

                    menuentry "Jaunty 2.6.28-15-custom" {
                    save_default_entry | sed -e "s/^/\t/"
                    set root=(hd0,7)
                    linux /boot/vmlinuz-2.6.28-15-custom root=UUID=12c55255-27b3-488b-hje7e-9dbe4e2esfg5 ro quiet splash
                    initrd /boot/initrd.img-2.6.28-15-custom
                    }

                    menuentry "SystemRescue" {
                    save_default_entry | sed -e "s/^/\t/"
                    set root=(hd0,6)
                    linux /sysrcd/rescuecd subdir=sysrcd setkmap=us
                    initrd /sysrcd/initram.igz
                    }
                  + Manual Windows Entry (with /etc/grub.d/30_os-prober made unexecutable)
                    Quote:
                    #! /bin/sh -e

                    echo "Adding Windows 43_custom" >&2
                    menuentry "Windows Vista 43_custom" {
                    insmod ntfs
                    set root=(hd0,1)
                    search --no-floppy --fs-uuid --set CFFCFF9EECFF7F49
                    chainloader +1
                    }

      - Don't forget to run "sudo update-grub" after making any changes to your /etc/grub.d files.

      x Manual Editing of grub.cfg (Not encouraged)
        Manual editing of /boot/grub/grub.cfg is not encouraged. Think of grub.cfg as a result, not as an initiator. The files that should be edited are contained in the /etc/grub.d folders and the /etc/default/grub file.

        In order to discourage its editing, grub.cfg is read-only. Even attempting to open, edit and save this file using root privileges cannot be done until the 'read-only' status is changed. If you must edit this file:

        sudo chmod +w /boot/grub/grub.cfg
        gksudo gedit /boot/grub/grub.cfg

        Note: This file is returned to 'read-only' status anytime the update-grub command is run.

---Removing Entries from Grub 2
  Entries should be removed by editing or removing files in the /etc/grub.d folder. The /boot/grub/grub.cfg file is read-only and should not normally require editing.

      x Automatically.

            - Too Many Kernels? Kernels removed via Synaptic or with "apt-get remove" will automatically update grub.cfg and no user action is required.
                  + In Synaptic, type the kernel number in the search window at the upper right (for example - 2.6.28-11).
                  + Find the "linux-image" and "linux-headers" files for the applicable kernel (example - linux-image-2.6.26-11 or "linux-image-2.6.26-11-generic).
                  + Right click and select "Mark for Complete Removal" and then press the Apply main menu button.
                  + The kernels will be removed from your system and from the Grub menu.
                  + If you are not sure of the kernel you are currently using, in a terminal type "uname -r".
                  + Many users keep one previous kernel on the machine which previously ran without problems.

            - Other Operating Systems which have been removed from the computer will also be removed from the menu once "update-grub2" is run as root.

            - To prevent one of the /etc/init.d files from running, remove the "executable" bit.
                  + Example: If you don't want to see the "Memtest86+" entries, run this command:

                    sudo chmod -x /etc/grub.d/20_memtest86+

                  + Run the update-grub command to allow the changes to be incorporated in grub.cfg

        User-Created Entries.

            - To remove a user-created menu entry, remove the applicable file from the /etc/grub.d folder.

            - If a custom file contains multiple entries, individual items may be removed and others retained.

            - Once the file has been removed or edited, run "update-grub2" to update grub.cfg.

Comment: This is very big help and cleared answer. Really appreciate it.
Comment: No. It is a personal collection.
It seems difficult to conform to all. I recommend expanding this answer to say something about how to do that –  Eliah Kagan - Terribly hard to read. –  guntbert


dynamically loaded element different than static element although they have the same HTMl

Question: i am working in ASP.NET MVC 3 and constructing my html page from model as follows:
foreach (var item in Model.OfficialHolidaysViewModel.OfficialHolidaysForCurrentYear)
{

      @item.ShortDateString

}

which will render and html element, for example:

        5/28/2013

and this looks like:

however, when i insert a new element with jquery:
$('#OfficialHolidaysCurrentYear').append(
       '
' +
            '' + toRomanianLiteralFormat(dateString) + '' +
            '' +
       '
')

this get parameterized correctly and the result is the html:

           02/Mar/2013

and this will look like in the browser:

I do not understand why they look different(notice the gap between the date text and the x icon in the first image), according to my style sheet the second one is correct....but why doesnt the first one look the same if they have the same html and css???
Btw, here is my stylesheet(.date-text has no stlyes applied):
.date-label
{
    -moz-border-radius: 3px;
    border-radius: 3px;
    border: 1px solid #aaa;
    border-color: rgba(0, 0, 0, 0.3);
    background: #fff;
    color: rgba(0, 0, 0, 0.8);
    font-size: 16px;
    font-weight: normal;
    display: inline-block;
    line-height: 1.3;
    padding: 1px 0px 1px 0px;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin:0px 5px 0px 0px;
    box-shadow: 1px 1px 1px #555555;
    -moz-box-shadow: 1px 1px 1px #555555;
}

.date-close-icon
{
    height:11px;
    width:11px;
    cursor:pointer;
}

UPDATE :
This was a problem of HTML Carriage Return, see link in Aleksandr M's answer for more details!
Answer: If you want it without the gap just write you code without the carriage return inside li like that
foreach (var item in Model.OfficialHolidaysViewModel.OfficialHolidaysForCurrentYear)
{

      @item.ShortDateString

}

See this link: http://www.netmechanic.com/news/vol1/html_no3.htm

In theory HTML doesn't pay attention to white space within your source document. In practice, your browser will interpret a carriage return as a single character of white space.
Comment: wow, it worked, but why?? Is it the browser or is Razor adding additional information somewhere?
Answer: Your issue seems to be caused by the line break (which insert a space in the rendered html document). If you don't need that space b/w those two element then you can float both those element to left, it will ignore the space.


Will several Soundcloud players on same page slow down my website?

Question: I'd like to swap out my current HTML5 audio player for the Soundcloud html5 widget player. My concern is that I have 11 posts per page on my Wordpress (org) music site, so that would be 11 different Soundcloud iframes per page. Will this slow my site down considerably?
Is there another way to embed the Soundcloud player besides iframe that would perform better?
Answer: Iframes will block onload and will slow down your page load.
See this article for a breakdown of loading iframes, and asynchronous solutions
Alternatively you could load the iframe on demand, have a placeholder image that when clicked on uses javascript to load the soundcloud player.
Here is a breakdown of this process applied to Youtube players
Lastly you could use the SoundCloud api/library to create a lightweight player to embed in your posts.
Comment: Thanks for the info. I like the loading on demand idea, unfortunately this is out of my league so I'll try and find someone to do it.
Answer: Kind of late but here's a way to do it without slowing down the page:
Requirements: jQuery and FitVids.js (this makes the iframe responsive without dealing with the css)
jQuery:
$(window).load(function() {

$(".soundcloud-wrapper").each(function() {
        var URL = $(this).attr('id');
        var htm = '';
        $(this).html(htm).fitVids().removeClass('.loading');
  });

});

HTML:

CSS
.soundcloud-wrapper iframe {
    /* --- your styles if applicable --- */
}

.soundcloud-wrapper.loading {
    width:100%;
    height:200px;
}

Note: The .loading is a class that's removed when the iframe loads. I'm using it so that a height is there for Masonry layouts otherwise the space is collapsed. It is useful so that the page doesn't jump around even if you're not using Masonry, you'd change the value in both the CSS and the jQuery to reflect your iframe size.
Comment: Thanks Christina, I'll keep that method in mind if I decide to use it. I'm currently just lazy loading the Soundcloud players using jQuery Lazy Load XT and it works good. I have 10 players total on each page and only the first two on the screen load until you scroll down.


Webkit context-menu

Question: I have a little program with a webkit window inside (realy cutted code attached), I would disable the context-menu, but I don't know how..
I found this 'enable-default-context-menu': http://webkitgtk.org/reference/webkitgtk-WebKitWebSettings.html, but I can't make it work..
Can you help me?
TNK

<code>
#!/usr/bin/env python

import gtk
import webkit
from webkit import WebView

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy", gtk.main_quit)

browser = webkit.WebView()
browser.open("http://www.stackoverflow.com")
scroller = gtk.ScrolledWindow()
scroller.add(browser)
window.add(scroller)

settings = browser.get_settings()
settings.set_property('enable-default-context-menu', False)

window.show_all()
gtk.main()
</code>
Comment: For me the `settings.set_property('enable_default_context_menu', False)` was worked
Answer: Going by the seat of my pants here, but try:
<code>#!/usr/bin/env python
import gtk
import webkit

browser = webkit.WebView()
settings = browser.get_settings()
settings.set_property('enable-default-context-menu', False)
browser.set_settings(settings)    # Push the changed settings back!

scroller = gtk.ScrolledWindow()
scroller.add(browser)

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy", gtk.main_quit)
window.add(scroller)

browser.open("http://www.stackoverflow.com")
window.show_all()
gtk.main()
</code>
Comment: It doesn't seem to work.. seems that set_property doesn't "know" enable-default-context-menu..   Have someone another idea?
Answer: I tried your code and it works fine for me... using pywebkit 1.1.7  (Linux Ubuntu)
What version of pywebkit do you have?
p.s. you should have edited your previous post instead of creating a new one.
Comment: Thanks Dave. It's interesting... I use, too, pywebkit 1.1.7 on Windows.. However if you say that work for you I'll try on another configuration, os. TNK

Webkit context-menu


warning: useless type name in empty declaration

Question: I have a project and two files in the project are named as query-structures.h query-structures.c. Contents in the query-structures.h are
#include <stdint.h>
typedef struct user_identifier user_identifier;
extern user_identifier;

and in query-structures.c are
#include "query-structures.h"
struct user_identifier
{
    uint64_t user_id;
};

Now the Compiler is giving me a warning as
warning: useless type name in empty declaration [enabled by default]
I cannot understand why this warning is there because I have to use this struct in other files of my project.
Answer: This line is abnormal because you declare a type but no variable name
extern user_identifier;

For example, with ints, you would write
extern int x;

not
  extern int;


Convert JSON string to plain key value pair for logging

Question: I have a JSON string, where consist of structure something like below, basically I have a chain of VO's and each VO will have list of VO's and Map of VO's as well.
sample:
"MessageHeader": {
    "type": "new",
    "id": 10,
    "add_record": "true",
},
"MessageBody": {
    "dob_required": false,
    "dept_name": "Purchase",
    "group": {
        "main_group": "main group",
        "sub_group": "sub group"
    },
    "family_info": {
        "person1": {
            "name": "HisName",
            "gender": "male",
            "age": "31",
            "office_info_present": {
                "office_name": "present office",
                "office_address": "some address"
                "some_other_vo":{

                },
            },
            "office_info_previous": {
                "office_name": "old office",
                "office_address": "some address"
            },
        },
        "person2": {
            "name": "HerName",
            "gender": "Female",
            "age": "25",
        }
    },
    "active":true
}

I want to print each and every attribute name and its value in key value pair. I don't want to print the VO name, rather just the end attributes (leaf level attributes)
like below string:
type=new id=10 add_record=true dob_required=false dept_name=purchase main_group="main group" sub_group="sub group" name=HisName gender=male age=31 .... name=HerName gender=Female age=25
How this can be done? I would prefer if it can be done using jackson. Otherwise also fine.
Comment: do you want to parse it ?
Comment: You can try with JSON to Plain Key Value Parsing:

https://github.com/tangkhaiphuong/jsonkv
Answer: The easiest way is probably by using Jackson's Tree Model, traversing it. Something like:
JsonNode root = mapper.readValueAsTree(jsonInput);
Map<String,String> flat = new HashMap<String,String>();
traverse(root, flat);

public void traverse(JsonNode node, Map<String,String> result)
{
   Iterator<Map.Entry<String,JsonNode>> it = node.fields();
   while (it.hasNext()) {
     Map.Entry<String,JsonNode> entry = it.next();
     JsonNode n = entry.getValue();
     if (n.isObject()) { // if JSON object, traverse recursively
       traverse(n);
     } else { // if not, just add as String
       result.put(entry.getKey(), n.asText());
     }
   }
}

and you'll get a Map that you can print.
Answer: you can use this link for creating POGO class for your response. It will automatically generate class for your response.
Use  google GSON  library to parse your response.
Comment: I dont want to create a pogo, I just need to parse and print each and every attribute. Is it possible to parse using jackson?
Answer: Yes jackson can be used to parse. but its not straight forward.
There are few implementations similar to JAXB for XML. But I never tested them
Here is the rough code snippet.
JSONParser parser = new JSONParser();

    try {

        JSONObject jsonObject = (JSONObject) parser.parse(new FileReader("c:\\sample.json"));

        String name = (String) jsonObject.get("name");
        long age = (Long) jsonObject.get("age");
        JSONArray msg = (JSONArray) jsonObject.get("messages");
        System.out.println("Name:"+name);
        System.out.println("Age:"+age);
        System.out.println("Messages:");
        Iterator<String> iterator = msg.iterator();
        while (iterator.hasNext()) {
        System.out.println(iterator.next());
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }


C++ nested classes issue

Question: i'm having some problems with C++ and nested classes. For example:
in main.cpp
int main()
{

B b(par);
cout <parametro;
cout <parametro;
return 0;}

In B.cpp
B: B(type par)
{

A a(par1,par2);
Aglobal=&a;}

in B.h
class B
{
public:
    B(type);
    A *Aglobal;}

in A.h
class A
{

public:
    A(type1,type2);
    int parametro;}

The main.cpp echoes are different and i can't undestand the reason.
Comment: Egads! On the assumption that you are new to c-like languages, I'd like to suggest that you investigate the many dueling brace styles and pick a more common one. Please. Even GNU.
Answer: You define a local variable of type A in the constructor of B, and return a pointer to that local variable. Using that pointer results in undefined behavior, because the object it points to no longer exists.
Solutions to the problem might include:

allocate the A object on the heap. But then try to wrap it in an appropriate smart pointer rather than a simple pointer.
Have a member of type A in B and return the member's address
Have an object of type A with static storage duration, like the pointer itself.

The decision between these three depends heavily on the context of your problem which is not deducible from your question.
One more thing. Nested classes are those classes that are defined in scope of another class. There are no nested classes in your example.
Comment: So, could something like this in B.cpp resolve the problem?

A *a=new A(par1,par2);
Aglobale=a;

and than in main.cpp i'll use
cout <parametro;
Answer: In the B constructor, you are saving the address of a local variable.  There are several ways to fix this, the right one depends on what you are trying to do with A.
Furthermore, you do not have a nested class.  A nested class is defined inside of another class like this:
class OuterClass {
    class InnerClass {
        //class members
    };

    //class members
};

Comment: For example how can i fix it? what kind of different solutions are there for different usages of A?

C++ nested classes issue


Finishing a rough-surface wall in bedroom

Question: We have an unfinished rough-surface wall in our upstairs bedroom,  (see the photo)
Its surface looks covered in parallel plastic threads or fibers, with lots of sharp knots and some nail heads, glued to the wall. It was this way when we moved in.
We want to install a kids' bunk bed next to this wall. But first we need to "finish" (make smooth) the wall, otherwise the kids may injure themselves.
May we ask:

How is this unfinished surface called - what keyword to search for?

What is the right procedure to "finish" it - again, the keywords to search for?
Comment: Hi Alex, It will be helpful if you could add some information regarding what the wall material is. Plaster on lathe? Drywall? Sheet material like plywood or paneling?
Comment: That's not "unfinished". That is an intentional finish of a rough textured wallpaper type material.
Comment: Can you upload a picture of the area that might injure a child? That section just looks rough.
Answer: That wall surface material looks like it is the backing of some older type wall covering that had a mesh material for adding strength or glue retention.
It is also possible that you are looking at the original wall covering itself that may be a straw or grass material that was woven into a mat and then glued to the wall in sheets.
A zoomed in closeup of your picture reveals that the wall covering is a grass or straw material that was woven with thin vertical threads. It is also clear that it was painted over!!

If that mesh material is covered with paint it will be very difficult to remove. If it is not painted over it may just be possible to lightly spray the wall with a mist of hot water from a squirt bottle to see if the old wall covering glue will soften. As it softens you should be able to scrape carefully with a "putty knife" and wipe away the excess glue with a sponge rinsed frequently in warm water.
A painted over surface like that would entail a lot more work. There are several possible alternatives:

Remove the wall materials completely down to the studs and apply a new wall surface using drywall. This will finish down smooth after taping and sanding.
Try installing a new thin layer of drywall over the existing surface. This may require smoothing off any bigger bumps in the old surface. Any electrical switch and outlet openings may require box extensions to be installed. Also if that wall has any windows or door openings there may need to be adjustment of the trim. Going the route leaves you with a fresh new surface to finish similar to the first option.
Another possible scheme is to do some scraping and rough sanding of that existing surface to smooth out any large bumps and then use a skim coat of drywall mud to smooth out the surface. I have used a similar process to smooth out a textured ceiling and wall and found that skimming works best if you take the smoothing in repeated steps of mud application and then sanding and scraping once the mud is dry. A skim coating leaves a relatively soft material on the wall and it is a good idea to come back afterwards and paint it with two to three coats of good quality primer paint.
Answer: If you search for "drywall finishing" you will get a lot of ideas and some professional drywall finishers in your area. If you feel that you are not able to do the correct job yourself then a professional may be a good choice.
Answer: The material is called "grasscloth wallpaper" and yours has been painted. Here's an example of the unpainted material:
https://www.wayfair.com/York-Wallcoverings--Grasscloth-by-York-II-Knotted-Grass-24-L-x-36-W-Wallpaper-Roll-VG443-L6161-K~WHW4818.html
You can remove it like ordinary wallpaper, but none of the easy ways will work because of the texture. You may have to painstakingly remove it bit by bit with something like a handheld steam cleaner.


Can I draw power from nearby recessed lighting for pendant lights?

Question: I want to add two pendant lights above my island where I have a bunch of recessed lighting. Can I draw power from them in order to power the chandeliers?
I'm considering an Insteon solution in order to control the two separately, but that's another matter.
Answer: You'd have to calculate the load of the circuit to determine if you have enough capacity.
Volts x Amps = Watts
So if you are in the US, you probably have a 15 amp circuit which should only be loaded up to 12 amps.  Now go add up everything else on that circuit. Lets say you have 10 pot lights at 50watts each.
120v x Yamps = 500watts
= 4.1amps
Now lets say your two lights are 100W each, that's another 1.67 amps (200W/120V), so 5.7 amps total being drawn which means you would be able to add these without overloading the circuit.
If the circuit was already approaching 12amps, you would not have enough capacity and would need to run a new circuit.


High read/write data storage

Question: I'm designing a short-linking service. When people click one of my shortlinks I want to collect some data like ip address, useragent etc and then forward them on their destination. What would be the best way to store this data if my links table grows into the tens of millions. I'm not sure whether to use sql of something like elastic search.
Answer: This is a quite opinion-based question, but I will try to answer.
The performance of your operations depends mainly on what kind of queries you are going to have. So the real question is what do you want to do with this data ? Some concepts, when dealing with a big amount of data follows:
Bulk Insert
In case you have to save a big amount of data records with one request, both RDBMSs and elasticsearch offer you the means to achieve that. (postgreSQL populate data, elasticsearch Bulk API)
Data Partitioning
If you deal with a huge amount of data, that is constantly getting bigger, the execution time of the queries can grow as the amount of data grows. At some point, you might realize, that you need to apply data partitioning.
With elasticsearch you can create time-based-indices: you can save this "traffic-analytics" into indices like 2018-03-traffic, 2018-04-traffic, etc.. Then you could refer to them under one name using aliases. Please refer to what-are-aliases-in-elasticsearch-for question.
Postgres, that also offers you the means for table partitioning
So far so good, let's see some other aspects:
Data Structure

Does your schema consist of strong predefined, complcated rules?
If not(and I think that is your case), you could use elasticsearch.
Would you need in the future to add/remove fields into/from your
existing schema?
Elasticsearch is more flexible accepting new fields in an existing index-you actually don't need to do anything-, where in a RDMS you should manage it yourself-aka update the table definition.

Opinion based conclusion
The above described assumption and the assumption, that you would like at some point to run data analytics and visualize them, leads me to conclude, that elasticsearch could be a better fit in your case. With kibana, you get this out of the box.
Notes: 1. I use PostgreSQL for the given RDBMS links, because I am familiar with that.2. You should also consider the Scalability of RDBMS vs elasticsearch.
Comment: Thank you very much or the details answer @Eirini. My main concern is to keep search times down. I want to be able to find the forwarding link from the incoming uri as fast as possible.
Comment: It depends on the writes, too ( If you have to do those simultaneously with the reads :)  Anyways if you use correct indexing and proper system tuning, you can achieve your goal with both of your alternatives. I hope, I helped somehow

High read/write data storage


Cannot change color of actionbar with appcompact v7 and Android Studio 1.1 Preview

Question: I tried many styles to change color of actionbar but not worked.
This is my style:

My emulator version: Android 4.2
Comment: https://stackoverflow.com/q/28356073/115145
Answer: in SupportV7 version 21 change ActionBar color use colorPrimary property
Like this:

Answer: In styles.xml:

and in Manifest.xml:
<activity
        android:name="yourPackage.MainActivity"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

i hope to help you.


I type php artisan package:discover and get error

Question: php artisan package:discover

error:"There are no commands defined in the package namespace"
Comment: What version of Laravel are you using?
Comment: Does `php artisan` return anything? Is `package:discover` in there?
Comment: Please add more info about your project
Comment: It looks like you found the solution ... any chance you can share it with the rest of us? I've run into the same thing. And I'm sure I'll figure it out before you get a chance to reply, it definitely would have saved some time.
Answer: Try to run composer self-update as I believe the package discovery process requires a more recent version of the composer.
Comment: thanks for your response.Although i have found a solution to that issues.thanks
Comment: Great, let us know the solution and if this helps you up the answer.