qid
int64 1
74.7M
| question
stringlengths 0
70k
| date
stringlengths 10
10
| metadata
sequence | response
stringlengths 0
115k
|
---|---|---|---|---|
13,504,753 | I am trying to show an alert dialog when an exception at start up (if a web service call fails).
I have simplified it as much as I can
The code is as follows:
```
protected override void OnStart()
{
base.OnStart();
// doWSCall();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetMessage("Test").Create().Show();
}
```
The dialog is not shown, nothing appears in the debug output nor does anything appear in the device log.
Note this is Mono. | 2012/11/22 | [
"https://Stackoverflow.com/questions/13504753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366038/"
] | You won't need separate CSS IDs, but you could use some jQuery on the class. `.each()` is used instead of `.css()` directly here because otherwise the random angle would be generated once and used for all of the images. To rotate individally on hover:
```
$('.photo').hover(function() {
var a = Math.random() * 10 - 5;
$(this).css('transform', 'rotate(' + a + 'deg) scale(1.25)');
}, function() {
$(this).css('transform', 'none');
});
```
If you want to smoothly animate these transformations, you can simply add a `transform` CSS property to the class:
```
.photo {
transition: transform 0.25s linear;
}
```
Demonstration: <http://jsbin.com/iqoreg/1/edit> |
16,570 | I'm trying to use the TCGA data portal to get gene expression data for cancer tissues, but I'm not sure what "Tumor matched normal" means.
It is unclear to me if the values are already compared to a control (non cancerous) tissue or there is another sample which gives the healthy tissue values. Assuming it is the latter, I don't see these samples anywhere.
This is a screenshot of my filter
<http://www.clipular.com/c/5452873408184320.png?k=rlA9jy3Kb2U47JT7GrXBTzdsln4>
And here is a picture of the result (only TNs appear).
![Only TNs appear](https://i.stack.imgur.com/qLptI.png) | 2014/04/15 | [
"https://biology.stackexchange.com/questions/16570",
"https://biology.stackexchange.com",
"https://biology.stackexchange.com/users/1190/"
] | I think there is a strong driving force for sperm to be free living haploid versions of human beings. Since they are a [product of meiosis](http://en.wikipedia.org/wiki/Meiosis) sperm are the product of recombination of both the male chromosome sets.
While I'm sure that if we look closely enough, the germline cells that produce the sperm are contributing some protein and structure to the sperm, the life cycle of the sperm is mostly the result of the genome that it contains within itself. Sperm are prone to defects. On the average in human beings about [half of sperm are non-motile](http://en.wikipedia.org/wiki/Semen_analysis#Motility): simply unable to form the flagellum or power its motion adequately for motility. That's a pretty strong selective force in the life of our other, 'half genome' selves.
Sperm selection - the sorting of which sperm from a single male achieves fertilization is pretty rigorous. It can take [30 minutes to days](http://www.newhealthguide.org/How-Long-Does-It-Take-To-Fertilize-An-Egg.html). Once in contact with the ovum, the sperm executes a [critical set of transformations and biochemical activations](http://en.wikipedia.org/wiki/Human_fertilization) to get past the various layers of the cell.
Sperm are from the man, but they are each living creatures on their own which we hope will deliver themselves up to the ovum to create another human being. They vary in their genetic quality and effectiveness and this is highly related to their genetic make up.
Because each sperm is the product of two stages of Meiosis, they can be full of genetic defects, most of which would be fatal in a diploid human being. The functions of the sperm as it goes through its short but competitive life weed out genetic abberations and help assure that the next generation of diploid human beings is as healthy as they can.
So they are not DNA boxes that swim. I'd be hard pressed to think of a passive role for a cell in biology - they are all working pretty hard... I'd be interested in a comment with suggestions of something that is not under selective pressure in biology.
It sort of reminds me of the old argument about passive mating in females. Behavioral biologists used to think that female animals had little or no active role in mating. That [myth was retired about 30 years ago now](http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3826201/). That link points to an introduction to an [entire volume reviewing that whole discussion of active female roles in reproduction](http://rstb.royalsocietypublishing.org/content/368/1631.toc) in case anyone reading is interested.
BTW I'm not an expert on gametes, but I'd be surprised if the ova also didn't have a complimentary but quite different selective process they had to get through to become a fully presented candidate for fertilization.
Just to add a note about how the functioning sperm genes affect the diploid organism: This is one of the most important things that sperm does. The genes that function in the living spermatazoan are the *same genes* the diploid organism uses, or at least a substantial number of them. Further, these genes are scattered across all the chromosomes and so major chromosomal defects and important genes are functional if fertilization is completed. As an example here's a cool blog post about how [mosquito sperm have been shown to use odorant receptors to orient themselves in the fertilziation process](http://nittygrittyscience.com/2014/04/14/mosquito-sperm-need-to-smell-to-swim/). Those same receptors and the signalling genes that link that signal to the sperm behavior are probably quite useful to the adult mosquito. I'd be surprised if human sperm also did not use similar pathways to function.
Not to beat a dead horse, but the recent nature has a report of [small RNAs in mouse sperm as being an epigenetic carrier for stress](http://www.nature.com/news/sperm-rna-carries-marks-of-trauma-1.15049). |
25,915,729 | I have set up my Angular app so when it's pushed to Heroku it runs `bower install`. However I'm getting errors due to version issues.
When I run `bower install` locally I get presented with this:
```
Unable to find a suitable version for angular, please choose one:
1) angular#1.2.16 which resolved to 1.2.16 and is required by angular-resource#1.2.16
2) angular#1.2.23 which resolved to 1.2.23 and is required by angular-cookies#1.2.23
3) angular#>= 1.0.8 which resolved to 1.2.25 and is required by angular-ui-router#0.2.10
4) angular#^1 which resolved to 1.2.25 and is required by angular-ui-codemirror#0.1.6
5) angular#~1.2.2 which resolved to 1.2.25 and is required by splitter#f5c2195050
6) angular#>=1.0.6 which resolved to 1.2.25 and is required by angular-elastic#2.4.0
7) angular#~1.2 which resolved to 1.2.25 and is required by angular-nanoscroller#0.2.1
8) angular#~1.2.9 which resolved to 1.2.25 and is required by angular-sockjs#0.0.1Prefix the choice with ! to persist it to bower.json
? Answer::
```
What should I do with this - I actually need version 1.3 of Angular because of the debounce feature
My `bower.json` looks like this:
```
{
"name": "myapp",
"version": "0.0.1",
"dependencies": {
"json3": "~3.3.1",
"es5-shim": "~3.1.0",
"angular-resource": "1.2.16",
"angular-sanitize": "1.2.16",
"angular-animate": "1.2.16",
"angular-ui-router": "~0.2.10",
"jquery": "~2.1.1",
"angular-ui-codemirror": "~0.1.6",
"splitter": "*",
"angular-cookies": "~1.2.23",
"angular-elastic": "~2.4.0",
"angular-local-storage": "~0.0.7",
"chance": "~0.5.6",
"nanoscroller": "~0.8.4",
"angular-nanoscroller": "~0.2.1",
"angular-sockjs": "~0.0.1"
}
}
``` | 2014/09/18 | [
"https://Stackoverflow.com/questions/25915729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1003632/"
] | Update your current angular dependencies to 1.3.x and add a resolution for angular to suppress the prompt:
```
{
"name": "myapp",
"version": "0.0.1",
"dependencies": {
"angular": "~1.3.x",
"angular-animate": "~1.3.x",
"angular-cookies": "~1.3.x",
"angular-resource": "~1.3.x",
"angular-sanitize": "~1.3.x",
"angular-ui-router": "~0.2.10",
"angular-ui-codemirror": "~0.1.6",
"angular-elastic": "~2.4.0",
"angular-local-storage": "~0.0.7",
"angular-nanoscroller": "~0.2.1",
"angular-sockjs": ">=0.0.1",
"json3": "~3.3.1",
"es5-shim": "~3.1.0",
"jquery": "~2.1.1",
"splitter": "*",
"chance": "~0.5.6",
"nanoscroller": "~0.8.4"
},
"resolutions": {
"angular": "~1.3.x"
}
}
``` |
68,023,441 | I've been struggling with this for ages and I can't figure out why I can't pass this at all.
I have an array that look like this:
```
{
"status": "OK",
"tickets": {
"open_tickets": [
{
"uuid": "XXXXXXX",
"package": {
"title": "XXXX",
"buyer": {
"name": "XXX",
"family_name": null,
"email": "XXXXX",
"buyer_profile": {
"telephone": "5435345"
}
}
}
}
],
"closed_tickets": []
}
}
```
I'm trying access the nested array(s). specifically, `open_tickets`.
So, I've tried this:
I've placed this in at the top of my view between the struct and body:
```
@ObservedObject var fetcherL = FetcherL()
```
And this is now I try to read that data from a remote URL:
```
public class FetcherL: ObservableObject {
@Published var ticket = [Open_Tickets]()
init(){
load()
}
func load() {
let url = URL(string: "HTTPS://xxxxxxx")
var request = URLRequest(url: url!)
URLSession.shared.dataTask(with: request) {(data,response,error) in
do {
if let d = data {
let res = try JSONDecoder().decode(RootO.self, from: d)
DispatchQueue.main.async {
//self.ticket = res.tickets.open_tickets
self.ticket = res.tickets.open_tickets
}
}else {
print("No Data")
}
} catch {
print (error)
}
}.resume()
}
}
struct RootO: Codable {
let tickets: [Tickets]
enum CodingKeys: String, CodingKey {
case tickets = "tickets"
}
}
struct Tickets: Codable {
let open_tickets: [Open_Tickets]
enum CodingKeys: String, CodingKey {
case open_tickets = "open_tickets"
}
}
struct Open_Tickets: Codable{
let ticket_number: String
enum CodingKeys: String, CodingKey {
case ticket_number = "ticket_number"
}
}
```
But this code Is giving this error and stops me from compiling my app:
```
Value of type '[Tickets]' has no member 'open_tickets'
```
[![enter image description here](https://i.stack.imgur.com/1hTGc.png)](https://i.stack.imgur.com/1hTGc.png)
Can someone please advice on this? | 2021/06/17 | [
"https://Stackoverflow.com/questions/68023441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1169039/"
] | The reason you are getting the error is in your **Root0**:
```
struct RootO: Codable {
let tickets: [Tickets]
enum CodingKeys: String, CodingKey {
case tickets = "tickets"
}
}
```
You are expecting your Root0 to have a field called **tickets** expecting an array of **Tickets**, but the **tickets** attribute of the response is a dictionary of `[String: [Tickets]`
Here is a working solution:
```
let json = """
{
"status": "OK",
"tickets": {
"open_tickets": [
{
"uuid": "XXXXXXX",
"package": {
"title": "XXXX",
"buyer": {
"name": "XXX",
"family_name": null,
"email": "XXXXX",
"buyer_profile": {
"telephone": "5435345"
}
}
}
}
],
"closed_tickets": []
}
}
""".data(using: .utf8)!
struct RootO: Codable {
let tickets: [String: [Ticket]]
var openTickets: [Ticket] {
if let data = tickets["open_tickets"] {
return data
} else {
return []
}
}
var closedTickets: [Ticket] {
if let data = tickets["closed_tickets"] {
return data
} else {
return []
}
}
}
struct Ticket: Codable {
let ticketNumber: String
enum CodingKeys: String, CodingKey {
case ticketNumber = "uuid"
}
}
let decoder = JSONDecoder()
let decoded = try! decoder.decode(RootO.self, from: json)
print("Open tickets = \(decoded.openTickets.count)")
print("Closed tickets = \(decoded.closedTickets.count)")
```
Some advice:
------------
* Use *singular* nouns for your struct **Ticket** not Tickets.
* You do not need to provide the coding keys if the attribute name is identical |
35,682,162 | Iam trying to sum the div value that are comma separated and if has 2 decimal value then sum that decimal value and show if none of it has decimal value then show total.00 in final result but my code is giving me false calculation.
[JS Fiddle](http://jsfiddle.net/shaikasifpasha3/9GVNT/27/)
HTML:
```
<div class=''>432.01</div>
<div class=''>4,12,412.01</div>
<div class=''>4,12,412.01</div>
<div class=''>12,41,241.01</div>
<span></span>
```
JS:
```
var sum = 0;
$('div').each(function() {
var val = $(this).text().replace(',', '.');
sum += parseFloat(val, 10);
});
$('span').text('result=' + sum);
``` | 2016/02/28 | [
"https://Stackoverflow.com/questions/35682162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4882188/"
] | You could use the following list comprehension:
```
L1 = [
{'ID':'1','file':'test1','ext':'txt'},
{'ID':'2','file':'test2','ext':'txt'},
{'ID':'3','file':'test3','ext':'py'}
]
L2 = [
{'file':'test1','ext':'txt','val':'5'},
{'file':'test3','ext':'py','val':'7'},
{'file':'test4','ext':'py','val':'8'}
]
L = [d1 for d1 in L1 if any(
d2.get('file') == d1['file'] and d2.get('ext') == d1['ext'] for d2 in L2)]
print(L)
```
**Output**
```
[{'ID': '1', 'ext': 'txt', 'file': 'test1'},
{'ID': '3', 'ext': 'py', 'file': 'test3'}]
```
This iterates over each dictionary `d1` in `L1`, and for each one tests if both the key:value pairs of `d1['file']` and `d1['ext']` exist in any of the dictionaries in `L2`. |
505,764 | I'm trying to install MySQL on Ubuntu 18.04. To do that, first I have donwload the package with the command:
```
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
```
And then, run the command:
```
sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
```
But I've got a problem with dependencies and I don't know what are these dependencies. This is part of the message that I've got:
```
Configuring mysql-community-server (8.0.15-1ubuntu18.04) ...
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-03-12 01:06:40 CET; 17ms ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 12302 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 12263 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 12302 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
mar 12 01:06:39 R2D2 systemd[1]: Starting MySQL Community Server...
mar 12 01:06:40 R2D2 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
mar 12 01:06:40 R2D2 systemd[1]: mysql.service: Failed with result 'exit-code'.
mar 12 01:06:40 R2D2 systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 8.0.15-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-server-dbgsym:
mysql-community-server-dbgsym depends on mysql-community-server (= 8.0.15-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-community-server-dbgsym (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-community-server
mysql-server
mysql-community-server-dbgsym
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
---
This is the log that I get consulting with `journalctl -xe`:
```
josecarlos@R2D2:~/Descargas$ journalctl -xe
mar 12 01:35:01 R2D2 CRON[13062]: pam_unix(cron:session): session closed for user root
mar 12 01:36:01 R2D2 org.gnome.Shell.desktop[1874]: (/usr/lib/firefox/firefox:10916): dconf-WARNING **: 01:36:01.2
mar 12 01:36:39 R2D2 sudo[13085]: josecarlos : TTY=pts/0 ; PWD=/home/josecarlos/Descargas ; USER=root ; COMMAND=/u
mar 12 01:36:39 R2D2 sudo[13085]: pam_unix(sudo:session): session opened for user root by (uid=0)
mar 12 01:36:40 R2D2 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has begun starting up.
mar 12 01:36:40 R2D2 audit[13150]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile
mar 12 01:36:40 R2D2 kernel: audit: type=1400 audit(1552351000.784:89): apparmor="STATUS" operation="profile_repla
mar 12 01:36:41 R2D2 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
mar 12 01:36:41 R2D2 systemd[1]: mysql.service: Failed with result 'exit-code'.
mar 12 01:36:41 R2D2 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mysql.service has failed.
--
-- The result is RESULT.
mar 12 01:36:41 R2D2 sudo[13085]: pam_unix(sudo:session): session closed for user root
```
---
Output of `sudo apt update && sudo apt upgrade`:
```
Hit:1 http://es.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://repo.mysql.com/apt/ubuntu bionic InRelease
Hit:3 http://archive.canonical.com/ubuntu bionic InRelease
Hit:4 https://deb.nodesource.com/node_11.x bionic InRelease
Hit:5 http://packages.microsoft.com/repos/vscode stable InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up mysql-community-server (8.0.15-1ubuntu18.04) ...
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
* mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-03-12 12:17:46 CET; 8ms ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 8839 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 8800 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 8839 (code=exited, status=1/FAILURE)
Status: "SERVER_BOOTING"
mar 12 12:17:45 R2D2 systemd[1]: Starting MySQL Community Server...
mar 12 12:17:46 R2D2 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
mar 12 12:17:46 R2D2 systemd[1]: mysql.service: Failed with result 'exit-code'.
mar 12 12:17:46 R2D2 systemd[1]: Failed to start MySQL Community Server.
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 8.0.15-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-community-server-dbgsym:
mysql-community-server-dbgsym depends on mysql-community-server (= 8.0.15-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-community-server-dbgsym (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-community-server
mysql-server
mysql-community-server-dbgsym
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
---
I have make a big mistake and this is that I've got installed mysql-server-5.5 previously in my laptop. I have remove and purge everything and reinstall again, but it doesn't work.
The log of the command `sudo apt install mysql-server` is:
```
josecarlos@R2D2:~$ LANG=C sudo apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server
mysql-community-server-core
The following NEW packages will be installed:
libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server
mysql-community-server-core mysql-server
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 58,3 MB of archives.
After this operation, 418 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://es.archive.ubuntu.com/ubuntu bionic/universe amd64 libmecab2 amd64 0.996-5 [257 kB]
Get:2 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-common amd64 8.0.15-1ubuntu18.04 [84,4 kB]
Get:3 http://es.archive.ubuntu.com/ubuntu bionic/universe amd64 mecab-utils amd64 0.996-5 [4.856 B]
Get:4 http://es.archive.ubuntu.com/ubuntu bionic/universe amd64 mecab-ipadic all 2.7.0-20070801+main-1 [12,1 MB]
Get:5 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-client-core amd64 8.0.15-1ubuntu18.04 [1.450 kB]
Get:6 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-client amd64 8.0.15-1ubuntu18.04 [2.310 kB]
Get:7 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-client amd64 8.0.15-1ubuntu18.04 [81,0 kB]
Get:8 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-server-core amd64 8.0.15-1ubuntu18.04 [17,6 MB]
Get:9 http://es.archive.ubuntu.com/ubuntu bionic/universe amd64 mecab-ipadic-utf8 all 2.7.0-20070801+main-1 [3.522 B]
Get:10 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-server amd64 8.0.15-1ubuntu18.04 [24,2 MB]
Get:11 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-server amd64 8.0.15-1ubuntu18.04 [81,0 kB]
Fetched 58,3 MB in 2s (30,7 MB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 821063 files and directories currently installed.)
Preparing to unpack .../00-mysql-common_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-common (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-client-core.
Preparing to unpack .../01-mysql-community-client-core_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-client-core (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-client.
Preparing to unpack .../02-mysql-community-client_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-client (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package mysql-client.
Preparing to unpack .../03-mysql-client_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-client (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package libmecab2:amd64.
Preparing to unpack .../04-libmecab2_0.996-5_amd64.deb ...
Unpacking libmecab2:amd64 (0.996-5) ...
Selecting previously unselected package mysql-community-server-core.
Preparing to unpack .../05-mysql-community-server-core_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-server-core (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-server.
Preparing to unpack .../06-mysql-community-server_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-server (8.0.15-1ubuntu18.04) ...
Selecting previously unselected package mecab-utils.
Preparing to unpack .../07-mecab-utils_0.996-5_amd64.deb ...
Unpacking mecab-utils (0.996-5) ...
Selecting previously unselected package mecab-ipadic.
Preparing to unpack .../08-mecab-ipadic_2.7.0-20070801+main-1_all.deb ...
Unpacking mecab-ipadic (2.7.0-20070801+main-1) ...
Selecting previously unselected package mecab-ipadic-utf8.
Preparing to unpack .../09-mecab-ipadic-utf8_2.7.0-20070801+main-1_all.deb ...
Unpacking mecab-ipadic-utf8 (2.7.0-20070801+main-1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../10-mysql-server_8.0.15-1ubuntu18.04_amd64.deb ...
Unpacking mysql-server (8.0.15-1ubuntu18.04) ...
Setting up mysql-common (8.0.15-1ubuntu18.04) ...
Setting up libmecab2:amd64 (0.996-5) ...
Setting up mysql-community-client-core (8.0.15-1ubuntu18.04) ...
Setting up mysql-community-server-core (8.0.15-1ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up mecab-utils (0.996-5) ...
Setting up mysql-community-client (8.0.15-1ubuntu18.04) ...
Setting up mecab-ipadic (2.7.0-20070801+main-1) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27327
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-client (8.0.15-1ubuntu18.04) ...
Setting up mecab-ipadic-utf8 (2.7.0-20070801+main-1) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27327
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-community-server (8.0.15-1ubuntu18.04) ...
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 8.0.15-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
Righ now, these are the package of mysql-server installed in my laptop:
[![enter image description here](https://i.stack.imgur.com/sry4y.png)](https://i.stack.imgur.com/sry4y.png)
I don't know what am I doing wrong right now. | 2019/03/12 | [
"https://unix.stackexchange.com/questions/505764",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/307606/"
] | This fixed it for me (MySQL 8.0 - Ubuntu 20.04)
```
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
```
But the package "**mysql-client-core-8.0**" don't uninstall, so...
```
sudo apt --fix-broken install
sudo apt-get --reinstall install mysql-client-core-8.0
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
sudo apt update
sudo apt install mysql-server
```
No more errors! |
400,915 | Consider a normal first course on category theory (say up to and including the statement and proof) of the adjoint functor theorem (AFT). What are the minimal assumptions for the definition of a set one needs to make in order that everything works? As far as I understand, up to and including the AFT there is very little one needs besides that fact that sets should have elements and that we have avoided Russell's paradox. So what is a minimal set of axioms allowing this to work? | 2021/08/03 | [
"https://mathoverflow.net/questions/400915",
"https://mathoverflow.net",
"https://mathoverflow.net/users/153228/"
] | To complement Tom Leinster's answer, let me try to be specific:
1. To form the product category $\mathcal{C} \times \mathcal{D}$, we need ordered pairs, which we can get from the axiom of **unordered pairs**.
2. It's probably a good idea to have the **empty set** $\emptyset$, so that the initial category exists.
3. My experience from type theory leads me to believe that we want function extensionality, or else we cannot reasonably work with functors and natural transformations (which are functions). Function extensionalty is equivalent to set-theoretic **extensionalty**.
4. To form the hom-set $\mathrm{Hom}(A,B) = \{f \in \mathcal{C}\_1 \mid \mathrm{dom}(f) = A \land \mathrm{cod}(f) = B\}$ we seemingly need **bounded separation**. It's a little more difficult to see whether we need unbounded separation (my guess would be that we can work pretty nicely without it).
5. To form functor categories, we need **powersets**. Indeed, given any set $A$, its powerset may be generated as the set of objects of the functor category $2^A$, where $2$ is the discrete category on two objects.
6. There are two functors form the terminal category $\mathbf{1}$ to the arrow category $\bullet \to \bullet$. If we think their coequalizer exists (in the category of small categories) then we believe in the axiom of **infinity**, because the coequalier is the monoid of natural numbers.
I am pretty sure the axiom of choice and excluded middle are not needed for general category theory, and foundation also seems quite irrelevant. How about union and replacement? |
9,521,917 | Does C# have something like the JavaScript if or value syntax?
For example, I know you can do this in JavaScript:
```
var test = someValue || thisValue;
```
if **someValue** is undefined, false, or empty string, then test becomes **thisValue**. However, I've never seen a way to do this in C# other than a traditional if, or inline if. | 2012/03/01 | [
"https://Stackoverflow.com/questions/9521917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/129682/"
] | [NullCoalesce](http://msdn.microsoft.com/en-us/library/ms173224.aspx)
```
var test = someValue ?? thisValue;
```
However, C# doesn't do weird JavaScript falsey behaviors.
The short circuit evaluation in C# is more pertinent in evaulating bools:
```
private bool EvaluateA()
{
return true;
}
private bool EvaluateB()
{
return false;
}
public static int main()
{
Console.Write(EvaluateA() || EvaluateB()); // EvaluateB is never called
}
``` |
20,466,813 | I have a folder with several subdirectories containing PHP files. At the moment I open each file individually in Netbeans. However, I would like to open this folder as a project, so I can use features like searching for a line throughout the entire project. Is this possible in Netbeans? What would be the best way to achieve this? | 2013/12/09 | [
"https://Stackoverflow.com/questions/20466813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119562/"
] | Create a new project, set sources directory to the one you have with current files
(might want to back up the files before if anything goes wrong). |
236,149 | Oracle Database Enterprise edition [costs](https://shop.oracle.com/pls/ostore/product?p1=OracleDatabaseEnterpriseEdition&sc=ocom_oracledatabaseenterpriseedition#) $47 000 per processor. I wonder what features make it worth this money? | 2011/02/16 | [
"https://serverfault.com/questions/236149",
"https://serverfault.com",
"https://serverfault.com/users/70972/"
] | My personal opinion (and do feel free to mark it down if you don't agree) is that the people at Oracle aren't that dumb. They know their marketplace and segment there offerings to match. So they price it based on what they believe the customer is willing to pay for the features available.
From the customer perspective i'm sure Oracle's clients do look at the feature set and services they offer. Then if the ROI proposition is sound and the features are required then thats what will be paid.
Having said that the $47,000 is the list price and depending on the company size and influence with Oracle this can be reduced when negotiating contracts. |
12,196,967 | I can't seem to find a lot of information on this checksum algorithm and nothing about in relating to C#, I have a scenerio as follows;
I have a string of data e.g.:
```
string input = "hello world"
```
and I would like to create a checksum, that I can later verify it with the same string | 2012/08/30 | [
"https://Stackoverflow.com/questions/12196967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1557484/"
] | `(byte) input.GetHashCode()`?......... |
9,993,432 | I have used a spinner on a custom alert box. Once the alert pops up there is a spinner attached to it. And after the user clicks on the spinner it gives you a list of countries. And i am searching a way to remove/hide/dismiss that country list (Only the spinner list) programmatically. How to accomplish this?
My goal is to remove that country list which generated from the spinner, once the onPause of the activity invoked. | 2012/04/03 | [
"https://Stackoverflow.com/questions/9993432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/511737/"
] | You may hide the spinner by setting its visibility `GONE` or by making `setEnabled(false)`. But, that doesnt solve your problem i guess. You may have to override `onResume()` and `onPause()` methods for that. |
70,890,482 | I am working on this legacy application. It is using react-scripts-ts for running it. So the scripts section of package.json looks like this:
```
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build"
},
```
I was cleaning some dependencies as they caused us an issue, but I am unable to get the application to work now.
If I do `npm start` all is good and works well.
If I do `npm run buil` all compiles ok no errors. However, if I try to use the application from the built artifacts I get:
```
Uncaught (in promise) TypeError: Super expression must either be null or a function
at 6.fb2d1b96.chunk.js:1:99050
at 6.fb2d1b96.chunk.js:1:99118
at Object.e.exports (6.fb2d1b96.chunk.js:1:100445)
...
```
Would you have any pointers or tips on how to debug this? | 2022/01/28 | [
"https://Stackoverflow.com/questions/70890482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11875271/"
] | Since I cannot post Chinese texts in SO, I will demonstrate how to do it with English sentences, but the same applies to Chinese:
```py
import tensorflow as tf
text = ['This is a chinese sentence',
'This is another chinese sentence']
tokenizer = tf.keras.preprocessing.text.Tokenizer(num_words=50, char_level = False)
tokenizer.fit_on_texts(text)
print(tokenizer.word_index)
```
```
{'this': 1, 'is': 2, 'chinese': 3, 'sentence': 4, 'a': 5, 'another': 6}
```
Make sure you have a list of Chinese space-separated sentences and it should work correctly. Using a list of lists will lead to unexpected behavior. |
377,167 | I'm a total beginner so I'm sorry for stupid question(s).
I want to design a circuit and I'm stuck. Here's the description:
Photosensor outputs 0V until the ambient light decreases below certain level, after which it outputs 5V. With that signal, I want to turn on 24 V light bulb (draws 250 mA).
I have a few questions:
* I definitely need 24 V battery or 24 V DC voltage source in my circuit right? I can't do much with just 5V?
* In LTspice there's no photosensor. Can I use 5 V DC voltage source instead? (As far I understand, photosensor acts as switch, right?)
* Do I use MOSFET or BJT?
If you check the picture, I tried to do it like this: The 5 V DC on left side activates the MOSFET. I need resistance of 93 ohm (since 24-0,7=23,3 and I want 250 mA). But it's not working. I think that left DC voltage is destroying my circuit.
Any help would be appreciated.
[![schematic](https://i.stack.imgur.com/Ohmha.png)](https://i.stack.imgur.com/Ohmha.png) | 2018/05/30 | [
"https://electronics.stackexchange.com/questions/377167",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/190178/"
] | *I want to design a circuit and I'm stuck.*
Yeah well, like many, many "aspiring circuit designers" have experienced before you, it is **nearly impossible** to do circuit design without knowing how certain circuits are build up. Yes, a MOSFET can act as a switch and yes a resistor can limit a current but knowing that is not enough.
For example, for an NMOS to act as a switch its gate-source voltage needs to be switched between for example 0 V (off) and 5 V (on). In your circuit the 5 V for on/off sits between the gate and something that is not the source.
I strongly advise you to search the internet and look for circuits which do the same. "NMOS switch circuit" should be a good start. Use the "images" tab to see pictures of schematics. Not how many are similar. Then build something similar in LTspice and experiment with it.
To learn how to properly design circuits I would recommend **looking** at circuits a lot and figure out what makes them tick. Re-build circuits in a simulator and make **small modifications** then **think** what effect that will have and then **confirm that** using the simulator. If you like that and gain more experience with that you can become an excellent circuit designer.
If you just want the night light function and don't aspire a career in electronics ( :-( but your choice) then **don't** try to design a circuit yourself, it will end in tears. Just browse the internet for similar projects and **copy that**. Circuit design isn't something you can learn quickly to make a circuit you suddenly need. The hard work has been done already by others so just copy what they did. |
26,850,039 | I'm trying to create a Redis Elasticache cluster using boto in the sa-east-1 region, and boto is giving me this error message:
```
{"Error":{"Code":"InvalidParameterValue","Message":"sa-east-1 is not a valid availability zone.","Type":"Sender"},"RequestId":"2q34hj192-6902-11e4-8b4a-afafaefasefsadfsadf"}
```
with this code:
```
from boto.elasticache.layer1 import ElastiCacheConnection
self.elasticache = ElastiCacheConnection()
boto.elasticache.connect_to_region(
'sa-east-1a',
aws_access_key_id=settings.AWS_ACCESS_KEY,
aws_secret_access_key=settings.AWS_SECRET_KEY
)
elasticache.create_cache_cluster(
cache_cluster_id='test1',
engine='redis',
cache_node_type='cache.m3.medium',
num_cache_nodes=1,
preferred_availability_zone='sa-east-1',
)
```
Thanks | 2014/11/10 | [
"https://Stackoverflow.com/questions/26850039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/307283/"
] | It's asking you for an availability zone but you are providing it with a region. Correct values would be one of `sa-east-1a` or `sa-east-1b` or just leave it blank if you have no preference. |
8,715 | Jeff mentioned in one of the podcasts that one of the things he always does is put in instrumentation for database calls, so that he can tell what queries are causing slowness etc. This is something I've measured in the past using SQL Profiler, but I'm interested in what strategies other people have used to include this as part of the application.
Is it simply a case of including a timer across each database call and logging the result, or is there a 'neater' way of doing it? Maybe there's a framework that does this for you already, or is there a flag I could enable in e.g. Linq-to-SQL that would provide similar functionality.
I mainly use c# but would also be interested in seeing methods from different languages, and I'd be more interested in a 'code' way of doing this over a db platform method like SQL Profiler. | 2008/08/12 | [
"https://Stackoverflow.com/questions/8715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/908/"
] | If a query is more then just a simple SELECT on a single table I always run it through EXPLAIN if I am on MySQL or PostgreSQL. If you are using SQL Server then Management Studio has a Display Estimated Execution Plan which is essentially the same. It is useful to see how the engine will access each table and what indexes it will use. Sometimes it will surprise you. |
5,917,431 | Using monotouch and monodevelop, I'd like to create a custom control.
I followed this steps:
* add a new file as "iPhone View" (calling it TestView)
* edit TestView.xib in Interface Builder, es. changing it's background and size
* edit MainWindow.xib in Interface Builder, adding a UIView and setting it's class identity as "TestView".
At this point, I'd like to launch the application and see in the UIView of MainWindow the content of an instance of TestView.
In order to get this "binding" I tried several steps (I know it can be done via code creating the outlets, etc.., but I'd like to understand if it can be done via Interface builder).
In one of the methods tried, I set via Interface Builder the value "TestView" as class identifier in the View of TestView.xib: in this way MonoTouch created the code in TestView.xib.designer.cs.
```
[MonoTouch.Foundation.Register("TestView7")]
public partial class TestView7 {
}
```
Then, in TestView.xib.cs, I added:
```
public partial class TestView : UIView
{
public TestView (IntPtr p) : base(p)
{
}
}
```
When I launch the app, I cannot see in the view of MainWindow the content of TestView, but if in TestView constructor I add something such as
BackgroundColor = UIColor.Yellow;
then, I can see TestView in MainWindow... or better I can see only the yellow rectangle, not the real content!
So, the problem is that TestView is binded to the UIView in MainWindow, but it's content comes only from the code and not from the content defined via Interface Builder in TestView.xib.
Is there a way to load the content from the TestView.xib? | 2011/05/06 | [
"https://Stackoverflow.com/questions/5917431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742513/"
] | There's nothing inherently 'bad' about using GET requests for non-idempotent operations, for example SOAP uses GET (or POST?) for all operations. Some web browsers, however, will view a link that uses GET as idempotent and try to pre-fetch it for you. This is a bad thing of course if that link was to perform a delete row on your back end database. |
47,842 | I want My formula to show Tier 0 if lifetime account Revenue is between 0 and 999, Tier 1 if Lifetime Account revenue is between 1000 and 10000 and so on.
Here is the formula I have:
```
IF (Lifetime_Account_Revenue__c >= 0, <= 999, "Tier 0",
IF (Lifetime_Account_Revenue__c >= 1000, <= 10000, "Tier 1",
IF (Lifetime_Account_Revenue__c >= 10001, <= 25000, "Tier 2",
IF (Lifetime_Account_Revenue__c >= 25001, <=50000, "Tier 3",
IF (Lifetime_Account_Revenue__c >= 50001, "Tier 4",
"")))))
```
I get a syntax error that says
>
> Error: Syntax error. Found '<='
>
>
>
Please Help! | 2014/08/26 | [
"https://salesforce.stackexchange.com/questions/47842",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/11205/"
] | You are trying to put in two conditions in your IF statements, if you want to do that, then you need to use an `AND()` statement. This should work for you
```
IF (AND(Lifetime_Account_Revenue__c >= 0, Lifetime_Account_Revenue__c <= 999), "Tier 0",
IF (AND(Lifetime_Account_Revenue__c >= 1000, Lifetime_Account_Revenue__c <= 10000), "Tier 1",
IF (AND(Lifetime_Account_Revenue__c >= 10001, Lifetime_Account_Revenue__c <= 25000), "Tier 2",
IF (AND(Lifetime_Account_Revenue__c >= 25001, Lifetime_Account_Revenue__c <= 50000), "Tier 3",
IF (Lifetime_Account_Revenue__c >= 50001, "Tier 4",
"")))))
```
For more information on formulas and operators, take a look [here](https://help.salesforce.com/HTViewHelpDoc?id=customize_functions.htm&language=en_US) |
50,611,908 | I would like to subset my data frame by selecting columns with partial characters recognition, which works when I have a single "name" to recognize.
where the data frame is:
```
ABBA01A ABBA01B ABBA02A ABBA02B ACRU01A ACRU01B ACRU02A ACRU02B
1908 NA NA NA NA NA NA NA NA
1909 NA NA NA NA NA NA NA NA
1910 NA NA NA NA NA NA NA NA
1911 NA NA NA NA NA NA NA NA
1912 NA NA NA NA NA NA NA NA
1913 NA NA NA NA NA NA NA NA
library(stringr)
df[str_detect(names(df), "ABBA" )]
```
works, and returns:
```
ABBA01A ABBA01B ABBA02A ABBA02B
1908 NA NA NA NA
```
So, I would like to create a dataframe for each of my species:
```
Speciesnames=unique ( substring (names(df),0, 4))
Speciesnames
[1] "ABBA" "ACRU" "ARCU" "PIAB" "PIGL"
```
I have tried to make a loop and use [i] as species name but the str\_detect funtion does not recognise it.
and I would like to add additional calculations in the loop
```
for ( i in seq_along(Speciesnames)){
df=df[str_detect(names(df), pattern =[i])]
print(df)
#my function for the subsetted dataframe
}
```
thank you for your help! | 2018/05/30 | [
"https://Stackoverflow.com/questions/50611908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2991591/"
] | Using your data you could do the following:
1. create a list to hold the data.frames to be created.
2. filter the data.frames and store in the list
3. give each data.frame the name of of the specie
4. bring all the data.frames to the global environment out of the list
```
Speciesnames <- unique(substring(names(df),0, 4))
data <- vector("list", length(Speciesnames))
for(i in seq_along(Speciesnames)) {
data[[i]] <- df %>% select(starts_with(Speciesnames[i]))
}
names(data) <- Speciesnames
list2env(data, envir = globalenv())
```
The end result after `list2env`is 2 data.frames called "ABBA" "ACRU" which you then can access. If further manipulation is needed you might leave everything in the list and do it there. |
26,852,991 | I've been looking around and perhaps I'm missing something, but I've been totally unable to figure out how to get this working. Basically, I want a state with three parallel views. Lets call them header, body, and footer. Header and footer work just fine as simple parallel views, but I haven't been able to figure out how to automatically render the body child state, so that I can use it to manage other views.
app.js
```
.state('main', {
url: '/',
views: {
mainModule: { templateUrl: 'partials/main.html'},
"header@main": {
templateUrl: "partials/header.html",
},
"footer@orders": {
templateUrl: "partials/footer.html",
},
}
})
.state('main.body',{
url:'/',
template:"<p>Test!</p>"
})
```
main.html
```
<div ui-view="header"></div>
<div ui-view></div>
<div ui-view="footer"></div>
```
I have a feeling that the ui-view section of the html is not the way to go, and that the answer might have to do with abstract states, but thus far I haven't managed to get it working. Any help would be appreciated.
I have also attempted to reference a view as if it were a state, but that also rendered nothing.
[This](https://stackoverflow.com/a/23997704/3043447) answer seems to come close, but I haven't been able to get what is suggested in the comments working.
I've looked at other questions that are layout related, but none of the solutions I've come across have worked for me. Thanks! | 2014/11/10 | [
"https://Stackoverflow.com/questions/26852991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043447/"
] | There is [a working plunker](http://plnkr.co/edit/cHepOKbCSOP8DWgv9QJ9?p=preview), showing all the small adjustments described below in action.
Firstly, we must be sure, that our index.html, the root view, has the place for our `'mainModule'` view template. So this is a snippet of the *index.html*:
```
<body>
<div ui-view="mainModule" ></div>
...
```
That, means, that our core view *(one of views defined in 'main' state)* will be properly injected into root view.
Now, our header and footer should both be using absolute names, but their suffix must be **'main'** *(not 'orders' like above for footer)*. That is saying to UI-Router: place them inside of views defined in this state (main.html)
Also, we can *(as part of this `'main'` state)* define some default content of the *"body"*. It could be let's say some list view...
```
.state('main', {
url: '/',
views: {
// it could be "mainModule" as well... so it needs its: ui-view="mainModule"
mainModule: { templateUrl: 'tpl.main.html'},
"header@main": {
...
},
// wrong absolute name
// "footer@orders": {
// we need the 'main' as well
"footer@main": {
...
},
// even the body, unnamed view could have some default
"@main": {
templateUrl: "tpl.list.html", // e.g. list
},
}
```
Next, we can defined few more states as children of the 'main'. They will *(by default)* use the unnamed view of the **main**. And what's more - replace the list view used above:
```
.state('main.body',{
url:'/body',
...
})
.state('main.detail',{
url:'/detail:/id',
...
})
```
Observe it [here](http://plnkr.co/edit/cHepOKbCSOP8DWgv9QJ9?p=preview), it should give all the answers... |
35,063,167 | I'm having a very simple problem which I can't overcome.
I have a parent div, with 4 images inside, I would like the images to overflow from the parent div (horizontally) but I can't seem to achieve this.
```css
.imgBanner {
border: 1px solid black;
width: 400px;
height: 400px;
display: inline-block;
}
.slideShow {
width: 400px;
}
```
```html
<div class="slideShow">
<img class="imgBanner">
<img class="imgBanner">
<img class="imgBanner">
<img class="imgBanner">
</div>
```
This is the code that I am using, but it doesn't seem to overflow, even though I am using display inline-block.
The outcome will be to hide the overflown images, and use JavaScript to create a slideshow.
EDIT: Forgot to add the fiddle. <https://jsfiddle.net/pwL2hy7s/>
Thanks :) | 2016/01/28 | [
"https://Stackoverflow.com/questions/35063167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2103072/"
] | You can use
```
white-space: nowrap;
```
on the container. This will allow the elements to continue being inline, without being forced to break. |
35,811 | I have installed CentOS 6.2 on HP Proliant server. I want to share my USB wireless internet (Tata photon +).
I am able to start internet on my server, but when I enable my LAN, I don't have internet access anymore. Also I am not able to share my server's internet to other Windows 7 computers.
How can I share my connection? | 2012/04/05 | [
"https://unix.stackexchange.com/questions/35811",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/17417/"
] | You can share the internet by configuring the Cent OS server as a NAT machine and giving private ip addresses to the LAN machines. As in your case, **the USB wireless interface is ppp0 and the LAN interface is eth0 on the Cent OS server**.
**Step-1:** Providing private ip addresses to LAN interface on Cent OS and to the other machines in the LAN.
You can give any of the following private ip addresses.
1. Class A (10.x.x.x )
2. Class B (172.16.x.x to 172.31.x.x)
3. Class C (192.168.x.x)
Suppose we select Class B private subnet 172.31.100.0/24 (netmask 255.255.255.0).
Assign 172.31.100.1 to eth0 of Cent OS machine statically. Similarly keep on assigning the private ip 172.31.100.2 , 172.31.100.3, and so on to the other machines in the subnet among whom you want to share the internet.
Check whether all the machines in the LAN are able to ping eth0 interface of Cent OS machine by using `ping` utility.
From all the machines try the following command:
`$ ping 172.31.100.1`
If ping reply is coming then configure the next step.
**Step-2:**
Now next step is to configure the Cent OS machine as Network Address Translator.
You can use `iptables` to configure the Cent OS machine as NAT machine.
**NOTE: Do all the below configurations using `root` access.**
By configuring the following rules you can configure the server as NAT machine:
Flush all the existing rules first:
`$ iptables -F`
Then give the following commands:
`$ iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE`
`$ iptables --append FORWARD --in-interface eth0 -j ACCEPT`
You have to configure the Cent OS machine so that it can forward the packets. For this you have to give following command.
`$ echo 1 > /proc/sys/net/ipv4/ip_forward`
Now every machine in your subnet should be able to access the internet. |
7,005,963 | I have made a class named Entity, and have the following code:
```
Entity zombie1 = new Entity();
```
I get input 'zombie' from a scanner, and then concatenate a number, based on level on the end of that, leaving 'zombie1' as the string... I want to be able to use that string and call
```
zombie1.shoot("shotgun");
```
but I can't seem to find a solution. I'd just do a if statement but I want to be able to create as many zombies as I want and not have to put in more if statements every single time.
I've read articles using reflection and forString but that doesn't seem to be what i'm looking for.
Any help would be nice. | 2011/08/10 | [
"https://Stackoverflow.com/questions/7005963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/887179/"
] | Possible solutions are to use a `Map<String, Entity>` to be able to store and retrieve entities based on specific Strings. If you have a limited number of sub-types of Entity such as Zombies, Vampires, Victims, etc, you could have a `Map<String, List<Entity>>`, allowing you to map a String to a specific type of entity and then get that type by number.
e.g.,
```
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Foo002 {
private static final String ZOMBIE = "zombie";
public static void main(String[] args) {
Map<String, List<Entity>> entityMap = new HashMap<String, List<Entity>>();
entityMap.put(ZOMBIE, new ArrayList<Entity>());
entityMap.get(ZOMBIE).add(new Entity(ZOMBIE, "John"));
entityMap.get(ZOMBIE).add(new Entity(ZOMBIE, "Fred"));
entityMap.get(ZOMBIE).add(new Entity(ZOMBIE, "Bill"));
for (Entity entity : entityMap.get(ZOMBIE)) {
System.out.println(entity);
}
}
}
class Entity {
private String type;
private String name;
public Entity(String type, String name) {
this.type = type;
this.name = name;
}
public String getType() {
return type;
}
public String getName() {
return name;
}
@Override
public String toString() {
return type + ": " + name;
}
}
``` |
50,861,641 | I have a task which restores our NuGet package for our dotnet core application:
```
Task("Restore-Packages")
.Does(() =>
{
DotNetCoreRestore(sln, new DotNetCoreRestoreSettings {
Sources = new[] {"https://my-team.pkgs.visualstudio.com/_packaging/my-feed/nuget/v3/index.json"},
Verbosity = DotNetCoreVerbosity.Detailed
});
});
```
However when run on VSTS it errors with the following:
```
2018-06-14T15:10:53.3857512Z C:\Program Files\dotnet\sdk\2.1.300\NuGet.targets(114,5): error : Unable to load the service index for source https://my-team.pkgs.visualstudio.com/_packaging/my-feed/nuget/v3/index.json. [D:\a\1\s\BitCoinMiner.sln]
2018-06-14T15:10:53.3857956Z C:\Program Files\dotnet\sdk\2.1.300\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\BitCoinMiner.sln]
```
How do I authorize access for the build agent to our private VSTS? | 2018/06/14 | [
"https://Stackoverflow.com/questions/50861641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4079967/"
] | I literally just had this same problem, apparently the build agents in VSTS can't get to your private VSTS feed without an access token so you are going to have to create a Personal Access Token in VSTS and provide that to the built in Cake method to add an authenticated VSTS Nuget feed as one of the sources. Here, I have wrapped it in my own convenience Cake method that checks to see if the package feed is already present, if not, then it adds it:
```
void SetUpNuget()
{
var feed = new
{
Name = "<feedname>",
Source = "https://<your-vsts-account>.pkgs.visualstudio.com/_packaging/<yournugetfeed>/nuget/v3/index.json"
};
if (!NuGetHasSource(source:feed.Source))
{
var nugetSourceSettings = new NuGetSourcesSettings
{
UserName = "<any-odd-string>",
Password = EnvironmentVariable("NUGET_PAT"),
Verbosity = NuGetVerbosity.Detailed
};
NuGetAddSource(
name:feed.Name,
source:feed.Source,
settings:nugetSourceSettings);
}
}
```
and then I call it from the "Restore" task:
```
Task("Restore")
.Does(() => {
SetUpNuget();
DotNetCoreRestore("./<solution-name>.sln");
});
```
Personally, I prefer to keep PATs away from the source control so here I am reading from env vars. In VSTS you can create an environment variable under the Variables tab of your CI build configuration.
[![enter image description here](https://i.stack.imgur.com/zu1Ll.jpg)](https://i.stack.imgur.com/zu1Ll.jpg)
Hope this helps! Here is a [link](https://cakebuild.net/dsl/nuget/) to Cake's documentation. |
40,206,779 | I have an ASP.NET Core application going on an have setup Github auto-deploy on it. But since it's an open repo I obviously don't want to upload my correct configuration file.
What I'd like to do is to replace some strings in the appsettings.json after a github auto deploy.
```
"AppSettings": {
"Token": "my super duper secret token"
}
```
How can I change `my super duper secret token` to my real token after a github deploy on Azure? | 2016/10/23 | [
"https://Stackoverflow.com/questions/40206779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681045/"
] | As I know we can config token in App Settings on the Azure port.
I do a test on this, it works successfully, the following is my detail steps.
1. Create an Asp.net core Application.
2. Add [AppSettings] section in the appsetting.json file (**Token vaule: mysecretkey**).
[![enter image description here](https://i.stack.imgur.com/Owsmg.png)](https://i.stack.imgur.com/Owsmg.png)
3. Add a public class AppSettings.cs under the created project.
[![enter image description here](https://i.stack.imgur.com/abfpG.png)](https://i.stack.imgur.com/abfpG.png)
4. Add the code `services.Configure<AppSettings>(Configuration.GetSection("AppSettings"))` in the function ConfigureService function in the Startup.cs file *(For .net Core 1.0)*.
>
> *Note:The syntax for model binding has changed from RC1 to RC2. Using `services.Configure<AppSettings>(Configuration.GetSection("AppSettings"))`, is no longer availableIn order to bind a settings class to your configuration you need to configure this in the ConfigureServices method of Startup.cs:
> `services.Configure<AppSettings>(options => Configuration.GetSection("AppSettings").Bind(options));`*
>
>
>
[![enter image description here](https://i.stack.imgur.com/HXDtU.png)](https://i.stack.imgur.com/HXDtU.png)
5. Add code to the HomeController.cs file.
[![enter image description here](https://i.stack.imgur.com/L4Vuj.png)](https://i.stack.imgur.com/L4Vuj.png)
6. Publish the WebApp to the Azure Portal.
7. Add [AppSettings: Token] in the Azure Portal.
[![enter image description here](https://i.stack.imgur.com/1uKTI.png)](https://i.stack.imgur.com/1uKTI.png)
8. Browse the WebApp and select the about tab to see the token value is that the value set in the portal.
[![enter image description here](https://i.stack.imgur.com/xA9xb.png)](https://i.stack.imgur.com/xA9xb.png) |
22,049,681 | Currently i have a requirement for comparing 2 tables each table having around 700M + records.
We have come up with a idea to compare in the File based rather than taking it to the DB , based upon our DB performance. Also heard that Perl is much faster than any other coding method
We need to compare for a Mobile number the Usage plan in one File to the same mobile Number in another File, either if present and its usage is matching or not , we need to write in a new file only the Not matching records.
Example:
File 1
```
number, Usage type , Usage Plan , Usage Volume (KB) ........
12344 , CP , FB , 100 ........
12323 , UP , FB , 200 ........
12322 , CP , G+ , 300 ........
```
File 2
```
number, Usage type , Usage Plan , Usage Volume (KB) ........
12344 , CP , FB , 100 ........
12323 , UP , FB , 210 ........
```
So in the above case my unmatch File should contain
Unmatch File
```
12323 , UP , FB , 210 ........
12322 , CP , G+ , 300 ........
```
`........` Means there are many columns after this, which we will not be using to compare. They are rather like more details about the plan.
Please share your suggestions and coding idea on this.
Our aim is to complete the comparison within 6 - 7 hours.. so that loading and other things can be completed within 2 days..
Thanks in Advance..
Sam | 2014/02/26 | [
"https://Stackoverflow.com/questions/22049681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2769015/"
] | How about this:
```
use strict;
open FILE1, 'file1.txt';
open FILE2, 'file2.txt';
open OUTPUT, '>output.txt';
my $regex = qr/^ *(\d+) , (.*) , (.*) , (\d+)/;
my $file1;
while(<FILE1>){
if(/$regex/){
$file1->{$1}->{type} = $2;
$file1->{$1}->{plan} = $3;
$file1->{$1}->{volume} = $4;
}
}
my $file2;
while(<FILE2>){
if(/$regex/){
$file2->{$1}->{type} = $2;
$file2->{$1}->{plan} = $3;
$file2->{$1}->{volume} = $4;
}
}
my $numbers;
$numbers->{$_} = 1 foreach keys %$file1;
$numbers->{$_} = 1 foreach keys %$file2;
my $output;
foreach(keys %$numbers){
if(defined $file1->{$_} && defined $file2->{$_}){
if($file1->{$_}->{type} ne $file2->{$_}->{type} || $file1->{$_}->{plan} ne $file2->{$_}->{plan} || $file1->{$_}->{volume} ne $file2->{$_}->{volume}){
push @$output, [$_, $file2->{$_}->{type}, $file2->{$_}->{plan}, $file2->{$_}->{volume}];
}
}elsif(defined $file1->{$_}){
push @$output, [$_, $file1->{$_}->{type}, $file1->{$_}->{plan}, $file1->{$_}->{volume}];
}else{
push @$output, [$_, $file2->{$_}->{type}, $file2->{$_}->{plan}, $file2->{$_}->{volume}];
}
}
print OUTPUT join(' , ', @$_)."\n" foreach @$output;
``` |
55,362,166 | I'm using lists for "Terms and conditions" page and in order to make the structure neater I'm using ordered lists. Problem is that I want to make the outer list unordered, and when I do that it's losing the count for the nested ordered lists. I know I can make it in many ways including manually, but I want to know if it's possible to handle this situation somehow.
```html
<ol>
<li>
<h2>Title of section 1</h2>
<ol>
<li>Text 1.1
<li>
<li>Text 1.2
<ol>
<li>Text 1.2.1</li>
<li>Text 1.2.2</li>
</ol>
</li>
</ol>
</li>
<li>
<h2>Title of section 2</h2>
<ol>
<li>Text 2.1
<li>
<li>Text 2.2
<ol>
<li>Text 2.2.1</li>
<li>Text 2.2.2</li>
</ol>
</li>
</ol>
</li>
</ol>
```
Using CSS I'm able to show everything as it should be
<https://jsfiddle.net/tutancamon/bfhkqtdg/41/>
What I want is to remove the number in front of the titles because it already contains them... | 2019/03/26 | [
"https://Stackoverflow.com/questions/55362166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9224174/"
] | Unorderded list element `<ul>` sounds like what you need to use.
```css
ul {
list-style: none;
}
```
```html
<ul>
<li>
<h2>Title of section 1</h2>
<ol>
<li>Text 1.1
<li>
<li>Text 1.2
<ol>
<li>Text 1.2.1</li>
<li>Text 1.2.2</li>
</ol>
</li>
</ol>
</li>
<li>
<h2>Title of section 2</h2>
<ol>
<li>Text 2.1
<li>
<li>Text 2.2
<ol>
<li>Text 2.2.1</li>
<li>Text 2.2.2</li>
</ol>
</li>
</ol>
</li>
</ul>
``` |
21,393,769 | I am using boto to launch ec2 instances as part of an autoscale group. I read a simple bash script and pass the base64 encoded string into user\_data. I'm using the Ubuntu AMI (ami-a73264ce) but I've also tried another Ubuntu AMI (ami-ad184ac4) and the Amazon Linux AMI (ami-bba18dd2) because one stackoverflow answer suggested that the AMI might be the problem ([EC2 instance loads my user-data script but doesn't run it](https://stackoverflow.com/questions/21149144/ec2-instance-loads-my-user-data-script-but-doesnt-run-it))
Here is my script (startup.sh)
```
#!/bin/bash
mkdir newdir
```
Here is my boto code:
```
conn = AutoScaleConnection(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)
f = open('startup.sh', 'r')
user_data = f.read()
lc = LaunchConfiguration(name=launch_config_name, image_id=ami_id,
key_name=key_name, security_groups=security_groups,
user_data=base64.b64encode(user_data))
conn.create_launch_configuration(lc)
ag = AutoScalingGroup(group_name=group_name, load_balancers=load_balancers,
availability_zones=availability_zones, launch_config=lc,
min_size=min_size, max_size=max_size, connection=conn)
conn.create_auto_scaling_group(ag)
```
Here is my /var/log/syslog:
```
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] cc_apt_update_upgrade.py[DEBUG]: mirror info: {'security': 'http://security.ubuntu.com/ubuntu', 'primary': 'http://us-east-1.ec2.archive.ubuntu.com/ubuntu/', 'mirror': 'http://us-east-1.ec2.archive.ubuntu.com/ubuntu/'}
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling landscape with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling timezone with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling puppet with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling chef with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling salt-minion with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling mcollective with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling disable-ec2-metadata with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling runcmd with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling byobu with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] cloud-init-cfg[INFO]: cloud-init-cfg ['all', 'final']
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling rightscale_userdata with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling scripts-per-once with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling scripts-per-boot with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling scripts-per-instance with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling scripts-user with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling keys-to-console with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling phone-home with freq=None and args=[]
Jan 27 23:13:17 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling final-message with freq=None and args=[]
```
Here is my /var/log/cloud-init.log:
```
2014-01-27 23:12:54,362 - cloud-init[INFO]: cloud-init start-local running: Mon, 27 Jan 2014 23:12:54 +0000. up 14.07 seconds
2014-01-27 23:12:54,659 - __init__.py[DEBUG]: searching for data source in ['DataSourceNoCloud', 'DataSourceConfigDrive', 'DataSourceOVF']
2014-01-27 23:12:55,281 - __init__.py[DEBUG]: Did not find data source. searched classes: ['DataSourceNoCloud', 'DataSourceConfigDrive', 'DataSourceOVF']
2014-01-27 23:12:55,998 - cloud-init[INFO]: cloud-init start running: Mon, 27 Jan 2014 23:12:55 +0000. up 15.43 seconds
2014-01-27 23:12:56,050 - __init__.py[DEBUG]: searching for data source in ['DataSourceNoCloudNet', 'DataSourceConfigDriveNet', 'DataSourceOVFNet', 'DataSourceMAAS', 'DataSourceEc2']
2014-01-27 23:12:56,588 - DataSourceEc2.py[DEBUG]: Using metadata source: 'http://169.254.169.254'
2014-01-27 23:12:56,663 - DataSourceEc2.py[DEBUG]: crawl of metadata service took 0s
2014-01-27 23:12:56,664 - __init__.py[DEBUG]: found data source DataSourceEc2
2014-01-27 23:12:56,670 - cloud-init[DEBUG]: found data source: DataSourceEc2
2014-01-27 23:12:56,675 - __init__.py[WARNING]: Unhandled non-multipart userdata starting 'IyEvYmluL2Jhc2gKbWtkaXIg...'
2014-01-27 23:12:56,684 - __init__.py[DEBUG]: handling bootcmd with freq=None and args=[]
2014-01-27 23:12:56,687 - __init__.py[DEBUG]: handling resizefs with freq=None and args=[]
2014-01-27 23:12:56,712 - cc_resizefs.py[DEBUG]: resize took 0.0159449577332 seconds
2014-01-27 23:12:56,713 - cc_resizefs.py[DEBUG]: resizing root filesystem (type=ext4, maj=202, min=1, val=True)
2014-01-27 23:12:56,713 - __init__.py[DEBUG]: handling set_hostname with freq=None and args=[]
2014-01-27 23:12:56,781 - cc_set_hostname.py[DEBUG]: populated /etc/hostname with ip-10-122-219-105 on first boot
2014-01-27 23:12:56,782 - __init__.py[DEBUG]: handling update_hostname with freq=None and args=[]
2014-01-27 23:12:58,478 - cc_update_hostname.py[DEBUG]: wrote ip-10-122-219-105 to /var/lib/cloud/data/previous-hostname
2014-01-27 23:12:58,478 - __init__.py[DEBUG]: handling update_etc_hosts with freq=None and args=[]
2014-01-27 23:12:58,479 - cc_update_etc_hosts.py[DEBUG]: not managing /etc/hosts
2014-01-27 23:12:58,479 - __init__.py[DEBUG]: handling ca-certs with freq=None and args=[]
2014-01-27 23:12:58,482 - __init__.py[DEBUG]: handling rsyslog with freq=None and args=[]
2014-01-27 23:12:58,620 - __init__.py[DEBUG]: handling ssh with freq=None and args=[]
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] cloud-init-cfg[INFO]: cloud-init-cfg ['all', 'config']
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling mounts with freq=None and args=[]
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] DataSourceEc2.py[DEBUG]: remapped device name /dev/sdb => /dev/xvdb
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] DataSourceEc2.py[DEBUG]: remapped device name /dev/sda3 => /dev/xvda3
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling ssh-import-id with freq=None and args=[]
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling locale with freq=None and args=[]
Jan 27 23:13:02 ip-10-122-219-105 [CLOUDINIT] cc_locale.py[DEBUG]: setting locale to en_US.UTF-8
Jan 27 23:13:13 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling set-passwords with freq=None and args=[]
Jan 27 23:13:13 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling grub-dpkg with freq=None and args=[]
Jan 27 23:13:13 ip-10-122-219-105 [CLOUDINIT] cc_grub_dpkg.py[DEBUG]: setting grub debconf-set-selections with '','true'
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling apt-pipelining with freq=None and args=[]
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] cc_apt_pipelining.py[DEBUG]: Wrote /etc/apt/apt.conf.d/90cloud-init-pipelining with APT pipeline setting
Jan 27 23:13:16 ip-10-122-219-105 [CLOUDINIT] __init__.py[DEBUG]: handling apt-update-upgrade with freq=None and args=[]
```
**EDIT:**
It works when I use the command line tool, but I'd still like to know why it doesn't work with boto because it might be more convenient to use boto | 2014/01/27 | [
"https://Stackoverflow.com/questions/21393769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1136342/"
] | Check if your user data is getting populated in your instance under:
```
/var/lib/cloud/data/scripts
```
Does it have newlines for every statement ?
How about adding this to your script to check that user data is right ?
```
f = open('startup.sh', 'r')
user_data = f.read()
print user_data
``` |
53,405,007 | I need to remove with jquery one div with class name 'form-group', the third 'form-group' div in my form.
Problem is there are several divs with the same class.
```
<div class="form-group header-group-0" id="form-group-ordersdetail">
<div class="col-sm-12">
<div id="panel-form-ordersdetail" class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bars"></i> Orders Detail
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-10">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-pencil-square-o"></i> Formulaire</div>
<div class="panel-body child-form-area">
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
This div is to remove
</div>
<div class="form-group">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
```
Would appreciate your expertise.
Thank you in advance, cheers, Marc | 2018/11/21 | [
"https://Stackoverflow.com/questions/53405007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4813836/"
] | Use the `nth-child(3)` psuedo-selector to select the third `.form-group` in its container:
```js
$('.form-group:nth-child(3)').remove();
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group header-group-0" id="form-group-ordersdetail">
<div class="col-sm-12">
<div id="panel-form-ordersdetail" class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-bars"></i> Orders Detail
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-10">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-pencil-square-o"></i> Formulaire</div>
<div class="panel-body child-form-area">
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
This div is to remove
</div>
<div class="form-group">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
```
Note that there's absolutely no need to include a big library like jQuery for something this simple, you can achieve it very easily with vanilla JS:
```
document.querySelector('.form-group:nth-child(3)').remove();
``` |
58,997,986 | I'm doing a research for the VANET network for my master thesis. I'm using OMNET++, SUMO and VEINS, for the evaluation of the performance in a scenario of car accident. For the moment I want to generate some results for the received power, signal to noise ratio, bit-rate and packet collision, based on three types of antenna's. From the results that I'm taking from the .sca file doesn't show those parameters. I have done some modifications in the source codes, but with no results!
So I wanted to ask you, is there any possibility to generate the results of those parameters and if yes can you help or guide me telling in quick steps how to do it well (modifying the source code or something else)? | 2019/11/22 | [
"https://Stackoverflow.com/questions/58997986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12417049/"
] | Given that it's unlikely that someone comes up with the *why* this happens, I'll answer my workaround.
A fix I found was to set the annotation to the following
```
nginx.ingress.kubernetes.io/auth-url: "http://oauth2.infra-system.svc.cluster.local/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://oauth2.domain.com/oauth2/start?rd=/redirect/$http_host$escaped_request_uri"
```
The `auth-url` is what the ingress queries with the cookie of the user. Hence, a local DNS of the oauth2 service is the same as the external dns name, but without the SSL communication and since it's DNS, it's permanent (while the cluster IP is not) |
1,688,420 | So here's the deal. I've got my solution which has a few projects in it:
* A wrapper project - this is just a console app that's currently standing in for a windows service during debugging.
* A worker project - this contains the guts of the code. This way I can easily debug the code for the windows service without the headache.
* A plugin library project - This contains a plugin factory to new up a concrete instance of a plugin.
* A plugin project - This contains a concrete implementation of my plugin.
My wrapper application contains my app.config which my plugin should reference directly for self configuration. This way my wrapper application doesn't need to know anything other than it needs to call the adapter factory to new up the instance of the plugin.
```
<configuration>
<appSettings>
<add key="Plugin" value="Prototypes.BensPlugin" />
<add key="Prototypes.BensPlugin.ServiceAddress" value="http://localhost/WebServices/Plugin.asmx" />
<add key="Prototypes.BensPlugin.Username" value="TestUserName" />
<add key="Prototypes.BensPlugin.Password" value="TestPassword" />
</appSettings>
</configuration>
```
Wrapper project:
```
using Worker;
public class Program
{
public static void Main()
{
var serviceProc = new ServiceProcess();
serviceProc.DoYourStuff();
}
}
```
Worker project:
```
using PluginLibrary;
namespace Worker
{
public class ServiceProcess
{
public string GetRequiredAppSetting(string settingName)
{
/* Code to get a required configuration setting */
}
public void DoYourStuff()
{
string pluginTypeName = GetRequiredAppSetting("Plugin");
//At this point, pluginTypeName = "Prototypes.BensPlugin"
Type type = Type.GetType(pluginTypeName); //type == null, wth!?
//string testTypeName = new BensPlugin().GetType().ToString();
///At this point, testTypeName = "Prototypes.BensPlugin"
//Type testType = Type.GetType(testTypeName)
///And testType still equals null!
if (type != null)
{
IPlugin plugin = PluginFactory.CreatePlugin(type);
if (plugin != null)
plugin.DoWork();
}
}
}
}
```
Plugin library:
```
namespace PluginLibrary
{
public interface IPlugin
{
void DoWork();
}
public class PluginFactory
{
public IPlugin CreatePlugin(Type pluginType)
{
return (IPlugin)Activator.CreateInstance(pluginType);
}
}
}
```
Plugin:
```
using PluginLibrary;
namespace Prototypes
{
public class BensPlugin : IPlugin
{
public string ServiceAddress { get; protected set; }
public string username { get; protected set; }
public string password { get; protected set; }
public void DoWork()
{
Trace.WriteLine("Ben's plugin is working.");
}
public BensPlugin()
{
/* Code to self configure from app.config */
}
}
}
```
Okay, so that sets the stage. Where I'm coming unstuck is in my worker project when I reference `Type.GetType(pluginTypeName)`. My `pluginTypeName` is being pulled from the configuration correctly, but `Type.GetType(pluginTypeName)` returns `null`. I've tried newing up an instance of my plugin directly at that same place in the code:
```
var obj = new BensPlugin();
```
This works just fine, and `obj.GetType().ToString()` returns the exact same string as I have configured in the `app.config`.
Can anyone tell me why I can new up a concrete object at that point in the code, but `Type.GetType(pluginTypeName)` would fail? | 2009/11/06 | [
"https://Stackoverflow.com/questions/1688420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40650/"
] | It could be that you need to specify which assembly the type is located in:
```
<add key="Plugin" value="Prototypes.BensPlugin, TheAssemblyName" />
``` |
17,513 | When I minimize folders and mozilla, it is not visible in the panel. I do not where it is stored. | 2010/12/15 | [
"https://askubuntu.com/questions/17513",
"https://askubuntu.com",
"https://askubuntu.com/users/-1/"
] | It looks like you have removed the Window List Applet:
* If the panel is still there, right click on it and select *Add to Panel*, then choose *Window List* and click *add*.
* If the panel is gone completely, click the upper one and select *New Panel* first.
The default widgets on the bottom panel are, in order: *Show Desktop, Window List, Workspace Switcher and Rubbish Bin*. |
3,344,137 | A submarine launches 4 missiles to a battleship. The probability that a missile hits is 0.3. For sinking the battleship it is enough that 2 missiles hit it, but if a single missile hits it, the probability that it sinks is 0.6.
What is the probability that the battleship sinks?
I tried to split it into two cases:
A) Only one missile of four hits the battleship:
then we get
$P$(sinks) = $P$(missile hits)\*$P$(battleship sinks given that it was hit by a missile) = 0.3\*0.6 = 0.18. Of course we multiply this probability with $\binom{4}{1}$ for choosing only one missile that hits the target.
B) Two missiles hit he target
$P$(sinks) = P(missile hits)\*$P$(missile hits) = 0.09 and of course we multipy this value with $\binom{4}{2}$, same reasoning as above.
In the end, I added A and B and that should be the final prbability.
Do you have any idea if it is correct? | 2019/09/04 | [
"https://math.stackexchange.com/questions/3344137",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/641159/"
] | Your answer is not correct, because you did not take into account that while some missiles hit, others have to miss. We can distinguish two cases in which the ship does not sink:
1. Only one missile hits and this missile is not crucial, with probability ${4 \choose 1} \cdot 0.3 \cdot 0.7^3 \cdot 0.4$
2. No missiles hit, with probability $0.7^4$
The probability of the ship sinking thus equals:
$$1 - 4 \cdot 0.3 \cdot 0.7^3 \cdot 0.4 - 0.7^4 = 0.59526$$ |
64,253,455 | I have the following mind-blowingly simple Go code.
```
package main
import (
"fmt"
"net/http"
)
func main() {
h := http.Header{
"my_id": []string{"XYZ"},
}
fmt.Println("h.Get(\"my_id\") = ", h.Get("my_id"))
}
```
But when I run it it doesn't work as expected, Here is the output:
```
h.Get("my_id") =
```
Why can't I print out the value of the header I *just* set?
Here is the live code for you to see yourself: <https://play.golang.org/p/L45LzVqd341> | 2020/10/07 | [
"https://Stackoverflow.com/questions/64253455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1742777/"
] | `Header.Get` uses `http.CanonicalHeaderKey` to lookup keys. If you use `h.Set` or put `My_id`, it will work.
This is explained in `Header.Get` documentation. |
606,865 | I have recently started working on bed forecasting project. I don't have data and I am asked to figure out a way to forecast the bed occupancy. As per the discussion with my supervisor/boss, I have to use probability to find out how many beds the hospital needs to start. For example: if there are 5 patients admitted (they had stroke), 1 of the admitted patients leave home the same day, of the remaining 4 patients:
* 1 patient leaves after 2 days
* 1 patient leaves after 5 days
* 1 patient leaves after 2 weeks
* 1 patient goes to rehab
How many beds are needed in this situation? I am not sure if I can correctly identify the overall hospital needs with this information for the patients admitted for stroke. (this forecast is only meant for the patients admitted with stroke.) I would appreciate some opinions on how to get started with this problem without having access to the data. As my supervisor said that it is not about the trend in the data, which is increasing of course, it is about the probability.
I was about fitting probability distribution such as Binomial or Poisson. | 2023/02/28 | [
"https://stats.stackexchange.com/questions/606865",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/369492/"
] | #### Use the `queue` function in the `utilities` package
This type of problem can be dealt with as a [queueing problem](https://en.wikipedia.org/wiki/Queueing_theory), which is a class of problem dealt with in statistical theory. For the case where you have the inputs for the use of the facilities by a set of users you can use a deterministic function to turn this into a set of queuing metrics. Typically, for each user you would have an input for the time they arrive, the amount of time they need to use the facilities, and a description of their waiting behaviour (i.e,. how long they are willing to wait for the facility before giving up and leaving).
Assuming you have all this information, you can use the `queue` function in the [`utilities` package](https://CRAN.R-project.org/package=utilities) in `R` to compute the queueing metrics under various numbers of beds in your facility (see [O'Neill 2021](https://arxiv.org/abs/2111.07064) for further explanation). Below I show an example of this function showing queueing results from using `n = 3` facilities for a set of twenty users with random arrival-times and use-times. By varying the parameter `n` you can see the queueing results using different numbers of amenities. As you can see, the function allows inputs for a range of aspects of the problem, including revival-times and close-times for the facilities.
```
#Set parameters for queuing model
lambda <- 1.5
mu <- 6
alpha <- 5
beta <- 2
#Generate arrival-times, use-times and patience-times
set.seed(1)
K <- 20
ARRIVE <- cumsum(rexp(K, rate = 1/lambda))
USE.FULL <- 2*mu*runif(K)
WAIT.MAX <- function(kappa) { alpha*exp(-kappa/beta) }
#Compute and print queuing information with n = 3
library(utilities)
QUEUE <- queue(arrive = ARRIVE, use.full = USE.FULL,
wait.max = WAIT.MAX, n = 3, revive = 2,
close.arrive = 30, close.full = 35)
#View the queue results
plot(QUEUE)
QUEUE
```
This code produces the following queueing output showing information for each of the users and facilities in the queueing problem. The =plot shows this same information graphically, which gives a clear visualisation of the waiting-times, use-times, etc.
[![enter image description here](https://i.stack.imgur.com/vDnC0.jpg)](https://i.stack.imgur.com/vDnC0.jpg)
```
Queue Information
Model of an amenity with 3 service facilities with revival-time 2
Service facilities close to new arrivals at closure-time = 30
Service facilities close to new services at closure-time = 35
Service facilities end existing services at closure-time = 35
Users are allocated to facilities on a 'first-come first-served' basis
----------------------------------------------------------------------
User information
arrive wait use leave unserved F
user[1] 1.132773 0.000000 1.295324 2.428096 0.0000000 1
user[2] 2.905237 0.000000 8.684531 11.589768 0.0000000 2
user[3] 3.123797 0.000000 4.935293 8.059090 0.0000000 3
user[4] 3.333490 1.094606 9.851356 14.279452 0.0000000 1
user[5] 3.987593 3.032653 0.000000 3.987593 7.7647223 NA
user[6] 8.330046 1.729045 9.395193 19.454283 0.0000000 3
user[7] 10.174389 3.032653 0.000000 10.174389 6.6364357 NA
user[8] 10.983913 1.839397 0.000000 10.983913 6.3566350 NA
user[9] 12.418764 1.171004 9.472275 23.062043 0.0000000 2
user[10] 12.639333 3.032653 0.000000 12.639333 0.2799744 NA
user[11] 14.725436 1.554016 5.726761 22.006213 0.0000000 1
user[12] 15.868481 3.032653 0.000000 15.868481 8.7877649 NA
user[13] 17.724886 3.032653 0.000000 17.724886 8.3127787 NA
user[14] 24.360787 0.000000 5.731435 30.092223 0.0000000 1
user[15] 25.942602 0.000000 9.057398 35.000000 1.2771158 2
user[16] 27.495468 0.000000 5.257165 32.752633 0.0000000 3
user[17] 30.309521 0.000000 0.000000 30.309521 2.9375673 NA
user[18] 31.291641 0.000000 0.000000 31.291641 0.8481486 NA
user[19] 31.797041 0.000000 0.000000 31.797041 1.1935939 NA
user[20] 32.679761 0.000000 0.000000 32.679761 3.7952605 NA
----------------------------------------------------------------------
Facility information
open end.service use revive
F[1] 0 30.09222 22.60488 8
F[2] 0 35.00000 27.21420 6
F[3] 0 32.75263 19.58765 6
``` |
54,751,514 | I should write a txt file with a specific format based on fixed-width columns (e.g. 1st variable in the columns 1-8, 2nd variable in the columns 9-15...).
The original data have different length and they have to be put on the right of the assigned columns.
For example: the values "-15.96" and "12.489" have to be written in the columns 1-8 of the first and the second line, while "-872.6" and "1723.6" in the columns 9-15. This will be:
```
123456789012345 (n columns)
-15.96 -872.6
12.489 1723.6
```
How could I do that with R? Now I have a simple table like this:
```
x <- data.frame(a= sample(-500.5:500.8,4),
b= sample(-250.6:420.9,4))
``` | 2019/02/18 | [
"https://Stackoverflow.com/questions/54751514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8788387/"
] | You need to limit your `DATEDIFF` in a way that only takes into account days from the month you need. You can do this with a `CASE`.
```
DECLARE @PatientInfo TABLE (
AdmissionDate DATE,
DischargeDate DATE)
INSERT INTO @PatientInfo (
AdmissionDate,
DischargeDate)
VALUES
('2019-01-01', '2019-03-10'),
('2019-02-15', '2019-02-17'),
('2019-02-25', '2019-05-01'),
('2019-01-05', '2019-01-06')
DECLARE @YearFilter INT = 2019
DECLARE @MonthFilter INT = 2 -- 2: February
DECLARE @StartOfMonth DATE = DATEFROMPARTS(@YearFilter, @MonthFilter, 1)
DECLARE @EndOfMonth DATE = DATEADD(DAY, -1, DATEADD(MONTH, 1, @StartOfMonth))
SELECT
P.*,
FilteredMonthDays = 1 + DATEDIFF(
DAY,
CASE WHEN P.AdmissionDate < @StartOfMonth THEN @StartOfMonth ELSE P.AdmissionDate END,
CASE WHEN P.DischargeDate > @EndOfMonth THEN @EndOfMonth ELSE P.DischargeDate END)
FROM
@PatientInfo AS P
WHERE
@MonthFilter BETWEEN MONTH(P.AdmissionDate) AND MONTH(P.DischargeDate)
```
Result:
```
AdmissionDate DischargeDate FilteredMonthDays
2019-01-01 2019-03-10 28
2019-02-15 2019-02-17 3
2019-02-25 2019-05-01 4
``` |
4,687,455 | What is faster (and better) ? :
1. Load variables to a special
static object and when a variable
from configuration file is needed
get variale from static object's
field.
2. Copy configuration
variable to a local field when
creating new object which needs a
configuration variable. | 2011/01/14 | [
"https://Stackoverflow.com/questions/4687455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/506078/"
] | Near miss of a very recent posting. See my response there on using exponential weighted moving averages.
[C++: Counting total frames in a game](https://stackoverflow.com/questions/4685610/c-counting-total-frames-in-a-game/4685758#4685758)
Here's sample code.
Initially:
```
avgFps = 1.0; // Initial value should be an estimate, but doesn't matter much.
```
Every second (assuming the total number of frames in the last second is in `framesThisSecond`):
```
// Choose alpha depending on how fast or slow you want old averages to decay.
// 0.9 is usually a good choice.
avgFps = alpha * avgFps + (1.0 - alpha) * framesThisSecond;
``` |
22,016,586 | I have looked around and could not seem to find a solution to this. I'm not sure what is wrong with my code here. Link to my code <http://pastebin.com/8z7rjVVK>
Error received while compiling:
```
===== COMPILING - PLEASE WAIT... =====
src\server\model\players\packets\ClickingButtons.java:1313: error: reached end o
f file while parsing
}
^
1 error
=============== DONE ===================
Press any key to continue . . .
```
Sorry, I know there are other questions regarding the same error, but I can't seem to fix this. Thanks. This is Java. | 2014/02/25 | [
"https://Stackoverflow.com/questions/22016586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3351572/"
] | The problem (or at least one of them) is that you have an `if` statement inside a `switch` block. It's almost at the end of the code:
```
if (c.isAutoButton(actionButtonId))
c.assignAutocast(actionButtonId);
```
You can't have code directly as a "child" of a `switch` statement, it must be placed inside a `case` block. |
37,959,900 | I have a simple piece of javascript code (toggle a class on element) that is not working on mobile (android chrome) when the address bar is visible on the page.
The code is a menu toggle, the + button next to the "Products" menu:
ok right so it doesn't work like this:
[![enter image description here](https://i.stack.imgur.com/advEF.png)](https://i.stack.imgur.com/advEF.png)
But as soon as I scroll down a little and hide the mobile address bar **IT WORKS!**:
[![enter image description here](https://i.stack.imgur.com/5b1d5.png)](https://i.stack.imgur.com/5b1d5.png)
What is going on? I'm so confused. Why does having the address bar visible change how this code works?
This is the code:
```
m.find( '.menu-dropdown-toggle' ).click(function(e){
e.preventDefault();
var $li = $( this ).parents( 'li' ).first();
if ($li.hasClass( 'toggle-closed' ) || ! ($li.hasClass( 'toggle-open' ) || $li.hasClass( 'current-menu-item' ) || $li.hasClass( 'current_page_ancestor' ) || $li.hasClass( 'current_page_item' ) || $li.hasClass( 'current_page_parent' ))) {
$li.removeClass( 'toggle-closed' ).addClass( 'toggle-open' );
} else {
$li.removeClass( 'toggle-open' ).addClass( 'toggle-closed' );
}
return false;
});
```
Also, this works fine on other mobile websites, it's just this one in particular that is having the address-bar-visible-bug (e.g. <http://beautiful.dtbaker.net/> works fine on mobile). | 2016/06/22 | [
"https://Stackoverflow.com/questions/37959900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/457850/"
] | The event is being triggered twice. The first trigger is opening up the menu, the second trigger is closing the menu. This doesn't explain why it is happening when the address bar is visible, but that is what some debugging seems to indicate.
It is possible that another script might be programmatically doing it, but I did not debug that far.
You could use a debounce to ensure the action only gets triggered once in a specific amount of time, which would get around the problem, without actually solving the reason. |
74,330,801 | **Background:** Trying to use ckeditor5 as a replacement for my homegrown editor in a non-invasive way - meaning without changing my edited content or its class definitions. Would like to have WYSIWYG in the editor. Using django\_ckeditor\_5 as a base with my own ckeditor5 build that includes ckedito5-inspector and my extraPlugins and custom CSS. This works nicely.
**Problem**: When I load the following HTML into ClassicEditor (edited textarea.value):
```
<p>Text with inline image: <img class="someclass" src="/media/uploads/some.jpeg"></p>
```
in the editor view area, browser-inspection of the DOM shows:
```
...
<p>Text with an inline image:
<span class="image-inline ck-widget someclass ck-widget_with-resizer" contenteditable="false">
<img src="/media/uploads/some.jpeg">
<div class="ck ck-reset_all ck-widget__resizer ck-hidden">
<div ...></div></span></p>
...
```
Because the "someclass" class has been removed from and moved to the enclosing class attributes, my stylesheets are not able to size this image element as they would appear before editing.
If, within the ckeditor5 view, I edit the element using the browser inspector 'by hand' and add back `class="someclass"` to the image, ckeditor5 displays my page as I'd expect it with "someclass" and with the editing frame/tools also there. Switching to source-editing and back shows the class="someclass" on the and keeps it there after switching back to document editing mode.
(To get all this, I enabled the GeneralHtmlSupport plugin in the editor config with all allowed per instructions, and that seems to work fine.) I also added the following simple plugin:
```
export default class Extend extends Plugin {
static get pluginName() {
return 'Extend';
}
#updateSchema() {
const schema = this.editor.model.schema;
schema.extend('imageInline', {
allowAttributes: ['class']
});
}
init() {
const editor = this.editor;
this.#updateSchema();
}
}
```
to extend the imageInline model hoping that would make the Image plugin keep this class attribute.
This is the part where I need some direction on how to proceed - what should be added/modified in the Image Plugin or in my Extend plugin to keep the class attribute with the element while editing - basically to fulfill the WYSIWYG desire? | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427640/"
] | Edit: I noticed I made a number of mistakes after sitting down with this one and was kind of interested since I wanted to make my own trading bot one day so I took the time to fix them for ya.
```
import pandas as pd
import sys
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
table = StringIO("""date open high low close slice
0 2022-05-19 09:15:00 33461.00 33624.90 33403.20 33412.45 0
1 2022-05-19 09:20:00 33413.10 33450.65 33393.90 33429.10 0
2 2022-05-19 09:25:00 33433.20 33490.05 33421.95 33460.25 0
3 2022-05-19 09:30:00 33460.55 33509.40 33419.05 33489.80 0
4 2022-05-19 09:35:00 33492.20 33506.40 33450.30 33454.70 20
5 2022-05-19 09:40:00 33452.25 33452.95 33396.40 33436.15 0
6 2022-05-19 09:45:00 33434.30 33454.80 33401.35 33439.05 0
7 2022-05-19 09:50:00 33438.30 33482.85 33423.50 33477.30 10
8 2022-05-19 09:55:00 33480.60 33535.85 33462.40 33523.65 30
9 2022-05-19 10:00:00 33527.65 33527.65 33484.10 33521.40 0
10 2022-05-19 10:05:00 33519.35 33599.25 33505.95 33530.55 0
11 2022-05-19 10:10:00 33527.50 33544.20 33496.60 33538.65 0
12 2022-05-19 10:15:00 33540.15 33565.85 33522.75 33563.25 0
13 2022-05-19 10:20:00 33563.50 33582.45 33525.95 33539.25 0
14 2022-05-19 10:25:00 33537.25 33537.50 33511.80 33516.35 20
15 2022-05-19 10:30:00 33518.00 33561.80 33513.60 33528.55 0
16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10
17 2022-05-19 10:40:00 33551.50 33573.60 33525.85 33537.45 0
18 2022-05-19 10:45:00 33534.80 33563.10 33510.75 33555.95 0
19 2022-05-19 10:50:00 33555.55 33573.45 33540.45 33541.00 0
20 2022-05-19 10:55:00 33545.40 33586.80 33542.75 33586.80 10""")
data = pd.read_csv(table, sep='\t')
def formatRow(rows):
tmp_list = []
for i in rows.index:
time = rows['date'][i]
entry = rows['open'][i]
sl = rows['low'][i] - 10
target = entry + (entry - sl) * 2
tmp_list.append([time, entry, target, sl, i])
return tmp_list
data.columns = ['date', 'open', 'high', 'low', 'close', 'slice']
data['group_min'] = False
# Filtering data by slice value
df = data[data['slice'] > 0]
buysell_list = []
for i in range(len(df)): #
print('Processing: ', i)
if df.iloc[i]['slice'] == 10:
group = group + 1
if i != 0:
start_index = df.iloc[i-1].name
end_index = df.iloc[i].name
while data.loc[start_index]['slice'] == 10:
print('previous slice > 0 is a 10!')
start_index = start_index + 1
if start_index < end_index:
rows = data.loc[start_index:end_index]
print('range {}-{}'.format(start_index, end_index))
data.loc[rows.index, 'group'] = group
min_row_index = rows['low'].idxmin()
# In case there are two lows that are somehow equal
min_rows = rows[rows['low'] == rows.loc[min_row_index]['low']]
data.loc[min_rows.index, 'group_min'] = True
rows_formatted = formatRow(min_rows)
else:
print('Somehow slices are next to each other')
rows_formatted = formatRow(df.iloc[i])
else:
print('First non zero is a 10')
# This isn't complete, you would need to calc from the index here to index 0
rows_formatted = formatRow(df.iloc[i])
for row_f in rows_formatted:
buysell_list.append(row_f)
df2 = pd.DataFrame(buysell_list, columns=['Time', 'Entry Price', 'Target', 'Stop Loss', 'Orig_Index'])
df2
```
Output
```
Time Entry Price Target Stop Loss Orig_Index
0 2022-05-19 09:40:00 33452.25 33583.95 33386.40 5
1 2022-05-19 10:25:00 33537.25 33608.15 33501.80 14
2 2022-05-19 10:45:00 33534.80 33602.90 33500.75 18
```
data.to\_markdown()
Output
| | date | open | high | low | close | slice | group\_min | group |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 0 | 2022-05-19 09:15:00 | 33461 | 33624.9 | 33403.2 | 33412.4 | 0 | False | |
| 1 | 2022-05-19 09:20:00 | 33413.1 | 33450.7 | 33393.9 | 33429.1 | 0 | False | |
| 2 | 2022-05-19 09:25:00 | 33433.2 | 33490.1 | 33421.9 | 33460.2 | 0 | False | |
| 3 | 2022-05-19 09:30:00 | 33460.6 | 33509.4 | 33419.1 | 33489.8 | 0 | False | |
| 4 | 2022-05-19 09:35:00 | 33492.2 | 33506.4 | 33450.3 | 33454.7 | 20 | False | 1 |
| 5 | 2022-05-19 09:40:00 | 33452.2 | 33452.9 | 33396.4 | 33436.2 | 0 | True | 1 |
| 6 | 2022-05-19 09:45:00 | 33434.3 | 33454.8 | 33401.3 | 33439.1 | 0 | False | 1 |
| 7 | 2022-05-19 09:50:00 | 33438.3 | 33482.8 | 33423.5 | 33477.3 | 10 | False | 1 |
| 8 | 2022-05-19 09:55:00 | 33480.6 | 33535.8 | 33462.4 | 33523.7 | 30 | False | |
| 9 | 2022-05-19 10:00:00 | 33527.7 | 33527.7 | 33484.1 | 33521.4 | 0 | False | |
| 10 | 2022-05-19 10:05:00 | 33519.3 | 33599.2 | 33505.9 | 33530.6 | 0 | False | |
| 11 | 2022-05-19 10:10:00 | 33527.5 | 33544.2 | 33496.6 | 33538.7 | 0 | False | |
| 12 | 2022-05-19 10:15:00 | 33540.2 | 33565.8 | 33522.8 | 33563.2 | 0 | False | |
| 13 | 2022-05-19 10:20:00 | 33563.5 | 33582.4 | 33525.9 | 33539.2 | 0 | False | |
| 14 | 2022-05-19 10:25:00 | 33537.2 | 33537.5 | 33511.8 | 33516.3 | 20 | True | 2 |
| 15 | 2022-05-19 10:30:00 | 33518 | 33561.8 | 33513.6 | 33528.6 | 0 | False | 2 |
| 16 | 2022-05-19 10:35:00 | 33527.8 | 33551 | 33527.6 | 33550.5 | 10 | False | 2 |
| 17 | 2022-05-19 10:40:00 | 33551.5 | 33573.6 | 33525.8 | 33537.4 | 0 | False | 3 |
| 18 | 2022-05-19 10:45:00 | 33534.8 | 33563.1 | 33510.8 | 33555.9 | 0 | True | 3 |
| 19 | 2022-05-19 10:50:00 | 33555.6 | 33573.4 | 33540.4 | 33541 | 0 | False | 3 |
| 20 | 2022-05-19 10:55:00 | 33545.4 | 33586.8 | 33542.8 | 33586.8 | 10 | False | 3 | |
4,000,745 | I am having problems visualizing infinitesimals. Like in a curve, when we integrate we can adjust in it a perfect infinitely thin rectangle. But how do I visualize it? Every time I try to visualize it, I always notice some gap area or error in the curve. Also in differentiation, $ dx $ is supposed to an infinitely close step. But every time I draw a line, I can cut it into smaller line and that becomes $ dx $. So I am facing bit problema visualizing infinitesimals. | 2021/01/26 | [
"https://math.stackexchange.com/questions/4000745",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/843686/"
] | sometimes there is error/gap, however as the dx (infinitesimal) tends to 0 this error tends to 0 faster (quadratically, cubicly...). Yes you may be able to make dx smaller which is what i think you are saying by "cut it into smaller line" and thats correct because thats the whole idea of a Reimann Sum which is what approximates an integral as the dx basically becomes 0 (almost) |
41,819,013 | I'm still new to java and writing/reading code, so I'm not quite sure what my professor wants. All I need is some reinforcement of what I should be doing.
The assignment is as follows:
Specify and then implement a method (of some class X) that is passed a NumberList and that returns an array containing the values from the NumberList.
(The NumberList is not changed by your method. Your method is NOT a member of NumberList. You won't be able to test your method by running it since I am not providing the NumberList class to you.)
[If you need it, here are the public methods.](https://i.imgur.com/7tyqjHJ.png)
The one method that I use is:
```
public int size() //returns number of items in this NumberList
```
So, as I understand, all I am doing is taking the NumberList and creating an array of the values. Easy enough. Is this handling the work that is asked?
```
public double [] arrayNL(NumberList list){
//pre: NL is not empty
//post: array with NL values is returned
double [] arrayNL = new double [list.size()];
for(int x=0;x<list.size();x++){
arrayNL[x]=list.nextDouble;
}
return arrayNL;
}
```
Just uncertain about list.size() and list.nextDouble... and that is if I'm correct in understanding the problem. Really haven't done enough object coding to be familiar/confident with it and I ***heavily*** rely on testing, so I'm questioning everything. Any help would be great, I just have trouble following this professor's instructions for some reason. | 2017/01/24 | [
"https://Stackoverflow.com/questions/41819013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7016046/"
] | Not sure I understand the question. Is the goal to write the code that copies the list to the array, or to implement the methods in the NumberList class based on the pre- and post- conditions? |
67,877,568 | ```html
<body>
<section class="info-container">
<div class="name-container">
<span>The Name :</span>enter code here
<div class="name"></div>
</div>
<div class="wrong-container">
<span>Wrong Tries :</span>
<div class="wrong-tries">100</div>
</div>
</section>
<section class="img-container">
<div class="img-block" data-naem="1">
<div class="face front">?</div>
<div class="face back">
<img src="images/1.png" alt="" class="img">
</div>
</div>
<div class="img-block" data-naem="1">
<div class="face front">?</div>
<div class="face back">
<img src="images/1.png" alt="" class="img">
</div>
</div>
<div class="img-block" data-naem="2">
<div class="face front">?</div>
<div class="face back">
<img src="images/2.png" alt="" class="img">
</div>
</div>
</div>
<script src="main.js"></script>
</section>
</body>
```
```js
let name = document.querySelector('.name'),
wrongTries = document.querySelector('.wrong-tries'),
imgContainer = document.querySelector('.img-container'),
imgBlocks = Array.from(imgContainer.children);
imgBlocks.forEach((block, index) => {
block.addEventListener('click', function () {
flipBlock(block)
})
})
function flipBlock(selectedBlock) {
selectedBlock.classlist.add('flipped');
}
```
[![Error message](https://i.stack.imgur.com/WfzAI.jpg)](https://i.stack.imgur.com/WfzAI.jpg)
The chrome says can not read property add of undefined , how can I add classlist.add to parameter without been defined and define it when I call , it's about selectedBlock parameter so I need to know if anything went wrong in my code , but please know that I see tutorial that has the same code and It worked I don't know how | 2021/06/07 | [
"https://Stackoverflow.com/questions/67877568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16157217/"
] | The line you are facing the issue on has a typing error -
`selectedBlock.classlist.add('flipped');`
The `classlist` should be replaced with `classList`.
Also instead of adding listeners to each of the image-blocks, you can try your hands on Event Delegation. You'll find a good resource for the same [here](https://javascript.info/event-delegation). This would certainly help in increasing the performance of your web application. |
180,571 | A home inspection noted that the center beam in our basement was not secured.
[![enter image description here](https://i.stack.imgur.com/R72nT.jpg)](https://i.stack.imgur.com/R72nT.jpg)
What is required to secure a beam to a column, and is it really required?
The house is in Oakland Co, Michigan, so not a lot of earthquakes there. | 2019/12/18 | [
"https://diy.stackexchange.com/questions/180571",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/110210/"
] | Some are welded, by bending those "ears" or "tabs" over, others are bolted with clamps using those tabs.
Check what was specified with the architect / design engineer.
And, YES, it is required, otherwise it could be knocked over... |
62,522,747 | I am trying to use the Golang Validator (<https://godoc.org/gopkg.in/go-playground/validator.v9>) to validate a Request body. I have two entities, Rule and Item. The Item entity relies on the Rule entity.
```
type Rule struct {
RuleNo int64 `json:"ruleNo" db:"rule_no"`
Category string `json:"category" db:"category" validate:"alphanum"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
type Item struct {
SeqNo int64 `json:"-" db:"item_restriction_no"`
ItemId string `json:"itemId" db:"item_id" validate:"alphanum"`
ItemType string `json:"itemType" db:"item_type" validate:"alphanum"`
Rules []Rule `json:"rules" db:"rules"` // how to validate this field?
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}
```
How can I validate that a Request body has a list of Rules for the "Rules" field for the Item struct? This is my validate function:
```
func (item *Item) Validate() error {
v := validator.New()
if err := v.Struct(item); err != nil {
return err
}
return nil
}
``` | 2020/06/22 | [
"https://Stackoverflow.com/questions/62522747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10475050/"
] | From the example [here](https://github.com/go-playground/validator/blob/master/_examples/struct-level/main.go#L18), you can do something like below:
```
type Rule struct {
...
}
type Item struct {
...
Rules []Rule `json:"rules" db:"rules" validate:"required"`
...
}
``` |
72,927,406 | I know that `[]` is a function itself, but is there a function that does the following ?
```r
vect = c(1, 5, 4)
# Slicing by row index with []
vect[2]
# [1] 5
# Does this kind of function exist ?
slicing_func(vect, 2)
# [1] 5
# And for dataframes ?
``` | 2022/07/10 | [
"https://Stackoverflow.com/questions/72927406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8806649/"
] | You can use `getElement` function
```
vect = c(1, 5, 4)
getElement(vect, 2)
#> 5
```
Or you can use
```
vctrs::vec_slice(vect , 2)
#> 5
```
which works for slices and data.frames too. |
13,124,606 | Ive got a few instances of subclasses of View (like ImageView, ViewGroup, TextView, etc) , which i have them all implement two methods a() and b() and they all have to run the same init() method which is long and does the same for all of them.
how should i design my architecture to enhance code reusability in that case?
if it was C++ i could multi inherite from view and a new abstract class that runs init() on time of creation and have abstarct methods a() and b(), how is it acheived in Java?
maybe there's some way to acheive it using some kind of a decorator? | 2012/10/29 | [
"https://Stackoverflow.com/questions/13124606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/891814/"
] | If I understand you correctly, you can create an abstract class `AbstractView` that extends `View` and implements your common `init()` method. `AbstractView` should declare the abstract methods `a()` and `b()`, but leave the implementations to the subclasses.
```
public abstract class AbstractView extends View {
public void init() {
// common init implementation here
}
public abstract void a();
public abstract void b();
}
```
Since you're trying to add behavior to a group of existing subclasses (`ImageView`, `ViewGroup`, `TextView`, etc.), you probably do need to create a wrapper for each subclass (`MyImageView`, `MyViewGroup`, `MyTextView`, etc.). Each of these subclasses would extend `AbstractView` and implement their own `a()` and `b()` methods, but inherit the common `init()` method (along with all of the methods implemented in the `View` class. You can then create delegate methods for the exising behavior in `ImageView`, `ViewGroup`, `TextView`, etc. that you need to keep unchanged.
```
public class MyImageView extends AbstractView {
private ImageView wrappedImageView;
public MyImageView(Context context) {
wrappedImageView = new ImageView(context);
}
// TODO: Implement other constructor wrappers
final void clearColorFilter() {
wrappedImageView.clearColorFilter();
}
// TODO: Implement other method wrappers
@Override
public void a() {
// specific implementation here
}
@Override
public void b() {
// specific implementation here
}
}
``` |
20,857,452 | I have huge table that is fully dynamic (not mapped to any POCO). It has multiple fields and one of them is named `two`. How can I remove this field for every document that has `ArchiveId` set to `1`?
I have tried getting all items and then saving each but it gives me error. I suspect that db just times out or something because it's working and running since I can get records just fine afterwards.
Note that I have over 1m records and this method that I'm doing is probably very bad but I don't know any better.
>
> Server instance localhost:27017 is no longer connected.
>
>
>
What I have tried
```
public void DeleteFieldByArchiveId(int id, string field)
{
var collection = _db.GetCollection("items");
collection.Find(Query.EQ("ArchiveId", id))
.ToList()
.ForEach(x =>
{
x[field] = null;
collection.Save(x);
});
}
```
EDIT (What I need)
==================
`db.items.update({ArchiveId: 1}, {$unset: {two : ""}}, {multi: true})`
Basically this is what I want to achieve using C# mongo driver. I just tested this query in RoboMongo and it removed all fields from 1m database in about 20 seconds without timeouts. How can I execute this query inside C# mongo driver? | 2013/12/31 | [
"https://Stackoverflow.com/questions/20857452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440611/"
] | Here's the C# way of performing the query using the static `Unset` method of the `Update` class:
```
IMongoQuery query = Query.EQ("Activity", 1);
UpdateBuilder ub = Update.Unset("two");
MongoUpdateOptions options = new MongoUpdateOptions {
Flags = UpdateFlags.Multi
};
var updateResults = examples.Update(query, ub, options);
```
This results in:
```
query = { "Activity" : 1 }
update = { "$unset" : { "two" : 1 } }
```
*(The value of `two` in the update expression doesn't matter [per the documentation](http://docs.mongodb.org/manual/reference/operator/update/unset/)).*
Full example:
```
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
var client = new MongoClient(); // connect to localhost
var server = client.GetServer();
var test = server.GetDatabase("test");
var examples = test.GetCollection("examples");
var query = Query.EQ("Activity", 1);
var ub = Update.Unset("two");
var options = new MongoUpdateOptions {
Flags = UpdateFlags.Multi
};
var updateResults = examples.Update(query, ub, options);
if (updateResults != null)
{
Console.WriteLine(updateResults);
}
``` |
28,267,501 | I'm trying to rock a more functional style, and would like to set all properties of an object (and if possible sub-objects) to a specific value, e.g. `false` inplace. Is there a shortcut or do I have to iterate over the properties?
```
var obj = {
a: true,
b: true,
c: true,
...
z: true
}
```
Transforms into:
```
var obj = {
a: false,
b: false,
c: false,
...
z: false
}
``` | 2015/02/01 | [
"https://Stackoverflow.com/questions/28267501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You can use underscore for the more functional style.
You can iterate over your object if missing you can change or if it sub-object reiterate and change every missing sub-object properties.
```js
function remap(object, missingValue, suppliedValue){
var keys= _.keys(object);
return _.reduce(keys, function(memo, key){
memo[key] = object[key];
if(memo[key] === missingValue){
memo[key] = suppliedValue;
}
if(_.isObject(memo[key])){
memo[key] = remap(memo[key],missingValue,suppliedValue);
}
return memo;
}, {});
}
var h = {val : 3, b : undefined, d : undefined , k : {
a: false, b: undefined
}, c: function(){ console.log(a);}};
console.log(remap(h,undefined,false));
```
If you need more complex check for comparing values then use the below function.
```js
function remap(object, complexCheck){
var keys= _.keys(object);
return _.reduce(keys, function(memo, key){
memo[key] = object[key];
memo[key] = complexCheck(memo[key]);
if(_.isObject(memo[key])){
memo[key] = remap(memo[key],complexCheck);
}
return memo;
}, {});
}
``` |
53,245,926 | I have the following code to convert RGB to HSV. This uses UIColor which is part of the UIKit. UIKit is not available in macOS. What is the alternative to do this in macOS?
```
func getHue(red: CGFloat, green: CGFloat, blue: CGFloat) -> CGFloat
{
let color = UIColor(red: red, green: green, blue: blue, alpha: 1)
var hue: CGFloat = 0
color.getHue(&hue, saturation: nil, brightness: nil, alpha: nil)
return hue
}
``` | 2018/11/11 | [
"https://Stackoverflow.com/questions/53245926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/848968/"
] | In macOS, use `NSColor` instead `UIColor`.
```
func getHue(red: CGFloat, green: CGFloat, blue: CGFloat) -> CGFloat{
let color = NSColor(red: red, green: green, blue: blue, alpha: 1)
var hue: CGFloat = 0
color.getHue(&hue, saturation: nil, brightness: nil, alpha: nil)
return hue
}
``` |
439,075 | Not actually sure if this is too simple a question for this exchange.
Just now I picked up my phone charger and unplugged it to move somewhere and plugged my phone in to the recently unplugged (from the wall) charger, and my phone registered that it was plugged in and charging. even though it was plugged into a charger not connected to a power source.
I can understand in theory that there was some residual electric current in the charger, just enough to trigger my phone. However, I fail to understand the scale. How much residual electric charge could be left in a 1m phone cable, and how long before it dissipated?
How does this play into the whole completing the circuit, as there was no real ground connection. | 2019/05/17 | [
"https://electronics.stackexchange.com/questions/439075",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/222254/"
] | >
> I can understand in theory that there was some residual electric current in the charger, just enough to trigger my phone.
>
>
>
Not quite right. There was *electrical charge* left in the device. Once you plugged in your phone the charge was able to move and moving charge is called current.
>
> However, I fail to understand the scale. How much residual electric charge could be left in a 1m phone cable, and how long before it dissipated?
>
>
>
No charge is stored in the cable. It's stored in the capacitors in the charger. The charge is given by \$ Q = CV \$ where *Q* is charge (coulombs, C), *C* is capacitance (farads, F) and *V* is voltage (volts, V).
>
> How does this play into the whole completing the circuit, as there was no real ground connection.
>
>
>
Circuits don't need a connection to ground (as in the Earth). If they did electrical circuits would not work in aircraft (insulated by air), cars (insulated tires) or your phone. What happend is that your phone completed the circuit between the charger positive and negative terminals and allowed current to flow around the circuit of the charger, cable and phone. |
54,342,999 | I'm working on a school assignment where I need to access data from an ArrayList with some methods I've written.
```
public static void main(String[] args) throws IOException {
String fileName = "USPopulation.txt";
File fileReader = new File(fileName);
ArrayList<Integer> populations = new ArrayList<Integer>();
Scanner inputFile = new Scanner(fileReader);
while (inputFile.hasNext()) {
populations.add(inputFile.nextInt());
}
System.out.println(populations.greatest());
/**
* Receives an ArrayList and returns the index of the value that has the
* greatest increase from the previous value in the collection.
*
* @param populations
* @return greatestI
*/
public static int greatest(ArrayList<Integer> populations) {
int greatestDiff = 0;
int greatestI = 0;
int i = 0;
while (i < populations.size() - 1) {
int tempDiff = populations.get(i + 1) - populations.get(i);
if (tempDiff >= greatestDiff) {
greatestDiff = tempDiff;
greatestI = i + 1;
}
i++;
}
return greatestI;
}
}
```
When I try and call my method, greatest, I'm met with the error
>
> The method greatest() is undefined for the type ArrayList.
>
>
>
I had thought that the defintion I needed was included in the parameter of my method, but apparently not.
The error messages and what I've found troubleshooting make it seem like I need to cast my `ArrayList populations` into a type the methods know how to deal with, but nothing I try seems to work.
Appreciate any help. Thanks to anyone who takes the time to help a noob out.
return smallestI; | 2019/01/24 | [
"https://Stackoverflow.com/questions/54342999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10960294/"
] | You need to add a form action here, post.store should work considering that you are using a resource controller':
```
<form action="{{ route('post.store') }}" method="post">
```
If this doesn't help let me know. |
56,494 | When using the `tex2d` function in a HLSL shader, as so:
```
float height = tex2D(heightMap, IN.texCoord).r;
```
What range of values can be returned to the height variable? Is it always a number between `0.0f` - `1.0f`? Or does it depend on the texture or sampler? | 2013/05/30 | [
"https://gamedev.stackexchange.com/questions/56494",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/31338/"
] | The tex2D function *usually* returns a float in the range of `[0.0, 1.0]`.
*Think of tex2D as a function that returns a color.*
Color components (like red, for example) range from `0.0` to `1.0` where the former is the total absence of that color and the latter is full intensity.
**However**, as Nathan Reed and other members have pointed out, texture formats that are not normalized may return values outside this range. Here is a StackOverflow post that explains floating-point textures: [What exactly is a floating point texture?](https://stackoverflow.com/questions/5709023/what-exactly-is-a-floating-point-texture) |
551,978 | My apologies, I read this post:
[TDD and ADO.NET Entity Framework](https://stackoverflow.com/questions/316897/tdd-and-ado-net-entity-framework)
But I don't think it covers what I'm looking for and other similar questions seem unanswered. So, forgive me if this has already been answered.
I have an application that I'm writing. I've created some Entity classes. I want to mock this during unit testing as I believe MS's implementation is good enough to warrant skipping the testing of it. =-}
So, my first guess:
Take the generated ObjectContext-deriving class and generate an interface off of it for the read properties that return ObjectQuery and the Add methods (at this point I'm not worrying about the updating of existing objects, just reading). However, I quickly ran into problems during the testing as I couldn't easily get the ObjectQuery properties working nicely.
I saw The Wayward Weblog's post about doing something similiar to this but with Linq to SQL and it just begs the question, hasn't anyone figured out a better way to mock the Entity framework than this?!
Thanks! | 2009/02/16 | [
"https://Stackoverflow.com/questions/551978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66766/"
] | So I take it there is no answer to this. Unfortunately, after doing lots of googling, I don't think the EF really supports a TDD approach to development, which is an absolute shame. Time to adopt nHibernate, it sounds like. |
27,465,922 | I'm trying to display an SVG image in my Android 4.X APP (I've debugged it on my Nexus7 Android 5.0 and my Moto. Razr i Android 4.1.2). I'm using [svg-android](https://code.google.com/p/svg-android/). I think I've tried everything..
Here's my code:
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView imageView = new ImageView(this);
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.hsv);
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
imageView.setImageDrawable(svg.createPictureDrawable());
setContentView(imageView);
}
```
And that's the [result](https://drive.google.com/file/d/0B_u6lqqDkvr4a0huTC0tMHh4ZEk/view). | 2014/12/14 | [
"https://Stackoverflow.com/questions/27465922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4358511/"
] | In any one of your js pages you are missing
```
module.exports = router;
```
Check and verify all your JS pages |
26,104,307 | I'm writing some simple connected component code and running into a weird weird segfault.
My code is as follows; with some definitions first.
```
Node* node;
typedef std::pair<int, Node*> Edge;
struct Node {
...
std::list<Edge> neighbors;
...
}
```
The code that segfaults is below:
```
if (node->neighbors.empty())
{
node->label = label_set.make();
}
else
{
Node* first_neighbor = node->neighbors.front().second;
node->label = first_neighbor->label;
int i = 0;
for (list<Edge>::iterator it = node->neighbors.begin(); it != node->neighbors.end(); it++)
{
i ++;
Node* n2 = (Node*)it->second;
node->label = label_set.merge(node->label, n2->label);
}
}
```
The really really weird bit is the following:
```
(lldb) p node->neighbors
(std::list<std::pair<int, _Node *>, std::allocator<std::pair<int, _Node *> > >) $4 = size=1 {
[0] = {
first = 78
second = 0x00d85520
}
}
(lldb) p *it
(std::pair<int, _Node *>) $8 = {
first = 0
second = 0xa0a45254
}
(lldb) p n2
(Node *) $5 = 0xa0a45254
```
Seeing this, I understand the segfault. `n2` is set to a completely weird value. It's not in the list; am I not iterating the list correctly? Is `n2` filled with random data because it is out of the list bounds? But then how did my iteration escape the bounds? I'm clueless.
**EDIT:**
I'm definitely outside the list bounds: at the time of the segfault `i == 3`.
**EDIT2**
Could it have something to do with the way I keep track of the nodes?
<https://gist.github.com/noio/3082a0f351edb1821e90> | 2014/09/29 | [
"https://Stackoverflow.com/questions/26104307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/224949/"
] | You have to create a **'bypass rule'** at the top to skip the subsequent rules if the request is for the addon (in our case the www.addon1.com).
Add to `www.mainwebsite.com` 's `.htaccess` file at the top the following:
```
RewriteCond %{HTTP_HOST} ^(www\.)?addon1\.com
RewriteRule .* - [L]
...
```
\*info for [L] rule [here](http://dev.filkor.org/2014/01/09/dot-htaccess-examples-and-explanations/).
* **EXPLANATION**
This tells [mod\_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) to quit processing right here if the requested domain is addon1.com or www.addon1.com.
To help you more i tried the senario at this excellent online rule test tool: <http://htaccess.madewithlove.be/>
and i give you the results.
**1st Type**: www.addon1.com
**Result**: Stop processing and other rules below could not met!
![enter image description here](https://i.stack.imgur.com/WHBkv.jpg)
**2nd Type**: www.whatever.com
**Result**: Continue processing and could met other rules!
![enter image description here](https://i.stack.imgur.com/SRaHg.jpg)
Finally, you can add whatever rule you want bellow this piece of code and it will work!
Be carefull,we made changes only to the domain `.htaccess` file
Hope it helps! |
69,564,878 | So I'm trying to add a folder for an amplify app which I started a react app inside. Doing `git add .` doesn't transfer the contents of the folder to Github just the folder with nothing inside. doing ```git add -f --all doesn't do anything either. | 2021/10/14 | [
"https://Stackoverflow.com/questions/69564878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14552254/"
] | What it means by `mutable default` is that the lists provided as defaults will be the same individual objects in each instance of the dataclass. This would be confusing because mutating the list in an instance by e.g. appending to it would also append to the list in every other instance.
Instead, it wants you to provide a `default_factory` function that will make a new list for each instance:
```py
from dataclasses import dataclass, field
@dataclass
class MyClass:
my_list: list = field(default_factory=lambda: ["list1", "list2", "list3"])
my_list2: list = field(default_factory=lambda: ["list1", "list2", "list3"])
``` |
236,111 | Let $G(V,E)$ be a graph. A path whose length is equal to the diameter of a graph is called a **diametral** path. In a cycle graph every vertex has $2$ diametral paths. Now I need to prove that this:
>
> If each $v \in V(G) $ has the same number of diametral paths initiated from it, then $G$ is a regular graph.
>
>
> | 2016/04/13 | [
"https://mathoverflow.net/questions/236111",
"https://mathoverflow.net",
"https://mathoverflow.net/users/78180/"
] | The claim is actually **false**, for both versions of the problem. That is, we may define a *diametral path* of $G$ as a path with length equal to the diameter of $G$ (I think this is the OP's intent), or as a path with length equal to the diameter with the additional property that it is a shortest path between its ends (this is Shahrooz Janbaz's interpretation).
Here is an infinite family of counterexamples to the second definition (Shahrooz Janbaz has already given a counterexample to the first defintion). Let $G\_k$ be the graph obtained from a cycle of length $2k$ by first adding a parallel edge for each edge and then subdividing each edge once. Observe that $G\_k$ is not regular (it has vertices of degree $2$ and $4$) and has diameter $2k$. Moreover, if $x$ is a degree $4$ vertex of $G\_k$, then there are $2^{k+1}$ diametral paths starting at $x$ (there are $2^k$ in each direction). Similarly, if $y$ is a degree $2$ vertex of $G\_k$, there are $2^{k+1}$ diametral paths starting at $y$. |
3,962,705 | Hi my application runs fine but when I try to run the unit tests I am getting this error...
```
2010-10-19 00:27:49.919 AssignmentUnitTest[27988:903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'*** -[NSURL initFileURLWithPath:]: nil string parameter'
```
Irony is I have searched the whole project & I dont have any similar line of code that uses `**[NSURL initFileURLWithPath:]**`
I have pretty much wasted half of my day on it without any success.
I am using coredata in the project & below is the screen shot with stack trace.
Can anyone please guide me to the right direction.
Thanks
![screen shot](https://i.stack.imgur.com/x7raH.png)
\*\*EDIt : \*\* The solution to this problem is to add not only the .xcdatamodel file but the root file .xcdatamodeld. Core Data was having trouble finding my model so was displaying this error. Hope it helps somebody someday. | 2010/10/18 | [
"https://Stackoverflow.com/questions/3962705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197688/"
] | Try adding `<style type="text/css">#sb-container { left:0; }</style>` to the head section of your pages. |
40,254,744 | Has somebody experience excluding the columns in the pdf result from a Table using jsPDF autoTable..Would appriciate a little help. | 2016/10/26 | [
"https://Stackoverflow.com/questions/40254744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4994527/"
] | Anyway, after digging deep in the API and in the examples. I found a solution. jsPDF with autoTable is kinda tricky specially for beginners so for those who will bump in to this predicament in the near fututre. Here's how:
```
var tTB = document.getElementById("myTable");
var atTB = doc.autoTableHtmlToJson(tTB, true);
var cols = atTB.columns;
//here you are going to set which column you will truncate. Moreover, .splice(index number of the column(your start), the number of columns you will exclude)
cols.splice(4,1);
doc.text("My Test Table", 40, 60);
doc.autoPrint();
```
cheers! |
23,918,559 | I have this code to get from binary to decimal:
```
#include <stdio.h>
#include <math.h>
#include <stdint.h>
int main() {
printf("%lld\n", binaryToDecimal(11110000111100001111000011110000));
return 1;
}
long long binaryToDecimal(long long binary) {
int power = 0;
return binaryToDecimalHelper(binary, power);
}
long long binaryToDecimalHelper(long long binary, int power) {
if (binary != 0) {
long long i = binary % (double)10;
return (i * pow(2, power))
+ binaryToDecimalHelper(binary / 10, power + 1);
} else {
return 0;
}
}
```
It works fine for small values (up to 16 bits) , but for 32 bits (which is what I need) it just returns garbage. | 2014/05/28 | [
"https://Stackoverflow.com/questions/23918559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2850788/"
] | The number 11110000111100001111000011110000 is of type int, which can't hold a number as big as 11110000111100001111000011110000 in your machine. It's better to use a string representation instead ("11110000111100001111000011110000") and adjust your algorithm, if you can. |
18,985,981 | I'm attempting to new-up a Regex object using a pattern. The string pattern and the original regex are below:
```
string search = "Root\\Hill";
var regex = new Regex(search, RegexOptions.IgnoreCase);
```
This throws a `System.ArgumentException` exception so I'd like to convert the pattern to a verbatim string. I've tried this:
```
var regex = new Regex(@search, RegexOptions.IgnoreCase);
```
and this:
```
string verbatim = @search;
var regex = new Regex(verbatim , RegexOptions.IgnoreCase);
```
but to no avail. They both throw the same exception. When I'm debugging, putting the "raw" string in the Regex constructor (eg. `new Regex(@"Root\\Hill", RegexOptions.IgnoreCase)`) works, but my search value changes of course.
How can I use a verbatim string with a variable? | 2013/09/24 | [
"https://Stackoverflow.com/questions/18985981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1315956/"
] | The fact that an outgoing queue has been created on the sending machine, and this queue has no messages, means that the message has been transmitted to the receiving machine.
So the problem will be something on the receiving machine. Probably queue permissions. Are the machines in different windows domains?
If you enable the msmq event log (Event Viewer -> Apps and Services Logs -> Microsoft -> Windows -> MSMQ) you should be able to see exactly what happens after the message arrives. |
22,133 | There are 4 classes in descending order:
1. *BrAhmaNa*
2. *Kshatriya*
3. *Vaishya*
4. *Shudra*
If a man of class X mates with a woman of class X, then definitely the child will inherit the class X.
How the intermixing of 2 classes (X & Y) works with respect to the child's class & duties?
**Note**: [caste-system](/questions/tagged/caste-system "show questions tagged 'caste-system'") is not appropriate for this Qn, as we are discussing about "classes" and not the "castes". [See this](https://hinduism.meta.stackexchange.com/a/952/1049).
**Update**: Some people may get offended due to wrong tagging in our site, so I will make a clarification here. There is a big difference between "caste-system" (tag available) and "class-system" (tag rejected). See [this answer](https://hinduism.stackexchange.com/a/11246/1049) for a detailed reference.
In short, if we consider "Bill Gates" and "Bill Clinton" as head of their family trees, then "Gates" & "Clinton" are castes, however "businessman" and "politician" are classes. Some may find former as racist, however this Qn intends to discuss about the latter. | 2017/11/15 | [
"https://hinduism.stackexchange.com/questions/22133",
"https://hinduism.stackexchange.com",
"https://hinduism.stackexchange.com/users/1049/"
] | First of all, the sons who are born out of proscribed marriages will not belong to any of the 4 castes (varna-s). As there is no 5th caste, they all will belong to the unknown caste or the out-cast. But they have different names so that they can be differentiated.
>
> 10.4. Brahmana, the Kshatriya, and the Vaisya castes (varna) are the twice-born ones, but the fourth, the Sudra, has one birth only; there
> is no fifth (caste).
>
>
>
Secondly, this topic is already dealt with in great detail in the Manu Smriti. See the following collection of verses:
>
> 10.8. From a Brahmana a with the daughter of a Vaisya is born (a son) called an Ambashtha, with the daughter of a sudra a Nishada, who is
> also called Parasava.
>
>
> 10.9. From a Kshatriya and the daughter of a Sudra springs a being, called Ugra, resembling both a Kshatriya and a Sudra, ferocious in his
> manners, and delighting in cruelty
>
>
> 10.10. Children of a Brahmana by (women of) the three (lower) castes, of a Kshatriya by (wives of) the two (lower) castes, and of a Vaisya
> by (a wife of) the one caste (below him) are all six called base-born
> (apasada).
>
>
> 10.11. From a Kshatriya by the daughter of a Brahmana is born (a son called) according to his caste (gati) a Suta; from a Vaisya by females
> of the royal and the Brahmana (castes) spring a Magadha and a Vaideha.
>
>
> 10.12. From a Sudra are born an Ayogava, a Kshattri, and a Kandala, the lowest of men, by Vaisya, Kshatriya, and Brahmana) females, (sons
> who owe their origin to) a confusion of the castes.
>
>
> 10.13. As an Ambashtha and an Ugra, (begotten) in the direct order on (women) one degree lower (than their husbands) are declared (to be),
> even so are a Kshattri and a Vaidehaka, though they were born in the
> inverse order of the castes (from mothers one degree higher than the
> fathers).
>
>
> 10.14. Those sons of the twice-born, begotten on wives of the next lower castes, who have been enumerated in due order, they call by the
> name Anantaras (belonging to the next lower caste), on account of the
> blemish (inherent) in their mothers.
>
>
> 10.15. A Brahmana begets on the daughter of an Ugra an Avrita, on the daughter of an Ambashtha an Abhira, but on a female of the Ayogava
> (caste) a Dhigvana.
>
>
> 10.16. From a Sudra spring in the inverse order (by females of the higher castes) three base-born (sons, apasada), an Ayogava, a
> Kshattri, and a Kandala, the lowest of men;
>
>
> 10.17. From a Vaisya are born in the inverse order of the castes a Magadha and a Vaideha, but from a Kshatriya a Suta only; these are
> three other base-born ones (apasada).
>
>
> 10.18. The son of a Nishada by a Sudra female becomes a Pukkasa by caste (jati), but the son of a Sudra by a Nishada female is declared
> to be a Kukkutaka.
>
>
> 10.19. Moreover, the son of by Kshattri by an Ugra female is called a Svapaka; but one begotten by a Vaidehaka on an Ambashtha female is
> named a Vena.
>
>
>
Some occupations are mentioned in the following verses:
>
> 10.32. A Dasyu begets on an Ayogava (woman) a Sairandhra, who is skilled in adorning and attending (his master), who, (though) not a
> slave, lives like a slave, (or) subsists by snaring (animals).
>
>
> 10.33. A Vaideha produces (with the same) a sweet-voiced Maitreyaka, who, ringing a bell at the appearance of dawn, continually. praises
> (great) men.
>
>
> 10.34. A Nishada begets (on the same) a Margava (or) Dasa, who subsists by working as a boatman, (and) whom the inhabitants of
> Aryavarta call a Kaivarta.
>
>
> 10.35. Those three base-born ones are severally begot on Ayogava women, who wear the clothes of the dead, are wicked, and eat
> reprehensible food.
>
>
>
In general, for all practical purposes, they can be treated as a Sudra. So, they can betake the jobs which are prescribed for the Sudras in the scriptures.
>
> 10.41. Six sons, begotten (by Aryans) on women of equal and the next lower castes (Anantara), have the duties of twice-born men; **but all
> those born in consequence of a violation (of the law) are, as regards
> their duties, equal to Sudras.**
>
>
>
*All verses are from the Manu Smriti.* |
276,603 | How can I remove the peaks in the top channel shown in the image? They are noises.
This image is from audacity
![sample](https://I.stack.imgur.com/XV8my.png) | 2011/04/28 | [
"https://superuser.com/questions/276603",
"https://superuser.com",
"https://superuser.com/users/78553/"
] | Have you tried Audacity's [Noise Removal feature(s)](http://wiki.audacityteam.org/index.php?title=Noise_Removal)?
This may be more of a 'click' than a 'noise' (looks like it), so perhaps you'll have better luck with the Audacity ["Click Removal"](http://wiki.audacityteam.org/wiki/Click_Removal) features?
Example of what's on the page:
>
> Sometimes an even better result can be obtained by zooming in (CTRL + 1) to near sample level and either silencing the click (Edit > Silence), or using the Draw Tool to smooth out the contours of the samples and so attenuate the click.
>
>
> |
11,931,640 | I'm making an application where I need to map sockets to some object. I thought I would be safe using the socket.id variable provided by Socket.IO. Unfortunately while debugging I found out that the socket.id changed without the client disconnecting/reconnecting or whatever.
Here's a small piece of code to show what I'm trying to do:
```
var io = require('socket.io').listen(8080),
var myVariable = new Array();
// Main event loop
io.sockets.on('connection', function (socket) {
socket.on('myEvent', function(data) {
myVariable[socket.id] = data;
}
// 'someOtherEvent' which uses the mapped data.
socket.on('someOtherEvent', function(data) {
// Doesn't always work because socket.id has changed and var is empty
doSomethingWith(myVariable[socket.id]);
}
});
```
I'm not sure but I don't think this is the desired effect. Why does this happen and how would I work around it? | 2012/08/13 | [
"https://Stackoverflow.com/questions/11931640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1106611/"
] | I was using [node-inspector](https://github.com/dannycoates/node-inspector/) to debug my application and because I was holding the code on some breakpoint it disconnected the client (probably some timeout client side). That's why I got a new socket.id when I continued the code execution. |
246,803 | This is not a programming issue, just want to ask any one having Internet Explorer Javascript disabled issue. I try go to Internet Option enable everything, including javascript restart it. But all the javascript still disabled.
I go to jQuery API website, test the javascript, at the Demo part nothing show. Even I write a alert("hello"); in a html file, nothing come out.
I am not sure what happen to my Internet Explorer. Initially I am using IE8, I try to update to IE9Beta, IE9RC, the problem start from IE8->IE9RC still haven't resolved. I am not sure what application crash with the IE.
Please advice! It is Urgent.
Thanks! | 2011/02/17 | [
"https://superuser.com/questions/246803",
"https://superuser.com",
"https://superuser.com/users/68074/"
] | Go to tools -> internet options -> advanced -> reset and it'll go back to default after restart. Also restore advanced settings.
If that fails uninstall IE9 or revert back to IE8 and do the above again and see if it helps.
**Update**
Steps to unlock ActiveX Internet Explorer 8
```
1. Start Internet Explorer 8.
2. Press "Tools", after that "Internet Options".
3. Now Press on the "Security" tab.
4. After that Press on the key "Custom Level."
5. Go down to "Run ActiveX controls and plug-ins" The default for this
value is "Enable." If you locate
that ActiveX is allowing untrusted
sites, Press the Reset key to reset
all advanced settings back to their
default values, including ActiveX,
as well as after that restart your
browser.
``` |
33,826,451 | I have this method to get a string of rows and print them.
Additionally, I have to do `while(Resultset.next())` two times. The first one is to get the number of rows and the second one is to print the string. But when the method runs the first time `Resultset.next()` the method skips the second `Resultset.next()`.
```
public static String[] gett() throws ClassNotFoundException, SQLException{
// this for get conneced to the database .......................
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","111");
Statement st = conn.createStatement();
ResultSet re = st.executeQuery("select location_id from DEPARTMENTS");
// Ok , now i have the ResultSet ...
// the num_row it's counter to get number of rows
int num_row = 0;
// this Arrar to store String values
String[] n = new String[num_row];
// this is the first ResultSet.next , and it's work ..!
// also , this ResultSet.next work to get number on rows and store the number on 'num_row'
while(re.next())
num_row++;
// NOW , this is the secound 'ResultSet.next()' , and it's doesn't WORK !!!!
while(re.next()) {
System.out.println(re.getString("location_id"));
}
}
```
The problem is, the first `Resultset.next()` works fine, but the second does not work!
Could someone explain why? And how can I make it work?
note:
I know, there is another way to do it in just one `Resultset.next()`
BUT I want to do it twice ;) | 2015/11/20 | [
"https://Stackoverflow.com/questions/33826451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5297080/"
] | you could initialize your `Statement` as the following
```
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
```
Due to this you can move the cursor around in the Statement.
Now you could either loop through it.
```
while(re.next())
num_row++;
re.beforeFirst();
```
but this is quite unneccessary and the optimal solution would be to just jump to the end of the set and return the row
```
num_row = 0;
if(re.last()) {
num_row = rs.getRow();
re.beforeFirst();
}
``` |
24,839,457 | Hi I have a html document's webView Show me how I can enable zoom in webView??
My Code:
```
WebView webView = (WebView) findViewById(R.id.webView1);
webView.loadUrl("file:///android_asset/police_gozarname.html");
``` | 2014/07/19 | [
"https://Stackoverflow.com/questions/24839457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3855687/"
] | If like me you're confused as to why you have to give Effort a connection string at all (since it works off an in-memory database, and you provide your context a connection directly), the [documentation](https://tflamichblog.wordpress.com/2012/11/04/factory-methods-in-effort-createtransient-vs-createpersistent/) makes it a bit clearer - it's only required if you're using database-first or model-first variants of the Entity Framework, because the Entity connection string provides the information necessary for Effort to locate your model so that it can build a schema from it!! So you can safely fill the server/database/user id/password portions of the connection string with dummy names.
This also makes it clear that the custom default DbConnectionFactory approach only works for code-first, which explains the first few hours of errors I was getting... For model first or database first, you have to inject an Entity Connection into your entity class, as described [here](http://bartwullems.blogspot.co.uk/2013/06/effort-entity-framework-unit-testing.html).
A useful tip - because your generated entity model class is a partial class, you can create another code file in the same assembly, give it the same namespace and make it also a partial class, and you can add the second constructor necessary for setting the EntityConnection to that code file instead, that way when you modify/recreate your entity model, the code with the custom constructor won't get deleted by the t4 template. |
31,635,088 | I'm trying to calculate a 2 tailed Student Distribution using `commons-math`. I'm using Excel to compare values and validate if my results are correct.
So Using excel to calculate TDIST(x, df, t) with x = 5.968191467, df = 8, tail t = 2
```
=TDIST(ABS(5.968191467),8,2)
```
And get the Result: 0.000335084
Using commons Math like so :
```
TDistribution tDistribution = new TDistribution(8);
System.out.println(BigDecimal.valueOf(tDistribution.density(5.968191467)));
```
I get Result : 0.00018738010608336254
What should I be using to get the result exactly like the TDIST value? | 2015/07/26 | [
"https://Stackoverflow.com/questions/31635088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4778780/"
] | To replicate your formula in Excel you can use CDF:
```
2*(1.0 - tDistribution.cumulativeProbability(5.968191467))
``` |
44,562,955 | I'm planning to work on a multi-tenancy application and for now I'm just looking at different implementations on the web to understand the requirements needed to implement such task.
Hibernate + Spring boot are the technologies I'm planning to use.
From my readings, all the different tutorials are using the same approach which is to declare the data sources in a config file so that session factories are launched with the boot of the application, but I really want to have a higher level of the app, where I can add tenants dynamically and input their data sources informations.
This way the application can get the information of the new tenant without the need to touch the config files and re-boot the app.
I thought about having a separate database where I can store my tenants data source credentials or something like that. Can you give me another approach to solve this requirement or a link to an existing implementation that I can refer to.
Thanks | 2017/06/15 | [
"https://Stackoverflow.com/questions/44562955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4682000/"
] | I got similar requirements in the past.
I implemented DataSource proxy class. The class has tenant resolver and a map of simple DataSources. All the places where we need a DataSource use the proxy.
On any method call e.g. getConnection() it resolves tenant, check whether the map contains already created DataSource (if not a new DataSource is created for the tenant and stored in the DB). Then the same method of real DataSource from the map is invoked.
Tenant resolver is ThreadLocal based where tenant value is stored in a filter (got tenant from request header) and used in the DataSource proxy. |
28,686 | I haven't been able to find any mentions on party size in the Numenera core book. What I want to know is the ideal size for a party and the practical maximum and minimum party sizes. Is it possible, for example, to play with 1 GM and 1 PC? Is it too unwieldy to play with more than 6 PC?
Please note my use of "ideal" and "practical" and "possible". I really want to know: can I GM for 2 people/1 people/7 people and *still have it be fun*?
**ADDENDUM:** After a couple of runs through the Beale of Boregal adventure, I can attest that the game is playable with only 1 PC. The biggest modification I had to make was to the intrusion system, because there was no other player with which to share the extra XP point. I houseruled that by giving 1 XP only.
Apart from that, I had very little combat happen, but the system was great fun to use 1 on 1. | 2013/09/11 | [
"https://rpg.stackexchange.com/questions/28686",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/932/"
] | Numenera is not more strongly tied to party size than any other trad style RPG. Like any trad style RPG, however, it's going to have trouble, or at least require special techniques, when dealing with, in this case, less than three or more than six characters.
**Why Less Than Three?**
There are three character classes - glaives, jacks, and nanos. In class based systems, unless the GM is specifically constructing adventures to avoid one of the primary concerns, you will often find yourself needing party members with those complementary skills.
Furthermore, in any game with much combat at all, especially when randomizers are in use, you have the "N+1 redundancy" problem. One party member being taken out by an unlucky roll - if there's one character, they're screwed; if there's two, it's still mighty hard for one person to haul another away especially if there's action going on (and what if no one else can heal...).
Of course, the Numenera book has a big chip on its shoulder in the GM advice section and strongly encourages you to tune challenges to the party you have (kinda) and to use fiat when necessary (unless you should be using the dice)... It's a little schizophrenic but the bottom line is "you can craft a campaign that is suited to fewer/non-balanced groups" but that takes a little extra zing on the part of the GM.
**Why More Than Six?**
Despite claims to the contrary, every tabletop RPG begins to break down with more than six players. Basic human group dynamics form a large portion of why (optimal team size is often cited at anywhere in that range, from [4.6](http://money.cnn.com/2006/05/31/magazines/fortune/intro_greatteams_fortune_061206/index.htm) to "[5-7](http://humanresources.about.com/od/teambuildingfaqs/f/optimum-team-size.htm)" (which would include your GM).
Since Numenera combat is light, it can go up to six safely (something like Pathfinder or D&D 3.5e or 4e becomes a boring PITA the more people you have) but it still has an action economy, and the more PCs there are, the harder it is to make a meaningful challenge just because you have N "bites at the apple" for whatever challenge is at hand, and the higher N is the lower the chance of failure is, so you have to add larger and more diverse challenges which is doable but is more work.
So Numenera is more tolerant of fewer or more PCs than some games, but as a trad game with defined class roles and action-based combat, there is a natural sweet spot in the 3-6 range where better GMing and adaptation is required the farther outside that range you go. |
15,462,589 | I am using msys Git in Windows. I have already gotten coloring for my prompt via setting the PS1 variable in .bashrc.
However - I am also looking to get standard bash coloring - for example, a different color for files vs directories when I do "ls". Does anyone know how to achieve this? | 2013/03/17 | [
"https://Stackoverflow.com/questions/15462589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1781201/"
] | I figured out that you have to actually set the --color flag for each command. I added this to .bash-rc for ls to: show coloring (--color=auto), show hidden files (-a), show list (-l), show human readable sizes (-h), and sort by extension so that directories are shown first (-X):
```
alias ls='ls --color=auto -alhX'
```
If there is any way to turn on coloring globally for all commands without having to create aliases individually for each command, let me know. |
378,016 | I am trying to tighten up my process for tackling a feature request. Currently, we use trello to manage feature requests using cards. They typically look like this.
```
Card Title: Invite a friend
Card Description: Allow the user to send an invite.
```
I then interpret the feature and start writing code to fulfill the request. I sometimes have to stop in the middle of coding and message the client or project manager questions like "Is this just for a regular user? What happens if that email already exists? Where should the link for the invite page go? etc..
I am getting into writing user stories and it seems to bring more of the conversation upfront and is helping with the planning phase of a feature, but I feel like there should be at least one more step before writing code.
As an example say we are working on a web application that allows teachers and students to communicate. We get a feature request to allow the user to send an invite. This feature has three scenarios.
**Scenario 1 User Story**
**As a**: Student
**I want**: to invite my classmate
**So that**: they can communicate with our teacher.
**Scenario 2 User Story**
**As a**: Student
**I want**: to invite my teacher
**So that**: we can communicate within the application.
**Scenario 2 User Story**
**As a**: Teacher
**I want**: to invite my colleague
**So that**: they can comunicate with their students.
What is the best way as a programmer/developer to break this out as part of the planning phase before writing any code? How can I break this user story up into something developer related and I can refer back while actually writing code. I use TDD so I usually would start writing the tests with the code that I wish existed and simply start writing the classes and methods to satisfy my test. Can I do something similar with a user story? | 2018/09/05 | [
"https://softwareengineering.stackexchange.com/questions/378016",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/314604/"
] | Most relational database systems will return the "number of records affected," which in the case of a DELETE, would be the number of records deleted. That's all the confirmation you need. |
41,547,555 | I'm trying to number each line of a file with this format: `/1/`,`/2/`,...
For example
From
```
UK
Australia
Newzealand
Brazil
America
```
To
```
/1/ UK
/2/ Australia
/3/ Newzealand
/4/ Brazil
/5/ America
```
I think about
```
grep -n file.txt // but the format is 1: , 2: , ...
nl file.txt // but the format is 1 , 2 , 3
```
Can i give a specific format to `nl` command? | 2017/01/09 | [
"https://Stackoverflow.com/questions/41547555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4726857/"
] | With GNU cat and GNU sed:
```
cat -n file | sed 's|^ *|/|;s|\t|/ |'
```
Output:
```
/1/ UK
/2/ Australia
/3/ Newzealand
/4/ Brazil
/5/ America
```
---
I used two `s` commands with this format: `s|regexp|replacement|`.
>
> `s|^ *|/|`: This replaces in a line starting (`^`) with zero or more (`*`) blanks by a `/`
>
>
> `s|\t|/ |`: This Replaces a tab (`\t`) by a slash followed by a blank.
>
>
>
---
See: [The Stack Overflow Regular Expressions FAQ](https://stackoverflow.com/a/22944075/3776858) |
3,532,453 | I have written a code that is saving some bitmaps in png format (using bitmap.Save() method). However for some unknown reason some of the images are saved as corrupted pngs so Photoshop cannot open them.
I need to detect these pngs in my code rather than opening them one by one in the Photoshop.
is there any way that I can read the created png and check if it is corrupted? | 2010/08/20 | [
"https://Stackoverflow.com/questions/3532453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426490/"
] | Are you making sure to close your stream properly when you are done? I think it's extremely unlikely that a Bitmap.Save() would result in a corrupted PNG or that Photoshop couldn't read any PNG created by .NET.
The easiest thing to try is to immediately load it again in .NET. I would try to get to the bottom of why this is happening -- what is specifically corrupt about it? |
2,825,717 | Consider a sequence $a\_n$
$$a,b,c,a,b,c,\ldots$$
and we want to find an expression/formula to represent this.
I'm new to complex numbers, and it feels we can somehow use the expression $\left(e^{i2\pi/3}\right)^n$ to represent above sequence. I've been trying, but I'm not able to form a connection between the two. It seems I need to scale the complex numbers successively by $\dfrac{a}{e^{i0}},\dfrac{b}{e^{i2\pi/3}},\dfrac{c}{e^{-i2\pi/3}} $. I'm kinda stuck.. Appreciate any help... | 2018/06/20 | [
"https://math.stackexchange.com/questions/2825717",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/168854/"
] | Let's just denote $e^{2i\pi/3}$ by $\omega$.
The main observation is that $\omega^n + \omega^{2n} + \omega^{3n}$ is $3$ when $n$ is divisible by $3$ and $0$ otherwise.
Also note that $\omega^3 = 1$.
So you can express your sequence as:
$$\frac a3 (\omega^n + \omega^{2n} + 1) + \frac b3 (\omega^{n-1} + \omega^{2n-2} + 1) + \frac c3 (\omega^{n-2} + \omega^{2n-4} + 1)$$ |
40,727 | H.P. Lovecraft (1890-1937) wrote his stories (including the "Cthulhu Mythos") in English, but [his Wikipedia page](https://en.wikipedia.org/wiki/H._P._Lovecraft) notes that several French authors provided commentary on his stories. It doesn't clarify if he corresponded with them though, so it's not clear to me if he actually understood French.
Which languages did H.P. Lovecraft understand (in either spoken or written form)? Unfortunately, neither the Wikipedia article itself, nor other sources I can find, actually say which languages he knew. | 2017/10/04 | [
"https://history.stackexchange.com/questions/40727",
"https://history.stackexchange.com",
"https://history.stackexchange.com/users/6378/"
] | Although I can find no evidence that H.P.Lovecraft understood French, he was accomplished enough in Latin to translate texts and, judging by this letter cited in *[Classical Traditions in Modern Fantasy](https://books.google.com.ph/books?id=yhqhDQAAQBAJ&pg=PA96&lpg=PA96&dq=lovecraft%20latin%20poem&source=bl&ots=wNf2NpCf6M&sig=i2JFEy_6ARzhslukXvVQDFYMN8s&hl=en&sa=X&ved=2ahUKEwixjtik2qHeAhVMat4KHUTvCIYQ6AEwDHoECAUQAQ#v=onepage&q=lovecraft%20latin%20poem&f=false)*, not unfamiliar with the spoken language either:
>
> Latin and Greek were my delight - although I had long-standing feud
> with teachers of the former over pronunciation. My grandfather had
> previously taught me a great deal of Latin, using the traditional
> English pronunciation taught in his day, but at school I was expected
> to follow the "Roman method"...
>
>
>
Lovecraft started learning Latin from his grandfather in 1898 when he was eight years old. By 1902 (by S. T. Joshi's estimate), he had translated "the first eighty-eight lines of Ovid’s Metamorphoses." He also had at least some knowledge of Greek as *[An H. P. Lovecraft Encyclopedia](https://books.google.com.ph/books?redir_esc=y&id=Myawoc_PbF4C&q=juvenile#v=snippet&q=juvenile&f=false)* (p209) says
>
> HPL’s surviving juvenile poetry consists largely of imitations or
> translations of Greek and Latin epics
>
>
>
*(note: [this thread](https://www.reddit.com/r/Lovecraft/comments/7ciafg/lovecrafts_latin/) says Joshi describes Lovecraft's Greek as rubbish, but I've been unable to confirm this)*
Joshi, in *[A Visionary and A Dreamer: H. P. Lovecraft in his Time](https://books.google.com.ph/books?redir_esc=y&id=tfrbBSFn_p8C&q=threshold#v=snippet&q=threshold&f=false)*, further states:
>
> In 1908 Lovecraft stood at the threshold of adulthood: he was doing
> reasonably well at Hope Street High School, he had become prodigiously
> learned in chemistry, geography, astronomy, and meteorology, and he
> was accomplished in belles-lettres as a Latinist, poet, and fiction
> writer.
>
>
>
Franz Rottensteiner, [in a review](https://www.depauw.edu/sfs/review_essays/rotten56.htm) of another Joshi book, *H.P. Lovecraft: The Decline of the West*, casts some doubt as the extent of Lovecraft's Latin, but at the same time indicates some knowledge of Spanish:
>
> He had almost no formal education and was almost entirely self-taught.
> Even though he was able to formulate Latin sentences and correct the
> Spanish grammar of his correspondents, it seems less than probable
> that he was sufficiently fluent in any language other than English to
> read books on difficult philosophical subjects published in that
> language.
>
>
> |
18,920,539 | In Linux, how do I get the man pages for C functions rather than shell commands?
For example, when I type `man bind` I get the manual page for the shell command `bind` and not the man page for socket binding C function. | 2013/09/20 | [
"https://Stackoverflow.com/questions/18920539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367736/"
] | ```
man 2 bind
```
You need a result from a different section of the manual! Man searches various sections for the information you want. As devnull lists below, the number indicates which section to search.
Incidentally, `bind` is a system call, not a C library function. System calls (kernel calls) are in section 2 of the manual, library functions are in section 3.
`man man` will tell you how to use the man command! |
16,898,305 | I have a line of C# code that I am trying to replicate in Java. The code looks as follows.
```
n.InnerText = DateTime.Parse(n.InnerText).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
```
The intent is to replace the DateTime already in the xml context with one representing universal time.
I have attempted to use
```
node.setTextContent = Date.parse(node.getTextContent())
```
but I am unable to continue due to the Date.parse() being deprecated. I read through the note in Eclipse and tried DateFormat as suggested but DateFormat does not have a parse method.
Can someone suggest a solution to my problem that does not use any third party libraries? | 2013/06/03 | [
"https://Stackoverflow.com/questions/16898305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1750067/"
] | You can use:
```
DateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ssZ");
Date date = format.parse(myString);
```
Be sure to check the locale if it's appropriate, and to check that the fields are the same (as I don't know what you intended to parse, I just copied them).
(For example "T" does not exist.) |
16,099,908 | I have a field in my page named as "myField"
Now this is dynamic So there are 2 cases i.e. it can be just 1 field as;
```
<input type="text" name="myField" />
```
OR there can be 2 fields as below;
```
<input type="text" name="myField" />
<input type="hidden" name="myField" />
```
I use the following code to access the value in JS;
```
document.forms[0].myField[0].value
```
However, this does not work if there is only 1 field (as in the first case)
How do I write dynamic JS code to handle the same?
It should be cross browser compatible. | 2013/04/19 | [
"https://Stackoverflow.com/questions/16099908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/485743/"
] | Yes, because in the first case you should use `document.forms[0].myField.value`.
I'd suggest to retrieve elements with [`getElementsByName()`](https://developer.mozilla.org/en-US/docs/DOM/document.getElementsByName) method:
```
var val = document.getElementsByName("myField")[0].value;
``` |
17,165,402 | i have a table Destinataire. unfotuntaly the clien had enter the symbol "-" in their data.
when i select them:
```
SELECT [CODE_DEST]
,[NO_CLIENT]
,[RS_NOM]
,[ADRESSE]
,[CP]
,[VILLE]
,[INSEE]
,[TEL]
,[PAYS]
,[FAX]
,[SIRET]
,[EMAIL]
FROM [Soft8Exp_Client_WEB].[dbo].[DESTINATAIRE]
WHERE code_dest like '%-%' or RS_NOM like '%-%' or ADRESSE like '%-%' or VILLE like '%-%'
```
there are about 700 element, it take time to change it one by one.
how can i update all this elment that contains "-" ?
example : MALLET-LIMOUZIN SARL becaome MALLET LIMOUZIN SARL
and BP 325 - 14 AVENUE MICHELET become BP 325 14 AVENUE MICHELET
i just wanna to replace all "-" with " ". | 2013/06/18 | [
"https://Stackoverflow.com/questions/17165402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1958628/"
] | ```
update [Soft8Exp_Client_WEB].[dbo].[DESTINATAIRE]
set code_dest = replace(code_dest,'-',' '),
column2 = replace(column2,'-',' '),
.....
``` |
3,933,150 | ```
<ScrollViewer Name="svDataGrid" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" ScrollChanged="ScrollViewer_ScrollChanged" >
<DataGrid VerticalScrollBarVisibility="Disabled" Background="Transparent" Visibility="Collapsed" Name="dgList" Grid.Row="1" IsSynchronizedWithCurrentItem="True"
AutoGenerateColumns="False" AlternatingRowBackground="Azure"
CanUserAddRows="False" CanUserDeleteRows="False"
CanUserSortColumns="True" CanUserReorderColumns="False"
CanUserResizeColumns="True" CanUserResizeRows="False" IsReadOnly="True" MouseDoubleClick="dgList_MouseDoubleClick" PreviewKeyDown="dgList_PreviewKeyDown">
</DataGrid>
</ScrollViewer>
``` | 2010/10/14 | [
"https://Stackoverflow.com/questions/3933150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438277/"
] | depending on what you want to call, either set a var to the address and do:
```
DWORD var = 0xDEADBEEF;
__asm jmp [var]
```
or, what I do:
```
__asm
{
mov eax,ModuleBase
add eax,RVA
call eax ;obviously call can be jmp
}
```
you can easily macro this(probably a good idea to add a register param):
```
#define JMP_IMM(x) __asm mov eax,x \
__asm jmp eax
```
---
Unfortunately MASM doesn't support relative calls to absolute addresses, and other assemblers like NASM can't do it for COFF object files either. So toolchain limitations force you to use this less efficient machine code with an indirect call or jmp.
* [How to write an absolute target for a near direct relative call/jmp in MASM](https://stackoverflow.com/questions/50058523/how-to-write-an-absolute-target-for-a-near-direct-relative-call-jmp-in-masm)
* [Error when calling function in user32.dll directly](https://stackoverflow.com/questions/53461451/error-when-calling-function-in-user32-dll-directly) |
37,054 | Now, I understand that European PhDs are far from monolithic in format, and that most quals in my field (physics) can fall into two general formats, as far as North American PhD programs are concerned:
1. A set of tests covering the fundamental areas of undergraduate-level education in your discipline (I know MIT and Princeton can be quite nasty in this regard for physics, but UChicago phased quals out due in part to student health concerns
2. A review of the literature in your research topic and the relevant fundamental notions underlying it, which must be explained in front of a jury that will ask questions as well
My question is: are quals present in European PhD programs and, if yes, what are formats commonly in use for that purpose? | 2015/01/19 | [
"https://academia.stackexchange.com/questions/37054",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/15996/"
] | Most central European universities don't traditionally have QEs. However, it seems to me as if it is getting more popular to have *something* after the first one or two years of your programme. Two data points:
* In my current university, PhD students need to defend their thesis proposal after (maximum) two years. This includes writing their proposal, receiving written comments by two other (i.e., not their advisor) professors of the faculty, and presenting and defending their proposal in front of the entire faculty (our faculty is pretty small). Questions are asked in this defense, but not typically about material that is not directly linked to the proposal. In theory students can fail at this step, but is is very uncommon. The goal is rather to force students (and advisors) to have a clear goal of where the thesis is going early on, something that was historically a bit of a problem.
* When I did my PhD, we did not really have any sort of entry exam or defense in my alma mater. However, since then, they have switched to a model not unlike what I explained above. The main difference is that proposals are only presented (there is no written document), and that only a small committee is responsible for giving feedback on the proposal (not the entire faculty). This defense has to be taken one year after start of the PhD. Failing this defense is again *very* uncommon.
**Summary**: the places I am well aware of don't have stressful QEs. Instead, we traditionally had pretty much nothing. Nowadays, many places have a proposal defense instead of a QE, but this is not a step that students typically have to be stressed out about. |
35,382,066 | I am searching for a design solution to the problem where I have 2 classes which depend on each other such that I have `class Customer` and `class Order` where:
`Customer` can have a list of orders (1-to-N) and an `Order` has a designated customer (1-to-1).
What is the best practice to break these kind of dependencies? | 2016/02/13 | [
"https://Stackoverflow.com/questions/35382066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1110075/"
] | Assuming you have a dependency as follows:
```
public class Customer {
private long customerId;
private String name;
private String address1;
// ....
private List<Order> orders;
}
public class Order {
private long orderNumber;
private Date orderDate;
// ... others
private Customer customer;
}
```
You could create a third class to break the dependency:
```
public class CustomerOrder {
private final Customer customer;
private final List<Order> orders;
public CustomerOrder(Customer customer) {
super();
this.customer = customer;
this.orders = new ArrayList<Order>();
}
public void addOrder(Order order) {
orders.add(order);
}
public Customer getCustomer() {
return customer;
}
public List<Order> getOrders() {
return orders;
}
}
```
Now you can drop orders from the Customer class, and customer from the Order class. Or am I misunderstanding your issue? |
57,982,050 | every time i run my app it shows this error in the title
and i have searched for the problem some said make the ViewModel constructor public and mine is public
other said Either:
Remove the Context context and LifecycleOwner lifecycleOwner constructor parameters from your HomeViewModel, or
Create a ViewModelProvider.Factory that can build your HomeViewModel instances, and use that factory with ViewModelProviders.of()
and i have made the two solutions and still get the same error
MainActivity
```
package com.example.architectureexample;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.widget.Toast;
import java.util.List;
public class MainActivity extends AppCompatActivity {
// 5th video
private NoteViewModel noteViewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
noteViewModel = ViewModelProviders.of(this).get(NoteViewModel.class);
noteViewModel.getAllNotes().observe(this, new Observer<List<Note>>() {
@Override
public void onChanged(List<Note> notes) {
// update recycleView
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_SHORT).show();
}
});
}
}
```
ViewModel class
```
package com.example.architectureexample;
// 5th video
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import java.util.List;
public class NoteViewModel extends AndroidViewModel {
private NoteRep rep;
private LiveData<List<Note>> allNotes;
public NoteViewModel(@NonNull Application application) {
super(application);
rep = new NoteRep(application);
allNotes = rep.getAllNotes();
}
public void insert(Note note){
rep.insert(note);
}
public void update(Note note){
rep.update(note);
}
public void delete(Note note){
rep.delete(note);
}
public void deleteAll(){
rep.deleteAll();
}
public LiveData<List<Note>> getAllNotes() {
return allNotes;
}
}
```
Repository class
```
package com.example.architectureexample;
// 4th video
import android.app.Application;
import android.os.AsyncTask;
import androidx.lifecycle.LiveData;
import java.util.List;
public class NoteRep {
private NoteDao noteDao;
private LiveData<List<Note>> allNotes;
public NoteRep(Application application){
NoteDatabase database = NoteDatabase.getInstance(application);
noteDao = database.noteDao();
allNotes = noteDao.getAllNotes();
}
// these methods works as API the the Repository Exports to the out side
public void insert(Note note){
new InsertNoteAsyncTask(noteDao).execute(note);
}
public void update(Note note){
new UpdateNoteAsyncTask(noteDao).execute(note);
}
public void delete(Note note){
new DeleteNoteAsyncTask(noteDao).execute(note);
}
public void deleteAll(){
new DeleteAllNotesAsyncTask(noteDao).execute();
}
public LiveData<List<Note>> getAllNotes() {
return allNotes;
}
private static class InsertNoteAsyncTask extends AsyncTask<Note ,Void,Void>{
// we need it to do database operations
private NoteDao noteDao;
// because the class is static we can't access the NoteDao directly so we have to pass it throw a constructor
public InsertNoteAsyncTask(NoteDao noteDao) {
this.noteDao = noteDao;
}
@Override
protected Void doInBackground(Note... notes) {
noteDao.insert(notes[0]);
return null;
}
}
private static class UpdateNoteAsyncTask extends AsyncTask<Note ,Void,Void>{
// we need it to do database operations
private NoteDao noteDao;
// because the class is static we can't access the NoteDao directly so we have to pass it throw a constructor
public UpdateNoteAsyncTask(NoteDao noteDao) {
this.noteDao = noteDao;
}
@Override
protected Void doInBackground(Note... notes) {
noteDao.update(notes[0]);
return null;
}
}
private static class DeleteNoteAsyncTask extends AsyncTask<Note ,Void,Void>{
// we need it to do database operations
private NoteDao noteDao;
// because the class is static we can't access the NoteDao directly so we have to pass it throw a constructor
public DeleteNoteAsyncTask(NoteDao noteDao) {
this.noteDao = noteDao;
}
@Override
protected Void doInBackground(Note... notes) {
noteDao.delete(notes[0]);
return null;
}
}
private static class DeleteAllNotesAsyncTask extends AsyncTask<Void ,Void,Void>{
// we need it to do database operations
private NoteDao noteDao;
// because the class is static we can't access the NoteDao directly so we have to pass it throw a constructor
public DeleteAllNotesAsyncTask(NoteDao noteDao) {
this.noteDao = noteDao;
}
@Override
protected Void doInBackground(Void... voids) {
noteDao.deleteAllNotes();
return null;
}
}
}
```
database class
```
package com.example.architectureexample;
// 3rd video
// this is a class where we connect the database table with the dao to get the to communicate with each other
import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteDatabase;
@Database(entities = {Note.class},version = 1)
public abstract class NoteDatabase extends RoomDatabase {
private static NoteDatabase instance;
// this will access our Dao
public abstract NoteDao noteDao();
public static synchronized NoteDatabase getInstance(Context context){
if(instance!=null){
instance = Room.databaseBuilder(context.getApplicationContext(),
NoteDatabase.class,"note_database")
.fallbackToDestructiveMigration()
// added call back 4th video
.addCallback(roomCallback)
.build();
}
return instance;
}
// 4th video
private static RoomDatabase.Callback roomCallback = new RoomDatabase.Callback(){
@Override
public void onCreate(@NonNull SupportSQLiteDatabase db) {
super.onCreate(db);
new PopulateDbAsyncTask(instance).execute();
}
};
private static class PopulateDbAsyncTask extends AsyncTask<Void,Void,Void>{
private NoteDao noteDao;
private PopulateDbAsyncTask(NoteDatabase database){
noteDao = database.noteDao();
}
@Override
protected Void doInBackground(Void... voids) {
noteDao.insert(new Note("Title1","des1",1));
noteDao.insert(new Note("Title2","des2",2));
noteDao.insert(new Note("Title3","des3",3));
return null;
}
}
}
```
table class
```
package com.example.architectureexample;
// 2nd video
// this is the database table
import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity(tableName = "note_table")
public class Note {
@PrimaryKey(autoGenerate = true)
private int id;
private String title ;
private String description;
private int priorty;
public Note(String title, String description, int priorty) {
this.title = title;
this.description = description;
this.priorty = priorty;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public int getPriorty() {
return priorty;
}
}
```
the DAO interface
```
package com.example.architectureexample;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;
// 3rd video
// this is the dao that will interact with the databse to get the data
import java.util.List;
@Dao
public interface NoteDao {
@Insert
void insert(Note note);
@Update
void update(Note note);
@Delete
void delete(Note note);
// sql code delete from (table name)
@Query("DELETE FROM note_table")
void deleteAllNotes();
@Query("SELECT * FROM note_table ORDER BY priorty DESC")
LiveData<List<Note>> getAllNotes();
}
```
the logcat Error
```
2019-09-18 17:38:07.042 15476-15476/com.example.architectureexample E/Minikin: Could not get cmap table size!
2019-09-18 17:38:07.088 15476-15497/com.example.architectureexample E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
2019-09-18 17:38:07.373 15476-15476/com.example.architectureexample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.architectureexample, PID: 15476
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.architectureexample/com.example.architectureexample.MainActivity}: java.lang.RuntimeException: Cannot create an instance of class com.example.architectureexample.NoteViewModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.RuntimeException: Cannot create an instance of class com.example.architectureexample.NoteViewModel
at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:238)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:164)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:130)
at com.example.architectureexample.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:230)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:164)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:130)
at com.example.architectureexample.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.example.architectureexample.NoteDao com.example.architectureexample.NoteDatabase.noteDao()' on a null object reference
at com.example.architectureexample.NoteRep.<init>(NoteRep.java:19)
at com.example.architectureexample.NoteViewModel.<init>(NoteViewModel.java:18)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:230)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:164)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:130)
at com.example.architectureexample.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3411)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
``` | 2019/09/17 | [
"https://Stackoverflow.com/questions/57982050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11725672/"
] | Your database is never initialized.
`instance!=null` should be `instance==null`. |
224,731 | I just saw the movie, and I can see that they can go crazy and make a lot of tie ins.
Maybe
New Series (Since the Mandalorian seems to be going great)
Or the clasic approach
Comics or Novels.
Are there any plans or have they already announced that they will indeeed make this? | 2019/12/19 | [
"https://scifi.stackexchange.com/questions/224731",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/57244/"
] | *Star Wars: The Rise of Skywalker* received a considerable number of preview novels, comics and factbooks (plus other materials) under the heading of [*Journey To Star Wars: The Rise of Skywalker*](https://www.hollywoodreporter.com/heat-vision/star-wars-rise-skywalker-publishing-tie-ins-revealed-1207746). This included;
>
> Journey to Star Wars: The Rise of Skywalker: We are the Resistance by
> Elizabeth Schaefer and Alan Baston (Random House Kids/Little Golden
> Books; young reader fiction, Oct. 4 2019)
>
>
> Journey to Star Wars: The Rise of Skywalker: Resistance Heroes by
> Michael Siglain, Diogo Saito and Luigi Aimé (Disney Lucasfilm Press;
> young reader fiction, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker: First Order Villains by
> Michael Siglain, Diogo Saito and Luigi Aimé (Disney Lucasfilm Press;
> young reader fiction, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker: Choose Your Destiny — A
> Finn & Poe Adventure by Cavan Scott and Elsa Charretier (Disney
> Lucasfilm Press; young reader fiction, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker: Spark of the Resistance
> by Justina Ireland and Phil Noto (Disney Lucasfilm Press; middle grade
> fiction, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker: The Resistance by Sally
> Little (Readerlink/Studio Fun, young reader sound book, Oct. 4)
>
>
> Star Wars: The Rise of Skywalker Magnetic Playset by Sally Little,
> Diogo Saito and Luigi Aimé (Readerlink/Studio Fun, playset, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker Search & Find by Sally
> Little, Art Mawhinney, Fabio Piacentini and Ferran Rodriguez
> (Readerlink/Studio Fun, young reader, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker: The Ultimate Star Wars
> New Edition by Adam Bray, Cole Horton, Tricia Barr, Ryder Windham;
> foreword by Anthony Daniels (DK; non-fiction, Oct. 4)
>
>
> Journey to Star Wars: The Rise of Skywalker — Star Wars: The Ultimate
> Pop-Up Galaxy by Matthew Rienhart and Kevin M. Wilson (Insight
> Editions, pop-up book, Oct. 8)
>
>
> Journey to Star Wars: The Rise of Skywalker: Allegiance Nos. 1-4 by
> Ethan Sacks and Luke Ross (Marvel; comic book, weekly from Oct. 9)
>
>
> Star Wars: The Rise of Skywalker: Amazing Sticker Adventure (DK;
> sticker book, Oct. 14)
>
>
> Star Wars Adventures Nos. 27-29 by John Barber, Michael Moreci, Derek
> Charm and Tony Fleecs (IDW Publishing; comic book, monthly from
> October TBD)
>
>
> Journey to Star Wars: The Rise of Skywalker: Resistance Reborn by
> Rebecca Roanhorse (Del Rey; adult fiction, Nov. 12)
>
>
> Journey to Star Wars: The Rise of Skywalker: Force Collector by Kevin
> Shinick (Disney Lucasfilm Press; young adult fiction, Nov. 19)
>
>
> Journey to Star Wars: The Rise of Skywalker: The Moviemaking Magic of
> Ships and Battles by Landry Walker (Abrams, non-fiction, Dec. 3)
>
>
> Star Wars: The Rise of Skywalker: The Galaxy Needs You by Caitlin
> Kennedy and Eda Kaban (Disney Lucasfilm Press, young reader, Dec. 17)
>
>
> The Art of Star Wars: The Rise of Skywalker by Phil Szostak (Abrams,
> non-fiction, Dec. 20)
>
>
> Star Wars: The Rise of Skywalker The Visual Dictionary by Pablo
> Hidalgo (DK, non-fiction, Dec. 20)
>
>
> Star Wars: The Rise of Skywalker Official Guide by Matt Jones (DK,
> young reader non-fiction, Dec. 20)
>
>
> Star Wars: The Rise of Skywalker Official Movie Special by various
> (Titan, non-fiction, Dec. 20)
>
>
>
Since the film's release, there have also been a [number of books relating directly to the film](https://starwars.fandom.com/wiki/Timeline_of_canon_media), including two direct novelisations.
>
> Star Wars: The Rise of Skywalker Graphic Novel Adaptation (Slated for
> Jan 2021)
>
>
> The Rise of Skywalker: Junior Reader Golden Book (Aug. 2020)
>
>
> Star Wars: The Rise of Skywalker: A Junior Novel (Apr. 2020)
>
>
> Star Wars Galaxy of Adventures: "Kylo Ren vs. Resistance Rebels" (Apr. 2020)
>
>
> Star Wars: The Rise of Skywalker: Expanded Edition (Mar. 2020)
>
>
> |
1,528 | It's shown (Yousef Saad, [Iterative methods for sparse linear systems](http://books.google.com/books?hl=en&id=Uoe7xBOhS5AC&pg=PA260), p. 260) that $cond(A'A) \approx cond(A)^2$
Is this true for $AA'$ as well?
In case $A$ is $N\times M$ with $N \ll M$, I observe that $cond(A'A) \gg cond(AA')$
Does that mean formulation in terms of $AA'$ is preferable in this case? | 2012/03/05 | [
"https://scicomp.stackexchange.com/questions/1528",
"https://scicomp.stackexchange.com",
"https://scicomp.stackexchange.com/users/1089/"
] | If $A\in\mathbb{R}^{N\times M}$ with $N<M$, then
$$
\mathop{\mathrm{rank}}(A^TA) = \mathop{\mathrm{rank}}(AA^T) = \mathop{\mathrm{rank}}(A) \leq N < M
$$
so that $A^TA \in \mathbb{R}^{M\times M}$ *cannot* be full rank, i.e. it is *singular.*
Accordingly the condition number is $\kappa\_2(A^TA)=\infty$. Due to finite precision arithmetic, if you compute `cond(A'A)` in matlab you obtain a large number, not `Inf`. |
2,645,902 | Can YouTube videos be played from within an AndroidOS without launching the separate YouTube player? How about WebOS or Blackberry?
On the iPhone I can do this with a WebView and the embedded YouTube code and I'm weighing the possibility of porting my app to other mobile platforms. Thanks | 2010/04/15 | [
"https://Stackoverflow.com/questions/2645902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1580229/"
] | Yes. webview.setPluginsEnabled(true); |
57,388,864 | This is a React Native Question.
What I want to achieve is to prevent triggering the scroll event if user is dragging a particular part of a scrollView.
Minimal example:
```
<View style={{ width: '100%', flex: 1 }}>
<ScrollView>
<View style={{ width: '100%', height: 1600, backgroundColor: 'red' }}>
<View style={{ width: '100%', height: 600, backgroundColor: 'blue' }}/>
</View>
</ScrollView
</View>
```
How can I disable the drag detection (scrolling parent scrollView) of the at the blue part? | 2019/08/07 | [
"https://Stackoverflow.com/questions/57388864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8036814/"
] | You can do a trick solution using `onTouchStart` and `onTouchEnd` events inside `ScrollView`.
Here is the code you can use,
```
constructor(props) {
super(props);
this.state = {
enabled: true
};
}
render() {
return (
<View style={{ width: '100%', flex: 1 }}>
<ScrollView
scrollEnabled={this.state.enabled}
onTouchStart={(event) => {
if (event.nativeEvent.locationY < 600) this.setState({ enabled: false });
}}
onTouchEnd={(event) => {
this.setState({ enabled: true });
}}
>
<View style={{ width: '100%', height: 1600, backgroundColor: 'red' }}>
<View style={{ width: '100%', height: 600, backgroundColor: 'blue' }}/>
</View>
</ScrollView>
</View>
);
}
```
This code only handles `scrollEnabled` according to your touch position on screen. If you start touching in blue area then it should block scrolling and once you release your finger then it should removes the blocking. |
25,585,419 | I was reading through [this SO question](https://stackoverflow.com/a/3755656/1252748). I sort of understand what's going on, but I'm confused why
```
!function foo() {
console.log(true) ;
}()
```
doesn't return `false`.
>
> `!function () {}()` This will also return the boolean opposite of the
> return value of the function, in this case true, because !undefined is
> true. If you want the actual return value to be the result of the
> call, then try doing it this way:
>
>
>
"will also return the boolean opposite" makes me think that `false` should be returned. Why isn't it. `alert(!true); //false` | 2014/08/30 | [
"https://Stackoverflow.com/questions/25585419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252748/"
] | Without a `return` statement the function returns `undefined`. When you apply `!` to `undefined` you get `true`.
Try
```
console.log(!function() { return true; }());
```
Note that the idiomatic use of `!` before an IIFE is just that — an idiom. The fact that the `!` operator has an effect on the return value almost always doesn't matter, because the return value is being completely ignored by the calling environment. Thus
```
+function() {
// whatever
}();
```
is effectively exactly the same, even though the `+` unary operator is different from the `!` unary operator. |
13,478,032 | I'm trying to downsize image uploaded by users at the time of upload.
This is no problem but I want to get specific with sizes now.
I'm looking for some advice on an algorithm im struggling to produce that will take any shape image - square or rectangle of any widths/heights and downsize it.
This image needs to be downsized to a target box size (this changes but is stored in a variable)..
So it needs to downsize the image so that both the width and height are larger than the width and height of the target maintaining aspect ratio. but only just..
The target size will be used to crop the image so there is no white space around the edges etc.
I'm looking for just the algorithm behind creating the correct resize based on different dimension images - I can handle the cropping, even resizing in most cases but it fails in a few so i'm reaching out.
I'm not really asking for PHP code more pseudo. Either is fine obviously.
Thanks Kindly.
Current code.. but I've gone through so many iterations this might not work at all anymore.. :P
```
$image = $image_orig->clone();
$wRatio = $imageprops['width'] / $dimensions[0]; // imageprops = original image dimens.
$hRatio = $imageprops['height'] / $dimensions[1]; // $dimensions[0] = new width
$maxRatio = max($wRatio,$hRatio); // $dimensions[1] = new height
var_dump('thumb');
$ratio = ($imageprops['width'] - $dimensions[0]) > ($imageprops['height'] - $dimensions[1]);
$shape = ($imageprops['width'] > $imageprops['height']);
$error = ($imageprops['width'] / $imageprops['height']);
if( $error < 0.95 || $error > 1.05 ) { // its NOT a square
if($shape){ // longer width
$scale = $imageprops['height'] / $dimensions[0];
var_dump('1');
$height = $imageprops['height'] / $scale;
$image->scaleImage(0, $height);
} else {
$scale = $imageprops['width'] / $dimensions[1];
var_dump('2');
$width = $imageprops['width'] / $scale;
$image->scaleImage($width, 0);
}
} elseif($ratio) { // is square
$scale = $imageprops['height'] / $dimensions[1];
$newWidth = $imageprops['width'] / $scale;
$extra = 0;
$height = $dimensions[1]+$extra;
$image->scaleImage(0, $height);
} else {
$scale = $imageprops['width'] / $dimensions[0];
$newHeight = $imageprops['height'] / $scale;
$extra = 0;
$width = $dimensions[0]+$extra;
$image->scaleImage($width, 0);
}
$image_size = $image->getImageGeometry();
$image->cropImage($dimensions[0], $dimensions[1],($image_size['width']-$dimensions[0])/2,($image_size['height']-$dimensions[1])/2);
``` | 2012/11/20 | [
"https://Stackoverflow.com/questions/13478032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1148163/"
] | **Notice:** I wrote this answer before the original poster edited his question to include things which clarified points which has since changed what I believed the original question was asking.
---
So, there are a few concepts and ideas that you can throw around to try and solve what it is you are intending to achieve. (Gravity Cropping, [Content Aware Cropping](http://jueseph.com/2010/06/opticrop-content-aware-cropping-with-php-and-imagemagick/), Content Aware Rescaling etc)
Because you are always decreasing the size of the original image, you are essentially just looking to "chop" out a section of the image. Very much like this:
![enter image description here](https://i.stack.imgur.com/kA8C1.png)
The issue however, is that you frequently want to make sure that you select the best region of the image so that you don't crop on an irrelevant segment of the image. This is known as content-aware image cropping, and by just searching using "Content Aware Image Crop" you can find a wealth of information.
Anyway, moving on, depending on your exact use case, you might discover that actually you don't want to chop out anything form the image, and instead you want to "liquid scale and crop" the image, so that you do "Content Aware Resizing". The difference with content aware resizing is that the resizing ignores all aspect ratios of the image and instead looks at neighbouring edges and colors in order to resize the image in a fluidic way.
So, luckily enough, `Imagick` comes with it's very own `[liquidRescaleImage][3]` function.
You can use it like
`$im->liquidRescaleImage(480, 260, 3, 18);`
Using Liquid Rescale can rescale out quite nicely. Here is an example below which is anything but perfect, but I purposefully have created an example that isn't perfect so you can actually see that liquidRescale changes the composition of the image, rather than just adjusts the aspect ratio.
Original
--------
![Original](https://i.stack.imgur.com/bsiDS.jpg)
Content Aware Liquid Rescale (450x350)
--------------------------------------
![Rescale](https://i.stack.imgur.com/5ybLb.jpg)
If however, you just want to scale an image, and keep the aspect ratio, you might want to do what sites such as Flickr do, where they make the images longestLength to be equal to a value. (Flickr for example has 6 or so different dimension sizes)
>
> We resize your photos to more web-friendly dimensions. Each image has
> a 75x75 and 150x150 square thumbnail and 100-, 240-, 320-, 500-, 640-
> 800\*-, 1024-, 1600\*-, and 2048\*-pixel versions (that's the length of
> the longest side), as well as your original file.
>
>
>
**Basic Class that Replicates the Flickr Resize Policies...**
```
<?php
class Scale {
public function getImageScale($x, $y, $longestLength, $allowDistort = false) {
//Set the default NEW values to be the old, in case it doesn't even need scaling
list($nx, $ny) = array($x, $y);
if ($x > $y) {
if ($longestLength > $x && !$allowDistort) {
return array($x, $y);
}
$r = $x / $longestLength;
return array($longestLength, $y / $r);
} else {
if ($longestLength > $x && !$allowDistort) {
return array($x, $y);
}
$r = $y / $longestLength;
return array($x / $r, $longestLength);
}
return array($nx, $ny);
}
}
```
And then if you were to pass in the Image Dimensions like this:
```
$originalImageX = 480;
$originalImageY = 260;
$scale = new Scale();
var_dump($scale->getImageScale($originalImageX,$originalImageY,120 ) );
/* Outputs
array(2) {
[0]=>
int(120)
[1]=>
int(65)
} */
```
Also, there is this Content Aware Cropping class on Git, that I have previously adapted the base class/Structure previously to use in my own project so I know that it works nicely. I'm not sure on the licencing of this class, but you can obviously take a look at it and slice out what works for you as I have done previously.
<https://gist.github.com/2468935#file_content_aware_image.php>
(And PS. Provide all the information in your questions straight up next time...) |
7,445,610 | I do not know why, but somehow two files were added to project with a mistake as you can see on screenshot. How can I safely remove them from Xcode project? I've already deleted them from disk, but `delete` button is grayed out in Xcode interface.
![delete is grayed out in xcode context menu](https://i.stack.imgur.com/01QRc.png) | 2011/09/16 | [
"https://Stackoverflow.com/questions/7445610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83938/"
] | Just had this problem today. The fix for me (on Mac) was:
1. Find **YourProjectName.xcodeproj** in finder.
2. Right click > Show package contents.
3. Inside there, right click on **project.xcworkspace** > Show package contents.
4. Open **contents.xcworkspacedata** (XML format) in any text editor and manually remove the references.
Hope this helps anyone with the same issue! |
12,752,515 | I have looked through all of the VB6 Error Numbers to no avail, and it seems the command object itself takes care of the error messagebox in the background. What I need to know is if their is someway to change the MsgBox for the ADODB.CommandTimeout error itself. My first thoughts were to just catch the error (using error numbers) and then set a MsgBox that way. However, I can't find any documentation on any error numbers handling ADO Events. Any suggestions? | 2012/10/05 | [
"https://Stackoverflow.com/questions/12752515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1431288/"
] | [InPursuit](https://stackoverflow.com/users/631017/inpursuit) is correct but I believe `$ ->` is more of a coffee idiom.
```
$ ->
$('#alert').delay(100).show 'drop', direction: "up", 900
```
... compiles to:
```
$(function() {
return $('#alert').delay(100).show('drop', {
direction: "up"
}, 900);
});
```
Check out [this link](http://coffeescript.org/#try:$%20-%3E%0A%20%20$%28%27#alert%27%29.delay%28100%29.show%20%27drop%27,%20direction:%20%22up%22,%20900) to see it in action and also play with a coffee repl. |
331,357 | I am working on a Windows Forms app for quite some time now, and I really find myself doing more typecasts in the GUI code than I ever did in my underlying business code.
What I mean becomes apparent if you watch the ComboBox control that accepts some vague "object" as it's item.
Then you go off and may display some DisplayMember and a ValueMember and so on.
If I want to retrieve that value later I need to typecast my object back to what it was. Like with strings getting the value takes
```
string value = (string)combobox1.SelectedItem;
```
Since there are generics in the Framework for quite some time now, I still wonder why in the Hell not one control from the standard toolbox is generic.
I also find myself using the .Tag property on ListViewItems all the time to keep the displayed domain object. But everytime I need to access that object I then need another typecast.
Why cant I just create a ComboBox or ListView with items of type ListViewItem
Am I missing something here or is this just another example of not perfectly well thought through controls? | 2008/12/01 | [
"https://Stackoverflow.com/questions/331357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21699/"
] | While the criticism of "didn't use generics" can't be fairly applied to controls developed before their existence... one must wonder about WPF controls (new in .NET 3.0, after generics in .NET 2.0).
I checked out the [AddChild](http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.addchild.aspx) method in [ComboBox](http://msdn.microsoft.com/en-us/library/system.windows.controls.combobox_members.aspx). It takes an object parameter (ugh).
This control is intended to be used primarily via XAML. Was this done this way because there is no way to specify a type parameter in XAML? (aside, is there no way to specify a type parameter in XAML?)
Sorry to have no definitive "Why" answer, just sharing the common misery of needing to cast when working with the UI. |
28,050,402 | I'm investigating Web Api in ASP.NET vNext using the daily builds. In a web api 2x project, I use HttpParameterBinding and ParameterBindingAttribute in some situations (see <http://bit.ly/1sxAxdk>); however, I can't seem to find either in vNext. Do/will these classes exist? If not, what are my alternatives?
Edit (1-22-15):
I want to be able to serialize a complex JS object to a JSON string, put the JSON string in a hidden form field (say name="data"), submit the form, and then bind my parameter to that JSON object on the server. This will never be done by a human, but rather by a machine. I also want this very same mechanism to work if the JSON is sent directly in the request body instead of form data. I also need this to work for several different types of objects.
I've been able to accomplish this scenario in Web Api 2.2 in a few different ways, including a custom ModelBinder; however, I remember reading an MSFT blog post that suggested to use a ModelBinder for query string binding, formatters for request body, and HttpParameterBinding for more general scenarios. Is it okay to read the request body in a ModelBinder ASP.NET 5, or is there a better mechanism for that? If so, then case closed and I will port my ModelBinder with a few minor changes.
I'm not sure that IInputFormatter will work for me in this case either. | 2015/01/20 | [
"https://Stackoverflow.com/questions/28050402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821924/"
] | Giving constant `id` to the elements which are created using loops is bad idea. In snippet below I have generated unique `id`'s for the elements `autocomplete` and `autocomplete2`(i have renamed `autocomplete2` to `auto2complete`). For initializing each autocomplete element, arrays are used.
Now for looping using ColdFusion variable in JavaScript, set `totalLoops` like:
```
<cfoutput>
<script>
var totalLoops = #add#;
/*rest of the code*/
</script>
</cfoutput>
```
Note that you cannot use jQuery id selector`#` in `<script>` if your script is nested inside `<cfoutput>`.
```js
var totalLoops=5;
for (i = 0; i < totalLoops; i++) {
var myHtml = '<div class="clearfix">'
+ ' <label for="street_' + i + '">Mailing Address 1 ' + i + ':</label>'
+ ' <input type="text" id="autocomplete'+i+'" name="street_'+i+'" onFocus="geolocate()" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="m2street_'+i+'">Mailing Address 2 '+i+':</label>'
+ ' <input type="text" name="m2street_'+i+'" id="route'+i+'" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="city_'+i+'">City: '+i+':</label>'
+ ' <input type="text" name="city_'+i+'" id="locality'+i+'" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="state_'+i+'">State: '+i+':</label>'
+ ' <input type="text" name="state_'+i+'" id="administrative_area_level_1'+i+'" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="postal_'+i+'">Zip Code: '+i+':</label>'
+ ' <input type="text" name="postal_'+i+'" id="postal_code'+i+'" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <input type="checkbox" name="billingtoo_'+i+'" id="chbSame" onclick="FillBilling_'+i+'(this.form)">'
+ '<em>Check this box if Physical Address and Mailing Address are the same.</em>'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="pstreet_' + i + '">Physical Address 1 ' + i + ':</label>'
+ ' <input type="text" id="auto2complete'+i+'" name="pstreet_'+i+'" onFocus="geolocate2()" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="p2street_'+i+'">Physical Address 2 '+i+':</label>'
+ ' <input type="text" name="p2street_'+i+'" id="route2'+i+'" value="">'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="pcity_'+i+'">City: '+i+':</label>'
+ ' <input type="text" name="pcity_'+i+'" id="locality2'+i+'" value="">'
+ '<div class="clearfix">'
+ ' <label for="pstate_'+i+'">State: '+i+':</label>'
+ ' <input type="text" name="pstate_'+i+'" id="administrative_area_level_12'+i+'" value="">'
+ '</div>'
+ '</div>'
+ '<div class="clearfix">'
+ ' <label for="ppostal_'+i+'">Zip Code: '+i+':</label>'
+ ' <input type="text" name="ppostal_'+i+'" id="postal_code2'+i+'" value="">'
+ '</div>'
+ '<br />';
$('body').append(myHtml);
}
var placeSearch;
var autocomplete = new Array();
var auto2complete = new Array();
var componentForm = new Array();
var componentForm2 = new Array();
for (i = 0; i < totalLoops; i++) {
componentForm[i] = {
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
postal_code: 'short_name'
};
componentForm2[i] = {
route2: 'long_name',
locality2: 'long_name',
administrative_area_level_12: 'short_name',
postal_code2: 'short_name'
};
}
function initialize() {
// Create the autocomplete object, restricting the search
// to geographical location types.
for (i = 0; i < totalLoops; i++) {
(function(i){
autocomplete[i] = new google.maps.places.Autocomplete(
/** @type {HTMLInputElement} */
(document.getElementById('autocomplete'+i)), {
types: ['geocode']
});
auto2complete[i] = new google.maps.places.Autocomplete(
/** @type {HTMLInputElement} */
(document.getElementById('auto2complete'+i)), {
types: ['geocode']
});
// When the user selects an address from the dropdown,
// populate the address fields in the form.
google.maps.event.addListener(autocomplete[i], 'place_changed', function() {
fillInAddress(i);
});
google.maps.event.addListener(auto2complete[i], 'place_changed', function() {
fillInAddress2(i);
});
}(i));
}
}
// [START region_fillform]
function fillInAddress(idx) {
// Get the place details from the autocomplete object.
var place = autocomplete[idx].getPlace();
for (var component in componentForm[idx]) {
document.getElementById(component+idx).value = '';
document.getElementById(component+idx).disabled = false;
}
// Get each component of the address from the place details
// and fill the corresponding field on the form.
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm[idx][addressType]) {
var val = place.address_components[i][componentForm[idx][addressType]];
document.getElementById(addressType+idx).value = val;
}
}
//var keys=[];for (var key in place.address_components[0]) keys.push(key);
//alert(keys):
document.getElementById('autocomplete'+idx).value =
place.address_components[0]['long_name'] + ' ' +
place.address_components[1]['long_name'];
/*document.getElementById('route').value = (document.getElementById('chbSame').checked ? document.getElementById('autocomplete').value : '');*/
document.getElementById('route'+idx).value = '';
}
function fillInAddress2(idx) {
// Get the place details from the autocomplete object.
var place = auto2complete[idx].getPlace();
for (var component in componentForm2[idx]) {
document.getElementById(component+idx).value = '';
document.getElementById(component+idx).disabled = false;
}
// Get each component of the address from the place details
// and fill the corresponding field on the form.
for (var i = 0; i < place.address_components.length; i++) {
var addressType = place.address_components[i].types[0];
if (componentForm2[idx][addressType+'2']) {
var val = place.address_components[i][componentForm2[idx][addressType + '2']];
document.getElementById(addressType + '2'+idx).value = val;
}
}
document.getElementById('auto2complete'+idx).value =
place.address_components[0]['long_name'] + ' ' +
place.address_components[1]['long_name'];
/*document.getElementById('route2').value = (document.getElementById('chbSame').checked ? document.getElementById('autocomplete2').value : '');*/
document.getElementById('route2'+idx).value = '';
}
// [END region_fillform]
// [START region_geolocation]
// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = new google.maps.LatLng(
position.coords.latitude, position.coords.longitude);
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
});
}
}
function geolocate2() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = new google.maps.LatLng(
position.coords.latitude, position.coords.longitude);
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete2.setBounds(circle.getBounds());
});
}
}
// [END region_geolocation]
initialize();
document.querySelector('#chbSame').addEventListener('change', checkedAddr);
function checkedAddr() {
if (document.getElementById('chbSame').checked) {
document.getElementById('route2').value = document.getElementById('route').value;
document.getElementById('locality2').value = document.getElementById('locality').value;
document.getElementById('administrative_area_level_12').value = document.getElementById('administrative_area_level_1').value;
document.getElementById('postal_code2').value = document.getElementById('postal_code').value;
document.getElementById('auto2complete').value = document.getElementById('autocomplete').value;
} else {
}
}
```
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>
```
Edit: Snippet Updated so that city, state, postal code are auto-filled. |
47,627,356 | I have a piece of code which uses JDBC "Statement" to perform CRUD operations. Now, I need to replace all the Statement with "PreparedStatement" but I am confused about how to return/use it like below code. Please help.
**MyDao.java**
```
public class MyDao extends BaseDao{
public MyDao() {
super();
}
public void search(){
ResultSet rs = null;
try {
statement.executeQuery("SELECT * FROM testTable");
rs = statement.getResultSet();
reset();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
```
**BaseDao**
```
public class BaseDao {
Connection connection=null;
Statement statement = null;
public BaseDao() {
try {
Class.forName("org.postgresql.Driver");
connection = (Connection) DriverManager.getConnection("url","user","password");
statement = connection.createStatement();
}
catch (Exception e){
e.printStackTrace();
}
}
public void reset(){
try{
statement.close();
connection.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
``` | 2017/12/04 | [
"https://Stackoverflow.com/questions/47627356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4427776/"
] | As stated, you can't. You would have to supply the SQL to be prepared. But the whole design is incorrect. You should not carry around Connections and Statements as instance members of a class. Connections can be closed by the database server any time, especially long-lived ones, at which point you need a new one anyway. Don't give it the chance. You should obtain both as required, and use a connection pool to amortise the costs. |
52,699,156 | I am trying for setting the initial weights or parameters for a machine learning (Classification) algorithm in Spark 2.x. Unfortunately, except for MultiLayerPerceptron algorithm, no other algorithm is providing a way to set the initial weights/parameter values.
I am trying to solve Incremental learning using spark. Here, I need to load old model re-train the old model with new data in the system. How can I do this?
How can I do this for other algorithms like:
* Decision Trees
* Random Forest
* SVM
* Logistic Regression
I need to experiment multiple algorithms and then need to choose the best performing one. | 2018/10/08 | [
"https://Stackoverflow.com/questions/52699156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2771169/"
] | Since its static function, you can call it without creating a new instance.
```
test('navigation options', () => {
const naviProp = { navigation: { navigate: () => {} } };
const navigationOptions = HomeScreen.navigationOptions(naviProp);
expect(navigationOptions).toMatchSnapshot();
});
``` |
43,067,231 | Upon transaction from fragment A to B, I'd like some specific view of fragment B to move from point X to point Y. That should be possible to achieve using content transition: [Frament.setEnterTransition(Object transition)](https://developer.android.com/reference/android/support/v4/app/Fragment.html#setEnterTransition(java.lang.Object)). I don't understand what should I pass to `setEnterTransition(Object transition)` in order to tell the specific view of B to animate in a specific way.
A lot can be found on the web but it mostly refers to shared element transition, I can't find any help with content transition. | 2017/03/28 | [
"https://Stackoverflow.com/questions/43067231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/957375/"
] | Assuming you have this as your fragment's layout:
```
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/white"
android:layout_height="match_parent">
<View
android:id="@+id/shared_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical|right"
android:background="#812432"/>
<View
android:id="@+id/non_shared_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="80dp"
android:layout_gravity="center_vertical|right"
android:background="#fff53f"/>
</FrameLayout>
```
And you perform this from your first fragment, that initiates opening of second fragment:
```
Slide slide = new Slide(Gravity.LEFT);
TransitionSet set = new TransitionSet();
set.addTransition(slide);
set.addTarget(R.id.shared_view);
Fragment secondFragment = new SecondFragment();
secondFragment.setEnterTransition(set);
getActivity().getSupportFragmentManager().beginTransaction()
.add(R.id.contentPanel, secondFragment)
.addToBackStack(null)
.commit();
```
You'll see, that `shared_view` will slide from left to it's initial position, while `non_shared_view` will stay in it's place.
[![enter image description here](https://i.stack.imgur.com/gKp3X.gif)](https://i.stack.imgur.com/gKp3X.gif)
[Source code](http://rgho.st/6tVBWbs87). |
66,661,667 | I'm using Airflow install via Docker image in AWS instance, and I have created a docker image of my project and pushed it to the GitLab container registry.
Now I want to pull this image in airflow to run daily, I know when we pull our own private image we have to authenticate **So How I can login using airflow dag, file, or any method to resolve this problem**.
My code
```
stripetos3_scheduler = DockerOperator(
task_id='stripe-to-s3',
image='registry.gitlab.com/mobinalhassan/stripetos3dags:latest',
auto_remove=True,
force_pull=True,
dag=dag
)
``` | 2021/03/16 | [
"https://Stackoverflow.com/questions/66661667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9025820/"
] | You can use `withCount` as demonstrated in the documentation here: <https://laravel.com/docs/8.x/eloquent-relationships#counting-related-models>. You can then use `orderBy` to sort them the way you want. |
61,129,669 | I'm working on a website that has a login page...
Here's the problem: the browser never offers the usual "Save this password? Yes / Never / Not Now" prompt that it does for other sites.
I tried wrapping the `<div>` in `<form>` tags with `"autocomplete='on'"` but that made no difference.
Is it possible to get the browser to offer to store the password without a major rework of my login flow? | 2020/04/09 | [
"https://Stackoverflow.com/questions/61129669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13273239/"
] | Hi there Aaryan Khadka!
I'm pretty sure this is a browser configuration setting only. I am not aware of any way to control this programmatically.
For example, on Firefox it's under settings / logins and passwords
- ask to save logins and passwords for websites
On Chrome it's under settings / passwords
- offer to save passwords
- auto sign-in |