text:
Q: How to properly typeset footnotes/superscripts after punctuation marks? I find the spacing of footnote marks after punctuation marks quite unsatisfactory, especially with sans serif fonts and compared to the spacing after letters. Example follows:

I came up with a little macro myself that tries to amend this manually.
\documentclass{article}
% URW Classico is a font that makes the issue apparent
\renewcommand{\sfdefault}{uop}
\renewcommand{\familydefault}{\sfdefault}
% define punctuation-aware footnote macro
\newlength{\punctuationfootlength}
\newcommand{\punctuationfootnote}[2]{#2\settowidth{\punctuationfootlength}%
{#2}\hspace{-\punctuationfootlength}\footnote{#1}}
% define a very small type area and don't care about margins
\setlength{\textwidth}{150pt}
\setlength{\textheight}{5\baselineskip}
\begin{document}
\noindent The three little pigs built their houses
out of straw\punctuationfootnote{not to be confused with hay},
sticks\footnote{or lumber according to some sources} and
bricks\punctuationfootnote{probably fired clay bricks}.
\end{document}

This will look like this:

I have to say, I didn't like this either. So I fiddled around a bit and set back the footnote marks by a half

and a third of the width of the punctuation mark.

Personally, I like the look of the last (-.3\punctuationfootlength) the best. But I'm a bit concerned that nobody ever seemed to have shared my opinion on this and if anything put a hair space between a letter and a footnote mark but never decreased the kerning. So if any typography guru here could put me straight on this matter that would be great. I'm also happy about anyone's second or third opinion on this.

Edit: Originally I also asked for a better way to TeX this here. As this is a separate question however, I moved it here.
Edit 3: That question led to a new package, fnpct, which should be used to automatically adapt footnote kerning in your LaTeX document.

Edit 2: Jon's comment caused me to succumb to the temptation I had all along of trying an additional intermediate between solutions 2 and 3. It seems like a ridiculously small change but here is -.4\punctuationfootlength:

Can't decide though. After a bit of pondering, I think I like the 3 a bit closer than the 1 which doesn't make things easier I guess.

A: (Obligatory Bringhurst reference warning)
Bringhurst has a few challenging comments about footnotes, including a mild "don't do that", but the relevant one for this question is (The Elements of Typographic Style, v3.2, pp68-69):

4.3.2 Check the weight and spacing of superscripts. ... "Superscripts frequently come at the ends of phrases or sentences. If they are high above the line, they can be kerned over a comma or [full stop], but this may endanger readability, especially if the text is set in a modest size."

A: I guess I'll use a .06em hair space before all regular footnotes as suggested by http://www.read.seas.harvard.edu/~kohler/latex.html (referring to Jan Tschichold) and a negative hair space for punctuation footnotes (actually the link suggests a .08em hair space and .3\punctuationfootlength miraculously turned out to be .0828em but still …). This comes close to the manual kerning I felt best about

The three little pigs built their houses out of
straw,\hspace{-.06em}\footnote{not to be confused with hay}
sticks\hspace{.07em}\footnote{or lumber according to some sources} and
bricks.\hspace{-.08em}\footnote{probably fired clay bricks}

Talk about putting paper between cast metal sorts …
All together this yields
\documentclass{article}
% URW Classico is a font that makes the issue apparent
\renewcommand{\sfdefault}{uop}
\renewcommand{\familydefault}{\sfdefault}
% define punctuation-aware footnote macro
\let\origfootnote\footnote
\renewcommand{\footnote}[1]{\kern.06em\origfootnote{#1}}
\newcommand{\punctfootnote}[1]{\kern-.06em\origfootnote{#1}}
% define a very small
\setlength{\textwidth}{150pt}
\setlength{\textheight}{5\baselineskip}
\begin{document}
\noindent The three little pigs built their houses out of
straw,\punctfootnote{not to be confused with hay}
sticks\footnote{or lumber according to some sources} and
bricks.\punctfootnote{probably fired clay bricks}
\end{document}

which looks like this:

This should also resolve the debate about the order and number of arguments since \punctfootnote became a drop-in replacement for \footnote.
Thanks a lot for your input! Of course further comments are still very welcome.


text:
Q: Nagios check_http on custom url I am trying to set up some monitoring for my host. I know that I can access it via the macro $HOSTADDRESS$, but how can I actually append the correct string to it? The $HOSTADDRESS$ won't return anything on just the root (so nothing on /), but I want it rather to check on /health-check. Is it possible to append the /health-check to $HOSTADDRESS$ somehow?
Using Opsview 6, which is based on Nagios.

A: You can pass the change to check_http in your service description
check_http --help
...
 -u, --url=PATH
    URL to GET or POST (default: /)
...

check_command   check_http!--url=/health-check

redpajama_set_name: RedPajamaStackExchange


text:
Q: ASP Repeater Not Updating After Databind Kind of a complicated question, but I have a custom user control ("roster list") which contains an ASP Repeater. This control has a method called RefreshRosterList that gets called on Page_Load of the control. This control gets dynamically inserted into an UpdatePanel.
The master page contains two update panels - one for my roster list, one for other controls.
I have a separate control that causes a postback. This control ("merge courses") inserts a new record into a database and calls my RefreshRosterList method.
At the end of my RefreshRosterList method is a call to databind my Repeater with new data. I know the data is correct when it binds to the Repeater.
I say it's not updating, but I've figured out the Repeater will show the new item if I commit a second post back. What I mean by that is if I create a merge of CIS161-01 and CIS161-02 called CIS161, it won't show. After that's merged, if I create a second merge of CIS171-01 and CIS171-02 called CIS171, that's when the CIS161 merge will show but the CIS171 merge will not.
How can I get my first merge to show on databind?
I hope this makes sense. I can try to provide whatever code necessary, but it's spread out over many different files.

A: You need to set the control as a trigger of the update panel the roster list is in or trigger the update yourself.


text:
Q: Building GMP 6.1.0 on 32 bit Windows 7 (MinGW): make fails on fib_table.c I tried to build GMP 6.1.0 on my Windows 7 x32 PC (CPU is Athlon 64 x2). GMP is needed to build riscv-gcc.
I run configure as shown
     ./configure --prefix=/mingw --enable-cxx

it completes succesfully, then I try to make and after this command
     /bin/sh ../libtool  --tag=CC   --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMP -I.. -DOPERATION_`echo fib_table | sed 's/_$//'`   -m32 -O2 -pedantic -fomit-frame-pointer -mtune=k8 -march=k8 -c -o fib_table.lo fib_table.c

     libtool: compile:  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_fib_table -m32 -O2 -pedantic -fomit-frame-pointer -mtune=k8 -march=k8 -c fib_table.c -o fib_table.o

I have an error
    In file included from ../gmp-impl.h:148:0,
             from fib_table.c:4:../mp_bases.h:4:1: warning: data definition has no type or storage class [enabled by default]

    Error, error, this data is for 64 bits

I have also tried
    ABI=32
     ./configure --prefix=/mingw --build=x86_64-w32-mingw32 --host=x86_64-w32-mingw32

but I still have the problem.
May be, anyone knows a solution?
Many thanks!


text:
Q: How to distinguish between int and long?  public class NewMain
 {
     public static void main(String[] args)
     {
         long num = 100;
         System.out.println(xMethod(5,1000000000000L));

     }

     public static int xMethod(int n, long x)
     {
         System.out.println("int, long");
         return n;
     }

     public static long xMethod(long n, long x)
     {
         System.out.println("long, long");
         return n;
     }

 }

To me, this looks very ambiguous.
A number within the range of an integer CAN be a long, which is demonstrated with the declaration of num.
And I was curious what would happen if I had two methods with two different parameters.
Apparently, when writing the parameters, the number MUST have an L at the end to indicate that it's a long, whereas when declaring num, that wasn't necessary.
Why is this?
I first thought that if it was within the range of an int, it'll automatically think of it as an int and when it goes above that range, it'll be used as a long.
However, with my second parameter, it won't pass unless I put the L. It says it's not within the range of an int.
Can someone give some clear rules to this?

A: A numeric literal with no decimal point is always treated as int unless it has a suffix that specifies otherwise (such as L).
If it's outside the range of int, this is a compilation error.

when declaring num, that wasn't necessary

You can assign an int literal to a long variable, since there's no loss of information.

A: Quoting Java Language Specification:

3.10.1. Integer Literals
An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1).
The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one).

So, an integer number is an int unless ending with L. Since 1000000000000 is too large for a int, it must end with L, or you get a compile error ("The literal 1000000000000 of type int is out of range").

3.10.2. Floating-Point Literals
A floating-point literal is of type float if it is suffixed with an ASCII letter F or f; otherwise its type is double and it can optionally be suffixed with an ASCII letter D or d (§4.2.3).

So, an decimal number is a double unless ending with f.

5.1.2. Widening Primitive Conversion

*

*int to long, float, or double

*float to double

So, the compiler will silently widen (convert) int values to long, if needed.
In your case, the compiler prefers the first method, because it can be called without any conversions.
If the first method hadn't existed, the second method would be called, after an implicit conversion of the first parameter to long.

A: Few points come to my mind for your question,
1. A variable is declared long then there is no need to put L for variable value
2. If you are passing a hard coded numeric literal, you put L at the end to make it long otherwise all numeric values are treated as int ( if not properly suffixed )
3.You can pass an int in place of long parameter ( automatic widening will happen )
4. You can't pass a narrow type in place of wider type without explicit casting
5. Parameter conversion is either via explicit casting and automatic widening without considering numeric value magnitude.
For below code sample - "Inside INT  LONG " will be printed due to automatic widening and in absence of private static void aMethod(int a , int b)
public class IntVsLons {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int a =100;
        long b=200;

        aMethod(a,a);

        }

    /*
    private static void aMethod(int a , int b){
        System.out.println("Inside INT  INT  ");
    }
    */

    private static void aMethod(int a , long b){
        System.out.println("Inside INT  LONG ");
    }

    private static void aMethod(long a, long b ){
        System.out.println("Inside LONG LONG ");
    }

Hope it helps !!

A: Your concern is a valid one. Take a look at this scenario:
public static void methodX(long x, int y){

}
public static void methodX(int x, long y){

}

In this case, if you invoke the following, it will give you different results:
methodX(123, 123);    //Compilation error (reference to methodX is ambiguous)
methodX(123L, 123);   //Ok!
methodX(123, 123L);   //Ok!

The first invocation gives you error because by default without the suffix (you create an integer) which will be able to fit into both overloaded methods.

A bit of additional info

*

*Without the suffix of l, the default whole number value will be an integer

*Without the suffix of d, the default decimal value will be a double.

A: An numerical literal without decimal point and without suffix, such as 42 or 100 is always of type int. To make it a long, you have to add a suffix: 42L or 100L.
If you call a method, the actual (compile-time) types of the arguments determine which overloaded method is called. If more than one overloaded method can be called with the given types, the most specific one will be taken. (For the exact rule, read Section 15.2 of the JLS.) So, in your case if the first argument is an int, the first method overload will be called, because int is more specific as long.
xMethod(1, 1)  --> xMethod(int n, long x) is called
xMethod(1L, 1) --> xMethod(long n, long x) is called


text:
Q: TFS 2012 TF50309 View Project Level Information I had create a testing collection name "Default Collection", at the "Default Collection" Group membership, I create "TFS Team" and put a user name window login "CLL" and set "Edit collection-level" information and "View Collection-level information" to true

when I access to the web, and click browse

I hit this error, I had try many way to control the security, the only way allow me to browse for different project but not able to change security is to add the "TFS Team" into Project Collection- Test Service Account, it is the correct way to do it?

A: Please go to Team-> Team Project Settings->Security and make sure your group has 'View project-level information' set to Allow.

A: According to your screenshot, you created Group "TFS Team" on Collection Level and set "view collection-level information".
To browse to Projects, you will need "view project-level information" permission on each Team Project. Please follow the steps below to set this permission:

*

*Open Team Explore 2010

*Connect to your TFS 2012 server.

*Go to menu Team->Team Project Settings->Security

*Add Group "TFS Team" and allow "view project-level information" permission.

FYI, Group "[Collection]\Project Collection Administrators", "[Collection]\Project Collection Build Service Accounts", "[Collection]\Project Collection Test Service Accounts" have been added to each Team Project by default. That's why you can browse the project after added "TFS Team" into "Test Service Accounts". You will NOT see these three groups from TFS 2012 Web Access. But you will see these groups with Team Explore 2010.


text:
Q: pre-populating apex:inputFile tag with attachment file I'm using an apex:inputFile tag on a VF page to import files that are added as attachments to records. If the user returns to this VF page is it possible to show the apex:inputFile prepopulated with the current attachment for that record? That way the user can see the name of the file that is already uploaded and choose to replace it.
Right now when I put these raw merge fields on the VF page they display the correct info:
{!attachments[0].name}
{!attachments[0].body}

However, when I add them to the apex:inputFile it still says 'No file chosen'
<apex:inputFile fileName="{!attachments[0].name}" value="{!attachments[0].body}" />

Any suggestions? Is this even possible?
Thanks!

A: The apex:inputFile component gets generated as a html input type of file. You cannot set the value of that any way other than through the file chooser due to security reasons.  This is enforced in the browser and is independent of Salesforce.
One other point:  You generally do not want the body of the attachment in your view state ever, because it can easily lead to a situation where the view state limit is violated.  You need to look at setting the attachment property to be transient and/or setting the body to null (before the page is rendered, after you submit it, validation failures, or any time the page is rendered and the value is set).
I suggest something like creating a link to the document next to the input, so that the user can click it to see the current value of it.  Something along the lines of the following (note I didn't test this code out):
<apex:inputFile fileName="{!attachments[0].name}" value="{!attachments[0].body}" />
<apex:outputLink
    value="{!URLFOR($Action.Attachment.Download, attachments[0].Id)}" target="_blank">
    {!attachments[0].name}
</apex:outputLink>


text:
Q: Implementation details of K-means++ without sklearn I am doing K-means using MINST dataset. However, I found difficulties in the implementation on initialization and some further steps.
For the initialization, I have to first pick one random data point to the first centroid. Then for the remaining centroids, we also pick data points randomly, but from a weighted probability distribution, until all the centroids are chosen

I am sticking in this step, how can I apply this distribution to choose? I mean, how to implement it? for the D_{k-1}(x), can I just use np.linalg.norm to compile and square it?
For my implementation, I now just initialized the first element
self.centroids = np.zeros((self.num_clusters, input_x.shape[1]))
ran_num = np.random.choice(input_x.shape[0])
self.centroids[0] = input_x[ran_num]

for k in range(1, self.num_clusters):

for the next step, do I need to find the next centroid by obtaining the largest distance between the previous centroid and all sample points?

A: You need to create a distribution where the probability to select an observation is the (normalized) distance between the observation and its closest cluster. Thus, to select a new cluster center, there is a high probability to select observations that are far from all already existing cluster centers. Similarly, there is a low probability to select observations that are close to already existing cluster centers.
This would look like this:
centers = []
centers.append(X[np.random.randint(X.shape[0])]) # inital center = one random sample
distance = np.full(X.shape[0], np.inf)
for j in range(1,self.n_clusters):
    distance = np.minimum(np.linalg.norm(X - centers[-1], axis=1), distance)
    p = np.square(distance) / np.sum(np.square(distance)) # probability vector [p1,...,pn]
    sample = np.random.choice(X.shape[0], p = p)
    centers.append(X[sample])


text:
Q: Cannot run h1 xterm on mininet (Diplay not found) I am trying to run wireshark on h1 node on mininet.
I have downloaded and imported the mininet VM
I was successfully able to ssh into the mininet VM from my host computer.
When I try running h1 xterm or xterm h1 or h1 wireshark & on mininet I get on of the following errors:

*

*Can't connect to display %s

*Could not connect to display

*Display not found

Here are all the things I have tried:

*

*setting $ DISPLAY=:0.0   $ export DISPLAY and then

*sudo -E mn

*using ssh -X mininet@192.168.56.102
I always end up getting the same error or no response.enter code here


text:
Q: Custom loops, sticky posts, and pagination nightmare I've tried everything.  I've looked at every. single. question. here, on StackOverflow, the WP help forum, googled 10 pages deep and literally tried EVERY combination of code I could find, for the last 2 days, and can't get anything to work how I want it.  Surely it can't be impossible?  The goal seems so simple!
THE GOAL: Show ALL sticky posts first, and then normal posts after them - WITH PAGINATION.
Example:  With posts per page set to 10, having 15 sticky posts and 15 normal posts, page 1 would be 10 sticky posts, page 2 would be 5 sticky posts and then 5 normal posts, and page 3 would be 10 normal posts.  Ordered by date.
I've tried multiple loops, various queries, and have come CLOSE but so far no cigar.  Here's what I have so far:
<!-- THIS CODE QUERIES ALL POSTS AND RETURNS ONLY STICKY POSTS, DISPLAYED AT TOP OF THE PAGE -->
<?php
// show only ads within this specific category
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
//$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$sticky=get_option('sticky_posts');
$args=array(
    'post_type' => 'my_custom_post_type',
    'ad_cat' => $term->slug,
    'caller_get_posts' => 1,
    'post__in' => $sticky,
    'posts_per_page' => -1
    //'paged' => $paged
    );
query_posts($args);
?>
<?php get_template_part( 'loop', 'post_featured' ); ?>
<?php wp_reset_query(); ?>

<!-- THIS CODE QUERIES ALL POSTS AND RETURNS ONLY REGULAR POSTS, DISPLAYED BELOW THE STICKIES -->
<?php
// show only ads within this specific category
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$sticky=get_option('sticky_posts');
$args=array(
    'post_type' => 'my_custom_post_type',
    'ad_cat' => $term->slug,
    'caller_get_posts' => 1,
    'post__not_in' => $sticky,
    'paged' => $paged,
    );
query_posts($args);
?>
<?php get_template_part( 'loop', 'post_normal' ); ?>
<?php wp_reset_query(); ?>

The above shows ALL sticky posts and then (5) normal posts.  This is the closest I have gotten, but #1, I don't want to show ALL sticky posts on the first page, I want to adhere to the pagination rules.  #2, ALL sticky posts show up on all paged pages.  So if I have 50 sticky posts and 50 normal posts, each page shows 55 posts - the first 50 are the sticky posts and the last 5 are normal, which is not my goal (see THE GOAL above).
Is there an easy modification to one or both loops?  Should I be using a double loop or is there another/better option to do this?  I'm open to suggestions as long as I get it to WORK.  I should note:  I'm using WP 3.2.1 and a slimmed down non-plugin pagination function which was taken from WP-PageNavi (full pagination function can be seen here: http://paste2.org/p/1596821).
Any help is appreciated!

A: I would combine your template loop with the code above.
And then insert some condition to the 1st loop and 2nd loop.
if($paged == 1) {
//Show Special Content for First

} else if($paged => 2) {
//Show Content for pages greater than 2

}

This probably would not work out of the box but it is definitely in the right direction by using more conditions to get the right settings you want.
Hence, I am a new user with this account on the wordpress exchange, I can't post comments and ask that you combine the code with the "get_template_part('loop')" or the loop template. I could probably give a better answer from there.

A: @Chris_O is right... currently sticky posts are not supported in custom post types so it must have something to do with the theme you are using.
Now disregarding the CPT problem... and assuming that it does work the same way wordpress stickies do then the goal that you are describing is exactly the way 'sticky' posts are designed to work in wordpress (i.e. show all the sticky posts before showing the normal posts and adhere to pagination), so from what I can tell your problem lies in the fact that you are trying to create two separate loops. In order to display the posts they way you want them to be displayed you should be using only one loop.
Have you tried just running one loop (i.e. removing the second query and replacing the first one with something like the below to see if the stickies are automatically added)?
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

$args=array(
  'post_type' => 'my_custom_post_type',
  'paged' => $paged,
  'posts_per_page' => 10
);
query_posts($args);

get_template_part( 'loop', 'post_normal' );


text:
Q: How to export QTable to .csv? How can I export values from a QTableWidget to .csv file or Excel file?
The program should collect values of three variables from a PLC. This PLC belongs to my company and have functions to do this collect.
Inserting items to QTableWidget .cpp:
void MainWindow::on_pushInsert_clicked()
{
/*
the program already is connected to plc,
so I just have to choose the address inside of the plc.
*/
    WORD wAddress = 50001;
    WORD value1 = 0;
    WORD value2 = 0;
    WORD value3 = 0;
    CollectVariables(wAddress,wValue);
    int ID = 0;
    string Name = "";
    int Age = 0;
    QTableWidget *table = ui->tableWidget;
    for(i=0;i<10; i++) {
        //id
        CollectVariables(wAddress+i, value1);
        table->setItem(i, 0, new QTableWidgetItem(value1));

        //name
        CollectVariables(wAddress+10+i, value2);
        table->setItem(i, 1, new QTableWidgetItem(value2));

        //age
        CollectVariables(wAddress+20+i, value3);
        table->setItem(i, 2, new QTableWidgetItem(value3));
        tabela->selectRow(i);
    }
}

A: The way I used to "export" QTableWidget to .csv file (I can't export do excel) was to store the value of each space on the table to an array while inserting items to the table.
QFile was used to create the .csv file and QTextStream to insert values on it.
To improve the code I created a button to select the directory where this .csv file should be save.
Select Directory .cpp:
void MainWindow::on_pushSelectDir_clicked()
{
    QFileDialog directory;
    ui->lineEditDir->setText(directory.getSaveFileName(this,"Choose an directory"));
    dir_name = ui->lineEditDir->text();
}

Create .csv file .cpp:
void MainWindow::on_pushExportCSV_clicked()
{
    QFile data(dir_name+".csv");
    if (data.open(QFile::WriteOnly | QIODevice::Append)) {
     }
    QTextStream output(&data);
    output <<"ID"<<","<<"Name"<<","<<"Age"<< '\n';
    for(i=0;i<10; i++) {
        output << ID[i] <<","<< Name[i] <<","<< Age[i] << '\n';
    }
    data.close();
}


text:
Q: Calculate a balance between 3 totals from different tables in FileMaker The 2 tables in question:
INV
Expense
The 3 fields in question:
INV_total,
EXP_total,
TAX_total
I need a calculation in a report that shows the difference between the 3 fields, a bit like:
INV_total - TAX_total + EXP_total
However for some reason this relatively simple idea eludes me (certainly in terms of execution :) )
Any help would be appreciated.
I'm relatively new to FMP.
Be... Gentle...

A: There are many possible answers, depending on what exactly you need and for what for purpose. It's unlikely that you would want to total all invoices and all expenses from all times since the beginning of your solution..
Let's say you want to do this calculation for a specific year. You could have a script find the invoices of the given year, place the invoice and tax totals in variables (using summary fields to get them), move to the expenses table and do the same.
Another way would be to use a third table and get the totals through a relationship based on a date range.

Added:
Here's an expansion of the first option, using a script to get the total of expenses.
These are the fields used in the script:
Expenses:

*

*Date (Date)

*Amount (Number)

*sTotalAmount (Summary, Total of Amount)

Invoices:

*

*Date (Date)

*gTotalExpenses (Number, Global)

The script itself would look something like this (here, we are producing a report for the current year):
Enter Find Mode []
Go to Layout [ Expenses ]
Set Field [ Expenses::Date ; Year ( Get (CurrentDate) ) ]
Perform Find []
Set Field [ Invoices::gTotalExpenses ; Expenses::sTotalAmount ]
Enter Find Mode []
Go to Layout [ Invoices ]
Set Field [ Expenses::Date ; Year ( Get (CurrentDate) ) ]
Perform Find []
Sort Records []

At the end of this script, you should see your report with the global gTotalExpenses field containing the total amount of expenses for the current year.

A: On a long shot I'm going to assume that the expenses relate to an invoice in this case.  So to do this calculation you will be best to use some relational database skills.

*

*Give your invoice a unique ID, the best way to do this is add a field called InvoiceID which is a unique serial number.  For this example let's assume you have an invoice with an InvoiceID of 123

*Add a field called InvoiceID to your Expense table.  Each expense that relates to invoice with InvoiceID of 123 will need InvoiceID set to 123.

*Go to the relationship graph and link InvoiceID in your invoice table to InvoiceID in your expenses table drag and drop InvoiceID in the Invoice table to InvoiceID in the expense table.

*In the invoice table create a calculation field which is INVTotal - TAXTotal + sum( Expense::EXP_total )


text:
Q: ECS Fargate with Dockerized container nginx not loading static files I have a webapp made in React and when I run the dockerimage locally, it works fine. No issues. When I deploy it to ECS Fargate with nginx it gives me a lot of weird errors.
Specifically, it cannot find the static assets. Here is my nginx file:
server {
listen       ${PORT:-80};
server_name  _;

root /usr/share/nginx/html;
index index.html;

location / {
    try_files $$uri /index.html;
}

I am unsure what to change here, or in my yml files to get it to access the static stuff on ECS.
The error I am getting is the following:
Failed to load resource: the server responded with a status of 503

Any help is appreciated, thank you


text:
Q: What is the largest open set $\frac{1}{\cos z-2i}$ is analytic in? This is a very interesting question that I came across and have never solved any question of this sort. How do I find the largest open set on which $\frac{1}{cosz-2i}$ is analytic?
Do I find the set in which $\cos z-2i\neq0$? Any answers will be much appreciated.
Note that $$\cos z=\frac{e^{iz}+e^{-iz}}{2}$$ where $z\in\mathbb{C}$

A: First, recall that
$$
\cos(x+yi)
=
\cosh(y)\cos(x)-i\sinh(y)\sin(x).
$$
If you haven't seen this before, it can be verified with a simple calculation.
So to have $\cos(x+yi)=2i$ we need to have $\cosh(y)\cos(x)=0$.
Since $\cosh(y)>0$ for all $y$, we must have $\cos(x)=0$.
Thus $x=\frac\pi2+\pi n$ for some $n\in\mathbb Z$ and therefore $\sin(x)=(-1)^n$.
Now we must have $\sinh(y)=-(-1)^n2$.
Therefore $\cos(x+yi)=2i$ if and only if $x=\frac\pi2+\pi n$ for some $n\in\mathbb Z$ and $y=-(-1)^n\operatorname{arsinh}(2)$.

A: This is a ratio of two analytic functions, so it is analytic wherever the denominator is nonzero. (The numerator is constant, so in fact it is analytic exactly on the complement of the zero set of the denominator.) So, like you say, it is analytic precisely on the complement of the set where $\cos z - 2 i = 0$.


text:
Q: How to assign value to unshared_at for a file using BOX API v2.0 I am trying to create a 'shared link' for a file uploaded. Using BOX API, I am sending a request with body as:
{"shared_link": {"access": "open","unshared_at":1347215400,"permissions": {"download": true, "preview": false }} }
However, it does not seem to work!??? ( of course, 1347215400 being unix-timestamp value corresponding to some time on Sep 9, 2012 )
The request without the unshared_at parameter, like
{"shared_link": {"access": "open","permissions": {"download": true, "preview": false }} }
works and sets the relevant attribute values as expected.
Have actually also tried various other possible timestamp formats but without success. API documentation does mention the format in which timestamps values are returned but does not say anything about what format it expects for setting the value!
Anyone out there to help?

A: Please send in the timestamp values as ISO 8601. The documentation was just updated to indicate this more clearly.


text:
Q: How to convert html code to a string that replaces the newlines with \n and tabs with \t Is there an easy way to convert HTML code, that is structured in a certain way, to a single string (that can then be used in a Javascript variable). The new lines and tabs in the html code need to be converted to \n and \t so that the formatting can stay in tact.
example HTML:

         <title>Hello World</title>

Title

Subtitle

Some text goes here

I've converted this manually to this:
\n\n\t\n\t\t <title>Hello World</title>\n \t\n\n \t\n \t\t
Title
\n \t\t\t
Subtitle
\n \t\t\t\t
Some text goes here
\n \t\n\n \n

Is there an easy way to do this automatically? Because I need to convert larger chunks of HTML to this format. Thanks.

A:     function format(data) {
        var returnStr = "";
        var lines = data.split("\n");
        var block = [];
        for (var i = 0; i < lines.length; i++) {
            block = lines[i].split('\t');
            for (var j = 0; j < block.length; j++) {
                returnStr += block[j];
                if (block.length>1) {
                    returnStr +=  "\\t";
                }
            };
            returnStr +=  "\\n";
        };
        return returnStr;
    }

A: If you are doing this to show new line and return carriage in html, then you don't need to do it explicitly. You can do it in css by setting the white-space attribute pre-line value.
CommentText


text:
Q: Array.Copy vs Skip and Take in c# I was browsing this question and some similar ones:
Getting a sub-array from an existing array
Many places I read answers like this:
Getting a sub-array from an existing array
What I am wondering is why Skip and Take are not constant time operations for arrays?
In turn, if they were constant time operations, won't the Skip and Take method (without calling ToArray() at the end) have the same running time without the overhead of doing an Array.Copy, but also more space efficient?

A: You have to differentiate between the work that the Skip and Take methods do, and the work of consuming the data that the methods return.
The Skip and Take methods themselves are O(1) operations, as the work they do does not scale with the input size. They just set up an enumerator that is capable of returning items from the array.
It's when you use the enumerator that the work is done. That is an O(n) operation, where n is the number of items that the enumerator produces. As the enumerators read from the array, they don't contain a copy of the data, and you have to keep the data in the array intact as long as you are using the enumerator.
(If you use Skip on a collection that is not accessible by index like an array, gettting the first item is an O(n) operation, where n is the number of items skipped.)


text:
Q: get current time in extjs view i have a extjs view file, here it is:
                {
                    xtype       : 'timefield',
                    name        : 'startTime',
                    minValue    : '00:00',
                    maxValue    : '24:00',
                    value       : '08:00',
                    format      : 'H:i',
                    increment   : 30,
                    width       : 80,
                    hidden      : true
                }

but i want to show current date, i have code to show current date value: new Date(yr, mt, (dt)) but i don't know how to show time.. i used value: new Date(ht) then value  : new Date(th) but they don't work. any solution for me?
thanks

A: To show the current time you can simply set the value in your timefield to new Date() and it will display it in the specified format. This can be shown here. It also uses a field label to display the current date using:
fieldLabel: Ext.Date.format(new Date(), 'Y-m-d')
You could show the current date elsewhere (not in a field label) but the logic remains the same.


text:
Q: In minecraft, how do I construct a 4-bit comparator? 4-bit comparators are a basic building block in electronics, and useful in many redstone devices, in particular computers. I'm interested in a good overview of the construction this type of device. It takes eight signals as input: a0, a1, a2, a3, b0, b1, b2, b3; and outputs 2 signals: a<b, a=b with a>b = !(a<b).
Diagrams of how to do it with real electronics are easy to find. Usually people build 1-bit, 2-bit, and 4-bit comparators directly, and larger ones are created through cascades (to minimize the number of transistors used). Translating this to minecraft is a bit of an art; sometimes a more complicated circuit in reality is easier to do (and works better) in minecraft. There's these points to consider, roughly in order of importance:

*

*Maintainability

The plan should be for the device to remain functioning as the game is updated. Answers using bugs or undefined behaviour would result in the device no longer working as the game updates, making these less useful.

*

*Speed

There's usually an expectation that whatever redstone contraption is providing the logic functions fast enough that the delay isn't noticeable.

*

*Simplicity

If the device is meant as a tutorial, it should be easy enough to understand, and not rely on too much obscure behaviour.

*

*Compactness

A device using a minimal amount of material is quicker to build and easier to fit in.

A: While it's possible to build a contraption that operates on discrete boolean arithmetics, built of logic gates, it would be terribly impractical; you have some 5 gates per bit, each gate a good couple blocks, cross-connections, this would be quite awful. Luckily, for arithmetics on numbers up to 4 bits, Minecraft provides a much handier and more graceful tool - analog redstone; use of signal strengths and the comparator.
This is the device that meets the requirements as stated (shown state: "15 > 14", green input greater than blue.):

It looks bulky, but that's only due to need to "massage" the problem as stated (binary input, outputs of "<,=") into what works naturally in Minecraft (analog inputs and outputs of "<,>"). If you take the Minecraft-natural approach all you need is the "core" of 2 comparators:

In this case, you deliver two signals of varying strength, X,Y. The outputs are their difference X-Y and Y-X if the result is positive; no output if zero or less.
What the "extended" version does is first convert 4 input bits into analog signal (through subtracting 1,2,4 or 8 respectively; in Minecraft analog circuitry all addition is done as a + b = 15 - (15 - a - b))*, then compared; then the two outputs are fed downwards into a NOR gate, to produce output if neither is active, meaning the inputs are equal. If you skip the repeaters on output, your output will contain magnitude of the difference too.
*The inputs aren't normalized back to the original value 15 - (15 - x), just fed into the comparator in the 15-complement form 15 - x, as this compacts the contraption; instead of reversing the values, I'm just  flipping the meaning of the outputs; if x < y, then (15 - x) > (15 - y)


text:
Q: inherit from a base class Let say I have this class :
class foo
{
    public foo(Guid guid)
    {
        //some code here
    }

    public foo(Guid guid, bool myBool)
    {
        //some other code here
    }

    //Here I have a bunch of method/properties

    public void GenX(bool french, int width)
    {
        //my method implementation
    }
}

and I have another class that does basically all the same than foo except the implementation of this method public GenX(bool french, int width) and the construtor must be different from foo's implementation.
If I implement bar this way the compiler complain : 'foo' does not contain a constructor that takes '0' arguments
class bar : foo
{
    public bar(Guid guid, bool myBool)
    {
        //some code here
    }

    new public void GenX(bool french, int width)
    {
        //my new method implementation
    }

    //I will be using the implementation of `foo` for the rest of the methods/properties
}

What am I doing wrong? Is this the correct way to do this kind of thing?
If this isn't clear enought I apologies and I will try to make it clearer

A: You'll have to make sure that the base constructor is called.
You can do that like this:
class bar : foo
{
    public bar(Guid g, bool b) : base (g)
    {
        // code here
    }
}

Since you haven't specified this in your code, the compiler will try to call the default constructor by default/implicitly.   However, since your base class doesn't have a default constructor (because you've specified another constructor, without specifying the default constructor), it cannot call it.
Hence, you'll have to tell the compiler what constructor of the base-class it should use.
In the case that the constructor in your inherited class does something completely different then the constructor in your base-class, and you do not whish to reuse the constructor of your base class, you can do this:
class foo
{
   protected foo()
   {
      // default constructor which is protected, so not useable from the 'outside'
   }

   public foo( Guid g )
   {}

   public foo( Guid g, bool b) : this(g)
   {}

   public virtual void GenX() {}
}

class bar : foo
{
   public bar( Guid g, bool b) : base()
   {}

   public override void GenX() {}
}

A: try this :
class foo
{
    public foo(Guid guid)
    {
        //some code here
    }

    public foo(Guid guid, bool myBool,bool fooclass = true)
    {

        if (fooclass)
        {
            //some other code here
        }

    }

    //Here I have a bunch of method/properties

    public void GenX(bool french, int width)
    {
        //my method implementation
    }
}

class bar : foo
{
    public bar(Guid guid, bool myBool,bool barclass = true) : base(guid,myBool,false)
    {
        //some code here
    }

    new public void GenX(bool french, int width)
    {
        //my new method implementation
    }
}


text:
Q: Android.mk , inking but not including Shared Libs in output Having a bit of an issue here. I am trying to port over the open source application IMSdroid to work with newer and more consistent build systems. I already got ANT working correctly, but need Android.mk working as well to make life easier. (Make all rebuilds automated with Gradle and Android.mk, enabling easier additions of new capabilities and codecs.)
The JAR files work fine.
The .so files are NOT being included in the final APK. Its not my first time with Android.mk and this one is just puzzling me.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_CERTIFICATE := debug
LOCAL_PACKAGE_NAME := IMSdroid

LOCAL_JAVA_LIBRARIES := telephony-common telephony-msim
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 libandroid-ngn-stack libsimple-xml-2.3.4

LOCAL_SHARED_LIBRARIES := libplugin_audio_opensles libtinyWRAP libutils

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PROGUARD_ENABLED := disabled

include $(BUILD_PACKAGE)

##################################################
include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libandroid-ngn-stack:libs/android-ngn-stack.jar libsimple-xml-2.3.4:libs/simple-xml-2.3.4.jar

include $(BUILD_MULTI_PREBUILT)

##################################################
include $(call all-makefiles-under,$(LOCAL_PATH))

LOCAL_LDFLAGS := -L$(LOCAL_PATH)/jni/

include $(BUILD_SHARED_LIBRARY)

Then in /jni folder
include $(CLEAR_VARS)

LOCAL_MODULE := libplugin_audio_opensles
LOCAL_SRC_FILES := libplugin_audio_opensles.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := libtinyWRAP
LOCAL_SRC_FILES := libtinyWRAP.so

include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)

LOCAL_MODULE := libutils
LOCAL_SRC_FILES := libutils_armv5te.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := libtinyWRAP_neon
LOCAL_SRC_FILES := libtinyWRAP_neon.so

include $(PREBUILT_SHARED_LIBRARY)

I need it to basically have the APK as built appear with /libs containing all of the library files. AT this point, it does not.

A: Couple of observations:

*

*In your first Android.mk file, I don't think you need the include $(BUILD_SHARED_LIBRARY) at the end.

*Try prepending the path to the LOCAL_SRC_FILES references, for exmaple:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libplugin_audio_opensles
LOCAL_SRC_FILES := $(LOCAL_PATH)/libplugin_audio_opensles.so
include $(PREBUILT_SHARED_LIBRARY)

*Also, check out https://android.googlesource.com/platform/packages/apps/Camera2/+/android-4.4.4_r2.0.1/Android.mk - you might could try that LOCAL_JNI_SHARED_LIBRARIES


text:
Q: change default username when ssh to another pc When I ssh between different pcs I can omit my username (tom) and just type
ssh pc_name

instead of
ssh tom@pc_name

I like this feature, and have got into the habit of using it.
Unfortunately, on one of my computers I went for the user name tommy.  Everytime I connect to this computer I forget to write tommy@creative_pc and wonder why my password doesn't work.  Is there a way to tell ssh what user name to use when the username is omitted?
Edit: Just found the following question that is similar: How to make ssh log in as the right user?  It didn't come up on my initial search.

A: I have a large list of servers, so I used a shell alias to set a default user for all hosts.
Put bellow line on your ~/.bashrc:
alias ssh="ssh -l default_user"

You can still set another user, using -l:
ssh server -l other_user

I started using today, seems working fine on Ubuntu 12.

A: Sure:
$ ssh -l tommy

will log you in as tommy.
You can also make this persistent per-host by having a record like this in ~/.ssh/config:
Host creative_pc
User tommy
HostName creative_pc # put the full host name here or the IP if it is static

then you just do:
$ ssh creative_pc # this is the string from Host setting

and you login there as tommy by default


text:
Q: Print PDF from BLOB Im getting a PDF file from and external API, using this code I can download the file correctly:
var req = new XMLHttpRequest();
    req.open("POST", url, true);
    req.responseType = "blob";
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.send(data);

    req.onload = function (event) {
       var blob = req.response;
       var link=document.createElement('a');
       link.href=window.URL.createObjectURL(blob);
       link.download="receipt_" + new Date() + ".pdf";
       link.click();
    };

But what I really need is to print the file without open it, I tried something like
window.open(window.URL.createObjectURL(blob));
window.print();

But when do this way the file does not show correctly, It shows something like this:
PDF-1.7
%����
6 0 obj
<< /Type /Page /Parent 1 0 R /LastModified (D:20201027223421-03'00') ... bla bla

Thanks in advance!

A: I have already solve this using:
req.onload = function (event) {
    var blob = new Blob([req.response], {type: 'application/pdf'}); //this make the magic
    var blobURL = URL.createObjectURL(blob);

    iframe =  document.createElement('iframe'); //load content in an iframe to print later
    document.body.appendChild(iframe);

    iframe.style.display = 'none';
    iframe.src = blobURL;
    iframe.onload = function() {
      setTimeout(function() {
        iframe.focus();
        iframe.contentWindow.print();
      }, 1);
    };
};

A: Try the code below to make sure the .pdf file is correct. Verify the pdf with the preview that opens.
    <!doctype html>

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


text:
Q: Features to include on a new embedded Linux board to make development and debug easier? At my work we're planning on developing a new ARM based embedded Linux board. I want to give the hardware guys some guidance on features they could add that would make the software development easier. My list so far is:
At least one dual/tri color LED controllable by GPO
A JTAG header
An extra serial port for debug log messages
Extra GPIOs taken out to a header for monitoring by logic analyzer etc.

Can anyone suggest any features they found they later needed that would have helped if present on an initial board?

A: Your list looks good. I'd add:

*

*some means of resetting the board other than de-powering it

*some means of recovering from bad firmware updates


text:
Q: Einstein Summation Proof, Does this count as an expansion? Prove curl grad $\phi = 0$ for all scalar fields. $\phi$ (i.e. $\nabla \times \nabla \phi \ 0$ using Einstein summation notation only, no term by term expansion.
Well, first step is to set up in notation form:
$\epsilon_{ijk}$$d\over x_j$$d\phi\over dx_k$
In which the next step, I use the identity of what $\nabla\phi$ is, which would be
$d\phi\over dx$x + $d\phi\over dy$y + $d\phi\over dz$z
then do
$\nabla \times ($$d\phi\over dx$x + $d\phi\over dy$y + $d\phi\over dz$z)
in which I show that the curl is 0, because each term is the partial of a component has no component of the partial.
Is this a valid proof technique?

A: Of course both ways are equally valid to prove the desired equation. But your approach is not really making use of Einstein summation.
For example writing $\nabla \phi$ as $\frac{\partial\phi}{\partial x}e_x+\frac{\partial\phi}{\partial y}e_y+\frac{\partial\phi}{\partial z}e_z$ is already something you do not have to to when using Einstein summation.
But you already had the right idea by writing
$$(\nabla \times \nabla \phi)_i
= \varepsilon_{ijk} \frac{\partial}{\partial x_j} \frac{\partial\phi}{dx_k}.$$
You could now proceed by changing the order of derivation and applyeaing $\varepsilon_{ijk} = - \varepsilon_{ikj}$. By exchanging names of the indices $j$ and $k$ you will then get an equation of the form $X = -X$, hence $X = 0$.
Note that you would do the same when expanding, e.g.
$$ (\nabla \times (\frac{\partial\phi}{\partial x}e_x+\frac{\partial\phi}{\partial y}e_y+\frac{\partial \phi}{\partial z}e_z))_x = \frac{\partial}{\partial y}\frac{\partial\phi}{\partial z} - \frac{\partial}{\partial z}\frac{\partial\phi}{\partial y}$$
which yields $0$ by changing the order of derivation in one of the summands.
I must admit that I do not really understand your last statement but note that it is not necessarily the case that applying $\frac{\partial}{\partial x_i}$ on $\frac{\partial \phi}{\partial x_j}$ yields $0$ for $i \neq j$.


text:
Q: Different proofs that $\lim_{n\to\infty}\sin n$ does not exist In this question it was proved that limit
$$
\lim_{x\to\infty}\sin x
$$
doesn't exists. What about
$$
\lim_{n\to\infty}\sin n?
$$
I asking about usual limit, where $n$ is integer. I know that this limit doesn't exists, I want to see different proves. My first idea was to use Kronecker's approximation theorem, but it's not very suited for such simple question.

A: That doesn't exist either.
No matter how large $n$ is, there will always be a larger $n'$ such that $n'$ is between $2\pi k-1$ and $2\pi k$ for some $k\in\mathbb N$. Thus $\sin n' <0 $ infinitely often, which means that a limit, if one exists, cannot be positive.
But then $n'+2$ is between $2\pi k+1$ and $2\pi k+2$, and therefore $\sin (n'+2) > \sin 1 \approx 0.84$. So the limit, if it exist, cannot be less than $\sin 1$. Since every real number is either positive or less than $\sin 1$ (and some are both), there is no number that can possibly be the limit.

A: $$ \left|\sin(n+1)-\sin(n-1)\right| = 2\sin(1)\left|\cos(n)\right| $$
hence $\{\sin n\}_{n\in\mathbb{N}}$ cannot be a Cauchy sequence, since $\cos(n)$ is bounded away from zero for infinitely many values of $n$. As an alternative, since $\sin n=\text{Im}(e^{in})$ and the length of circumference of radius one is $2\pi\approx 6$, among:
$$\sin(n),\quad \sin(n+1),\quad\ldots\quad \sin(n+7)$$
there are two numbers whose difference is at least one, so, again, $\{\sin n\}_{n\in\mathbb{N}}$ cannot be a Cauchy sequence.

A: Expanding on the idea of Kronecker's approximation theorem: The map $T(x) = x + 1$ is uniquely ergodic on $[0, 2\pi]$, so $f(x) = \sin x$ has
\begin{align*}
\frac{1}{N}\sum_{n\leq N} \chi_A (\sin T^n 0) = \frac{1}{N} \sum_{n\leq N} \chi_A (\sin n) \to \operatorname{vol}(A)
\end{align*}
as $N\to\infty$ for any measurable $A\subset [0, 2\pi]$, where $\chi_A$ is the characteristic function for $A$. In particular, for any $A$ of positive measure, there exists an infinite sequence $n_1, n_2, \dots$ such that $\sin n_i\in A$.

A: I got another idea on how to prove that $\lim_{n\to\infty}\sin(n)$ doesn't exists, I'll do this via contradiction.
So first let's assume the limit exists,
 $$
\lim_{n\to\infty}\sin(n)=a\Rightarrow\lim_{n\to\infty}\sin(2n)=a\in[-1,1]
$$
Now we use the representation
$$
\sin(2x)=2\sin(x)\cos(x)\Rightarrow \lim_{n\to\infty}\cos(n)=\frac{1}{2}=\lim_{n\to\infty}\cos(2n)
$$
Now we use another representation
$$
\cos(2x)={\cos(x)}^2-{\sin(x)}^2\Leftrightarrow\cos(2n)-{\cos(n)}^2=-{\sin(n)}^2
$$
And now we take the limit and we get, since all limits exist and everything is continuous
$$
\lim_{n\to\infty}(\cos(2n)-{\cos(n)}^2)=\lim_{n\to\infty}(-{\sin(n)}^2)\\
\Leftrightarrow\
(\frac{1}{2}-\frac{1}{4})=\frac{1}{4}=-a^2\Leftrightarrow a^2=-\frac{1}{4}
$$
which is a contradiction.

A: If $|\sin(n+1) - \sin(n)\,|$ is very small, then either
$n \approx 2k\pi + \frac\pi2 - \frac12$ or
$n \approx 2k\pi - \frac\pi2 - \frac12$,
where $k$ is an integer.
Then either $\sin(n+1) \approx \sin(n) \approx 0.878$
or $\sin(n+1) \approx \sin(n) \approx -0.878$.
Using the same value of $n$ for the moment,
consider $|\sin(n+2) - \sin(n+1)\,|$.
We have $n + 2 \approx 2k\pi + \frac\pi2 + \frac32$
or $n +2 \approx 2k\pi - \frac\pi2 + \frac32$,
so either $\sin(n+2) \approx 0.071$ or $\sin(n+2) \approx -0.071$,
and $|\sin(n+2) - \sin(n+1)\,| \approx 0.807.$
That is, whenever you have two successive terms that are close together,
the next term is significantly different.
The sequence therefore cannot converge.


text:
Q: what are the differences between urls.py in project's folder and app folder in django? In django there is a concept that makes me dazzled a bit.Why we should make a urls.py in our app folder while we have one in project folder.
what is the specific job each one do ?
how both have relation with each other e.g how do they interact with each other to make a django website ?

A: The urls.py in your project folder are the "base" URLs for your site.
You can then forward requests made on a certain route to your app's urls.py using include.
Here is an example :
# project's urls.py

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('myapp/', include("myapp.urls")) # requests on a route starting with "myapp/" will be forwarded to "myapp.urls"
]

And then in myapp.urls :
# myapp's urls.py
from django.urls import path
from . import views

app_name = "myapp"

urlpatterns = [
    path("", views.index, name="index"),
    path("contact/", views.contact, name="contact")
]

So for instance, if I request "localhost:8000/myapp/contact", your project's urls.py will detect that it must forward the request to your app myapp, which will call its view views.contact.


text:
Q: Why does an indexer property in a class need a private array field and not just an integer telling the object its index? I thought the point of indexers was so that if you had an array or list of a certain class in something like a winform, you could just get the index of the object by typing myObject[index].SomeMethod();
Why do examples about indexers in C# need for a class to have a private field of an array, and then the public indexer property gets the index from that private array? Wouldn't it be better to just hold an integer that tells it what its index is? What's the difference?

A: The class needs to know exactly what the index is referencing.
An integer containing just the index doesn't tell the class what object it's supposed to retrieve with that index, especially if that class isn't itself a collection (but this can be the case even with a collection type depending on its implementation). For example, if myObject is an instance of MyClass and MyClass isn't a collection, what exactly would myObject[index] refer to? The calling code needs to know this (since it expects a return type that contains a SomeMethod() method), but only MyClass can tell the calling code exactly how its indexer works since the indexer is part of its class definition.
In short, think of the indexer as the interface — in fact, you can declare an indexer on an interface:
public interface IFooList
{
    Foo this[int i] { get; set; }
}

— and the underlying collection as the implementation.
You don't need a private array field — you could just as easily use a collection that's already being exposed as an auto-implemented public property for example (although this is usually bad practice since now you have two potentially different methods of accessing that collection instead of just one):
public IList<Foo> FooList { get; } = new List<Foo>();

public Foo this[int i]
{
    get { return FooList[i]; }
    set { FooList[i] = value; }
}

You could even use something that's not a collection entirely, and write custom logic for the index within the indexer definition. But the point is that the indexer needs to know exactly what to look for.


text:
Q: JS regular expression engine - recursion w/ limited number of levels Using: JavaScript regular expressions
https://regex101.com/r/bWkBpD/2
function {
  if () {
    if {}
  }
}

// I do not want to match this (only 3 level nesting not 4):

function {
  if () {
    if {
      if {}
    }
  }
}

I know JavaScript regular expression engine does not includes balancing groups, recursion or whatever. This is reason why I need a limited number of levels.
What I have to match (only 3 level nesting):
function {
  if () {
    if {}
  }
}


text:
Q: What invisible flicker do different types of light bulbs have? What waveform does the light coming off different types of artificial light sources have and (of course) what are the underlying physical reason for them?

I was inspired to ask this question because of several things I have been hearing lately.
Firstly, there was a recent TED talk about how LED bulbs can be used to transmit data.  Researchers have been working on the problem for a little while now and they've made a fairly impressive product, but it was only recently made possible by the LED technology, which has such a fast response that it can easily compare to the transfer rates of electric information condiuits that we normally use.
My understanding is that incandescent bulbs flicker because they have 60 Hz AC power being pulsed through them.  In fact, I think 60 Hz was chosen in the first place because it was a threshold that was unnoticeable to humans.  Looking at a high speed youtube video of such a bulb demonstrates that it has a very significant lag time responding to both the normal electrical phasor and being turned off.  In other words, it flickers but it doesn't go dark at any point in the AC waveform.
Looking for more information, however, I was a little disappointed, since nothing seemed to give a graph of lumens emitted over time for all different kinds of bulbs.  Of course, there isn't just one relevant time scale.  A light could flicker with 60 Hz and also flicker with 2000 Hz (I just made that up).  I'm interested in the complete picture of what lights exhibit what patterns.

A: Old fashioned (or very cheap) fluorescent bulbs flicker at twice the mains frequency if they use magnetic ballasts driven directly from the AC.
Modern fluorescent bulbs use an electric ballast that runs at 5khz - 40khz (for CFLS), then the electrons stay excited for longer than the switching frequency and the light output is constant.
LEDs are constant, unless you count the individual electrons moving over the diode junction!
High power LEDs normally have their own driver chip which carefully controls the current and voltage of the diode so they are less sensitive to the supply power.
Solid state lasers are essentially the same as LEDs.
edit: some very cheap LED lights, eg christmas decoration are driven directly from AC - using the diodes themselves to rectify it - these will flicker at the 1/2 mains frequency.

A: LEDs are often driven so that they flicker at whatever frequency the driver designer chose. Some types of LEDs are prone to burning out when driven with a constant current and it is possible to get a higher average brightness by turning them on for short pulses. LED dimming is also achieved by pulse width modulation, rather than changing the peak current.

A: Incandescent lamps have a lot of thermal inertia. Because they are hot metal, the filament can't heat up and cool down 120 times per second, so they don't flicker.
Flourescent lamps work by a glowing gas (Mercury) that gets phosphor glowing on the inside of the tube. White phosphor is pretty fast, so a cheap flourescent can flicker. Radar and sonar displays used to use a very slow green phosphor that would not flicker, but who wants a green light bulb?
LEDs are super fast. If you drive them with DC, they will not flicker. But, LEDs use very low voltage (around 1 volt) and converting 12 or 120 volts to a small DC using resistors or transistor in old-fashioned "linear" regulation wastes most of the power. So, folks usually pulse width modulate (PWM) LEDs. This turns them on and off at a very fast rate. It wastes very little power and allows you to vary the brightness by changing the % of the time it is on. If the on/off frequency is high enough, you can't see any flicker. One issue is that if you move your head quickly, the LED will look like a dotted line. Modern car tail lights have this problem.

A: Incandescent light bulbs flicker at twice the AC frequency, because the filament grows a bit hotter each time the current peaks. So: 50 Hz AC => 100 Hz flicker; 60 Hz AC => 120 Hz flicker.
Fluorescent bulbs do the same, for the same reason. Their flicker has a higher amplitude than incandescent bulbs, because there's no thermal inertia.
LEDs... I don't know. I'm fairly sure there must be at least some residual flicker, even if internally they are being fed DC, because that DC is never going to be 100% filtered. But whether any filtering occurs, and if so then how much, I don't know. Or maybe they have some kind of switching invertor and their flicker is at a much higher frequency than the AC mains.


text:
Q: How to prove that $e^x +1- \sin(x) > 0$? So I have found a solution but I don't think it's the best one.
So by saying that $$ |\sin x|\le 1 (\forall x \in R) \Rightarrow -1 \le \sin x \le 1 \Rightarrow 0 \le 1- \sin x$$ and if we add $$ +e^x $$ on both sides we get $$ e^x \le e^x +1 - \sin x $$ but because $$ e^x > 0 , \forall x \in R $$ we finally get:
$$ 0 < e^x \leq e^x + 1 -\sin x   \Rightarrow e^x+1-\sin x > 0$$
Is there a better way to prove this? Thanks for your time.

A: You can find the derivative, thats the other way i can suggest. Of the function $F(x)=e^x +1- \sin(x) $


text:
Q: How do emojis sort in a dictionary? Oxford Dictionaries Word of the Year 2015 is…

AKA the 'Face with Tears of Joy' emoji.

Where will they file this in their dictionary?
Have the people at Oxford made a large mistake, or is there a standard method for dealing with non alphanumeric symbols such as

@#$%^(*&";

etc.?


text:
Q: Adding foreign key to MySQL Database I have a DigitalOcean LAMP instance to do my homework for class, however scripts that run on the lab machines error on my server when trying to add foreign keys.
--------------
create table STATE (
statecode   char(2),
description varchar(30) NOT NULL,
constraint state_statecode_pk primary key (statecode))
--------------

Query OK, 0 rows affected (0.02 sec)

--------------
create table EMPLOYER (
companyname     varchar(30) NOT NULL,
division        varchar(30) NOT NULL,
address         varchar(30),
city            varchar(20),
statecode       char(2) not null,
zipcode         int(5),
constraint employer_coname_div_pk PRIMARY KEY (companyname, division),
constraint employer_statecode_fk foreign key (statecode) references state(statecode))

--------------

ERROR 1215 (HY000): Cannot add foreign key constraint

What kind of differences could cause it to not work on my machine, but work on the lab machines?
version on my computer: 5.6.19
version on lab machine: 5.6.21
show create table employer from lab machine:
| employer | CREATE TABLE `employer` (
  `companyname` varchar(30) NOT NULL,
  `division` varchar(30) NOT NULL,
  `address` varchar(30) DEFAULT NULL,
  `city` varchar(20) DEFAULT NULL,
  `statecode` char(2) NOT NULL,
  `zipcode` int(5) DEFAULT NULL,
  PRIMARY KEY (`companyname`,`division`),
  KEY `employer_statecode_fk` (`statecode`),
  CONSTRAINT `employer_statecode_fk` FOREIGN KEY (`statecode`) REFERENCES `state` (`statecode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |

They're both InnoDB. The lab machine charset is utf8 while the server is latin1, but that shouldn't cause an error with creating the constraint.

A: Please check the engine of the database table on different machines . For foreign key constraints InnoDB is supported.
ENGINE=InnoDB should show up in "show create table tablename"
Database schema should be created like :
create table STATE (
statecode   char(2),
description varchar(30) NOT NULL,
constraint state_statecode_pk primary key (statecode)) ENGINE=InnoDB;

A: Since the case sensitivity depends on the machine's filesystem, the tables of the lab machine (windows) were case insensitive, where the tables on the server (ubuntu) were case sensitive.
Because of this, referencing the sales table on Windows or OS X works because SALES and sales both reference the same table, where as on Ubuntu the table sales doesn't exist, and you can't make a foreign key to a table that doesn't exist.


text:
Q: How do I symlink certain directories in /home to an SSD? In Is a 40GB SSD practical to use for ' / ' Jorge describes how he symlinks things in his /home that would benefit from being on an SSD. How is this done?
I've figured that I need to do the following:

*

*Create a directory on the SSD to hold what I want to link from /home, e.g. mkdir /var/jorge.

*Move the things from /home that should be on the SSD, e.g. mv /home/jorge/.config /var/jorge.

*Create the symlinks, e.g. ln -s /var/jorge/.config /home/jorge/.config.

Is this the correct way to proceed? Do I need to do it from a live CD?

A: You can do it from a Live CD, but if you logout from a graphical session and switch to a virtual console using Ctrl + Alt + F1, you'll be able to move the folders too.
Your steps are correct, some expansion below:

*

*Switch to a virtual console and login

*Mount the SSD if needed, that can be as easy as:
sudo mkdir /media/ssd-store
sudo mount /dev/disk/by-label/YOUR-SSD-NAME /media/ssd-store

You can use tab-completion after /dev/disk/by-label/. This only works if your partition has a label, otherwise you need to replace it by /dev/sdXY

*create a folder that holds the files from home:
sudo mkdir -p /media/ssd-store/home/jorge

If you've a custom umask setting like 0027, you need to sudo chmod 755 /media/ssd-store. You can check your umask setting by running umask (defaults to 0022)

*Change the ownership if needed, so the user can always create more symlinks if needed:
sudo chown jorge: /media/ssd-store/home/jorge

*Move the files (add sudo if you do not own /media/ssd-store/home/jorge):
mv /home/jorge/.config /media/ssd-store/home/jorge/

*Create the symlink:
ln -s /media/ssd-store/home/jorge/.config /home/jorge/

Notes on the above: you should add an entry in /etc/fstab for automounting the SSD. Use sudo blkid to determine the UUID for your SSD partition and add the next line to /etc/fstab:
UUID=[uuid] /media/ssd-store ext4 relatime,errors=remount-ro,discard 0 2


text:
Q: Java Swing JScrollPane shows different output than the one the book shows. The row labels just vanish in Java The following code does not give me the output that it should. The output that it should give is shown below:
Output that I want to get
Instead of that output I got an output which is like the one below:
Wrong output that I get now
Things that I have noted that I'm not getting are:

*

*I don't get the ScrollBars both vertical and horizontal.

*I don't get the row headers for each row which are in the panel 'p'.

*The format also seems disturbed. And when the program starts, the radio buttons are not visible until I move the mouse over them.

This code is from the Java Swing book of O'REILLY (Chapter 11) using Eclipse IDE.

package khan.ajmal.oreilly.swing;

import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class BasicWindowMonitor extends WindowAdapter {

    @Override
    public void windowClosing(WindowEvent e) {
        Window w = e.getWindow();
        w.setVisible(false);
        w.dispose();
        System.exit(0);
    }
}

/A JScrollPane with a component larger than the application window./
package khan.ajmal.oreilly.swing.Chapter11_SpecialtyPanesAndLayoutManagers;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.ScrollPaneConstants;

import khan.ajmal.oreilly.swing.BasicWindowMonitor;

public class ScrollDemo2 extends JFrame {
    JScrollPane scrollPane = new JScrollPane();

// Constructor
    public ScrollDemo2() {
        super("JScrollPane Demonstration");

    /* Add in some JViewports for the column and row headers */
        JViewport jv1 = new JViewport();
        jv1.setView(new JLabel(
            new ImageIcon(
                       "C:/Users/Ajmal/workspace/OreillySwing/src/khan/ajmal/oreilly/swing/Chapter11_SpecialtyPanesAndLayoutManagers/columnLabel.jpg")));

        scrollPane.setColumnHeader(jv1);

        JViewport jv2 = new JViewport();
        jv2.setView(new JLabel(
            new ImageIcon(
                    "C:/Users/Ajmal/workspace/OreillySwing/src/khan/ajmal/oreilly/swing/Chapter11_SpecialtyPanesAndLayoutManagers/rowLabel.jpg")));
    scrollPane.setRowHeader(jv2);

    /* And throw in an information button */
    JButton jb1 = new JButton(
            new ImageIcon(
                    "C:/Users/Ajmal/workspace/OreillySwing/src/khan/ajmal/oreilly/swing/Chapter11_SpecialtyPanesAndLayoutManagers/question.jpg"));
    jb1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String message = "This is an active corner!";
            String title = "Information";
            int type = JOptionPane.INFORMATION_MESSAGE;
            JOptionPane.showMessageDialog(null, message, title, type);
        }// method actionPerformed ends here.
    }// Definition of inner class ActionListener ends here.
    );/* Passing arguments to method addActionListener ends here. */
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, jb1);
    setSize(300, 200);
    addWindowListener(new BasicWindowMonitor());
    init();
    setVisible(true);
}// Constructor ends here.

private void init() {
    JRadioButton form[][] = new JRadioButton[12][5];
    String counts[] = { " ", "0-1", "2-5", "6-10", "11-100", "101+" };
    String categories[] = { "Household", "Office", "Extended Family",
            "Company (US)", "Company (World)", "Team", "Will",
            "Birthday Card List", "High School", "Country", "Continent",
            "Planet" };
    JPanel p = new JPanel();
    p.setSize(600, 400);
    p.setLayout(new GridLayout(13, 6, 10, 0));

    for (int row = 0; row < 13; row++) {
        // creating a button group in each iteration of the row loop
        ButtonGroup bg = new ButtonGroup();
        for (int col = 0; col < 6; col++) {
            // We need to create column headers in the first row
            if (row == 0)
                p.add(new JLabel(counts[col]));
            else {
                /*
                 * When the control moves to a new row, check for the
                 * column. In the first column put row headers
                 */
                if (col == 0) {
                    p.add(new JLabel(categories[row - 1]));/*
                                                             * row will have
                                                             * at least
                                                             * value of 1
                                                             * when control
                                                             * is at this
                                                             * line.
                                                             */
                } else {
                    form[row - 1][col - 1] = new JRadioButton();
                    bg.add(form[row - 1][col - 1]);/*
                                                     * add this button to
                                                     * the button group
                                                     */
                    p.add(form[row - 1][col - 1]);
                }
            }
        }// col for loop ends here.
    }// row for loop ends here.

    // Adding the panel to a scrollpane
    // scrollPane = new JScrollPane(p);
    scrollPane.add(p);
    // adding the scrollpane to the contentpane of the frame
    getContentPane().add(scrollPane, BorderLayout.CENTER);
}// method init ends here.

public static void main(String[] args) {
    new ScrollDemo2();
}// method main ends here.

}// class ScrollDemo2 ends here.

A: There are some issues with the order in which components are initialized in your code. Those are a bit hard to pick out, so I took the liberty of re-organizing your code to make things more clear. I think you'll find this code more workable. (Note: I removed the import of the BasicWindowAdapter and your calls to ImageIcon)
Some take-away tips:

*

*Try to use a given component in only one method. Your code was accessing scrollPane from both the Constructor and from init().

*Don't hesitate to create methods that do something very specific, that take specific input, and provide specific output. For example, createScrollPane() below takes a JPanel and returns a JScrollPane. It's clear what the method does, and it does not require the use of variables with class scope.

*Try not to build the UI in the constructor. A good practice is to create an init() method, and have init() call other methods to build specific parts of the UI.

Here's your revamped code:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.ScrollPaneConstants;

public class ScrollDemo2 extends JFrame {

// Constructor
public ScrollDemo2() {
    super("JScrollPane Demonstration");
    init();
    setSize(300, 200);
    setVisible(true);
}// Constructor ends here.

private void init() {
    JPanel panel = createFormPanel();
    JScrollPane scrollPane = createScrollPane(panel);
    this.getContentPane().add(scrollPane, BorderLayout.CENTER);
}// method init ends here.

private JPanel createFormPanel() {
    JRadioButton form[][] = new JRadioButton[12][5];

    JPanel p = new JPanel();
    p.setSize(600, 400);
    p.setLayout(new GridLayout(13, 6, 10, 0));

    for (int row = 0; row < 13; row++) {
        // creating a button group in each iteration of the row loop
        ButtonGroup bg = new ButtonGroup();
        for (int col = 0; col < 6; col++) {
            // We need to create column headers in the first row
            if (row == 0)
                p.add(new JLabel(COUNTS[col]));
            else {
                /*
                 * When the control moves to a new row, check for the
                 * column. In the first column put row headers
                 */
                if (col == 0) {
                    p.add(new JLabel(CATEGORIES[row - 1]));/*
                                                             * row will have
                                                             * at least
                                                             * value of 1
                                                             * when control
                                                             * is at this
                                                             * line.
                                                             */
                } else {
                    form[row - 1][col - 1] = new JRadioButton();
                    bg.add(form[row - 1][col - 1]);/*
                                                     * add this button to
                                                     * the button group
                                                     */
                    p.add(form[row - 1][col - 1]);
                }
            }
        }// col for loop ends here.
    }// row for loop ends here.
    return p;
}

private JScrollPane createScrollPane(JPanel panel) {
    JScrollPane scrollPane = new JScrollPane(panel);

    /* Add in some JViewports for the column and row headers */
    JViewport jv1 = new JViewport();
    jv1.setView(new JLabel("COL LABEL"));

    scrollPane.setColumnHeader(jv1);

    JViewport jv2 = new JViewport();
    jv2.setView(new JLabel("ROW LABEL"));
    scrollPane.setRowHeader(jv2);

    /* And throw in an information button */
    JButton jb1 = new JButton("?");
    jb1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String message = "This is an active corner!";
            String title = "Information";
            int type = JOptionPane.INFORMATION_MESSAGE;
            JOptionPane.showMessageDialog(null, message, title, type);
        }// method actionPerformed ends here.
    }// Definition of inner class ActionListener ends here.
    );/* Passing arguments to method addActionListener ends here. */
    scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, jb1);

    return scrollPane;
}

public static void main(String[] args) {
    new ScrollDemo2();
}// method main ends here.

public static final String[] COUNTS = { " ", "0-1", "2-5", "6-10", "11-100", "101+" };
public static final String[] CATEGORIES = { "Household", "Office", "Extended Family",
        "Company (US)", "Company (World)", "Team", "Will",
        "Birthday Card List", "High School", "Country", "Continent",
        "Planet" };

}// class ScrollDemo2 ends here.


text:
Q: What do parallel lines in a fitted values vs. residual plot mean? How should I transform my data?
Possible Duplicate:
Parallel lines on residual vs fitted plot

I'm regressing the time it took for an event to happen on another, normally-distributed predictor.
When I plot the fitted values against the residuals, the data line up in a series of parallel lines (with negative slopes).
The Q-Q plot is sigmoidal, but not too too bad.
Any suggestions for what I should do to my data?
Transform the response variable? Use a generalized linear model (glm) instead? If the latter, what family of error distribution should I use?
Many, many thanks!

A: You said the qq-plot has a sigmoidal shape but not too bad.  If it's not too bad then just use what you have.  Your series of parallel lines with negative slopes is hard to imagine as well.  It does sound like there's some pattern happening in the data that your regression isn't explaining.  Without seeing your actual figures it's hard to tell if you have any problem at all.
Time variables often have tails out to the right.  Often a useful transform is rate.  Right now you might have the time it took something to occur in seconds.  Let's say it took 2s for something to occur.  The rate would be 0.5 occurrences / second.  The transform is just 1/t.  That might fix your qq-plot but it would just change the parallel lines, not eliminate them.


text:
Q: Spark repartition to specific resources Given a Spark cluster with a mix of machine types (e.g. with and without GPU).  I want to run a Spark pipeline where some stages run on machines with no GPU and some stags with GPU
I'm open to using any cluster manager (YARN, Kubernetes, Mesos, etc..)
import org.apache.spark.sql.functions.udf
val cpu_only = udf((v: String) => v)
val gpu_only = udf((v: String) => v)

val dataset = Seq((0, "hello"), (1, "world")).toDF("id", "text")

dataset
  .withColumn("from_cpu", cpu_only('text))
  .withColumn("from_gpu", gpu_only('from_cpu))
  .show

/* conceptual need "repartitionToResourcePool" (which doesn't exist)
  dataset
      .repartitionToResourcePool("CPU_ONLY")
      .withColumn("from_cpu", cpu_only('text))
      .repartitionToResourcePool("GPU_ONLY")
      .withColumn("from_gpu", gpu_only('from_cpu))
      .show
  */

In the case above, the the cpu_only UDF code should only be executed on machines with no GPU and gpu_only should only be executed on machines with GPUs
Any pointers on how to achieve this scenario?

A: I was able to do this with just a bit of customization to Spark.
Two basic changes

*

*Add new RDD to allow manually setting preferredLocations.

*Add ability to mark a preferredLocations as fixed.  This prevents the scheduler from using Workers that aren't in the preferredLocations list

Code is available on github spark-fixed-location
Example usage
import org.apache.spark.sql.functions.udf
val cpu_only = udf((v: String) => v)
val gpu_only = udf((v: String) => v)

val dataset = Seq((0, "hello"), (1, "world")).toDF("id", "text")

import example.extend_spark_api._ // NEW

val cpu = sc.getWorkersFromTag("CPU") // NEW
val gpu = sc.getWorkersFromTag("GPU") // NEW

dataset
  .repartitionTo(cpu) // NEW
  .withColumn("from_cpu", cpu_only('text))
  .repartitionTo(gpu) // NEW
  .withColumn("from_gpu", gpu_only('from_cpu))
  .show


text:
Q: Trying to hide domain from my android application if someone uses url snooper or whireshark I have an android application that is connected with my website. This app shows some content from my database in my server that is connected successfully with cloudflare. While i open my application from bluestacks and i snoop it with URL snooper it doesn't reveal my website url. It only shows ssl urls. That's the point. I want to hide my domain if someone tries to snoop my application with these programs.
The problem is that i have build the same app in another language in another website with the same things. Admin Panel, database etc. While im trying to snoop my app with URL snooper or Whireshark, it reveals my domain. I don't want this to happen. I want my domain to be hidden from everyone who tries to snoop my app like i do in my first android app. I have the same options like my other website in my cloudflare. The only difference is that i use wordpress in my first website and in the second one i don't use wordpress. Just a blank page. I don't have any public content. Everything else is the same.
https://i.gyazo.com/a7f382758685e89edc3831f671c7beb3.png
I found some threads here that they say that domain cannot be hidden while the app takes requests from the server. But i did it in my first application. I was navigating everywhere in my app and my domain was hidden.
Before i used cloudflare in my first website the domain was shown. After i used cloudflare i figured out that domain was not visible anymore while using url snooper.
Why i can't do the same in my second website? What you believe can cause that?


text:
Q: how to get last x facebook message + answer with php? Is there a way to get my latest facebook message +comments to show on my own  website?

A: I would recommend looking into Facebook Connect, which provides API's for exactly the functionality you're looking for.

A: Facebook has fairly well-documented developer resources; you can get started at http://developers.facebook.com/, which should lead you to a few options for what you want to do.  In the deeper integration stuff, PHP integration is pretty well-supported, so you should be able to find good information.
Once you've gotten a handle on the general structure of their API/Connect framework, the specific information you need is in their dev wiki documentation for Message (FQL).


text:
Q: NPM, package.json - how to add dependency with "@" in name I am trying to install new Angular 2 RC in my project. Module name in NPM was changed from angular2 to @angular/core. But when I add it to my package.json, it tries to install module angular/core instead and doesn't find it. When I type
npm install @angular/core

in console, then Angular 2 is properly installed. Do you know why package.json skipps "@" in module name and how to fix it?
//Edit: I found out that it's not just a name, but "@" indicates a scoped package. Anyway, this should work using package.json (as described in documentation), but for some reason doesn't.
I am using Visual Studio 2015 with latest updates and my project is an ASP.NET MVC 6 project (which comes equipped with npm support)

A: You should use the package.json from Angular2 Docs:
{
  "dependencies": {
    "@angular/common": "2.0.0-rc.0",
    "@angular/compiler": "2.0.0-rc.0",
    "@angular/core": "2.0.0-rc.0",
    "@angular/http": "2.0.0-rc.0",
    "@angular/platform-browser": "2.0.0-rc.0",
    "@angular/platform-browser-dynamic": "2.0.0-rc.0",
    "@angular/router-deprecated": "2.0.0-rc.0",
    "@angular/upgrade": "2.0.0-rc.0",
    "systemjs": "0.19.27",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "zone.js": "^0.6.12",
    "angular2-in-memory-web-api": "0.0.5",
    "bootstrap": "^3.3.6"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings": "^0.8.1"
  }
}

Then make sure and run npm install in the root directory.

A: Thanks @Dov Benyomin Sohacheski, I wasn't aware of this file.
But unfortunately it didn't resolve my problem. The key was my usage of Visual Studio 2015 and possible outdated version of NPM that shipped with it. I installed Node.js and configured Visual Studio to use this version instead of built-in one and it started working.
Here is a tutorial of how to make VS use our own version of GIT instead of built-in one. Steps for NPM are basically the same. One important difference is you cannot just uncheck $(DevEnvDir)\Extensions\Microsoft\Web Tools\External, because there are also other tools, so you need to add location of NPM above it.
My final configuration:

Don't forget to restart VisualStudio after that.


text:
Q: How can this dom-to-vars code be shortened in JavaScript? Just found this code in a YouTube tutorial and found it to be very verbose:

So I thought, can't this be shortened? Isn't there some kind of ES2015 magic or so that can make this a one-liner?
The smartest that I could come up with was this:
const els = ['txtEmail', 'txtPassword', 'btnLogin', 'btnSignUp', 'btnLogout'];
const values = {};
for (var i=0; i<els.length; i++) {
  values[els[i]] = document.getElementById(els[i]);
}

This isn't much shorter but if there were more dom elements this would definitely pay off in the long run.
However, how can this be optimized to be as non-verbose as possible?

A: You could make a list of elements with map.
const ids = ["txtEmail", "txtPassword", "btnLogin", "btnSignUp", "btnLogout"];
const elems = ids.map(id => document.getElementById(id));

Or you could make an object with reduce.
const ids = ["txtEmail", "txtPassword", "btnLogin", "btnSignUp", "btnLogout"];
const elems = ids.reduce((obj, id) => {
    obj[id] = document.getElementById(id);
    return obj;
}, {});

A: With reduce
const els = ['txtEmail', 'txtPassword', 'btnLogin', 'btnSignUp', 'btnLogout'];
const elms = els.reduce( (o, id) => {
  o[id] = document.getElementById(id);
  return o
}, {} )

without the fat arrow
const els = ['txtEmail', 'txtPassword', 'btnLogin', 'btnSignUp', 'btnLogout'];
const elms = els.reduce( function (o, id) {
  o[id] = document.getElementById(id);
  return o
}, {} )

In the end, not sure what the benefit of it is....

A: Another solution
var fields={
txtEmail,
txtPassword
}

Object.keys(fields).forEach(e=>fields[e]=document.getElementById(e));

console.log(fields.txtEmail);

A: You can use destructuring assignment

const [txtEmail, txtPassword, btnLogin, btnSignUp, btnLogout] = [
      document.getElementById("txtEmail")
      , document.getElementById("txtPassword")
      , document.getElementById("btnLogin")
      , document.getElementById("btnSignUp")
      , document.getElementById("btnLogout")
      ];

console.log(txtEmail, txtPassword, btnLogin, btnSignUp, btnLogout);
<input id="txtEmail">
<input id="txtPassword">
<input id="btnLogin">
<input id="btnSignUp">
<input id="btnLogout">

Alternatively, using .querySelectorAll() with attribute begins with selector and spread element

const [txtEmail, txtPassword, btnLogin, btnSignUp, btnLogout] = [
      ...document.querySelectorAll("input[id^=txt]")
      , ...document.querySelectorAll("input[id^=btn]")
      ];

console.log(txtEmail, txtPassword, btnLogin, btnSignUp, btnLogout);
<input id="txtEmail">
<input id="txtPassword">
<input id="btnLogin">
<input id="btnSignUp">
<input id="btnLogout">


text:
Q: Should I style a DIV or its enclosed contents?

<fieldset style="position: absolute; top:8px; left: 136px; width: 136px; height: 64px;">
<legend> </legend>

Hello world

A second piece of text

</fieldset>

I am a CSS newbie and have googled & seen a lot of confllicting info on this.
If I want positioning, where does the style go? On the enclosing DIV? On the enclosed fieldset? On what the fieldset encloses? Some permutation thereof?

Do I even need an enclosing DIV around a FIELDSET?

A: A rule-of-thumb while creating CSS styles is that, as much as possible, it should be re-usable.
In the above example, you'd place the DIV absolutely using a CSS class and then position all the elements within the DIV relatively. You should (1) set the positions of the DIV, (2) remove the position of FIELDSET, (3) remove position of the inner DIV (ID=Label1), and (4) add a margin or padding to the inner DIV (ID=Label2).


text:
Q: Doctrine ORM in ZF2 giving "The target-entity Application\\Entity\\UserCmsPermission cannot be found in 'Application\\Entity\\User#cmsPermissions'." I have an existing ZF2 project to which I have added entities before, and I have just added a new entity by copying an existing one and changing the details as necessary. This UserCmsPermission entity links to the User entity via the User entity's cmsPermissions property.
I have redeployed the database using the following commands:
doctrine-module orm:schema-tool:drop --force
doctrine-module orm:schema-tool:create
doctrine-module data-fixture:import

This executes successfully with no errors at all. However, when I access my application I receive the following error:
The target-entity Application\\Entity\\UserCmsPermission cannot be found in
'Application\\Entity\\User#cmsPermissions'.

The relevant code from each entity is as follows:
module/Application/src/Application/Entity/User.php
<?php

/**
 * User model
 *
 *
 */

namespace Application\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Tilt\Entity\Base\User as TiltUser;

/**
 * @ORM\Entity
 */
class User extends TiltUser
{

    // … etc …

    /**
     * @var ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="UserChallenge", mappedBy="user", cascade={"all"})
     */
    protected $challenges;

    /**
     * @var ArrayCollection
     *
     * @ORM\OneToMany(targetEntity="UserCmsPermission", mappedBy="user", cascade={"all"})
     */
    protected $cmsPermissions;

    // … etc …

}

module/Application/src/Application/Entity/UserCmsPermission.php
<?php

/**
 * User CMS Permission model
 *
 *
 */

namespace Application\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Tilt\Exception\InvalidArgumentException;
use Tilt\Entity\Base\Entity as BaseEntity;

/**
 * @ORM\Entity
 */
class UserCmsPermission extends BaseEntity
{

    // … etc …

    /**
     * @var User
     *
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     * @ORM\ManyToOne(targetEntity="User", inversedBy="cmsPermissions", cascade={"all"})
     */
    protected $user;

    // … etc …

}

As far as I can tell, the code is correct, and I have also removed data/DoctrineORMModule/ in case the entity metadata was being cached, but this hasn't fixed the problem, and neither has restarting PHP5-FPM in case something was being cached there, so I've now run out of ideas.
Anyone got a clue as to what could be causing this to happen?

A: Finally figured out what is causing this. Doctrine throws this error if you are using a class map to load classes rather than the standard ZF2 autoloader and you've forgotten to update your class map, which was what I'd not done.
Simply running this in the project folder fixed it:
php vendor/zendframework/zendframework/bin/classmap_generator.php

Et voila.


text:
Q: How to Call the Generated file of filesaver.js into the backend code I used filesaver.js to allow me to download the file successfully.
var out = doc.getZip().generate({
type: "blob",
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
}) //Output the document using Data-URI
saveAs(out,"Details.docx");

I need to call the downloaded file into backend code to save the file in S3 Bucket.
I'd be grateful for getting any assistance.


text:
Q: Is It possible to use Lightning app exchange components in custom lightning app? i installed a lightning component from app exchange ,now i  want to use that component in my custom lightning app
is it possible??
<aura:app>
//code for adding components

</aura:app>

A: If you are working with components:
<aura:component >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    {!v.body}
</aura:component>

And in the controller ("mvc:CalendarComponent" as example, put here your component):
doInit : function(component, event, helper) {
    $A.createComponent(
        "mvc:CalendarComponent",
        {

        },
        function(newCmp){
            if (component.isValid()) {
                component.set("v.body", newCmp);
            }
        }
    );
}


text:
Q: Communication between Clients I have a very basic WCF SOAP Service that does simple tasks like commiting MYSQL commands sending the reply to the client.
Now, I want to be able to communicate something like an event inbetween two or more clients. If two clients active their events, I want the server to send them both the same specific information at the same time.
So basically, i am looking for a way to communicate between clients in a server-client based architecture.

A: I believe what you are looking for is a duplex contract which is documented here (and has code examples) I have not done this myself but this seems to be exactly what you are looking for.
Another method would be to publish a method to an esb bus/message queue and have your clients consume that.
Always remember in network communication that latency means you may not receieve this information at exactly the same time... but theres no way around that.


text:
Q: Цикл для слайдера картинок bootstrap Здравствуйте. На главную страницу 'base.html' хочу вывести слайдер изображений по три блока.

Код bootstrap (сама разметка):

Цикл:

{% for obj in img_list %}

{% endfor %}

Необходимо, чтобы цикл пробегал по всем изображением и группировал их по три, оборачивая в нужные теги.
В 'base.html':

                    {% include 'partners.html' %}

Посоветуйте решение. Спасибо!

A: Как вариант, который первый пришел в голову - отдавать в шаблон список списков, т.е img_list = [[img1,img2, img3], [img4,img5,img6]...] и затем уже:
{% for obj in img_list %}

    {% for el in obj %}

    {% endfor %}

{% endfor %}