text:
Q: Jenkins multibranch pipeline with pipeline-github plugin: limitation on first run I have a multibranch pipeline and I am using pipeline-github plugin to trigger by comments on PR and it's fine.
Now I would like to trigger only by PR comments.
But there is a limitation

The Pull Request's job/build must have run at least once for the trigger to be registered. If an initial run never takes place then the trigger won't be registered and cannot pickup on any comments made.

In my configuration, PR are discovered and not triggered by the basic-branch-build-strategies plugin so config.xml is created in the job/PR directory.
So I think I am missing only to register the trigger. How can I do programmatically? Is there a way to force a "fake" first run? What is the steps that I miss?
Thanks in advance, Pierluigi

A: solved with your suggestion adding:
def buildCause = currentBuild.getBuildCauses()[0]
echo "Build caused by: ${buildCause}\n"
if ("${buildCause}".contains("github.trigger.IssueCommentCause")) {
     echo "Build will proceed..."
} else {
     currentBuild.result = 'ABORTED'
     error('Skipping build…')
}

maybe it can be improved but it's fine


text:
Q: ¿Cual es mi error en esta consulta de MySQL? Intento llamar los datos de las columnas "RFC_UsuaAG" y "Nombre_AdminGeneral" de dos tablas diferentes las cuales son "admingeneral" y "usuariosag" pero al momento de ejecutar mi sintaxis me muestra como si tuviera dos datos iguales (los cuales no tengo)
Esta es la consulta que ejecuto:
SELECT DISTINCT RFC_UsuaAG, Nombre_AdminGeneral FROM usuariosag INNER JOIN admingeneral

Así es como me lo muestra:

Y estos son los datos que tengo en mis dos tablas "admingeneral" y "usuariosag":

Como ven no tengo datos repetidos y en la consulta que ejecuto me muestra otro "Miguel" y "yenis"
No sé si estoy mal o es un error en mi sintaxis, tal vez sea otra cosa no lo sé, cualquier ayuda se los agradecería mucho por favor :D

A: Trata siempre que hagas un select de los campos que precises, indicar antes de qué tabla vienen, a veces es posible que si un campo existe en dos tablas el motor de bbdd te devuelva error porque no sabe cual debe de coger.
P.e. (no se de donde está cada campo):
SELECT DISTINCT usuariosag.RFC_UsuaAG, admingeneral.Nombre_AdminGeneral FROM usuariosag INNER JOIN admingeneral

Además te falta poner el "on" al final como te han dicho primero indicando el nombredelatabla.campo quelasrelaciona=nombredeotratabla.campoquelasrelaciona

A: Muchas gracias por su ayuda @RobertoLeOr, @LuisCazares, @EduardoJaramilloLicea y @Jose la consulta ya me la ejecuta correctamente :D. Que tengan un excelente Miércoles y éxito en todo lo que hagan

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can i deploy an angular/firebase application? I've built an angular application for a school project and then I used firebase database for user login & stuff but I didn't used any sort of "npm i firebase..." command, so which steps do I have to follow to deploy this app with firebase?
I've read something on the internet about firebase project that where thereafter integrated with angular, but nothing about this kind of situation. If this kind of solution is uncomfortable for my case, there are any other method to deploy my app without using firebase?


text:
Q: Make gulp-scp2 ask for password I'm using gulp to move some folders in a remote directory via scp. Actually if I declare the password in the gulpfile it works fine. I rather want the password is required every time I try to run this task by the prompt, and not to put it visible in the file.
How can I do that?
My gulp task:
var scp = require('gulp-scp2');

gulp.task('deploy', function(done) {
    return gulp.src("./dist/**")
    .pipe(scp({
        host: 'localhost',
        username: 'saifer',
        dest: '/home/saifer/'
        }))
    .on('error', function(err) {
        console.log(err);
        });
   });

Starting the task this way obviously throws an error like:
Error: Authentication failure. Available authentication methods: publickey,gssapi-keyex,gssapi-with-mic,password

I'm looking for something to add the scp's passing object to let the gulp taks ask for a password before trying to connect

A: I believe prompting is an unrelenting problem. You should solve it with a separate module(or just with readline module from standard library). The solution below uses the prompt module:
const util = require('util')
const prompt = require('prompt')

var schema = {
  properties: {
    password: {
      hidden: true
    }
  }
};

prompt.start();

util.promisify(prompt.get)(schema).then(({ password }) => {
  var scp = require('gulp-scp2');

  gulp.task('deploy', function(done) {
    return gulp.src("./dist/**")
      .pipe(scp({
        host: 'localhost',
        username: 'saifer',
        dest: '/home/saifer/',
        password
      }))
      .on('error', function(err) {
        console.log(err);
      });
  });
});


text:
Q: Use Index and Match with multiple lookup values to get a single result Using INDEX & MATCH, I'm trying to copy some data across from one worksheet to another (both of which are in the same workbook). I want to grab the description of an item via its ID and it's subset lettering.
EXAMPLE:
Sheet 1 (Destination)
             Formula goes here
                     ↓
   +------+---+---------------
   |  A   | B |      C
---+------+---+---------------
 1 | R976 | A | Lazy Brown Dog
 2 | R976 | F | Grey Bird
 3 | R976 | D | Fox

Sheet 2 (Source)
   |  A   |    B   | C |      D
---+------+--------+---+---------------
 1 |  ID  | Subset |   | Description
---+------+--------+---+---------------
 2 | R976 |    A   |   | Lazy Brown Dog
 3 | R976 |    D   |   | Fox
 4 | R976 |    F   |   | Grey Bird

I want the formula in column C of Sheet 1 to grab the description from column D of Sheet 2, based off the ID in column A and the unique letter in column B.
Current:
=INDEX(A1:A4,MATCH(A1,Sheet2!A2:C4, 0))

What I'm trying to do:
=INDEX(A1:A4,MATCH(A1&B1,Sheet2!A2:C4, 0))

However, I'm getting an #NA even after using CTRL+SHIFT+ENTER.

A: I believe you want Sheet1!C2 to have a formula of:
{=INDEX(Sheet2!$D$1:$D$4,MATCH(Sheet1!$A2&Sheet1!$B2,Sheet2!$A$1:$A$4&Sheet2!$B$1:$B$4,0))}

Then copy that down to cells C3 and C4.


text:
Q: Xpath query for HTML - what am I doing wrong? I have this snippet of HTML inside a  that I'm trying to select with scrapy:

BY xxx

            September 07, 2015

This is the xpath selector I'm using to get the date:
response.selector.xpath('//p/@byline/text()')

Which returns a null result.
What am I doing wrong in my xpath selector?

A: //p/@byline/text() would match nothing since here you are basically trying to get the byline attribute from a p element and the provided p element does not have a byline attribute.
You can get the following sibling of the a element inside the div element having byline class:
In [1]: response.xpath("//p[contains(@class, 'byline')]//a/following-sibling::text()").extract()[0].strip()
Out[1]: u'September 07, 2015'

Alternatively, you may get all the text nodes from the appropriate p element and filter out the desired one by checking it with a regular expression pattern via re:test() function:
In [2]: response.xpath("//p[contains(@class, 'byline')]//text()[re:test(., '\w+ \d{2}, \d{4}')]").extract()[0].strip()
Out[2]: u'September 07, 2015'


text:
Q: Prevent the fieldset element's border from going through the legend element I have a fieldset, how can I position the legend inside a fieldset with a border? I want the border to go around the legend and not through the middle of it.
JSFiddle

fieldset {
  border: 0;
  padding: 0!important;
  margin: 0;
  min-width: 0;
  border: 1px solid red;
}
legend {
  padding: 0!important;
}
<fieldset>
  <legend>Title</legend>
</fieldset>

A: One option would be to float the legend element to the left:

fieldset {
  border: 2px solid #f00;
}
legend {
  float: left;
  width: 100%;
  padding: 0;
  font-weight: bold;
}
<fieldset>
  <legend>This is a legend</legend>
  Here is an input element: <input type="text" />
</fieldset>

Another approach would be to use an outline rather than a border:

fieldset {
  border: none;
  outline: 2px solid #f00;
}
legend {
  padding: 0.6em 0 0;
  font-weight: bold;
}
<fieldset>
  <legend>This is a legend</legend>
  Here is an input element: <input type="text" />
</fieldset>

Another approach would be to absolutely position the legend element relative to the parent fieldset element. This is probably the least flexible approach.

fieldset {
  border: 2px solid #f00;
  position: relative;
  padding-top: 2.6em; /* Displace the absolutely positioned legend */
}
legend {
  position: absolute;
  top: 0; left: 0;
  padding: 12px;
  font-weight: bold;
}
<fieldset>
  <legend>This is a legend</legend>
  Here is an input element: <input type="text" />
</fieldset>

A: A variation on the accepted answer (using SASS) which should work in all modern browsers (IE9+)
fieldset {
  > legend {
    float: left;

    + * {
      clear: both;
    }
  }
}

This will clear the next element after the float so you don't have to worry about your layout being messed up.


text:
Q: Android Canvas hardware acceleration Upon the link
Hardware accleration
I found that Canvas now supports hardware acceleration(mostly).
I downloaded the 4.2.2 AOSP(API Level 17) source and checked the code in external/skia/src/core/sKCanvas.cpp
I reached sKCanvas.cpp because this will finally get called via jni from Android Canvas class.
However, say drawPosText(), this function should be using hardware acceleration (open gl)
in the code. But when I checked this function in sKCanvas.cpp, I dont see any code related to open gl.
Did I misunderstand anything? This does confuse me.
Thanks.
void SkCanvas::drawPosText(const void* text, size_t byteLength,
                       const SkPoint pos[], const SkPaint& paint) {
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type)

while (iter.next()) {
    SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
    iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 0, 2,
                              dfp.paint());
}

LOOPER_END

}

A: You are looking at the software implementation. The hardware implementation is in frameworks/base/libs/hwui and frameworks/base/core/java/android/view/ (see HardwareRenderer.java, HardwareCanvas.java, GLES20Canvas.java, etc.)


text:
Q: Rails migration error with id default null I'm trying to get a legacy Rails app up and running and when I do a
   rake db:migrate
I get the following:
arx_rails [master●] % rake db:migrate
==  AddSessionsTable: migrating ===============================================
-- create_table(:sessions)
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead: CREATE TABLE `sessions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `session_id` varchar(255) NOT NULL, `data` text, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `block in execute'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in `create_table'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:434:in `create_table'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:466:in `block in method_missing'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `block in say_with_time'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `say_with_time'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:458:in `method_missing'
/Users/steve/projects/asu/arx_rails/db/migrate/20120825213542_add_sessions_table.rb:3:in `change'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:407:in `block (2 levels) in migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:407:in `block in migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:389:in `migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:528:in `migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `call'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:777:in `ddl_transaction'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:719:in `block in migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `each'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `up'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:in `migrate'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in `block (2 levels) in     <top (required)>'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/bin/ruby_executable_hooks:15:in `eval'
/Users/steve/.rvm/gems/ruby-1.9.3-p194/bin/ruby_executable_hooks:15:in `<main>'

The migration file is:
class AddSessionsTable < ActiveRecord::Migration
  def change
    create_table :sessions do |t|
      t.string :session_id, :null => false
      t.text :data
      t.timestamps
    end

    add_index :sessions, :session_id
    add_index :sessions, :updated_at
  end
end

Rails has always created the id field itself without having to have it explicitly coded in the migration file and that it makes it a primary key but without a default value. So, I'm wondering where it might be setting the id fields to a DEFAULT of NULL for newly created tables. In some configuration file somewhere I don't know about?
Has anyone seen this before?

A: It looks like an issue with Rails and MySQL:
https://github.com/rails/rails/pull/13247
In the notes, user "pjg" suggests the following:

With Rails 2.3.5, MySQL version 5.7.9 and mysql gem you need to have
  this bit as an initializer in
  config/initializers/abstract_mysql_adapter.rb:
class ActiveRecord::ConnectionAdapters::MysqlAdapter
  NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end

For mysql2 it should be
  config/initializers/abstract_mysql2_adapter.rb:
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
  NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end

Does that resolve the issue?
(EDIT: giving credit to solution provider)

A: For Rails 3.0.5 works that way:
class ActiveRecord::ConnectionAdapters::ColumnDefinition
  def sql_type
    type.to_sym == :primary_key ? 'int(11) auto_increment PRIMARY KEY' :  base.type_to_sql(type.to_sym, limit, precision, scale) rescue type
  end
end

A: With Rails 4.0.6 works fine:
 config/initializers/abstract_mysql2_adapter.rb:

class ActiveRecord::ConnectionAdapters::Mysql2Adapter
  NATIVE_DATABASE_TYPES[:primary_key] = "int(11) NOT NULL auto_increment PRIMARY KEY"
end

$ gem list mysql

* LOCAL GEMS *
mysql2 (0.3.18)


text:
Q: disk full because of tmpdir, safe to restart? My disk is full, an .MAD file in tmpdir takes up all the space on the file system (179G out of 189G)
from log:
[Warning] mysqld: Disk is full writing '/var/tmp/#sql_b6f_0.MAD' (Errcode: 28). Waiting for someone to free space
Can I stop mariadb, or do I need to free some space first and then stop it?

A: I was able to do a service mysqld stop and that deleted the files in tmpdir, that solved the problem....

A: Aaargh I had been searching for a fix for exactly 5 hours!
However I'm quite the beginner so yeah...
We're running our MariaDB on a SUSE Linux server in production, so stopping the whole mysql service was not a good option for me.
I ran a select query with nested selects using order by and inner join and this was my exact error:

Error Code: 1021 Disk full (/tmp/#sql_xxx_y.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")

By connecting to the server and running
cd /tmp
ls -al

or
ls-lh

I could find the culprits: #sql_xxx_y.MAD (as big as my total available space on tmp partition) and #sql_xxx_y.MAI size 8K (this must be the temp query). Also the *.MAD file would keep updating its date - yet another indicator of a still running query!
So this thread and this other one helped me figure it out:
mysql -u root -p
show processlist;
kill "thread_id (number in 1st col of the faulty query)";

I ran show processlist; twice after that: 1st time it showed my query as killed, the 2nd time my query had dissapeared from the list and the .MAD and .MAI files were gone and my disk space back in place.

Note: luckily my "faulty" query was an ad-hoc select, and did not alter any tables, nor was it set to run on a regular basis/ from some webservice or a client in production. So watch out, if your situation is different then all those threads where someone like me can easily waste 5h might still be useful :D


text:
Q: R kableExtra two center alignments: one for columns with linebreaks and another for others Output Desired
Using R kableExtra, I want to create the following table formatting in both PDF and HTML  output (at least the newline, centering and LaTeX equations are present) like the following.

The Code Attempt
The following R code renders the desired PDF output correctly:
#-------------------
library(tidyverse)
library(kableExtra)
#-------------------

fs_dt <- tibble(
  school = 1:4,
  nstudents = c(1471,890,1021,1587),
  nf_total = c(792,447,511,800),
  nf_intv = c(25,15,20,40),
  nsmokers = c(10,3,6,27)
)

fs_dt %>%
 kbl(booktabs = T,
    col.names = linebreak(c("School",
                  "No. of students",
                  "No. of females\n($M_i$)",
                  "No. of females interviewed\n($m_i$)",
                  "$\\sum_{i\\in\\mathcal{S}} y_{ij}$"),
                  align = "c"),
    escape = FALSE,
    align = "ccccc"
    ) %>%
  kable_styling(latex_options = c("striped","hold_position"))

However, the HTML output looks like the following where the third and fourth column names are missing.

The Question
How can we achieve both output using a single code without resorting to conditional coding (e.g., is_html_output()/is_latex_output())?

A: Here is a little problem.
Library kableExtra doesn't work with  \n in "HTML-mode".
What do you can to do?

*

*You can change \n to
 when knitting to HTML.

*It isn't conveniently, especially, when you have a lot of tables (changing \n to
 every time.
For this case you can use column_spec:
#your code above
escape = FALSE,
align = "ccccc"
) %>%
column_spec(3, width = "3cm") %>%
column_spec(4, width = "5.3cm") %>% #4.8 cm for PDF!!!
kable_styling(latex_options = c("striped","hold_position"))

You should determinate your width every time (sometimes for the every output), it is a little tedious.
Every solution have some underwater rocks, so we must fight with compromises :(


text:
Q: Newsstand App download when app is closed I am implementing a newsstand magazine app, which receives new issues via Urban Airship push notifications.
This works fine, as long as the app is in foreground or background, but as far as I know, the download should also be triggered when the app is completely closed. But sending a push with "content-available":1 in the payload does not do anything if my app is closed.
I set the required background mode in the targets properties and I use NKDontThrottleNewsstandContentNotifications to avoid problems with testing.
Am I missing something?
Shouldn't the push lead to my
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

being called with UIApplicationLaunchOptionsRemoteNotificationKey?
Help much appreciated!

A: As per this article,
developers that are developing Newsstand apps can deliver a new "souped-up" push notification that informs their app (rather than the user as push notifications normally do), that a new issue is ready to be downloaded. When a Newsstand app receives such a notification, it can download in the background if the device is on WiFi. The main limitation here is that each app can only send 1 of these push notifications per day, so at the moment developers cannot develop newspapers that deliver both a morning edition and evening edition – although I suspect this might change eventually.
So it can download only if the device is on Wifi.
These are other similar questions, new stand push and execute code, iOS newsstand: push notification does not launch the app in background, Newsstand restarts the download on Resuming and this iPhone Newsstand push registration Failure. Check if you are missing anything mentioned in those answers as well.
Here is the apple documentation on this and another blog on this.


text:
Q: Left/Right Cosets I am trying to understand left/right cosets in group theory.
Here is the example in my text:
Let $G = \lbrace 1, a, b, c, d ,e \rbrace$
Lets define the group operation $.$ by the following table, where the entry at row $x$ and column $y$ gives $x.y$
ex. $d.e = b$
 1 a b c d e
1 1 a b c d e
a a b 1 d e c
b b 1 a e c d
c c e d 1 b a
d d c e a 1 b
e e d c b a 1

This is no problem I understand this. But then we get the left and right cosets.
Let $G$ be a group and let $H \leq G$. A left coset of $H$ in $G$  ($G / H$) is a set of the form $gH = \lbrace gh : h \in H \rbrace$ for some $g \in G$. A right coset of $H$ in $G$ ($H$ \ $G$) is a set of the form $Hg = \lbrace hg : h \in H \rbrace$ for some $g \in G$.
Here are some examples that I am trying to figure out how they are generated. I guess i just do not understand the theory fully. I would like a little help explaining and possible a few more examples.
$\lbrace 1, a, b, c, d, e \rbrace / \lbrace 1, a, b \rbrace = \lbrace \lbrace1, a, b\rbrace , \lbrace c, d, e \rbrace\rbrace$
$\lbrace 1, a, b \rbrace$ \ $\lbrace 1, a, b, c, d, e\rbrace = \lbrace \lbrace 1, a, b \rbrace, \lbrace c, d, e \rbrace \rbrace$
$\lbrace 1, a, b, c, d, e \rbrace / \lbrace 1, c \rbrace = \lbrace \lbrace 1, c \rbrace, \lbrace a, d \rbrace, \lbrace b, e \rbrace \rbrace$
A few more examples which i want to figure out are:
$\lbrace 1, a, b, c, d, e \rbrace / \lbrace 1, e \rbrace = ?$
$\lbrace 1, d \rbrace$ \ $\lbrace 1, a, b, c, d, e \rbrace = ?$
Thanks!

A: The fundamental idea of a coset is that of taking a subgroup and "translating" it to fill up $G$.  A coset is just one such "translate."  No coset but $H$ itself is a subgroup of $G$, since they don't contain $1$, but there is a lot of ground that can be covered by treating them like elements of a group or set instead.  Since the cardinality of the cosets is constant, they represent ways of dividing up $G$, and you get nice formulas like $|G|=|H|[H:G]$, where $[H:G]$ is called the index of $H$ in $G$ and is equal to the number of cosets.
In my opinion, the biggest use of cosets is to set up the idea of a quotient group.  You may have seen the general idea -- formally dividing one mathematical structure by a substructure -- in other fields, like topology.  What you do in almost every case is add, to the laws defining your mathematical structure, another law that sets everything in the substructure equal to a point, or the identity, or zero.  Then you try to make everything else work.
In group theory, in particular, the set $G/H$ (or $H\backslash G$) always has an induced group structure when $H$ is a normal subgroup.  And in fact, it's easy most of the time to just think of its elements as abstract and indivisible group elements.  But sometimes, especially when you're proving that this works, it's useful to think of them as equivalence classes instead, where the equivalence relation is of the form $a\sim b$ when $a=bh$ for some $h\in H$.  Of course, such an equivalence class is just the coset $bH$.
I'll give one nice example with abelian groups before moving on.
The quotient group $\mathbb{R}/\mathbb{Z}$ is the set of cosets of the form $x+\mathbb{Z}$, with $(x+\mathbb{Z})+(y+\mathbb{Z})=(x+y)+\mathbb{Z}$, which is just the induced addition.  But you can also think of the elements of the group as numbers of the form $0\le x<1$, with addition being done "modulo $\mathbb{Z}$": that is, $x+y$ in $\mathbb{R}/\mathbb{Z}$ is equal to the fractional part of $x+y$ in $\mathbb{R}$.  So all we really have is a circle with an addition operation.  One place where this pops up is the group formed by numbers $e^{i\theta}$, the unit circle in $\mathbb{C}$, under multiplication.
(Another, weirder example is $\mathbb{R}/\mathbb{Q}$.  I don't know much about it in terms of group theory, but it gives rise to a standard example of a non-measurable set in analysis.)
Another use of cosets will pop up when you study group actions.  I think this is just called the coset action.  Basically, given a subgroup $H$, $G$ acts on $G/H$ by multiplication: $(g,kH)\mapsto gkH$.  Surprisingly, this action works differently than $G$'s normal multiplication on itself.  I don't know any good examples of this.
Now let's look at the coset questions you mentioned.
First, the line $\lbrace 1,a,b,c,d,e\rbrace=\lbrace\lbrace 1,a,b\rbrace,\lbrace c,d,e\rbrace\rbrace$ looks like a typo or something.
Now let's look at the right cosets of $\lbrace 1,a,b\rbrace$ in $G$.  If you look at the top left corner of the multiplication table, you see that right multiplication by $a$ or $b$ just gives you the same set $\lbrace 1,a,b\rbrace$, though its elements are permuted.  Multiplying by $c,d,$ or $e$ gives something different.  We don't have to check that these all give the same coset, since the sizes of the cosets are identical.
In the second example, you can look at the two columns labeled $1$ and $c$.  Then just scan down the rows: $a\mapsto\lbrace a,d\rbrace,b\mapsto\lbrace b,e\rbrace,c\mapsto\lbrace c,1\rbrace$, and so on.  These are all cosets, and identifying three distinct ones is easy.  They also show you something important: if, for example, $aH=\lbrace a,d\rbrace$, you know for a fact that $dH$ is the same set, simply because $H$ contains $1$.  Thus, the elements of a coset always give the same coset when multiplied by the subgroup.
Now let's do the same thing for the left cosets of $\lbrace 1,e\rbrace$.  Again, ignore everything but the $1$ and $e$ columns, and scan down.  We get $aH=\lbrace a,c\rbrace =cH,bH=\lbrace b,d\rbrace =dH$.  And, of course, $eH=H$ since $e\in H$.
The right cosets of $\lbrace 1,d\rbrace$ will be similar, but you'll be using the rows $1$ and $d$ instead of columns.
Good luck, and I hope this was at least somewhat helpful!
Also, what book are you using?  I learned all this from Artin, but it's possible that you might be getting a different perspective if you have a different book.

A: gprime, thinking about cosets in the following context may help you out. Leg $G$ be $\mathbb{R}^3$, the group operation will be vector addition. Suppose you want to know the left cosets of $H$, where $H$ is a straight line through the origin, which as you know, is a subspace. You look at the sets "$x+H$". Fix such an $x$, and see what happens when you add $x+h_1$, $x+h_2$, etc. where $h_1, h_2, ...$ are elements of $H$. You get a straight line that is parallel to $H$, but no longer passes through the origin. Which point does it surely pass through? For one, $x$, because, being $H$ a subspace of $\mathbb{R}^3$, $x+0$ is one of the elements of $x+H$. If you change the $x$ for $y$, another point not in the same straight line that is $x+H$, you'll obtain another straight line parallel to $H$. The left cosets (which in this case are the same as the right cosets, because vector addition is commutative) are thus all straight lines parallel to $H$. Since in this case the left and right cosets are the same, all these parallel straight lines form a group themselves, with the group operation defined simply as this: to add two straight lines, just take one point from on one of them, another point on the other, and add them, and all points that you obtain doing this will be a new straight line parallel to $H$. This new group is called the quotient group.
As your textbook says, however not all left cosets will be right cosets, in which case there's no defining a quotient group.
Well, I hope I didn't make it worse, but that particular example was helpful for me.

A: Some general notes: the notation G/H is used to denote the set of left cosets of H in G. Note that this is a set whose elements are also sets (in particular, they are the left cosets of H). Similarly, the notation H\G is used to denote the set of right cosets of H in G; again, this is a set whose elements are sets.
So, let's look at the first three equations. Unfortunately, the first one makes no sense (OP has since edited the first equation), so let's start with the second one.
Notationally, as per what I wrote above, {1,a,b} \ {1,a,b,c,d,e} denotes the set of right cosets of {1,a,b}. To actually compute this, you take each element of H={1,a,b} and multiply on the right by each element of G={1,a,b,c,d,e}. So for example:
H*1 = {1,a,b}*1 = {1*1, a*1, b*1} = {1,a,b} = H
But that's too easy. Try the element a:
H*a = {1,a,b}*a = {1*a, a*a, b*a} = {a,b,1} = H, where we're using the multiplication table given to figure out each of these products.
Proceed similarly for each of the remaining elements of G (which are b,c,d,e). That is, compute the cosets H*b, H*c, H*d, H*e in exactly the same way we did above. You should find that every coset is either H or {c,d,e}. Thus, H\G = { H , {c,d,e} }.
For the third equation, you want to compute the left cosets of the subset {1,c}. You do this exactly as I've done above, except remember to multiply on the left.
For the two examples you'd like to see worked out, we again proceed exactly as above. The only difference is that the first example is left cosets of {1,e} while the second example is right cosets of {1,d}.
I highly recommend working through these examples on your own. Working with cosets can be a little goofy at first, but doing the legwork on your own is really invaluable.

A: Cosets arise when you want to model the idea that certain elements of a group are effectively equal.
To see this, rather that looking at one coset at a time it is best to think of all possible cosets of a subgroup. Then you will find that cosets partition a group $G$ into equivalence classes such that two elements of a class differ by an element of the subgroup $H$.
For example sometimes in number theory we do not want to distinguish two numbers that differ by a multiple of a given number $n$. Say $n=4$. Then let $G$ be the set of integers under addition and $H$ be the set of multiples of $4$. The cosets of $H$ are
$$H\cdot 0=\{\ldots,-4,0,4,8,\ldots\}$$
$$H\cdot 1=\{\ldots,-3,1,5,9,\ldots\}$$
$$H\cdot 2=\{\ldots,-2,2,6,10,\ldots\}$$
$$H\cdot 3=\{\ldots,-1,3,7,11,\ldots\}$$
$$H\cdot 4=\{\ldots,0,4,8,12,\ldots\}$$
$$H\cdot 5=\{\ldots,1,5,9,13,\ldots\}$$
Note that $H\cdot 0 =H\cdot 4$ and $H\cdot 1 =H\cdot 5$. In fact there are only $4$ distinct cosets, each corresponding to one congruence class of integers modulo $4$. If we care only about the remainder of an integer after division by $4$ then all the elements in a coset are equivalent and we can think of them as a single entity.
To take another example, let $G$ be the group possible rotations of a point on a unit circle and we care only about where a point ends up on the circle after the rotation. Then let $H$ be rotations that are a multiple of $2\pi$. The cosets of $H$ will now be rotations which differ by multiples of $2\pi$ and which therefore have the same effect on the final position of the point rotated.
In general, two elements $g_1$ and $g_2$ of $G$ are defined to be equivalent ($g_1 \equiv g_2$) if $g_1 \cdot g_2^{-1} \in H$.
You can prove the following

*

*For all $g$ in $G$, $g \equiv g$ since the identity element belongs to $H$ as it is a subgroup.

*If $g_1 \equiv g_2$ the $g_2 \equiv g_1$ since if an element belongs to $H$ then so does its inverse.

*If $g_1 \equiv g_2$ and $g_2 \equiv g_3$ then $g_1 \equiv g_3$ since $H$ is closed under multiplication.

This show that $\equiv$ is a genuine equivalence relation. We define the equivalence class of an element $x$ of $G$ as
$$[x]=\{y \in G\mid x \equiv y\}$$
You can show that

*

*$x \in [x]$

*For any $x,y \in G$, either $[x] \cap [y] =\emptyset$ or $[x]=[y]$.

So the equivalence classes are either equal or disjoint and they cover $G$.
Finally, back to cosets. The equivalence classes we have defined above are the same as the right cosets. If $y \equiv x$ then $yx^{-1}=h$ for some $h \in H$ or $y=hx$. So $[x]=Hx$. If we had instead defined our equivalence relation by the condition $x^{-1}y \in H$ then we would have got the left cosets.

A: If your table is correct, it should be the symmetric group in three letters, with a and b the 3-cycles, and c, d, and e the transpositions.
Now. Your first equations is, alas, nonsense. The set that contains $1$, $a$, $b$, $c$, $d$, and $e$ is certainly not equal to the set whose elements are the sets $\{1,a,b\}$ and $\{c,d,e\}$. You are writing nonsense.  The rest are a bit better because you are looking at cosets. Fixed in problem.
$G$ has six different subgroups: the trivial subgroup $\{1\}$; the whole subgroup $G$; one subgroup of order three, $H=\{1,a,b\}$, and three subgroups of order two: $K_1=\{1,c\}$, $K_2=\{1,d\}$, and $K_3=\{1,e\}$.
What are the left cosets of $H$ in $G$? They are the sets $1H$, $aH$, $bH$, $cH$, $dH$, and $eH$. As it happens, $1H=aH=bH = H$, and $cH=dH=eH=\{c,d,e\}$. You can verify it exlicitly; for instance,
$$aH = \{ ah : h \in H\} = \{a1, aa, ab\} = \{a, b, 1\} = H$$
and
$$cH = \{ ch: h \in H\} = \{c1, ca, cb\} = \{c, e, d\}.$$
The right costs of $H$ are the same as the left cosets.
Now, what are the left cosets of $K_3=\{1,e\}$ in $G$? They are the sets $1K_3$, $aK_3$, $bK_3$, $cK_3$, $dK_3$, and $eK_3$. They are:
$$\begin{array}{rcl}
1K_3 & = & \{1k : k \in K_3\} = \{11, 1e\} = \{1,e\} = K_3\\
aK_3 & = & \{ak : k \in K_3\} = \{a1, ae\} = \{a, c\}.\\
bK_3 & = & \{bk : k \in K_3\} = \{b1, be\} = \{b, d\}.\\
cK_3 & = & \{ck : k \in K_3\} = \{c1, ce\} = \{c, a\} = aK_3.\\
dK_3 & = & \{dk : k \in K_3\} = \{d1, de\} = \{d, b\} = bK_3.\\
eK_3 & = & \{ek : k \in K_3\} = \{ei, ee\} = \{e, 1\} = K_3.
\end{array}$$
So there are three distinct left cosets, and they are $\{1,e\}$, $\{a,c\}$, and $\{b,d\}$.
What are the right cosets of $\{1,d\}$ in $G$? They are $K_21$, $K_2a$, $K_2b$, $K_2c$, $K_2d$, and $K_2e$. Let us be a bit smarter this time, rather than computing them directly: we know that any two distinct cosets are disjoint, and that the right coset of $x$ contains $x$. So $K_21$ contains both $1$ and $d$, hence must be equal to the right coset of $d$, $K_2d$; that is, $K_21=K_2d = \{1,d\}$. The right coset of $a$ contains $a$ and contains $da = c$, hence must be equal to the right coset of $c$, $K_2c$; indeed it is, as $dc = a$; so $K_2a=K_2c=\{a,c\}$. And the right coset of $b$, $K_2b$, contains $b$ and $db=e$, hence must equal the right coset of $e$, $K_2e$, which it does (since $de=b$ and $1e=1$). So $K_2b=K_2e=\{b,e\}$. So the three right cosets of $K_2$ in $G$ are $\{1,d\}$, $\{a,c\}$, and $\{b,e\}$.


text:
Q: How to add symbols on smooth lines in a R's lattice xyplot? In a lattice xyplot with multiple smooth curves, I plotted curves categorized by color (y1, y2, y3 in blue; z1, z2, z3 in red).
If we consider the following simple data :
x<-1:50
y1<-rnorm(50,100,20)
y2<-rnorm(50,80,20)
y3<-rnorm(50,90,20)
z1<-rnorm(50,60,20)
z2<-rnorm(50,40,20)
z3<-rnorm(50,65,20)

we can make such a plot with smooth lines and specify colors with this code:
xyplot(y1+y2+y3+z1+z2+z3~x,type='smooth', span=0.4,
par.settings=list(superpose.line=list(col=c('blue','blue','blue','red','red','red'))))

and we get this result:

My question : Do you know how to add symbol (markers) on each curves to identify it ?
For instance, y1 with a triangle marker in blue, y2 with a square marker in blue, etc.
It is easy to do this when raw data is plotted, but I can't find how to do it with smooth curves. I tried to use superpose.symbol but it seems that it's works only when type=c('p','smooth'). But in this case, symbols are not on the curves but in the raw positions.
NB. I tried to identify the curves with different line type (cf. lty) but but the result does not allow a good visualization with my data.

A: Here is a way to achieve this:
library(lattice)
library(gridExtra)

my.df <- data.frame(y=c(y1, y2, y3, z1, z2, z3),
                    g=gl(6, 50), x=rep(x, 6))

my.panel.loess <- function(x, y, span=2/3, ...) {
  loess.fit <- loess.smooth(x, y, span=span)
  panel.lines(loess.fit$x, loess.fit$y, ...)
}

pp <- list()
pp[[1]] <- xyplot(y ~ x, data=my.df, groups=g, type="b",
                  col=rep(c("blue","red"), each=3), cex=.6,
                  panel=function(...)
                    panel.superpose(panel.groups=my.panel.loess, ...))

pp[[2]] <- update(pp[[1]], span=1/5)
pp[[3]] <- update(pp[[1]], col=1:6, type=c("p", "g"))
pp[[4]] <- update(pp[[1]], pch=rep(c(2,6), each=3))

do.call(grid.arrange,  pp)

You will notice that I had to briefly define a custom panel function for the smoother. This is because I need to pass an extra parameter to panel.lines ("p"+"l"="b"); note that it cannot be used directly when calling panel.lines since this formal parameter is already defined in xyplot.
The rest of the code is pure drawing with varying parameters (all digested through the ... argument). Although I arranged your data in a more convenient data.frame, I believe your original formulation will work with slight adaptation around the call to panel.groups.

However, you can annotate the curves directly with the directlabels package (a lot of examples are available on R-forge). Something along those lines should work fine:
library(directlabels)
pp0 <- xyplot(y ~ x, data=my.df, groups=g, type="smooth")
direct.label(pp0, "follow.points")

I should note that there is a nice function, labcurve(), in the Hmisc package that does pretty much the same job.


text:
Q: How to open default browser if app is not installed in mobile Xamarin.Forms (IOS issue) try {
     Device.OpenUri (new Uri("fb://page/page_id"));
    } catch(Exception e){
     System.Diagnostics.Debug.WriteLine (e.Message);
     Device.OpenUri (new Uri("https://www.facebook.com/pages/...."));
}

If the application is not installed or the scheme is not valid, it should go in the catch and open the Facebook page in the browser.
It working properly in android by the raise of an exception, but there isn't any exception raise for iOS. Is there any other solution to open default browser if fb app is not installed in device.

A: Unfortunately it will never raise exception with iOS.
I suggest you use DependencyService to implement opening Facebook in iOS , so that you can detect if the application is not installed or the scheme is not valid.
 bool isSuccess = UIApplication.SharedApplication.OpenUrl(new NSUrl("fb://page/page_id"));
 if (isSuccess == false) {
     UIApplication.SharedApplication.OpenUrl(new NSUrl("https://www.facebook.com/pages/...."));
 }


text:
Q: Help with solution to 2 variable quadratic equation. Could someone help with an explanation on how to treat the equation below, please?
A solution I have read uses the discriminant to find the range i.e. $9-20y^2-16y>or = 0$.
To me this means treating the variable Y as a constant , is that "acceptable" ? does anyone have a reference for these equations ?
$yx^2+5y-3x+4=0$
rewrite as
$yx^2-3x+(5y+4)=0$
thanks
ralph

A: Yes, I take from $$yx^2-3x+(5y+4)\ge 0~~~(1)$$
A quadratic $f(x)=Ax^2+Bx+C$ is positive definite for all real values of $x$ if $B^2\le 4AC$ and $A>0$
So (1) will hold for all real values of $x$ if $y>0$ and
$B^2 \le 4AC$. So we get
$$9 \le 4y(5y+4) \implies 20y^2+6y-9 \ge 0  $$ $$ \implies \left(x-\frac{4+\sqrt{61}}{10}\right) \left(x-\frac{4-\sqrt{61}}{10}\right) \ge 0 $$ So
$$\implies  y \ge \frac{4+\sqrt{61}}{10} ~or~ y \le \frac{4-\sqrt{61}}{10}$$
But due to the condition $y>0$, we finally get
$$ y \ge \frac{4+\sqrt{61}}{10}.$$


text:
Q: Snakemake not interpreting wildcard correctly? I am trying to run a snakemake file but it is producing a weird result

refseq = 'refseq.fasta'
reads = '_R1_001'
reads2 = '_R2_001'
configfile: "config.yaml"
## Add config

def getsamples():
    import glob
    test = (glob.glob("*.fastq.gz"))
    samples = []
    for i in test:
        samples.append(i.rsplit('_', 2)[0])
    print(samples)
    return(samples)

def getbarcodes():
    with open('unique.barcodes.txt') as file:
        lines = [line.rstrip() for line in file]
    return(lines)

rule all:
    input:
        expand("called/{barcodes}{sample}_called.vcf", barcodes=getbarcodes(), sample=getsamples()),
        expand("mosdepth/{barcodes}{sample}.mosdepth.summary.txt", barcodes=getbarcodes(), sample=getsamples())

rule fastq_grep:
    input:
        R1 = "{sample}_R1_001.fastq.gz",
        R2 = "{sample}_R2_001.fastq.gz"
    output:
        "grepped/{barcodes}{sample}_R1_001.plate.fastq",
        "grepped/{barcodes}{sample}_R2_001.plate.fastq"
    shell:
        "fastq-grep -i '{wildcards.barcodes}' {input.R1} > {output} && fastq-grep -i '{wildcards.barcodes}' {input.R2} > {output}"

I have files in my directory with *.fastq.gz on the end of them but I get this:

Missing input files for rule fastq_grep:
0_R1_001.fastq.gz
0_R2_001.fastq.gz

Those two files do not exist, where is it getting them from?
I would expect to see a lot of fastq files that are in my directory but it is only listing one file that does not exist.

A: It's a common problem due to {barcodes}{sample} pattern.
Snakemake won't know where {barcodes} ends and where {sample} starts without a wildcard_constraint. Right now, snakemake is thinking that your sample wildcard is just a 0.


text:
Q: Alternative of ASP.NET's UserControls in PHP? I have developed many web applications in ASP.NET in which I have make use of UserControls to manage header footer and any other common part of a web page. Now I am developing an app in PHP, is there anything which I can use as an alternative of UserControls??
How I can implement the similar concept in PHP?
Thanks?

A: A second answer which is a bit harder to explain in detail here, is to build your own 'UserControl' classes. The Classes would have the neccessary properties that you require, and Would have a RenderHTML() method that would output the control to the screen.

A: The UserControl concept does not explicitly exist in PHP, though you can encapsulate the the functionality that you want in a file and use the include() function to place it into your pages where you wish.
<html>
 <head>
   <title></title>
 </head>
 <body>
   <?php include('header.php'); ?>
   <?php include('pageBody.php'); ?>
   <?php include('footer.php'); ?>
 </body>
</html>

Note that Smarty provides for much better separation of processing and rendering, and will make this type of thing super smooth.


text:
Q: Question on improper integrals $$\int_0^2 \dfrac{\mathrm dx}{\sqrt{x}(x-1)}$$
I want to determine whether this integral converges or diverges. Now usually problems like these are easy, but this one is kind of tricky since it is discontinuous at both 0 and 1. Whereas with one situations where the integral is only discontinuous at 1 value, I could just set up 2 integrals and use the "lim of t" method, but here I cant set up two integrals. The only way that two integrals could be set up is if the first one is from 0 to 1 and the second one is from 1 to 2, but the first one is discontinuous at both values, so not sure what the work around is.

A: You can break up the integral at any point or points you like. In this case, you could break it up into three integrals: pick a point $c$ strictly between $0$ and $1$, and consider:
\begin{align*}
\int_0^2 \frac{dx}{\sqrt{x}(x-1)} &= \int_0^c\frac{dx}{\sqrt{x}(x-1)}+\int_c^1\frac{dx}{\sqrt{x}(x-1)} + \int_1^2\frac{dx}{\sqrt{x}(x-1)}\\
&= \lim_{a\to 0^+}\int_a^c \frac{dx}{\sqrt{x}(x-1)} + \lim_{b\to 1^-}\int_c^b\frac{dx}{\sqrt{x}(x-1)} + \lim_{d\to 1^+}\int_d^2\frac{dx}{\sqrt{x}(x-1)}.
\end{align*}
The original improper integral exists if and only if each of the three improper integrals exist.

A: Consider the change of variables $t=\sqrt x$. It transforms the interval $[0,2]$ into $[0,\sqrt 2]$ and removes one of the problem zeroes. It is easy to see from the resulting expression that the integral diverges.

A: $\newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{{\rm e}^{#1}}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\sgn}{{\rm sgn}}%
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}$Try to solve the integral. You'll find whether it converges. For example,
$\ds{\int_{\epsilon}{\dd x \over \sqrt{x\,}\,\pars{1 - x}}}$ with $\epsilon > 0$.
Later on, you can study the limit $\ds{\epsilon \to 0^{+}}$. In this way, you "kill two birds with a one shot".


text:
Q: 403 error when posting to django view from react native I am having a hard time getting data to and from django/react. I'm wondering if anyone has any suggestions.
Here is the django view I would like to access
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse

@csrf_exempt
def getData( requests ):
    return JsonResponse( {"data": "hello world" } )

My react native code looks like this:
    const fetchSearchItems = ( query ) => {
        console.log( query )
        fetch(url, {
            method: 'post',
            headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
            body: JSON.stringify({ query: query })
        }).then( (data) => {
            console.log( data )
        })
        .catch(function(error) {
            console.log('There has been a problem with your fetch operation: ' + error.message);
             // ADD THIS THROW error
              throw error;
        });
    }

My django settings.py (updated)
ALLOWED_HOST = [ mydomain.com ]

My info.plist
<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>mydomain</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

And finally the error message:
{ type: 'default',
  status: 403,
  ok: false,
  statusText: undefined,
  headers:
   { map:
      { vary: 'Accept-Encoding',
        date: 'Thu, 10 Sep 2020 18:05:20 GMT',
        'content-type': 'text/html',
        'x-frame-options': 'DENY',
        server: 'PythonAnywhere',
        'referrer-policy': 'same-origin',
        connection: 'keep-alive',
        'x-content-type-options': 'nosniff',
        'transfer-encoding': 'Identity',
        'content-encoding': 'gzip' } },
  url: 'xxxxxx',
  bodyUsed: false,
  _bodyInit:
   { _data:
      { size: 2864,
        offset: 0,
        blobId: 'EA6FE4A5-BE26-4D8A-98D2-8EA76C248D52',
        type: 'text/html',
        name: 'xxxx',
        __collector: {} } },
  _bodyBlob:
   { _data:
      { size: 2864,
        offset: 0,
        blobId: 'EA6FE4A5-BE26-4D8A-98D2-8EA76C248D52',
        type: 'text/html',
        name: 'xxxx',
        __collector: {} } } }

I would really appreciate some advice. Thank you!


text:
Q: Saving API Data to a file PHP I am getting price and volume data from six bitcoin exchanges to make a price converter but it is super slow because every time you load the page it has to query all those sites for their data.
I want to run something in the background every 1 minute that gets the data and saves it to a file on the server and then when a user comes to the site it just grabs it from the file with the already retrieved API data. I've been trying to use file_put_contents to no avail.
Here is the code I've got so far:
<?php

function getData($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$rawData = curl_exec($curl);
curl_close($curl);
return json_decode($rawData, true);
}

//BTC Volume LocalBitcoins
$BTCVolumeLocal = getData('https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/');
$LocalVolume = $BTCVolumeLocal["USD"]["volume_btc"];

//BTC Volume BTCE
$BTCVolumeBTCE = getData('https://btc-e.com/api/3/ticker/btc_usd');
$BTCEVolume = $BTCVolumeBTCE["btc_usd"]["vol_cur"];

//BTC Volume Bitstamp
$BTCVolumeStamp = getData('https://www.bitstamp.net/api/ticker/');
$StampVolume = $BTCVolumeStamp["volume"];

//BTC Volume Bitfinex
$BTCVolumeFinex = getData('https://api.bitfinex.com/v1/pubticker/btcusd');
$FinexVolume = $BTCVolumeFinex["volume"];

//BTC Volume OKCoin
$BTCVolumeOK = getData('https://www.okcoin.com/api/ticker.do?ok=1');
$OKCoinVolume = $BTCVolumeOK["ticker"]["vol"];

//BTC Volume LakeBTC
$BTCVolumeLake = getData('https://www.lakebtc.com/api_v1/ticker');
$LakeVolume = $BTCVolumeLake["USD"]["volume"];

//Totals the Volumes
$TotalVolume = $LakeVolume + $FinexVolume + $OKCoinVolume + $StampVolume + $BTCEVolume + $LocalVolume;
//Percents of Total Volume
$BTCEPercent = $BTCEVolume / $TotalVolume;
$StampPercent = $StampVolume / $TotalVolume;
$FinexPercent = $FinexVolume / $TotalVolume;
$OKPercent = $OKCoinVolume / $TotalVolume;
$LakePercent = $LakeVolume / $TotalVolume;
$LocalPercent = $LocalVolume / $TotalVolume;

//BTC Price BTCE
$BTCPriceBTCE = getData('https://btc-e.com/api/3/ticker/btc_usd');
$BTCEPrice = $BTCPriceBTCE["btc_usd"]["last"];

//BTC Price Bitstamp
$BTCPriceStamp = getData('https://www.bitstamp.net/api/ticker/');
$StampPrice = $BTCPriceStamp["last"];

//BTC Price Bitfinex
$BTCPriceFinex = getData('https://api.bitfinex.com/v1/pubticker/btcusd');
$FinexPrice = $BTCPriceFinex["last_price"];

//BTC Price OKCoin
$BTCPriceOK = getData('https://www.okcoin.com/api/ticker.do?ok=1');
$OKPrice = $BTCPriceOK["ticker"]["last"];

//BTC Price LakeBTC
$BTCPriceLake = getData('https://www.lakebtc.com/api_v1/ticker');
$LakePrice = $BTCPriceLake["USD"]["last"];

//BTC Price LocalBitcoins
$BTCPriceLocal = getData('https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/');
$LocalPrice = $BTCPriceLocal["USD"]["avg_1h"];

//BTC Price * Percent
$BTCEPricePercent = $BTCEPrice * $BTCEPercent;
$StampPricePercent = $StampPrice * $StampPercent;
$FinexPricePercent = $FinexPrice * $FinexPercent;
$OKPricePercent = $OKPrice * $OKPercent;
$LakePricePercent = $LakePrice * $LakePercent;
$LocalPricePercent = $LocalPrice * $LocalPercent;

//Bitcoin Price
$bitcoinPrice = round($LakePricePercent + $OKPricePercent + $FinexPricePercent + $StampPricePercent + $BTCEPricePercent + $LocalPricePercent, 2);

?>

A: I've done a couple of projects with various Bitcoin API's and have spent alot of time storing API data for the very same reason of lag.
1.) Put the data into a database,...you're going to go crazy working with flatfiles and this many sources. Doesn't need to be big or complicated, but it's the right tool for the job and will be much more flexible long-term.
2.) A CRON job would be the ideal way to go to trigger the code at whatever interval you'd like. In the past I've used user visits to trigger the processing script and it does work, my experiences doing that lead me to not do that anymore.
In your example, if you don't have a visitor every minute, then every visitor is still going to have to sit through the API calls and the gains are evaporated.  If you do have one or more visitor each minute, then this method is a bit better looking,...but one of those visitors is still going to have to wait.
3.) With the CRON method, you'll have a full log of the API's,...which isn't a bad thing to have. Could make for some useful historical info, covers you if there's ever any API downtime. If it's triggered by the user, you'll have holes in that data and less options in the future.
Good luck.


text:
Q: Passing parameter to controller extension? I wish to create hyperlinks to a specific visual force page which displays a list of opportunities.  The data in the page will need to be different. In some cases it will be all open opportunities above a certain value and in other cases it might be all opportunities not updated in last 6 months.
So, I am writing my own extension controller.  I need to pass query parameters along the HTTP request to the extension controller so the extension controller knows what Opportunities to get for the page.
Is it possible to do this?

A: Yes, you can do this with the getParameters method on the PageReference class.  See this link for more details on that:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm
For example, assuming you had the following URL parameters:
?a=1&b=2&c=3

In your code you can retrieve them like this:
String a = ApexPages.currentPage().getParameters().get('a');
String b = ApexPages.currentPage().getParameters().get('b');
String c = ApexPages.currentPage().getParameters().get('c');

Note, ApexPages.currentPage() returns a PageReference object.


text:
Q: WPF: can a page own a WindowsForms form I have a wpf application where several pages are displayed inside a window (using uniformgrid with dynamically added frames). The pages get rearranged inside the window when special events are called. The problem is: sometimes I have to call a System.Windows.Forms form inside a page. I want this form to be displayed on top of the page (overlaying the page). I already calculated the position:
StatusForm frm = new StatusForm (m_object, parameters);
frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
Point topleftPageCoord = this.PointToScreen(new Point(0, 0));// get topleft coordinates of the page
int x = (int)topleftPageCoord.X + ((int)this.ActualWidth - frm.Size.Width) / 2;
int y = (int)topleftPageCoord.Y + ((int)this.ActualHeight - frm.Size.Height) / 2;
frm.Location = new System.Drawing.Point(x, y);
frm.ShowDialog();
if (frm.Result != "") do something;

but when my whole window gets rearranged the form is (of course) still at this old position.
Is there a way to call the form with the page as owner? So that the form is somehow connected to the page and automatically moved when the page is moved?


text:
Q: How to wait for a child directive render? I have a directive which uses another directive:

     <my-internal-directive></my-internal-directive>
     <my-internal-directive></my-internal-directive>
     <my-internal-directive></my-internal-directive>

The internal directive:

foo

The internal directive controller:
internalDirectiveModule.directive('myInternalDirective', function($document){
    return {
      restrict:'E',
      scope: {},
      //templateUrl: 'myInternalDirective.html',    // EXTERNAL directive render first
      template: '
foo
',                     // INTERNAL directive render first
      link: function(scope, element){
        $document.find('body').append('
internal directive\n');
      }
    };
});

The problem is when I use templateUrl for the internal directive the external one renders first, but when I use template - the internal directive renders first. I have to get data from the internal directive inside the external one after the internal one renders (link method is called), but I can't reach this behavior because I suppose to use templateUrl only. How can I get data from a renderred child directive inside the link method of a parent one?
DEMO

A: Instead of a function, set link to an object containing a post function.
link: { post: function() {  }  }

post-linking-function documentation

A: You can try a couple of things:

*

*Set the priority of the the inner directive higher than the priority of the outer directive.

*Fire the link function of the outer directive after a timeout like this:
link: function () { $timeout(linkFn, 1000, false); }
Updated:
Here's an example for setting priority:
    angular.module('abc').directive('xyz', directive);

    directive.$inject = ['$timeout'];

    function directive($timeout) {

            return {
                    restrict: 'A',
                    priority: 100,
                    link: function ($scope, $element) {

A: As told by Sidharth &  Arlen , you can set priority or in normal ways if it's not mandatory to have this scope: {} in your code than you can do it pretty easily using two way data binding in directives.  https://docs.angularjs.org/guide/directive.


text:
Q: CDT: How can I analyze the AST of a c/c++ file which are not linked to some project in an Eclipse workspace In my source code analysis Eclipse RCP project, I want to getAST to analyze the AST of some c/c++ files, which is neither a source file of a project within an eclipse workspace, nor a link resources of a project within an eclipse workspace. Basically, I do not have any workingspaces in my RCP application. Any suggestions would be appreciated!
cheers,

A: You need to programmatically create new project from folder of sources (make sure you have some basic .cproject file inside with correct source root):
IWorkspace workspace = ResourcesPlugin.getWorkspace();
project = workspace.getRoot().getProject("project");
if (!project.exists()) {
    IProjectDescription description = workspace.newProjectDescription("project");
    CCorePlugin.getDefault().createCDTProject(description, project, null);
} else {
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
}

After you can use AST:
ITranslationUnit translationUnit = (ITranslationUnit) CoreModel.getDefault().create(file);
IASTTranslationUnit ast = translationUnit.getAST();

A: I found a simpler way if you happen to have that file in the editor, then you can use getEditorInput method on the editor part to get ITranslationUnit, i.e.:
// here is how you can get the active editor
 IWorkbench workbench = PlatformUI.getWorkbench();
 IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
 IEditorPart editorPart = window.getActivePage().getActiveEditor();
// for an external file the editor input will be of type ITranslationUnitEditorInput
 IEditorInput input = editorPart.getEditorInput();
 if (input instanceof ITranslationUnitEditorInput) {
    ITranslationUnit externalTU = ((ITranslationUnitEditorInput) input).getTranslationUnit();
 }


text:
Q: Sphinx search engine, a couple of quick questions So, I'm just starting to read up on this, I've never implemented a search in PHP before. I have a couple of questions that I was wondering:

*

*By the sounds of things, Sphinx needs
a 'daemon', a program running in the
background, to operate?

*Say I built    an index of a mySQL
table, then a    user uploads another
record. For the    search to show
this record, would I    have to build
the index over and    over, every
time a user updates /    creates a
record?

Thanks.

A: Basically you need a base index then a delta index. The delta updates anything in the base. So you might run the base index at 1 am then every 5 minutes update the delta. You store a timestamp in either a table or another database and that controls which records go in the delta.
You can then look at sql_query_killlist to remove things that are deleted, see the docs.
An example conf might look like this.
source _user
{
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = db
    sql_port = 3306
    sql_attr_uint = category_id
    sql_attr_timestamp = time_posted
}

source user_base : _user
{
    sql_query_pre = REPLACE INTO sphinx_lastrun (object_name, object_value) SELECT 'users', @max_stamp:=UNIX_TIMESTAMP(MAX(stamp))-1 FROM users
    sql_query = SELECT id, category_id, name, UNIX_TIMESTAMP(stamp) AS stamp FROM users WHERE stamp < FROM_UNIXTIME(@max_stamp)
    sql_query_info = SELECT id FROM users WHERE id=$id
}

source user_incr : _user
{
    sql_query = SELECT id, category_id, name, UNIX_TIMESTAMP(stamp) AS stamp FROM users WHERE stamp >= (SELECT FROM_UNIXTIME(object_value) FROM sphinx_lastrun WHERE object_name = 'users')

    # You'll need sql_query_killlist to get rid of stuff that is deleted. See the docs

    sql_query_info = SELECT id FROM users WHERE id=$id
}

index _user
{
    docinfo = extern
    mlock = 0
    morphology = none
    min_word_len = 2
    charset_type = sbcs
    min_prefix_len = 3
    enable_star = 1
}

index user_base : _user
{
    source = user_base
    path = /opt/sphinx/var/data/user_base
}

index user_incr : _user
{
    source = user_incr
    path = /opt/sphinx/var/data/user_incr
}

index user
{
    type = distributed
    local = user_base
    local = user_incr
}

searchd
{
    listen = 3312
    log = /opt/sphinx/var/log/searchd/searchd.log
    query_log = /opt/sphinx/var/log/searchd/query.log
    pid_file = /opt/sphinx/var/log/searchd/searchd.pid
}

A: To answer your first question: yes Sphinx comes with a daemon that runs in the background and performs searches when instructed to do so.

A: You can use an incremental indexing scheme, see here.


text:
Q: Deploy Heroku application node js ;) I created my portfolio with NodeJs and VueJS , it works perfectly in local and I would like to deploy my website in online with heroku. But i follow instructions and finally I have the message " application error ".
I don't understand !
So this is my code :
index.js in folder config

'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},

    // Various Dev Server settings
    host: 'localhost', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',

    /**
     * Source Maps
     */

    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],

    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }
}

package.json :

{
  "name": "app",
  "version": "1.0.0",
  "description": "Portfolio",
  "author": "Alex Salicki <salicki.alex@gmail.com>",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "build": "node build/build.js"
  },
  "dependencies": {
    "ev-emitter": "^1.1.1",
    "vue": "^2.5.2",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "gsap": "^1.20.4",
    "html-webpack-plugin": "^2.30.1",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.0",
    "scrollmagic": "^2.0.5",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

I add too the file " procfile " with the code : " web : node index.js " for heroku application
You can see my complete code in GitHub : https://github.com/Alexsalicki91/website/tree/master/portfolio-1/spa
Can you help me ? Where is my errors ?
Have a nice days guys !
Alex Salicki


text:
Q: How to retain the state of the app when navigating to another screen in flutter using riverpod Good day, guys
I'm new to using Riverpod, I have a counter app that when the FAB button is tapped it increases the counter by 1. This works well using Riverpod ChangeNotifierProvider.
The issue I'm currently having is retaining the state of the counter in the second screen when I click on another button that takes the user to the second screen.
Below is my code
main.dart
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod_app/counter.dart';
import 'package:flutter_riverpod_app/second_screen.dart';

final counterProvider = ChangeNotifierProvider<Counter>((ref) => Counter());

void main() {
  runApp(ProviderScope(
    child: MyApp(),
  ));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Consumer(builder: (context, watch, _) {
          final count = watch(counterProvider);
          return Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '${count.count}',
                style: Theme.of(context).textTheme.headline4,
              ),
              FlatButton(
                  onPressed: () {
                    Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (BuildContext context) => SecondScreen()));
                  },
                  child: Text('Go to second screen'))
            ],
          );
        }),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => context.read(counterProvider).updateCount(),
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

second_screen.dart
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_riverpod_app/counter.dart';

final counterProvider = ChangeNotifierProvider<Counter>((ref) => Counter());

class SecondScreen extends ConsumerWidget {
  @override
  Widget build(BuildContext context, watch) {
    final counter = watch(counterProvider);
    return Scaffold(
      appBar: AppBar(
        title: Text('Second Screen'),
      ),
      body: Center(
        child: Text('${counter.count}', style: TextStyle(fontSize: 30,),),
      ),
    );
  }
}

counter.dart
import 'package:flutter/foundation.dart';

class Counter extends ChangeNotifier {
  int count = 0;

  updateCount() {
    count++;
    notifyListeners();
  }
}

I don't really know how to get the state of the counter on the second screen, if it was the Provider Package, all I just have to do on the second screen was to use Provider.of<counter>(context, listen: false).counter and it will display the counter.

A: The problem is that you created the Provider twice. You only want to create it once and access it globally.
Remove final counterProvider = ChangeNotifierProvider<Counter>((ref) => Counter()); from your SecondScreen and instead import the counterProvider from your FirstScreen and it will behave as you expect.

A: In misc/global.dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
final kCounterProvider = StateProvider((ref) => 0);

In screen/riverpod_screen.dart
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter_kitchensink/src/misc/global.dart' as global;

class RiverpodScreen extends HookConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Riverpod'),
      ),
      body: Container(
        child: Center(
          child: Text(ref.watch(global.kCounterProvider).toString()),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          ref.read(global.kCounterProvider.notifier).state++;
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

In screen/riverpod2_screen.dart
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter_kitchensink/src/misc/global.dart' as global;

class Riverpod2Screen extends HookConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Riverpod2'),
      ),
      body: Container(
        child: Center(
          child: Text(ref.watch(global.kCounterProvider).toString()),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          ref.read(global.kCounterProvider.notifier).state++;
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}


text:
Q: Prove graph does not have a bridge
Let $H$ be a connected graph and it contains two spanning trees $A, B$. $A, B$ do not share any edges with each other (H may contain edges in neither A or B). Show $H$ does not have a bridge.

For contradiction suppose edge $e$ is a bridge and in $H$ and let $e = uv$ so Now suppose there are 2 connected components of $H - e$: $G_1, G_2$ such that $u$ is in $G_1$ and $v$ is in $G_2$.
However, notice that if $e$ is not in $A$ or if $e$ is not in $B$ then it is not possible for either of the trees to cover one of $\{u, v\}$ vertices so $e$ must be in both $A, B$. Contradiction.
Is this correct justification?


text:
Q: jQuery update event and DOM event is not working with popover tag handler I am not able to call jQuery's update event for popover with live event.
Is there any way that I don't need to reinitialize the popover on each live event.
I have tried using $(selector).action(), but it's not working.
Is there any way that i can initialize the popover on DOM live event without calling its initialize method?


text:
Q: Why do I get 502 errors in a load balancer, but not 5XXs? My Load balancer shows 502 errors, but not 5XXs errors.

A: Based on the screenshot, this is an application load balancer (and not a classic or network load balancer).
Here are the docs for ALB metrics: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html
Graph titled HTTP 5XXs is showing the HTTPCode_Target_5XX_Count metric. Which is the number of HTTP response codes generated by the targets. This does not include any response codes generated by the load balancer.
Graph titled HTTP 502s is showing the HTTPCode_ELB_502_Count metric. Which is the number of HTTP 502 error codes that originate from the load balancer.
So the issue is with the load balancer itself. See here for possible causes.


text:
Q: We know that moving charge creates a magnetic field, so, does that created magnetic field have any effect on the motion of that very charged particle I understand that a moving charge creates a magnetic field, the question is, does that created magnetic field have any effect on the motion of that very charged particle in simple terms does that created magnetic field contribute to the force on that very moving charge?
NB: I am referring to a quantum particle

A: A charged body in motion does generate some magnetic field, but does so
in a direction perpendicular to its velocity (circumferential around
the axis of motion).   The effect of such a charge impinging on its own field generates a force perpendicular to BOTH the velocity of the
charge, and to the field, which is... inward.
The effect is called a Z-pinch, and is responsible for the narrow tracks left in
soil by lightning bolts... but is relatively unspectacular in less intense
currents.
This kind of pinch is a major concern in
fusion reactor research, since it would contain the charges in
fully ionized gasses.

A: A charge is always at rest with regard to itself, so it won't see its own magnetic field. A magnetic field is only seen by other particles in case they are not co-moving with the first one.

A: If the charge is considered point-like, then no, it does not feel its own field while in a uniform motion. But an accelerated or decelerated charge has a small "radiation friction:reaction" effect. Read R. Feynman lectures, chapter 28.


text:
Q: Xcode 4.2 - c++ include guard structure I seem to be doing something wrong with the way I use include guards. Most of the time my structuring works, but in certain circumstances like the code below, I have problems. What might be causing the problem is me using the header file "all.h" as a big collection of other header files (like "another.h" and any other header files needed).
The code will compile if code in the file "another.cpp" is commented out, so somewhere along the line there is a duplication of the function "sleepFunc" (I think), since I get the following error:

Apple Mach-O Linker (Id) Error
ld: duplicate symbol sleepFunc(unsigned int) in
/Users/(project path)/.../Another.o and
/Users/(project path)/.../main.o for architecture x86_64
Command /Developer/usr/bin/clang++ failed with exit code 1

I am using Xcode version 4.2 on Mac OS X Snow Leopard (10.6.8).
During the typing of this post, I discovered the issue, which was me including the header "all.h" in "another.cpp". But if I do the thing that I had to do (#include  in "another.h", use header "another.h" in file another.cpp), it makes me unhappy, since this means all files that need other files start getting messy. I would like to have just one header file for each new file I make.
(And another question, why did the compiler duplicate the "sleepFunc", even with the include guards???)
Is there a better, more clean way to structure the include guards and/or includes?

all.h
#ifndef IncluderTest_all_h
#define IncluderTest_all_h

#include <iostream>
#include <stdlib.h>
#include "Another.h"

void sleepFunc(unsigned milliseconds);

#ifdef _WIN32
#include <windows.h>
void sleepFunc(unsigned milliseconds)
{
    Sleep(milliseconds);
}
#else
#include <unistd.h>
void sleepFunc(unsigned milliseconds)
{
    usleep(milliseconds * 1000); // takes microseconds
}
#endif
#endif

main.cpp
#include "all.h"

int main (int argc, const char * argv[])
{
    sleepFunc(500);
    printf("Hello world!");
    return 0;
}

another.h
#ifndef IncluderTest_another_h
#define IncluderTest_another_h

class Another{
public:
    void spunky();
};

#endif

another.cpp
#include "all.h"

void Another::spunky(){
    printf("Very spunky");
}

A: Because you include all.h in two cpp files you have the Symbol repeated. Try to put the implementation of sleep into a third cpp file or use static void for the functions. The include guards are okay for what I see.


text:
Q: Generating unauthenticated token with upload scope I'm trying to get an unauthenticated token with upload scope making a request to
https://api.vimeo.com/oauth/authorize/client with scope value of "public private upload".
In response token scope have value "public private" or "public private ".
My app has upload permissions, my account is PLUS. I can create token with upload scope in app control page and upload video via API using it.
I'm trying to make possible to upload a video directly from client's browser to my Vimeo account without oAuth2. The client making a request to the backend to get the unauthorized token. Backend authorizes the user in my system, create a token with API request, save it in my system for this user for reuse, return token to the client. Client upload video using Uppy via tus protocol directly to Vimeo. Everything except creating token is working. What I'm doing wrong? Maybe I need another account plan and/or check "Other people created these videos" at Request Upload Permissions page?

A: An unauthenticated token can only be used to interact with resources public on vimeo.com. In other words, a token is used the same way as a user who is not logged into a Vimeo account. Upload requires a login.
If you want to upload to your account without going through the OAuth flow, you must generate a "Personal Access Token". To do so, go to your app management page at https://developer.vimeo.com/apps, select your app, and select the Authentication tab.
From there, scroll down to "Generate a personal access token", select the scopes you want that token to have (for upload I would recommend at minimum public private edit upload), and click Generate. Copy the token and save it somewhere secure. You can then use that token to authenticate your requests with the API.
I hope this information helps!


text:
Q: Find $P(Y=5)$ for $Y=X_1+X_2+X_3$, where $X_i$ are mutually indpt Poisson R.V In this problem, I am told that $X_1,X_2,X_3$ are mutually independent Poisson random variables with means $2,1,4$ respectively. I am also told to find the moment generating function for $Y=X_1+X_2+X_3$, which I found to be $M(t)=e^{7(e^t-1)}$. My question is how do I find $P(Y=5)$?. Is there a connection between $P(Y=5)$ and $M(t)$?
Attempt at a solution:
Since $X_1,X_2,X_3$ are mutually indpt. Poisson R.V. with mean $2,1,4$, we know that $$f(X_1)=\frac{e^{-2}2^x}{x!},$$ $$f(X_2)=\frac{e^{-1}1^x}{x!}$$ and $$f(X_3)=\frac{e^{-4}4^x}{x!}$$, which imply that $f(Y)=f(X_1)f(X_2)f(X_3)$ (is this true?I think it is bc of independence) Hence, after computations $$f(Y)=\frac{e^{-7}2^{3x}}{x!x!x!}.$$ To find $P(Y=5)$, do I just plug in $x=5$ into $f(Y)$? or do I take the summation of $f(Y)$ for $x=0$ all the way up to $x=5$ or neither? It's been a while since I have seen this material. Any help will be appreciated. Thanks!

A: The moment generating function of $Y$ is the mgf of a Poisson parameter $7$, so $Y$ has Poisson distribution parameter $7$. The required probability is $e^{-7}\frac{7^5}{5!}$.
Remark: We can prove by a direct computation of probabilities that if $U$ and $V$ are independent Poisson with parameters $\lambda$ and $\mu$, then $U+V$ has Poisson distribution with parameter $\lambda+\mu$. The result is also almost obvious if one considers the defining properties of the Poisson. However, the mgf approach is quick, and is a useful exercise.

A:
$f(Y)=f(X_1 )f(X_2 )f(X_3)$
   (is this true? I think it is bc of independence)

No.   Not in the slightest.   Independence means that the joint probability mass of the three random variables is the product of their probability masses.
 $$f_{X_1, X_2, X_3}(x_1, x_2, x_3) = f_{X_1}(x_1)\cdot f_{X_2}(x_2)\cdot f_{X_3}(x_3)$$
That is quite different from the probability mass of their sum, which is rather convoluted.
$$f_Y(y) = \sum_{x_1=0}^y\sum_{x_2=0}^{y-x_1} f_{X_1}(x_1)f_{X_2}(x_2)f_{X_3}(y-x_1-x_2)$$
Which can be solved but is lengthy and using moment generating function to handle the load is much easier.   The moment generating function of a sum of independent random variables is the product of their moment generating functions.   $$M_Y(t) = M_{X_1}(t)\cdot M_{X_2}(t)\cdot M_{X_3}(t)$$
Hence you found that $M_Y(t)=\mathsf e^{7\mathsf (e^t-1)}$.   Which you should recognise as the moment generation function of a Poisson Distributed random variable with rate parameter $7$.   Thus:
$$f_Y(y) ~=~ \dfrac{7^y\,\mathsf e^{-7}}{y!}\;\mathbf 1_{y\in \Bbb N}$$


text:
Q: What is wrong with this mysql query? This is my mysql query:
SELECT *
FROM wp_bp_group_documents
WHERE group_id = 4
  AND id IN (2)
  AND (file LIKE '%jpg'
       OR file LIKE '%png'
       OR file LIKE '%jpeg'
       OR file LIKE '%gif')
ORDER BY created_ts DESC LIMIT 0, 20

and this is my table structure:
'id', 'user_id', 'group_id', 'created_ts', 'modified_ts', 'file', 'name', 'description', 'featured', 'download_count'
'1', '1', '1', '1301587327', '1301587327', '1301587327-NewApplicationForm.pdf', 'Tenancy application form', 'This is a tenancy application form. Please download and fill in.', '0', '0'
'2', '1', '4', '1301934439', '1302005432', '1301934439-bupa_large.png', 'BUPA Stand Image', 'asd', '0', '0'

So from this query I expect it to find the second record in the database, however it returns no values.
There are no mysql errors. I'm just wondering if I've done the query right?
Thank you

A: file is a MySQL keyword. Try wrapping the file name in backquotes: `file`.

A: Your id column appears to be a string, but you're specifying an integer in the array. Could that be the problem?

A: Slightly off the OP's topic, but you know (right?) that when you include "like" in any select, then MySQL has no choice but to read through the entire table. To avoid that, some folks try to make sure that values like filetypes -- things that already, by definition, lend their own taxonomy -- are broken out as non-unique indices.
If you decide to do that, your table suddenly becomes unnormalized. To remedy that, the table needs another column, say `pictype`, that you'd index. To me, that's a stronger table design anyway, but it's just MHO.


text:
Q: Importing Java classes run-time and compilation Could someone explain what importing java.net.* imports? Also could someone explain briefly how importing say java.swing.* would affect the run-time and compilation.

A: Importing a package, class, or any class member simply makes it possible to use that component's Simple Name instead of needing to use its Fully Qualified name. It doesn't affect runtime. It is a compilation feature. So instead of having to write
java.net.URL url = ...

you could simply write
URL url = ...

it won't affect performance or anything like that.

A: java.net.* will import all classes of the java.net package. java.swing.* should have little affect on run-time and compilation because it is written entirely in Java and follows standard class hierarchy rules.


text:
Q: "Have you known" or "Did you know"? First of all, I know it has been mentioned before but I'm not sure which is correct. I've been learning about the Past Simple and the Past Perfect and if I've understood correctly, well, in high level:
Past Simple - Occur in the past (in a specific time) and finished.
Past Perfect - Occur in the past, certainly continues to the present, and maybe continue in the future.
This is correct?
--The main Question--

Have you known that Harald has a very bad disease?

*

*So, Here someone explained that, "Did you see this?" is for events that happened in the past but finished/passed (you can't see it anymore).
However, use "Have you seen this.." if you missed that, you still can see that. Is this correct?

So I thought why not, if I ask someone: Have you known that she's been married? (Did you hear that she's been married? if not, now you can still know about this, because she's still married. Related to the above explanation) and it looks like I ask "Have you known..." from the past until now (present perfect), so why is this incorrect?
Well, Here I found that example about Harald, and they commented that you can never say "Have you known...?" only "Did you know?" but they didn't explain why the former was grammatically incorrect.

*Actually, I want to understand what is correct, and why in context to past simple and present perfect (grammatically) and how can I use both of them correctly in questions?

A: Regarding:

Have you known that Harald has a very bad disease?

I think most people would say:

Did you know that Harald has a very bad disease?

because you are asking what someone knew at the present time. Unlike seeing (where you see something at some point in time), you generally don't "unknow" some piece  of information.
However, you can explicitly refer to a time progression like this:

How long have you known that Harald has a very bad disease?


text:
Q: Roku development: Problem of SceneGraph Development Extensions I tried to use ComponentController to navigate from Main Scene to ViewA, then I found two problem

*

*The button in ViewA does not respond to remote events. (button.setFocus(true))

*The font:LargeBoldSystemFont/font:MediumBoldSystemFont does not work normally

I am new to Roku development. Any hint is appreciated.
Update:
I figured out the solution for 1
I was not supposed to setFocus in init() function.
I have to add
m.top.observeField("focusedChild","onChildFocused") to init()
Then setFocus in onChildFocused
sub onChildFocused()
    print "child focused"
    if m.top.isInFocusChain() and not m.button.hasFocus() then
      m.button.setFocus(true)
    end if
end sub

I still don't know why the fonts don't work normally.

A: Its not clear from your question what issue you are facing with fonts. If your question is regarding button text font, check whether you are setting fonts for "textFont" and "focusedTextFont" both for the button.


text:
Q: Need help on a specific Regex I want to validate an attribute of an xml file with an XSD file. This attribute must contain a list of comma-separated languages, like this :
<Params languages="English,French,Spanish" /> // OK
<Params languages="French,Spanish" />  // OK
<Params languages="French" /> // OK
<Params languages="English,French,Spanish,French" /> // NOK (Two times French)
<Params languages="English,Spanish,French," /> // NOK (Comma at the end)

So i try to write a regex pattern to validate this. Here are the constraints :

*

*I must have at least one language

*I cannot have a comma at the end of the string

*I one language can appear only one time in the string

*EDIT : I have an important list of possible languages
The two last constraints are the problem, i don't know how to do it.
Here is what i got now :
^[English,|French,|Spanish,...]+$

But it's really poor. Thanks for your help.

A: The below regex would satisfy all your requirements,
^(English|French|Spanish)(?:,(?!\1)(English|French|Spanish))?(?:,(?!\1|\2)(English|French|Spanish))?$

DEMO
Update:
^(English|French|Spanish|German)(?:,(?!\1)(English|French|Spanish|German))?(?:,(?!\1|\2)(English|French|Spanish|German))?(?:,(?!\1|\2|\3)(English|French|Spanish|German))?$


text:
Q: If statement- diagonal of matrix Im trying to put -5 in the diagonal of my matrix. I am using if statements. But my if statment is wrong. Can anyone give me some help?
X= rbind(c(1.2,3.4,10.3),c(2,8,78),c(45,-36,8))
array(X,dim=c(3,3))
if (X != (1.2,8.0)){
    cat(X)
} else {
    cat(-5)
}

A: X <- rbind(c(1.2, 3.4, 10.3), c(2, 8, 78), c(45, -36, 8))
diag(X) <- -5

Joshua wasn't trying to be a jerk like they said - it's fairly obvious that you're new to R because a lot of what you've written just doesn't work.
The condition inside an if statement has to be of length 1 and it appears as if you're hoping to feed in the entire matrix.  There is a vectorized version of if and that is ifelse but it won't work like you want it to for your matrix.
cat prints to the console but it won't replace elements in your matrix for you.  You need to do some sort of replacement to actually accomplish that.
It's probably also not the best idea to try to just manually identify which elements are unique to the diagonal to do the replacement.  There are better ways - a few of them are found in the intro manual that Joshua linked to.  Good luck.