INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
sql query select date equal rows from datetime
I need to select the row when date equal particular date, where as the TIMESTAMP column contain datetime.
This works fine,
select USERNAME from ACCESSACTIVITY where UPPER(LOCATION)=UPPER('remote-PC')and TIMESTAMP = STR_TO_DATE('28-05-2016 01:00:00','%d-%m-%Y %H:%i:%s')
where as when I avoid time, it doesn't work.
select USERNAME from ACCESSACTIVITY where UPPER(LOCATION)=UPPER('remote-PC')and TIMESTAMP = STR_TO_DATE('28-05-2016 ','%d-%m-%Y')
|
You don't need the wildcards. Try this:
select USERNAME from ACCESSACTIVITY where UPPER(LOCATION)=UPPER('remote-PC')and DATE(TIMESTAMP) = STR_TO_DATE('28-05-2016 ','%d-%m-%Y')
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mysql, sql"
}
|
What DBMS is used by ArcGIS Online?
I work in an Oracle shop. My I.T. department uses ArcGIS Online to host data for use in data collection activities.
The data goes through a yearly cycle:
1. Export from our Oracle enterprise geodatabase
2. Import to ArcGIS Online
3. Edit on tablets or phones via the Collector app during the course of the year
4. Export to a file geodatabase
5. Process the data
6. Import back into the Oracle enterprise geodatabase
I'm involved in steps 1, 5, and 6. But, it has occurred to me that I have no idea what goes on in step 2. Out of curiosity, what is the underlying DBMS of ArcGIS Online?
|
The short answer is this, ArcGIS online is a "blackBox". Esri won't release the exact details to the public. I understand the desire to know but some companies prefer to keep info like this away from the public domain.
|
stackexchange-gis
|
{
"answer_score": 4,
"question_score": 1,
"tags": "enterprise geodatabase, arcgis online, database"
}
|
Using a function as an argument of another function and execute it in each loop
I have several functions in R that get me vectors with different random results, let's call these functions r1, r2, r3 and r4.
Now I want to write another function named 'simulation' that simulates one of these functions above and evaluates different values like the expected value etc. Furthermore, I want only one function that can simulate either r1, r2, r3 or r4, which is possible, because they all put out the same type of vector.
I have tried it by the following way:
simulation <- function(f, n) {
result <- 0
for (i in 1:n) {
result <- result + f[1]
}
result
}
Then I execute it like this: simulation(r1(), 500)
This works fine, but the problem is that the function r1() just runs once, but as I want to simulate it n times, I want it to run each time I go through the for-loop.
Is there any way I can do this?
Thanks in advance!
|
You can pass the function itself instead of its return value :
simulation(r1, 500)
But then you have to modify the code :
result <- result + f()[1]
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "r, function, arguments"
}
|
document library with document set views (how to change)
I have a document library which has document sets. Is it possible to have the view (columns) that is displayed when you first navigate to the document library different than the view/columns that are displayed once you click on a particular document set?
My document set contains a content type (with columns) and these columns really don't have values when viewing the document library from the top. The columns are visible however they do not contain values because the document set itself doesn't have values for those fields.
|
OOTB the views are the same when displaying the list of document sets and displaying one document set with all the files in it. But you can set different views:
1. Create a new view to use when displaying the files in the document set
2. Go to the list settings and allow management of content types in Advanced Settings
3. Select the Document Set contenttype
4. In the next screen select Document Set settings
5. Select your newly created view at the Welcome Page View section
6. Press Ok
Now the default All Documents view will be shown when displaying all the document sets and the newly created view will be displayed when viewing one document set with the files within.
|
stackexchange-sharepoint
|
{
"answer_score": 8,
"question_score": 5,
"tags": "document set, document library"
}
|
Haar Cascades don't work well in Dark Lighting
When I dimmed the lights, I noticed that the face Haar cascade was having difficulty finding my face. (It was not even that dark!)
When the lights are dimmed, how can I track as if the lights were on?
|
Assuming lighting conditions are still good enough to distinguish face details, you can try to **increase brightness** to overcome darkness or **equalize histogram** to increase contrast.
In general, any recognition algorithms relies on some image features. If the image is too dark or too bright, it's harder for algorithm to find relevant features. Thus, recognition algorithms are **trained** on images with **normal lighting conditions**. You can also train algorithm (such as cascade classifier) on, say, dark images, but most probably this will hit recognition performance a lot. Thus, better way is to normalize dark images before fitting them to the algorithm.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, python, opencv"
}
|
Is there any python package that could configure IP address of network interface?
I am writing a server application which allow remote client to show/add/change/delete IP addresses of network interfaces of the machine where the host is running.
The OS is Linux(CentOS 5.2), so I could do that by simply parse and edit configure file. But is there any package that could simplify the job?
And if there is none such package, if I open source my implementation, will that help other people?
|
It looks like the open source project confparse should be able to easily do what you're looking for. In fact, one of their examples is parsing and modifying `/etc/sysconfig/network-scripts/ifcfg-eth0` with ease.
If you find this isn't what you need, I say that any efforts towards open sourcing software will inevitably help other people at some point, given that it is actually useful. ;)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "python, linux"
}
|
How to escape everything in a block in HTML
I seem to recall that there is an HTML tag that escapes absolutely everything inside it except the matching closing tag. Kind of like `<plaintext>` but not fundamentally broken.
|
<xmp> is the tag you are looking for:
<xmp>some stuff <tags></tags> too</xmp>
But, since it's depricated, the best you can get is <pre>.
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 10,
"tags": "html, escaping"
}
|
How do I check spelling of a user input?
I'm creating a website where the user types whatever he hears in an audio file. On submit, I want to compare his input to the actual paragraph and then display the misspelled words. How can I do that?
|
// answerParagraph is the true answer (string)
// inputParagraph is the input from the user (string)
let mistakes = 0;
let mistakedWords = [];
for(let i = 0; i < answerParagraph.length; i++){
if(answerParagraph[i] != inputParagraph[i]){
mistakes++
mistakedWords.push(answerParagraph[i])
}
}
alert("You have " + mistakes + " typos!")
I think this should work. :)
Edit: Well if you want to check every word one by one instead of the whole paragraph then the code is:
// answerParagraph is the true answer (string)
// inputParagraph is the input from the user (string)
let mistakes = 0;
let answerWords = answerParagraph.split(" ")
let inputWords = inputParagraph.split(" ")
for(let i = 0; i < answerWords.length; i++){
if(answerWords[i] != inputWords[i]){
mistakes++
}
}
alert("You have mistakes in " + mistakes + " words!")
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "javascript"
}
|
Low-latency peer to peer udp tunneling library?
I am interested in developing a peer-to-peer network that uses UDP tunneling to get around NAT for low-latency communication for something similar to a multiplayer game. There will be central server available for authentication and identifying external IP addresses. Is there an open source library out there with a LGPL or BSD (etc) license? I'd like to avoid reinventing the wheel if possible.
|
The following open source libraries are all variants or direct implementations of ICE for P2P NAT traversals scenarios for UDP.
PJNATH
libnice
libjingle
I've been using pjnath and find it to be quite good, robust, and has the widest platform support.
See my classic answer here on the basics of UDP NAT tranersal and P2P.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "networking, udp, p2p"
}
|
Control plane terminology - Cisco Nexus
Is it true to speak about layer 2 control plane (LACP, STP, etc), and layer 3 control plane (OSPF, EIGRP, etc) ? or do we have only a general control plane ?
We know Cisco Nexus vPC cluster has a separated control plane, and same data plane. For Nexus vPC, is it true to tell it has a same layer 2 control plane and a separated layer 3 control plane ?
|
While most devices probably have a single _physical_ control plane, others may have two or both layers may be differentiated in software with two _logical_ control planes. I guess there's no single answer...
The Nexus 7000 series has a physically distributed control plane assembled into one logical unit, see <
|
stackexchange-networkengineering
|
{
"answer_score": 5,
"question_score": 3,
"tags": "cisco, routing, switching, cisco nexus"
}
|
Functions between Sets of different Cardinality
Let $\alpha : A \to B$ be a function between finite sets. Show that if $|A| > |B|$, then $α$ cannot be injective, and if $|A| < |B|$, then $α$ cannot be surjective .
|
Suppose we have $\alpha$ injective with $|A|>|B|$. Then, $\forall b \in B$, $\alpha^{-1}(b)$ must have $0$ or $1$ element. Then, $|A|=|\alpha^{-1}(B)|\leq|B|$, what is a contradiction.
Suppose we have $\alpha$ surjective with $|A|<|B|$. Then $\forall b \in B$, $\alpha^{-1}(b)$ must have at least $1$ element. Then, $|A|=|\alpha^{-1}(B)|\geq|B|$, what is a contradiction.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "elementary set theory"
}
|
True Or False with a proof
?
How to change the name of the page with jquery and ajax?
I would like to use php script and call the load function. The function returns the title to me. How do I set the page title?
|
JQuery is probably overkill for setting a title when you can just do
`document.title = 'foo';`
but if you really want to use JQuery you can do
`$("title").text("foo");`
It's probably a lot slower though, although if you're only doing it once I wouldn't worry about that.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "jquery, ajax, title"
}
|
Passing a value into a python variable via Splinter
I'm looking at a web page and making a yes/no decision. I'm trying to create a prompt that will allow me to pass the "yes" / "no" to a python variable via Splinter.
1.) Page loads
2.) Execute something like `browser.execute_script("window.prompt()")` with a yes/ no to a variable
3.) Some business logic is done based on that variable
ie -
data = browser.execute_script("window.prompt()")
if data == 'yes':
print('the value is good')
else:
print('the value is bad')
Is there a good way to go about doing this?
|
> Is there a good way to go about doing this?
No. Use Python's `input` (or `raw_input` if using Python 2), or get that value as a command line argument.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python"
}
|
how to add &tmpl=component parameter in menu url in Joomla 3 when seo friendy url is set to ON
I want to display the article content without template (header, footer, sidebars etc). I just want to display content. I fetching the content using ajax so dont want to display in template.
|
Passing tmpl=component in url renders page without template (header, footer etc) but it still renders
I created custom component_ajax.php compoment file in root of template and passed tmpl=component_ajax in ajax request. In component_ajax.php removed all parts which are not needed and kept only . Removed all other html tags. So what i get in ajax response is the content only.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, joomla, joomla template"
}
|
Uncaught TypeError: Object [object global] has no method 'call' [Решено]
Консоль в гуглХроме ругается на след код:
function isBd(user) {
$.get('/index/8-0-' + user, function (data) {
var bDate = new Date(Number($("#ubd", data).text()) * 1000);
var date = new Date();
if ((bDate.getMonth() == date.getMonth()) && (bDate.getDate() == date.getDate())) {
$('.bd' + user).html('<img src="h/sml/okore.gif" style="margin: 75px 80px 0px 100px; position: absolute;" alt="" width="64pxpxpx" height="64pxpxpx">');
}
})
}
В чем проблема?
|
jQuery 1.3 выпустили в начале 2009 г., а сейчас уже 2013. Советую использовать последнюю стабильную версию библиотеки.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
}
|
How do I convert an array of numbers from an old range to a new range, where the highest valued number is 100 and the lowest valued number is a 0?
I am trying to develop weights for a mapping application of mine. I know it's a bit of a weird question, but say we have an array of some values like [1, 5, 7, 9, 3] I want the converted array to have the 9 be replaced with a 0 and the 1 replaced with a 100 as it's the lowest value. What would be the best way to approach this?
|
I think what you're looking for is a min-max normalization. You want to normalize the array but instead of the usual range of 0-1 you want it to be from 0-100, but also reversed I suppose because you want 9 to be 0 and 1 to be 100.
For a value v in the array you have, it can be normalized on this new range via: $v’ = (v-min)/(max-min) * (newmax-newmin) + newmin$
$v$ is the old value and $v'$ is the new value.
Heres a Python function that would do what I believe you're looking for ; // Olá Mc'Neil | Olá Mc'Neil
Em outras linguagens como o PHP é diferente.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "javascript"
}
|
How to extract a node in a Postgres record datatype
I am using Postgres 9.1 and I have a function that returns a `record` datatype using the `row()` function.
For a simple example, try:
select row(1,2,3);
It will return a single-cell row with "(1,2,3)" in it.
In my more complex function, it returns a geocode and other data as in:
`(90,"Sydney, Australia",0.431951065304161,151.208784,-33.873982)`
So what I am trying to do is figure out how to exact each of these node values in this "row" or "array" (whatever is technically correct).
Anybody that can help, this would be appreciated.
|
Example function:
create or replace function a_function()
returns record language sql as $$
select 90, 'Sydney, Australia'::text, 0.431951065304161, 151.208784, -33.873982;
$$;
select a_function();
a_function
------------------------------------------------------------------
(90,"Sydney, Australia",0.431951065304161,151.208784,-33.873982)
(1 row)
You should call the function in from clause with a column definition list:
select *
from a_function() as (id int, city text, num1 numeric, num2 numeric, num3 numeric);
id | city | num1 | num2 | num3
----+-------------------+-------------------+------------+------------
90 | Sydney, Australia | 0.431951065304161 | 151.208784 | -33.873982
(1 row)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, postgresql, types"
}
|
Android ORMLite add annotations to library model
I am using ORMLite in android. I have a library which provides me with a POJO which has certain fields (name, id, description) but it is not annotated with the ORMLite annotations.
Is there a way to use ORMLite to store this model in my db without actually modifying the library model directly. Can i use a wrapper object somehow as an adapter?
public class Asset {
private String id;
private String name;
private String description;
}
|
I have found the solution. I can specify a config file which will describe each field and use that in the Database Helper.
Here is the reference link. Works perfectly!
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, android, annotations, ormlite"
}
|
Retrieving Values in a Dictionary in C#
So I have a code that has a Dictionary that looks like the following
Dictionary<int, List<object>> records = new Dictionary<int, List<object>>();
Now the dictionary is populated bot the list of objects and int.
My question is the list of Objects.
I need to retrieve those values how do I do it?
Please note that everything is populated I just need to retrieve the values from the list of objects and convert it to an array.
|
You can do like this
foreach (var item in records)
{
// records will have key & value
var arr = item.Value.ToArray();
}
foreach (var item in records)
{
// records will have key & value
var key = item.key;
var arr = item[key].ToArray();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, datagridview"
}
|
group by is messing up my counts mysql
I have a basic table:
id client trans_date returned
1 bob 20180301 0
2 frank 20180301 0
3 bob 20180401 1
id like to get a result that groups by the client and counts how many items bought and how many returned. Like this
name bought returned
bob 1 1
frank 1 0
i tried this but it didnt work
SELECT
soldto AS name,
IF(return=0,count(id),'0') AS bought,
IF(return=1,count(id),'0') AS returned
FROM sales
WHERE sdate BETWEEN '20180201000000' AND '20180501000000'
group by soldto;
|
Use conditional aggregation
SELECT
soldto AS name,
COUNT(*) AS bought,
-- or maybe COUNT( CASE WHEN return = 0 THEN 1 END) AS bought,
COUNT( CASE WHEN return = 1 THEN 1 END) AS returned
FROM sales
WHERE sdate BETWEEN '20180201000000' AND '20180501000000'
GROUP BY soldto;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql, if statement, group by"
}
|
Searching multiple tables with MySQL
I am writing a PHP/MySQL program and I would like to know how to search across multiple tables using MySQL.
Basically, I have a search box as in the top right of most sites, and when user's search something in that box, it needs to search in users.username, users.profile_text, uploads.title, uploads.description, sets.description and comments.text. I need to get the ID (stored in a id field in each table) and if possible, a google like excerpt.
|
You can either write your procedure to query each of these tables individually, or you could create a relatively simple view that conglomerates all of the searchable columns of the important tables along with an indicator showing which table they're from. There's not really a magic way to search multiple tables other than writing the statements normally.
The second approach would look something like this:
(SELECT 'Table 1' AS TableName, id as Id, text as Searchable
FROM table1)
UNION
(SELECT 'Table 2' AS TableName, table2_id as Id, name as Searchable
FROM table2)
UNION
...
Then search on the resulting view. It's important to note that this method won't be fast.
A similar, and faster, alternative would be to dedicate a table to this task instead of a view, and populate it on insert/update/delete of the real tables instead of recomputing it on access.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "sql, mysql, search"
}
|
how to reload ng-view with new data?
I have a situation to refresh the page as per the user search results. I have a fixed navbar with search bar. and also i am changing the view using `ng-view`. when my url is '`localhost/index`' and when i search for any location means my url will change to 'localhost/searchresults' using the `"$location.url()"` and i will get what i want. The problem is, when i am in the same url `"localhost/searchresults"` and search for any location means its not working. How to do that????
Edit: Actually both are at different controller. search bar is at one controller and search results is on another controller. that's why i am using `$location.url()` to change my ng-view and controller.
Updated: This is the answer. "$route.reload()".
|
To force angular to re-render the current page, you can use:
$route.reload();
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "angularjs, node.js"
}
|
Symfony plugin: call to undefined function 'enablePlugins'
I'm trying to install sfMediaBrowserPlugin ( < ).
When running 'symfony plugin:publish-assets', it says that the ProjectConfiguration::enablePlugins() method is undefined.
How could I solve this? Thanks!..
By the way: I have a symfony 1.1.6 project with Propel.
|
As listed on the plugin page, you need at least symfony 1.2.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "plugins, symfony1, undefined"
}
|
Saving Files in to the memory/virtual file C#
Is there any possibilities to save a file to a virtual folder or something. I use a method, which needs a string(path,where to save the file) as parameter to save the content. But i just want to save the file into the memory.Can I programmatically create a virtual folder/path?
|
If your component want to recevice a file, you need a file on your HDD/SSD. In those cases, i prefer to use the APP-Data folder and create a sub directory in it. It is accessable over: `Environment.SpecialFolder.LocalApplicationData`.
To come back to your question, it is not possible. Because the method you want to use, will take the os file system.
The only in memory solution would be, if there is an overload which accept a `MemoryStream` or just a `Stream`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c#, memory, save, virtual"
}
|
How do I create performance counter instance names for two different iis applications
I have several iis servers setup visibly identically in different environments (Dev/Test/Staging/etc). Within iis, I have an app pool "MyApplicationAppPool" and three web applications running within that app pool: MyApplication1, MyApplication2, MyApplication3.
When I open up perfmon and try to monitor the performance counter instance associated with an application, I can't seem to find all of them. For instance, I can find
\SERVERNAME\ASP.NET Apps v2.0.50727\\_LM_W3SVC_1_Root_MyApplication **1** \SERVERNAME\ASP.NET Apps v2.0.50727\\_LM_W3SVC_1_Root_MyApplication **3**
But I can't find
\SERVERNAME\ASP.NET Apps v2.0.50727\\_LM_W3SVC_1_Root_MyApplication **2**
My Question: What makes these "instance names" show up in perfmon? Why do some applications seem to create an instance name but others don't?
I'm running on IIS6 on Windows Server 2003
|
There seems to be a simple answer to this question. The Instance Name does in fact represent a web "application" and each application can be tracked in perfmon separately. If the web application does not have a place in memory at a particular point in time, the instance name will not appear in perfmon. To have it appear, you simply have to make a call to one of the asp.net web pages or services in that application. Subsequently, load the perfmon add counter window and the new instance name will be available
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 2,
"tags": "asp.net, performance counters"
}
|
What does $/ mean in Ruby?
I was reading about Ruby serialization (< and came across the following code. What does $/ mean? I assume $ refers to an object?
array = []
$/="\n\n"
File.open("/home/alan/tmp/blah.yaml", "r").each do |object|
array << YAML::load(object)
end
|
`$/` is a pre-defined variable. It's used as the input record separator, and has a default value of `"\n"`.
Functions like `gets` uses `$/` to determine how to separate the input. For example:
$/="\n\n"
str = gets
puts str
So you have to enter `ENTER` twice to end the input for `str`.
Reference: Pre-defined variables
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 6,
"tags": "ruby, syntax, operator keyword"
}
|
Differing factors for $f(x) = x^4+x^2+1$
$$f(x)=x^4+x^2+1$$
$\implies f(x)= (x^2)^2+x^2+1=(x^2+\frac{1}{2})^2-\frac{1}{4}+1 =(x^2+\frac{1}{2})^2+\frac{3}{4}$
$\implies f(x) = (x^2+\frac{1}{2}+\frac{\sqrt{3}i}{2})(x^2+\frac{1}{2}-\frac{\sqrt{3}i}{2})$
But we also have:
$f(x) = (x^2+x+1)(x^2-x+1)$
Both of these factorisations satisfy $f(x)=f(-x)$, and expanding them again yields the original expression. So I was computing this to determine if $x^4+x^2+1$ is reducible in $\mathbb{Q}[x]$. Why are there two different factorisations?
|
These aren't actually different factorizations. Notice that when we can factor the product $$(x^2+x+1)(x^2-x+1)$$ further to get $$(x+\frac{1}{2}-\frac{\sqrt 3}{2}i)(x+\frac{1}{2}+\frac{\sqrt 3}{2}i)(x-\frac{1}{2}-\frac{\sqrt 3}{2}i)(x-\frac{1}{2}+\frac{\sqrt 3}{2}i)$$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "polynomials"
}
|
How to setup a rails app within same domain as another php application?
I have webserver using default virtualhost apache
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
My PHP apps runs fine in subfolders and I can access like below
domain.com/phpapp1
domain.com/phpapp2
domain.com/phpapp3
But How can I run a rails app using passenger like it domain.com/railsapp1? I would like to use the same domain for all apps
|
I'm not sure if it is the best way but I got it working adding the following lines to configure redmine and a main app for example on the same domain
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
<Directory /var/www/redmine>
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /var/www/redmine
</Directory>
</VirtualHost>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "apache, passenger, virtualhost"
}
|
How can I retrieve data from a textbox in Visual Basic
I have created a simple username and password login form on visual basic. this works perfectly. but what I would like to know is there any way I could retrieve the usernames and passwords entered and save them as a string or anything similar?
|
I assume you have two different textboxes for the username and password so you would do:
Dim UserName as String
Dim Password as String
The textboxes each have a different name so you do:
UserName = NameOfYourTextbox1.text
Password = NameOfYourTextbox2.text
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "asp.net, vb.net, visual studio 2012"
}
|
How do I query between two time range using MySQL?
I need help with a query. I am taking input from a user where they enter a time range between 00:00 to 23.59. So it could be like 10:00 to 12:00 or 12:00 to 18:00. Then I need a query to pull data from a table that has a match_time stored in time format. Here we can assume that 10:00 being min and 12:00 being max range.
So if a user did 10:00 to 12:00 and the table had entries for 1:00, 2:30, 10:00, 11:30, 12:00, 15:00, 19:00 and 22:00 it would find 10:00, 11:30, 12:00. using MySQL
match_time BETWEEN (CAST('10:00:00' AS time)) AND (CAST('12:00' AS time))
But if they pass 18:00 to 3:00 that should output 1:00, 2:30, 19:00 and 22:00, not sure how to achieve this. Please help.
|
Datatype `TIME` does not include knowledge about date ranges (3:00 in your query represents next day's 3:00). You have to handle this yourself:
SELECT columns
FROM table
WHERE
(cast('18:00' as time) <= cast('3:00' as time) and match_time between '18:00' AND '3:00')
OR
(cast('18:00' as time) > cast('3:00' as time) and (match_time >= '18:00' or match_time<='3:00'));
See db-fiddle.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "mysql"
}
|
What crime is Shay D. Guy commiting?
Nobody trusted Guy. He always seemed to be up to something. Unfortunately, the police couldn't lock him up, simply because they had no evidence against him. Not even the circumstantial kind.
Guy worked at a factory, the kind that made construction products. It was a dirty, low paying job, but it was the only place in town that dare hire Guy. The factory was filled with security cameras, so they were confident that Guy could not get away with his devious schemes.
As expected, Guy shows some suspicious behavior. Every night at 9:28, just minutes before the factory closes, Guy leaves with a wheelbarrow filled with scrap parts. The security footage clearly shows that there is nothing of value inside. Despite this, the owner of the factory is still suspicious.
> What is Shay D. Guy up to?
|
Shay D. Guy is
> **Stealing wheelbarrows**!
The factory is one where they make
> wheelbarrows, and by filling it with scrap, Shay is misdirecting the attention of the security staff to its contents, not the wheelbarrow itself.
|
stackexchange-puzzling
|
{
"answer_score": 14,
"question_score": 5,
"tags": "story, situation"
}
|
Make event for a multiple buttons and know which button been clicked
I am writing an web app in asp.net, In the code behind I have this code:
foreach(UserDetails _UD in m_TeachersDetailsList)
{
Button button = new Button();// a Button control
button.Text = "click";
button.ID = "SelectedTeacher";
TableCell tableCell = new TableCell();// a Cell control
tableCell.Controls.Add(button);
TableRow tableRow = new TableRow();
tableRow.Cells.Add(tableCell); // a table row
TableSearchResult.Rows.Add(tableRow); // a table that had been created in the aspx
}
How can I make an event that when you click on the button you go to a function, and how can I know which button had been click and Brought me to my function. thanks.
|
You do this
int id = 0;
foreach(UserDetails _UD in m_TeachersDetailsList)
{
Button button = new Button();// a Button control
button.Text = "click";
button.ID = "selectedTeacher" + id++;
TableCell tableCell = new TableCell();// a Cell control
tableCell.Controls.Add(button);
TableRow tableRow = new TableRow();
tableRow.Cells.Add(tableCell); // a table row
TableSearchResult.Rows.Add(tableRow); // a table that had been created in the aspx
button.Click += new EventHandler(this.button_Click);
}
And common event handler
protected void button_Click(object sender, EventArgs e)
{
//This way you will get the button clicked
Button button = (Button)sender;
}
**Important**
You will need to add the controls in `OnInit`.
Hope this works for you.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "asp.net, button, event handling"
}
|
jQuery tablesorter parser for datetime in DD.MM.YYYY HH:MI in 24hour format
I found this thread: jQuery tablesorter parser for datetime in MM.DD.YYYY HH:MI AM format
but i want to sort date times like so: 22/01/2012 23:43
how can this parser which is in AM/PM format be modified to do that:
`ts.addParser({ id: "srsDate", is: function (s) { return /\d{1,2}\.\d{1,2}\.\d{1,4} \d{1,2}:\d{1,2}\s(am|pm)/.test(s); }, format: function (s) { return Date.parse(s); }, type: "numeric" });`
or can this be done directly from the tablesorter by setting the dateFormat to something like:
$("table").tablesorter({
theme : 'blue',
dateFormat : "ddmmyyyy HH:mm", // set the default date format
}
Thanks in advance!
|
Sort UK/European date format dd/mm/yyyy hh:mm(works both with and without hour) by defining dateformat:"uk" like so:
$("#tableName").tablesorter({dateFormat: "uk"});
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery, parsing, datetime, tablesorter"
}
|
Problems with DateTime, it appears with 00:00:00
I have my database which has a DateTime type for Birthdate value when I register the user.
When I receive my data back, to edit the register form, I have my Razor like this:
@Html.TextBoxFor(model => model.Birthdate)
The date shows like this: 28/05/1983 00:00:00
I want only the birthdate, obviously. In my Controller, I have this:
User userset = db.User.Find(id);
return View(userset);
Very simple... Could anyone help me to solve that?
|
You can do something like this using `Html.TextBox` instead of using `Html.TextBoxFor`.
@Html.TextBox("Birth date", String.Format("{0:dd/MM/yyyy}", Model.Birthdate))
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "asp.net mvc 3, datetime, c# 4.0, razor"
}
|
Orbeon is ignoring oxf.epilogue.theme?
I'm using Orbeon 4.4.0.201311042036 PE
I am trying to set a theme for the form builder by using these two properties in **properties-local.xml**
<property as="xs:anyURI" name="oxf.epilogue.theme" value="oxf:/config/theme-plain.xsl"/>
<property as="xs:boolean" name="oxf.epilogue.use-theme" value="true"/>
I have modified the **/config/theme-plain.xsl** to add a custom header to the page.
I have also tried creating a new file (for example: /confg/theme-custom.xsl) and pointing the property to that, but Orbeon is completly ignoring the property.
By using the url parameter: _?orbeon-theme=plain_ I am able to activate the modified _theme-plain.xsl_ , but _?orbeon-theme=custom_ does not activate the _theme-custom.xsl_. (also pressing any button, ie. "Home" removes the url parameter and the theme)
How do I configure Orbeon use a theme?
|
Alessandro has answered the question and I have verified that the solutions works great. Thanks.
See: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "orbeon"
}
|
Rails - Create or Update Record .... If statement vs find or create by
I have
@user = User.find(1)
@event = Event.find(1)
for interest in @event.interests
@user.choices.create(:interest => interest, :score => 1)
end
Working properly but it creates records every time. I would like to check to see if a record with the corresponding interest_id from the for loop exist and if it does I would like to update, else creating is fine.
I looked around and found the "find_or_create_by" method but its not really working for me. I had =>
@user.choices.find_or_create_by_interest(:interest => interest.id, :score => 1)
and get the error "undefined method `find_by_interest'".
Can you see what I'm doing wrong? Or is it better to stick with the an if/else statement?
I wasnt sure if the find_or_create_by method had the update attribute capability within it.
|
Once again, you should do `find_or_create_by_interest_id_and_score`
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "ruby on rails"
}
|
Python Wiki Style Doc Generator
Looking for something like PyDoc that can generate a set of Wiki style pages vs the current HTML ones that export out of PyDoc. I would like to be able to export these in Google Code's Wiki as an extension to the current docs up there now.
|
Take a look at pydoc.TextDoc. If this contains too little markup, you can inherit from it and make it generate markup according to your wiki's syntax.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "python, documentation, wiki, pydoc"
}
|
EU Data Retention Directive and the Draft Investigatory Powers Bill 2015
Was the EU Data Retention Directive ever transcribed into English law?
If so, the Draft Investigatory Powers Bill 2015 would appear to be somewhat moot?
|
The Data Retention Directive (DRD) was written in 2006, in 2009 the UK implemented the DRD as the Data Retention Regulations (DRR). However, in 2014 the European Court of Justice (ECJ) rules the DRD was non-compliant with the Charter of Fundamental Rights of the European Union (CFR). The DRD was annulled and so was all implementing legislation. As an aside, countries which were fined for NOT implementing the DRD were reimbursed.
For a report on the whole affair you might like to read this:
Cole, M., & Boehm, F. (2014). Data Retention after the Judgement of the Court of Justice of the European Union.
|
stackexchange-law
|
{
"answer_score": 2,
"question_score": 2,
"tags": "united kingdom, european union, england and wales"
}
|
Hide PHP errors in ExpressionEngine
I recently switched hosts with a new PHP version. I'm getting an error from a plugin (Calendar) that just won't go away. It's a non-static method error that is causing 0 issues and it can't be fixed without trying a different plugin. I'm at the point where I just need it gone so this ugly message isn't showing on every page and I'll debug it later. I have tried disabling errors, setting every debug setting I can find to 0, but this error message won't go away! It's showing to everyone. What setting am I missing???
I've set the index.php debug=0
I've set the config.php $config['debug'] = 0;
I've added in an extra ini_set for display_errors and error_reporting to 0
I've double checked that the settings in the config file editor and output and debugging pages are showing 0
Why aren't any of these settings working? I'm using EE 2.5.5
|
What you are looking for is error suppression, you can find more info on it here
Code example
class foo {
public function bar() {
echo 1;
}
}
foo::bar(); // Strict standards: Non-static method foo::bar() should not be called statically
@foo::bar(); // no warning
The @ symbol will suppress any error resulting in the fopen.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, expressionengine"
}
|
Stimulus check for resident alien on 2020 tax return
As a F1 student, I was nonresident alien from 2015-2019, then my status changed to resident alien at 2020. But, as you know, this status change happens at August 2020, I didn’t get the stimulus check, which is eligible to resident alien. What should I do to get stimulus check in this tax return?
|
You would file a 2020 tax return (on form 1040 since you were a resident alien), and you would claim the Recovery Rebate Credit on line 30. See the instructions for line 30 for the worksheet to calculate the credit that you should get. It should be $1,800 assuming your income is low and you are filing by yourself.
Note that in order to be eligible for this credit, you must have a Social Security Number that is "valid for employment" (i.e. your card does not say "Not Valid for Employment") issued before the due date of 2020 tax returns (April 15, 2021, or October 15, 2021 if you get an extension). You do not qualify for the stimulus money if you don't have a Social Security Number.
|
stackexchange-money
|
{
"answer_score": 1,
"question_score": 2,
"tags": "united states, income tax, f1 student visa, stimulus"
}
|
doubt with unequal induction
Show that for all n ≥ 2 it is verified:
$$\frac{1}{\sqrt{1}}+\frac{1}{\sqrt{2}}+\frac{1}{\sqrt{3}}+ ...+\frac{1}{\sqrt{n}} > \sqrt{n} $$
I have used the induction method to arrive at the following result:
$$\sqrt{k}+\frac{1}{\sqrt{k+1}}>\sqrt{k+1} $$
someone can help me, I think I have not solved it well
|
That ... is enough.
If you have proven that $\sqrt{k} + \frac {1}{\sqrt{k+1}} > \sqrt{k+1}$
Then you can state that for $\frac 1{\sqrt 1} + \frac 1{\sqrt 2} =\sqrt{1} + \frac {1}{\sqrt{2}} > \sqrt{2}$, so the base step of the induction is done.
You can state if you know $\frac{1}{\sqrt{1}} + .... + \frac{1}{\sqrt{j}} > \sqrt j$
Then $(\frac{1}{\sqrt{1}} + .... + \frac{1}{\sqrt{j}}) + \frac 1{\sqrt{j+1}} >$
$(\sqrt{j})+ \frac 1{\sqrt{j+1}}>$
$\sqrt {j+1}$.
So the induction step holds.
So it has been successfully proven by induction.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "inequality, induction"
}
|
Xcode 3.2.3 (SDK 4) cannot support device iPod touch (iOS 4.1) and iPad (iOS 3.2.2)
I cant do test apps on my devices. Following are screenshots.
iPod: 
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "android, ios, mobile, web, google analytics"
}
|
Printing the offsets of all struct members
My intention is to output a list with offsets of all struct members from a `typedef struct`.
In my case this struct is stored in an external EEPROM which can be accessed bytewise via an interface accessible via a serial connection.
To access the EEPROM contents, I need to know the offsets of the struct members.
How can I tell the compiler to perform the offsetof task on every struct member?
|
The C standard, and most C implementations, do not provide a way to automatically list the offsets of structure members or to iterate through structure members. You must either manually list the structure members or write your own software to parse the source code defining the structure (and to use the results of parsing to generate more code to display the offsets).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c, struct, offsetof"
}
|
keeping line height vertically centered in div without a fixed height
I am working on a responsive website using a standard grid system so my divs cannot have a fixed height. With that said, I have setup a fiddle file to _simulate_ my problem. I have a min-height of 50px for cosmetic reasons on a desktop and set line height also to 50. so the text is centered vertically in the div. If you make the window more narrow, the line will eventually break of course. Is there a way to maintain keeping the content vertically centered after it breaks so it does look so bad?
here is some of the code:
.box {
width: 100%;
min-height: 50px;
line-height: 50px;
font-size: 16px;
color: #fff;
background-color: #000;
text-align: center;
}
here is the fiddle file: <
|
You can't center verticaly in CSS BUT you has some workarounds for different situations. In your case I recommend use display: table; in a wrapper: <
<div class="verticalCentered">
<div class="box"> test content test content test content test content</div>
</div>
CSS:
.verticalCentered {
display: table;
height: 100px; /*variable*/
width: 100%;
}
.box {
display: table-cell; /**/
vertical-align: middle; /**/
line-height: 50px;
font-size: 16px;
color: #fff;
background-color: #000;
text-align: center;
}
But remember it has problems sometimes. It is useful only in certain situations. Other ways: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "percentage, css"
}
|
expected an indented block python error
I am new to Python so don't know much about it. But I know the basics of indentation and I cannot solve the error of **_expected an indented block_** in the following code.
meal =["egg","milk","spam","tomato"]
for item in meal:
if item =="spam":
nasty_food =item
break
if nasty_food:
print("there is nasty food")
|
Visually I don't see an indentation issue in the code you posted. Verify that you are not mixing up tabs and spaces as that can also lead to indentation issues.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, indentation, python 3.6"
}
|
How to read from file and supply it to variables
I am making a game engine. I need to load a text file into my program and then sort each line into a specific value. I need to extract each line into specific string so I can read it in the program later.
This is how the config file looks:
title=HelloWorld
developer=MightyOnes
config=classic
And the code would extract `title=` into a string that says `HelloWorld`. Same for the rest. Developer would be `MightyOnes`. I think you got it by now.
|
What you really need is a `Dictionary`. A dictionary can hold key-value pairs, which can later be retrieved by key name.
Dim KeyValues As Dictionary(Of String, String)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'' to fill the dictionary
KeyValues = New Dictionary(Of String, String)
Dim fileContents = IO.File.ReadAllLines("C:\Test\test.txt") '-- replace with your config file name
For Each line In fileContents
Dim kv = Split(line, "=", 2)
KeyValues.Add(kv(0), kv(1))
Next
'' to get a particular value from dictionary, say get value of "developer"
Dim value As String = KeyValues("developer")
MessageBox.Show(value)
End Sub
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "vb.net, config"
}
|
How do I access a cell's content that is outside of a filtered range in Excel?
This code will go through a filtered range and insert only the visible cells into an array (pretend column A was filtered according to my criteria). BUT, what I really want to do is shift one column over and insert the contents of "B3" into my array instead of "A3". How do I modify my code to this?
For Each cell In Range.SpecialCells(xlCellTypeVisible)
Array1(i) = cell.Value
i = i + 1
Next c
I was thinking something like Array1(i) = Cells(cell.Row, cell.Column + 1).Value
|
For Each cell In Range.SpecialCells(xlCellTypeVisible)
Array1(i) = cell.Offset(ColumnOffset:=1).Value
i = i + 1
Next c
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "excel, vba"
}
|
Limit in the closure of f(A)
**PROBLEM:** Given a function $f:A\rightarrow N$, if there exist $\lim_{x\to a} f(x)=b$, then $b\in \overline{f(A)}$
Im not really sure how to proceed, I was thinking that I could split in cases, if $a\in A$ and if $a\in \overline{A}-A$. Then im pretty sure that I must use the fact that $f(A)\subset f(\overline{A})$ and if the function is continuous, $f(\overline{A})\subset \overline{f(A)}$ but I cant manage to join both things. I suppose its an easy question, hope you guys can help me.
Thanks in advance :)
|
A topological definition of lim(x->a) f(x) = b:
for all open V nhood b, some open U nhood a with
f(U - {a}) subset V.
Assume a is not isolated, a necessary
condition to prove the proposition.
So if V is an open nhood of b, there's an
open U nhood a with f(U - {a}) subset V.
As a is not isolated f(U - {a}) is not empty.
Let x be any point in f(U - {a}).
Thus x in V $\cap$ f(A). Conclude b in closure f(A).
No. You have not been given that f is continuous.
Use of sequences is a failure unless the spaces are first countable.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "general topology, limits"
}
|
What do you call an unsupported roof that juts out over the entrance to a building?
Here is a sample picture:
>  but display them all separably. ?
I've searched for this answer but they all have "count(*) and group by" section that demands the rows to be exactly same.
|
Try This:
SELECT A, B FROM MyTable
WHERE A IN
(
SELECT A FROM MyTable GROUP BY A HAVING COUNT(*)>1
)
I have done with SQL server. But hope this is what you need
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql, oracle, duplicates"
}
|
jasper studio: truncating numbers in columns
 where for an example 026.126572.1 becomes, as an output, 026.126572 when queried? this is in jasper studio version 6.3 i think or the latest version of jasper studio
|
The answer is as follows:
SELECT SUBSTRING(your table name here,starting point,length) as "name", right(RTRIM(your table name here),length) as "name"
from "table name"
found on W3S school
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "jasper reports"
}
|
How to set up a test in OBIEE as a hyperlink?
There is such an SQL request:
Select
(((('<a href=" || scall.id) || '">'::text) || (scall.title)::text) || '</a>'::text) AS call_link
Produces this result:
!enter image description here
In the next step, I connect to OBIEE 12c, do the analysis and set up the text as a hyperlink, but it does not work out correctly:
!enter image description here
Tell me how to do it right?
|
This can be accomplished by selecting the HTML format under Column Properties > Data Format:
 in the browser without connecting to a node. If I understand correctly, in order to use web3.js we need to set a provider (Metamask or localnode) to use `web3.personal.newAccount("SEED", (response) => { console.log(response)})`
I found `ethereumjs-wallet` perfect for my use case but it exists only as a node module. Any way to use it as a browser module or alternatives to that?
|
Another key management tool from EthereumJS community is the Keythereum
Keythereum is a JavaScript tool to generate, import and export Ethereum keys. This provides a simple way to use the same account locally and in web wallets. It can be used for verifiable cold storage wallets.
A minified, browserified file dist/keythereum.min.js is provided by them for use in the browser. Including this file simply attaches the keythereum object to window:
<script src="dist/keythereum.min.js" type="text/javascript"></script>
You can try with this one.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, npm, ethereum, web3"
}
|
How to split string into an alphabetic string and a numeric string?
I need to use `preg_split()` function to split string into alpha and numeric.
Ex: `ABC10000` into, `ABC` and `10000`
`GSQ39800` into `GSQ` and `39800`
`WERTYI67888` into `WERTYI` and `67888`
Alpha characters will be the first characters(any number of) of the string always and then the numeric(any number of).
|
This is a tiny task. Use `\K` with matching on an capital letters in a character class using a one or more quantifier:
Code:
$in='WERTYI67888';
var_export(preg_split('/[A-Z]+\K/',$in));
Output:
array (
0 => 'WERTYI',
1 => '67888',
)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "php, regex, preg split"
}
|
unique validate using laravel
this is my controller
$rules = [
'Group_Id'=>'required',
'Group_Code'=>'required',
'Group_Name'=>'required| string',
'Currency'=>'required',
'Country'=>'required',
'State'=>'required',
'City'=>'required',
]
I want group id Group code should be unique while create if group id /group code already present in table means I want to print error as group id/group id already exit .while updating don't want to change group id filed that's remains same
|
$rules = [
'Group_Id'=>'required|unique:group,id',
'Group_Code'=>'required|unique:group,code',
'Group_Name'=>'required| string',
'Currency'=>'required',
'Country'=>'required',
'State'=>'required',
'City'=>'required',
]
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "php, laravel, validation"
}
|
Db2 rollforward "to end of backup" vs. "to end of logs"?
On Db2 Enterpise Server Edition v11.1 single patitioned database on Linux/Intel using LOGARCHMETH1 I executed backup and restore commands:
db2 "backup database mydb online to /path/to/backup include logs without prompting"
Then on identical Linux/Db2 computer:
db2 "restore database mydb from /path/to/backup into mydb logtarget /path/to/logs"
What is the difference between "end of backup" and "end of logs"?
db2 "rollforward database mydb to end of backup and stop overflow log path (/path/to/logs)"
db2 "rollforward database mydb to end of logs and stop overflow log path (/path/to/logs)"
Regards
|
to end of backup and stop: it will apply only the transaction logs backuped during the online backup (it will apply only the log generated during the backup to have a coherent database).
to end of logs and stop: will apply all transaction log that it find
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "db2, database backups, db2 luw, database restore, roll forward"
}
|
Fetch input value from certain class and send with jquery
<input id="u1" class="username">
<input id="u2" class="username">
<input id="u3" class="username">
...
How to fetch input value with "username" class and send with ajax jquery to php page.
i want to recive data like simple array or simple json. (i need INPUT values and not ids)
|
var inputValues = [];
$('input.username').each(function() { inputValues.push($(this).val()); });
// Do whatever you want with the inputValues array
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, jquery"
}
|
"Downside" versus "drawback"
My essay was about the advantages and disadvantages of international travel between countries.
When it comes to the disadvantages, I wrote _downside_ to avoid repeating _disadvantage_ , but my teacher suggested to use _drawback_ instead. She said _downside_ was not appropriate.
Can you tell me the difference, and when to use both of them?
|
_Downside_ is more modern/informal, and a bit slangy (some would still call it "business jargon").
Interestingly, people sometimes head up the section on, say, a business case assessment, with singular _Downside_ \- followed by perhaps several separate disadvantages. They usually head it up with plural _Downsides_ though. But it would be very unusual to use _Drawback_ or _Disadvantage_ in the singular there.
_Drawbacks_ is somewhat more informal than _disadvantages_ , but they're both fine for almost all contexts.
|
stackexchange-ell
|
{
"answer_score": 4,
"question_score": 5,
"tags": "word usage, difference"
}
|
Deserialization of key value pair in XML to c# object
I have XML as shown below.
<Device-array>
<Device>
<id>8</id>
<properties>
<PropKeyValuePair>...</PropKeyValuePair>
<PropKeyValuePair>...</PropKeyValuePair>
</properties>
</Device>
<Device>...</Device>
<Device>...</Device>
</Device-array>
I am planning to deserialize it to C# object so that it will be faster. I only require the id field. But i understand that the class need to have an array for (properties). But how do i represent the key valuepair ?
[Serializable()]
public class SLVGeoZone
{
[XmlElement("id")]
public string id { get; set; }
//Arraylist of key value pairs here ?
}
need suggetions.
|
You can use LINQ to XML instead of deserialization and get just what you need: list of ids:
var xDoc = XDocument.Load("FilePath.xml");
var ids = xDoc.Root
.Elements("Device")
.Select(x => (int)x.Element("id"))
.ToList();
If you really need to use deserialization you can just omit properties you don't need and `XmlSerializer` will deserialize just declared content, skipping elements you didn't declare in your class.
**Update**
To get more then just a name into list of anonymous type:
var ids = xDoc.Root
.Elements("Device")
.Select(x => new {
Id = (int)x.Element("id"),
Name = (string)x.Element("name")
})
.ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, .net, xml, deserialization"
}
|
Creating design document from existing java code
I have existing java code and need to create Design Document based on that.
For starter even if I could get all functions with input / output parameters that will help in overall proces.
Note: There is not commeted documentation on any procedures, function or classes.
Last but not least. Let me know for any good tool which will reduce time required for this phase. As currently we write every flow and related stuffs.
|
What you want is just too much. Quoting Linus Torvalds: “Good code is its own best documentation.”. Anyway, I digress.
You might want to look into UML tools which generate class/sequence diagrams from the code. There are many of them but only a handful support reverse engineering (into and from the class diagram), and even fewer subset support the same to/from sequence diagram. I only know MagicDraw could do this, but I am biased as I used to work for the manufacturer of this tool so do your shopping around first.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "sdlc"
}
|
is it possible to do text wrapping ALL AROUND an element?
**Is it possible to style text wrapping ALL AROUND an element as it appears in the image attached? (Either CSS, or JQuery)**
` method provided in `CharSequence` and since `String` class implements this interface you can access it. The `chars()` method returns an `IntStream` , so you need to cast it to `(char)` if you will like to convert `IntStream` to `Stream<Character>`
E.g.
public class Foo {
public static void main(String[] args) {
String x = "new";
Stream<Character> characters = x.chars().mapToObj(i -> (char) i);
characters.forEach(System.out::println);
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 10,
"tags": "java, string, java 8, java stream"
}
|
Get current directory, not path, in a function .bashrc
I would like to display a * in my prompt if the name of the current rvm gemset does not match the name of the current directory. I can get the name of the current gemset with no problem by using `$(~/.rvm/bin/rvm-prompt g)` which, if the gemset is foo, will return `@foo`.
I've tried both `"@${PWD##*/}"` and `"@${\W}"` but unfortunately with no success. My entire function looks like this:
function ps1_rvm() {
[[ $(~/.rvm/bin/rvm-prompt g) != "@${PWD##*/}" ]] && echo "*"
}
I am then using this function to set the value of PS1 so that it is output to my prompt.
Edit: I want to get the directory name, not the path.
|
Have you tried
function ps1_rvm() {
[[ $(~/.rvm/bin/rvm-prompt g) != $(basename $(pwd)) ]] && echo "*"
}
? That should work...
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "bash, rvm"
}
|
WAMP virtual host contains no domain
I'm using WAMP, with a virtual host. The problem is that when I'm on my virtual host,
$_SERVER['REQUEST_URI']
contains only a "/" when I'm on the index; it doesn't contain the domain name. Why?
|
Yes, the `REQUEST_URI` is not supposed to contain the host, only the part after the host and before the query string. Use:
$_SERVER['HTTP_HOST']
Or:
$_SERVER['SERVER_NAME']
`HTTP_HOST` is the one that was specified in the request header (the actual host being visited). `SERVER_NAME` is the one that is set up as the `ServerName` on the virtual host. Not always the same as each other if coming in on a `ServerAlias`.
References:
* PHP: Predefined Variables
* HTTP_HOST vs. SERVER_NAME
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "php, apache, wamp"
}
|
Loading initial data at application startup with Spring Data MongoDB
I use embedded MongoDB database in a development environment. It is setup empty at the application startup. I would like to load initial data which is needed for the application when the Spring context is setup.
Is there a way in Spring Data MongoDB to point a JSON file(s) which would be loaded into a database (something like import.sql (hibernate.hbm2ddl.import_files) in Hibernate or @UsingDataSet in NoSql Unit)?
|
mongeez see wiki link for spring integration wiki
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 5,
"tags": "java, spring, mongodb, spring data, spring data mongodb"
}
|
can I get an entity type using only a guid
I have a process that one of the params been used is a record's guid of a specific entity (always salesorder for example). Now I've been asked to support an other entity (case for example) but I don't want to pass a new param (entity type), I want to use the record's guid to get the entity type, is there an option to get entity type only by guid (c#)
|
It's not possible to get directly the entity type (or Entity Name if you prefer) from the Guid inside a Dynamics CRM / 365 CE / Dataverse instance.
You can eventually do a try/catch (like a service.Retrieve to salesorder and if fails try against incident) but is an approach I would not suggest if you have other options available.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "dynamics crm"
}
|
iOS UIPickerView: How to limit the scrolling range
When you scroll `UIPickerView` you can move your finger on the touchpad up and down - far up and down to how big the screen is. Is there a way to limit this range of scrolling up and down to the area of the `UIPickerView`? So that once you move your finger outside of the `UIPickerView` the scrolling of the `UIPickerView` stops? I am making `UIPIckerView` as a spinner in a game, and I need to achieve this for a fair gaming.
|
//viewDidLoad
UILongPressGestureRecognizer* gestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(pickerLongPressDetected:)];
gestureRecognizer.minimumPressDuration = .001;
gestureRecognizer.cancelsTouchesInView = NO;
gestureRecognizer.delegate = self;
[self.rollerView addGestureRecognizer:gestureRecognizer];
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
// return
return true;
}
-(void)pickerLongPressDetected:(UILongPressGestureRecognizer *)gesture
{
CGPoint touchPoint = [gesture locationInView:self.view];
CGRect frame = self.rollerView.frame;
if(!CGRectContainsPoint(frame, touchPoint))
{
//methods for when you scroll outside of your picker view's frame
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios, uipickerview"
}
|
How to make a bootstrap site non-static?
I am currently developing static websites with bootstrap. However, I would like to try create some non-static websites so the client can update simple texts by themselfs.
What kind of tool would you recommend me to do so with? I would still like to use bootstrap for structure and design.
Thanks in advance!
|
What you're talking about is using a CMS (Content Management System). There are a number of ways to approach using Bootstrap's framework with a CMS.
One simple CMS you could offer your clients would be CushyCMS: < CushyCMS allows you to specify editable regions within an HTML file and a client would only be able to edit those areas. This is great if you want to leave most of the website static, but allow them to change a few things in there.
If you wanted to use Wordpress, there is a Bootstrap 3 theme for Wordpress located here: < Wordpress is a much more complicated CMS, but it has a lot of power and capability. If you take some time to master Wordpress, you can use this basic Bootstrap 3 theme plus Wordpress and develop dynamic sites using Bootstrap.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, static"
}
|
USA immigration by a European citizen
I'm exploring the possibility to move to the USA (possibly permanently).
I've already made some research regarding the different options (green card, visa types etc) but it seems that none of them covers my case, what I would like to do is to move there (with a good amount of money on my account to pay my stuff until I find a stable job) and then find a job.
Details: I own both French and Swiss citizenship, I have a master degree in IT and currently work as a software developer (I guess USA lacks developers).
The only option I found is to find a company that would sponsor me or to win green card lotery... but as a junior it would be easier for me to find a job once I'm already there, is it possible ?
Feel free to edit my question or to ask in comment for more details.
|
What you've found is pretty much it, but "a company to sponsor you" could be a company that has offices both in the EU and the US. You might look for companies that you could begin working for in Europe and then try to convince them to transfer you to the US. And keep entering the lottery.
You can spend up to 90 days at a time in the US on the visa waiver program, or six months with a B visa. Whether you can hunt for work during that time is not clear. I think it should be permissible, but some users on this site and on Travel (and apparently some CBP officers) think it is forbidden. Since some CBP officers seem to think that it is forbidden, it is risky to seek entry into the US for this purpose, and you probably shouldn't do it without consulting a US immigration lawyer.
|
stackexchange-expatriates
|
{
"answer_score": 5,
"question_score": 2,
"tags": "usa, visa, immigration"
}
|
What privileges do I need to disable network adapter in Windows 7?
From time to time my Lenovo notebook has problem to connect to wifi network after waking from stand by or hibernation. The only fix (besides reboot) is to disable and enable wifi network adapter.
Windows 7 wants me to provide administrator credentials for this, which is pretty annoying.
Is it possible to add some permissions to my regular profile to be able to disable/enable without entering admin credentials? What permissions would that be?
|
Yes it is possible.
To disable network cards you need to add the user account to the Windows group called _Network Configuration Operators_.
In this Microsoft article you can get more information about this group:
> A Description of the Network Configuration Operators Group
Administrator rights are not required.
Also, you can manually change this right using `gpedit.msc` and modifing the setting
USER CONFIGURATION / ADMINISTRATIVE TEMPLATE / NETWORK CONNECTION / Ability to enable/disable a LAN connection
|
stackexchange-superuser
|
{
"answer_score": 5,
"question_score": 2,
"tags": "windows 7, permissions, privileges"
}
|
how do i loop through the response of an http request in angular 11
I am new to Angular, am using Angular 11, and having trouble doing an http request. I have looked through pages of stack overflow posts and none have worked for me, even though some have similar questions. I have an http request to a server to get json data, which the result comes back like this:
{
"OleOleOle":3463,
"Saitama":1,
"SalsaMan":563,
...
}
I need to loop through the JSON and put each key value pair in an array as an object, with the key as the name and the value as the viewCount.
I have been trying to do it with this:
getLiveStreams() {
this.http.get<any>(this.server.url).subscribe(data => {
console.log(data)
data.forEach((stream: any) => console.log(stream))
})
}
But I get an error saying:
ERROR TypeError: data.forEach is not a function.
|
Your response is object try to use `Object.keys(data).forEach((key: any) => console.log(key + ":" + data[key]))`
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "angular, typescript"
}
|
Load balancer /target group relationship query
I cannot seem to find anywhere in the AWS load balancer console a field which tells me which target group is associated with the particular load balancer.I think I remember which one I configured, but I just want to confirm that the correct target group is associated with the correct load balancer and I cannot find it.
|
From the 'Load Balancers' console you can go to the Listeners tab and look at the link in _forwarding to_.
Alternately you can click on 'Target Groups' in the left side menu and search for your load balancer in the Load Balancer column:
The `aws` cli method would look something like this:
$ aws elbv2 describe-load-balancers \
--query 'LoadBalancers[*].[LoadBalancerArn]' \
--output text | xargs -I {} aws elbv2 describe-target-groups \
--load-balancer-arn {} \
--query 'TargetGroups[].TargetGroupName'
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "amazon web services, cloud, elastic load balancer"
}
|
Fireworks crashing on opening (CS6 and CS5) Mac OS X Mountain Lion and Mavericks
Mac Fireworks CS6 and CS5 won't start. Even after trying all suggested solutions on the Adobe forum, ranging from removing the fireworks preferences to remove all user fonts of my mac system.
After loading the fireworks always remains not responding and I have to force quit.
|
Believe me, it's all because of Flash Firebug in FIREFOX! I disabled flash firebug in firefox, restarted firefox, removed the flash firebub, closed firefox, opened the fireworks, and happiness returned to my macbook. After much time and many attempts the fireworks works again.
I can not believe that a firefox plugin could cause me so much trouble.
Here is the source of the solution that saved my day: <
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "crash, fireworks"
}
|
Call to undefined function hash() in /var/www/site/ problem
I have called hash function in my code like (php version 5.2.14 )
$username =hash("sha256",trim($_POST['username']));
$password =hash("sha256",trim($_POST['password']));
but I got error like **Call to undefined function hash() in /var/www/site/** What to do ?
|
It means it cannot find the function `hash()`. Checking the manual I see this:
(PHP 5 >= 5.1.2, PECL hash >= 1.1)
What php version do you run? Try:
<? phpinfo() ?>
To check. If it is lower then 5.1.2 you do not have the `hash()` function available
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "php"
}
|
Adding code to new excel sheet dynamically
I need some help Regarding VBA. In My code I add an excel sheet and rename it and add a validation list to it.I need to run some code on changing value in that validation list.And that must run only on change of that particular cell. If I am not clear please let me know.Please Help me solving this.
|
Instead of trying to create the individual code for each new worksheet with the Visual Basic Extensibility (see this link for further reading), simply use the Workbook wide event `Workbook_SheetChange` (you need to place it in the `ThisWorkbook`module).
In this event code first check, if the worksheet which caused the event is one of the newly created worksheets. This can be done most easily, be checking the `.Name` of the worksheet.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 6,
"tags": "vba, excel, validation, programmatically created"
}
|
Changing the height, width of moderncv type resume
I am trying to change the pagewidth and pagelength of a `moderncv` type CV that can be found here (< by changing the values inside inside `moderncv.cls`:
\DeclareOption{a4paper}{
\setlength\paperheight{607mm}
\setlength\paperwidth{210mm}}
But, nothing really changes when I alter the values. Any ideas?
|
Don't. As the `moderncv` examples load `geometry`, so should you, and change the settings using the package interface:
\usepackage{geometry}%
\geometry{paperwidth=210mm,paperheight=607mm}
|
stackexchange-tex
|
{
"answer_score": 6,
"question_score": 4,
"tags": "moderncv, geometry, cv"
}
|
std::vector constructor with two input arguments
I came across a piece of C++ code in one of my projects that initializes a vector with two inputs.
One of the inputs is an existing array, and the other is the same array plus the array length.
I found a similar piece of code on another site:
// Create an array of string objects
std::string arr[] = {"first", "sec", "third", "fourth"};
// Initialize vector with a string array
std::vector<std::string> vecOfStr(arr, arr + sizeof(arr)/sizeof(std::string));
for(std::string str : vecOfStr)
std::cout << str << std::endl;
Can someone explain what `arr + sizeof(arr)/sizeof(std::string)` is?
The website that this code was referenced in said that this was the corresponding constructor used:
vector (InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
|
`arr` itself is of type `std::string[4]`. When passed to a function, it is decayed to pointer to the first element. In the expression `arr + sizeof(arr)/sizeof(std::string)`, the first occurrence of `arr` is again decayed. The second is not. `sizeof(arr)/sizeof(std::string)` therefore evaluates to `4` which is the array extent. The whole expression `arr + sizeof(arr)/sizeof(std::string)` then evaluates to a pointer to the position past the final element in `arr`. This is usually called the off-the-end iterator. This effectively invokes the constructor `vector(InputIterator first, InputIterator last, ...)` where `InputIterator` is instantiated with `std::string*`.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c++, vector, constructor, std"
}
|
XACT support outside of XNA?
I was building a new game in Monogame when I realized that it didn't have XACT support like XNA did. I was wondering if anyone knew another framework that could be used with or instead of MonoGame (preferably with) to get the ability to load XACT projects into the game?
|
XACT itself is only supported on platforms that already support the official XNA framework (specifically Windows Desktop and Xbox; and not WP7). I'm not aware of any re-implementations of XACT for other platforms.
So your choices are basically to use the official XNA framework (if you only need Windows/Xbox support). Or select another audio technology (possibly `SoundEffect` in XNA/MonoGame, possibly something else).
Also keep in mind that XACT is no longer "supported" on Windows (similar to XNA - it's not broken - it will still _work_ if you choose to use it).
|
stackexchange-gamedev
|
{
"answer_score": 1,
"question_score": -1,
"tags": "xna, c#, audio, xact"
}
|
Trouble with Jquery widget
I have a widget like this
$.widget("ui.myWidget", {
//default options
options: {
myOptions: "test"
},
_create: function () {
this.self = $(this.element[0]);
this.self.find("thead th").click(function () {
this.self._headerClick(); //how do I do this!!!
});
this.self._somethingElse();
},
_headerClick: function (){
},
_somethingElse: function (){
},
.
.
.
The line `this.self._headerClick();` throws an error. This is because in that context `this` is the `th` element that was clicked. How do I get a reference to the _headerClick function?
|
Store the scope of desired `this` within a variable.
$.widget("ui.myWidget", {
//default options
options: {
myOptions: "test"
},
_create: function () {
var that = this; // that will be accessible to .click(...
this.self = $(this.element[0]);
this.self.find("thead th").click(function () {
that._headerClick(); //how do I do this!!!
});
this.self._somethingElse();
},
_headerClick: function (){
},
_somethingElse: function (){
},
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "javascript, jquery, jquery ui, jquery plugins, jquery widgets"
}
|
Are there some modern UI equivalents that can be used instead of a ComboBox?
ComboBoxes do a good job when on (e.g.) web forms.
However, they just look dated in a modern UI with a touch screen. Is there a more modern alternative to them? Or is it just a case of stripping away the ugly drop-arrow button?
|
There‘s no combobox element for the web and the definition of a combobox differs depending on who you ask.
I would say a combobox is a mix of a text box and a select box. That is, you can select from a list of options like a select box but type in a value that's not in the list of options.
If you‘re looking for this sort of thing then maybe you could consider an autocomplete component which offers suggestions as the user types.
This functionality is now in HTML5 via the datalist element but it's buggy and doesn‘t provide a great fallback.
So you‘d have to create your own – I‘ve made an accessible one if you‘re interested: <
If you do go down this route, then you‘d have to provide custom styles anyway so you'd be more in control of the way it looks as well – not that should be the main concern.
|
stackexchange-ux
|
{
"answer_score": 0,
"question_score": 0,
"tags": "gui design, interaction design, input fields, drop down list"
}
|
Redirecting traffic to a https site
In our mail server there are multiple virtual email domain hosted. User can use webmail.example.com (this is the first apache virtualhost) to check mail or they can use mail.THEIR-DOMAIN.com. If the put mail.THEIR-DOMAIN.com apache shows the webmail.example.com as it is the first virtualhost and mail.THEIR-DOMAIN.com doesn't exist. Recently we imposed https for webmail.example.com and added this mod_rewrite rule:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*)
But now users not getting the default webmail page as they were getting before. How can we redirect all request coming to the URL "mail.ANY-DOMAIN.com" to "< I've tried the following but it didn't work:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (mail.*)
Thanks for your help in advance.
|
Try this:
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail. [NC]
RewriteRule ^(.*)$ [L,R=301]
</VirtualHost>
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 1,
"tags": "apache 2.2, mod rewrite"
}
|
How to use Example from Adobe reference in FlashDevelop IDE
I try to use the example from Adobe help reference as following address:
<
I open FlashDevelop IDE, creat a new Flex 3 project, then copy the code of example to the main.mxml, save it, then run builder.
It failed with "...\TreeExample\TreeExample\src\Main.mxml(5): Error: Could not resolve <s:Application> to a component implementation." error message.
There is a "How to use this example" link beside this example, but I didn't find any useful information I want.
How can I run this example in FlashDevelop IDE?
|
It seems, that you try to compile component from newer Flex sdk with older one (3.x instead of 4.x)
Download newest from Adobe site: <
And install it to Flash Develop: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "apache flex, flashdevelop"
}
|
Why do i get a wrong barcode for my EAN using ZPL
i have a question regarding printing EAN Barcodes with ZPL. Why do the Barcode and my given EAN dont match?
I have following ZPL code to generate the Barcode.
^XA^PQ1,0,0,N^FO50,20^BY^BEN,140,Y,N^FD4250164837159^FS^XZ
The result of this is following:
 is limited to exactly 12 characters. ZPL II
automatically truncates or pads on the left with zeros to achieve the
required number of characters
See p101 of the Zebra Programming Guide for details. If you need to encode the 9 (which is not the correct checksum) then you should look at EAN14(or GTIN14).
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "barcode, zpl"
}
|
Titanium - iOS equivalent for Menu/MenuItem?
I am developing in Appcelerator, and I have looked through the documentation and have not been able to find a menu element for iOS devices. Even if it's just a single button an a pop up dialog comes up that would be fine too. Is there a way to add a button to the far right of the navigation bar that says "Options"? It's for a messaging feature, so I will have options like "Select" and "Delete".
|
For iOS there are the `Window` properties LeftNavButtons and LeftNavButton and of course also the Right equivalent.
Don't try to use them the same as you try on Android, they're completely different. The UX meant for these buttons is also different. But since you can just put an icon/button there and watch for click event what you do after is up to you.
Look into the Guidelines from Apple for more info on how to properly implement UI/UX on iOS
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, titanium, appcelerator, titanium alloy"
}
|
Looking for duplicates in columns between 2 dataframes in pandas Python
How would I be able to write a function that detects if there are duplicates of a pandas Dataframe. So if I compare the `index` column between `first` and `second` there are no duplicates. But if I compare the `index` column between `first` and `third` there are duplicates of `1`. I want to write a function that returns a `bool` of True when there are duplicates and a `False` when there aren't.
import pandas as pd
first = pd.DataFrame({'index': [1,4,5,6],
'vals':[3,4,5,7] })
second = pd.DataFrame({'index': [13,7,8,9],
'vals':[3,2,3,1] })
third = pd.DataFrame({'index': [1,11,2,12],
'vals':[6,7,51,2] })
Expected Output:
first and second: False
first and third: True
|
Use `sets` predicate:
>>> any(set(first['index']).intersection(second['index']))
False # because {}
>>> any(set(first['index']).intersection(third['index']))
True # because {1}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python, pandas, database, dataframe, compare"
}
|
Grails change locale
How to change `locale` in grails application and force the browser to use the same. I tried this solution.
def locale = new Locale("de","DE")
RequestContextUtils.getLocaleResolver(request).setLocale(request, response, locale)
Also tried to change browser location as well nothing worked.
Any suggestions?
|
You could make use of params.lang. I use a grails filter to set the language on every request, e.g.
languageFilter(controller: '*', action: '*')
{
before = {
params.lang = "de"
return true;
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "spring, grails"
}
|
Looping through an array gives back different SQL results, depending on the code
I am turning the (key,value) into a PDO select search, but I have found a weird behavior.
This works:
$statement = $this->handler->prepare("SELECT * FROM $table WHERE pid=:pid AND section=:section");
foreach ($data as $key => $value)
$statement->bindParam(":$key", $data[$key]);
$statement->execute();
debug($statement->fetchAll(PDO::FETCH_ASSOC));
But when I change the function inside the loop to this, it does **NOT** work
foreach ($data as $key => $value)
$statement->bindParam(":$key", $value);
Even though `$value == $data[$key]` is true, they second code doesnt give me the right results back. Why?
|
The reason it's not working is because you are binding the parameter to `$value`, which constantly changes.
If you do:
$value = 5;
$statement->bindParam(":$key", $value);
$value = 10;
Then `10` will be sent in the query.
Instead what you want to do is bind the VALUE instead of the parameter:
foreach ($data as $key => $value)
$statement->bindValue(":$key", $value);
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "php, arrays, pdo, foreach"
}
|
How to deal with label that not included in training set when doing prediction
For example, using supervise learning to classify 5 different people face. But when test on 6th people face that not in training set, the model will still predict it within the 5 people. How to let the model predict the 6th and onwards people face as unknown when the model doesn't train them before?
|
You could set a certain threshold for prediction the known classes. Your model should predict from the known classes only if it predicts it with a certain threshold value, otherwise, it will be classified as _unknown_.
The other (and less preferable) way to deal with this problem is to have another class called _unknown_ even during training and put some random faces as corresponding examples of this class.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, machine learning"
}
|
Помогите найти определение к "атмосфере", употреблённой не в прямом своём значении
> Монти. Первый район города Рима обозначается на картах соответствующей римской цифрой, а название его переводится с итальянского как «горы», хотя **по атмосфере это скорее можно назвать очаровательной долиной**.
Или чем заменить атмосферу; или и так всё понятно, читатель не споткнётся (как я)?
|
В этом контексте, как мне кажется, **определениями** к "атмосфере" могут быть:
романтическая, созерцательная, пейзажная, панорамная, ландшафтная.
А если **заменять** "атмосферу", то, возможно, подойдет:
очертание, восприятие, ощущение.
Или даже симбиоз: панорамное ощущение, пейзажное восприятие, романтические очертания...
|
stackexchange-rus
|
{
"answer_score": 1,
"question_score": 1,
"tags": "выбор слов"
}
|
Hausdorff dimension of $\lim_{n\to\infty}\sin(2^nx)$
> Calculate the Hausdorff dimension,$\dim_H$ of $$S=\\{x\in(0,1):\lim_{n\to \infty}\sin2^nx=0\\}$$
By definition We need to find the minimal $\alpha$ s.t $\sum_{i\in I}|U_i|^\alpha$ is minimal where $U_i$ is an open cover for the set.
On the other hand, I'm not sure it exists since the function diverges when $n\to\infty$. How can I find the dimension or prove that it doesn't exist?
|
Follow the hint by Daniel Fischer: $$ \lim_{n\to\infty} \sin 2^n x = 0 \iff \exists n\ \sin 2^n x=0 \tag{1} $$ The set of $x$ that satisfy the condition on the right is countable.
To prove (1), observe that if $|\sin y|\le 0.1$ then $|\cos y|\ge0.9$, so $|\sin 2y|\ge 1.8|\sin y|$. Thus, if for some $n$ the value of $|\sin 2^n x|$ is small but not zero, it will grow for a while and will not be that small.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 3,
"tags": "real analysis, general topology, functions, dimension theory analysis"
}
|
System.net.Sockets.SocketException No Connection could be made because the target machine actively refused it
I am a new member in a team project. I got the latest version of the solution, configured SQL Server and IIS, where they host the services (WCF). when I debug the solution I get this exception.
> System.net.Sockets.SocketException No Connection could be made because the target machine actively refused it
I tried this, and didn't work:
* Disable the firewall.
* Change the port in IIS.
 as a primary monitor?
I have an old PC in the den without Video Card (I have to remove it after it start failing). I access it through Remote Desktop.
I don't want to invest in a new video card since the PC is old.
If I buy a USB monitor I can use it as a secondary monitor in the main pc, and plug to the old PC when need.
The question is:
**Does the USB monitor work during booting before the OS was loaded?**
|
I very much doubt that a USB monitor will display anything during OS boot, and I'm certain it will not during earlier parts of the boot process (when the BIOS is in control).
From the prices I have seen the price difference between a USB monitor and a DVI or VGA monitor is much larger than a cheap graphics card would cost (larger still if you consider 2nd hand cards) so unless you need a USB monitor specifically for other reasons (yur main PC has no more unused VGA/DVI outputs, or you specificity want one of the small monitors not a full size one) you would be better of getting a DVI/VGA monitor and a cheap graphics card for the currently headless server.
Also, if the old machine is _very_ old and so only has USB 1.1 ports you may have trouble as all the USB run monitors I've seen specify requiring USB 2.
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 6,
"tags": "usb, display, graphics card, bios"
}
|
How to upload image from Android device to Rails server?
I am working on a Android project and want to upload Bitmap images to my rails server. But I have no idea how to write the Rails models or controllers.
I find someone using MultipartEntity post to upload images and paperclip to recieve images on RoR server. I want to know how to connect the post and server (what url?) and how to write the model or controller.
|
I use a stupid method. I convert the Bitmap image to byte array and use Base64 method to convert it to a string. Post the string to server. When I want to get image, download the string and convert it to Bitmap.
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 0,
"tags": "android, ruby on rails, post, paperclip"
}
|
Centring a flow in Shoes
Can I center the contents of a flow in Shoes?
I know that a paragraph can be centred like:
para 'Centred paragrpah', :align=>'center'
However, this does not work with flows:
flow(:align=>'center') do
…
end
No errors are brought up, but the contents remain left justified.
|
Not completely sure. What is it in your flow you are trying to centre? You can try a margin left trick as per HTML and CSS.
This gives a flow with left, centre and right justified text that remains centred in the window as it is resized:
Shoes.app do
flow do
style(:margin_left => '50%', :left => '-25%')
border blue
para "Some left justified text\n", :align => 'left'
para "Some centred text\n", :align => 'center'
para "some right justified text\n", :align => 'right'
end
end
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "ruby, layout, shoes"
}
|
How to put a Google Maps with approximate location?
In facebook marketplace they put a map, then encircled the approximate location of the seller's address. How am I going to implement it in android studio? here's a screenshot from facebook marketplace. Click here for the image
|
> after integrating google map you can use following code
GoogleMap map;
// ... get a map.
// Add a circle in Sydney
Circle circle = map.addCircle(new CircleOptions()
.center(new LatLng(-33.87365, 151.20689))
.radius(10000)
.strokeColor(Color.RED)
.fillColor(Color.BLUE));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, maps"
}
|
Upload files to WordPress site from iOS app
So I want my iOS app to upload files created by mobile users to my WordPress site.
* Users will locally create JSON files.
* The files will be uploaded using the WordPress REST API as Media files. I have enabled uploading non-image media files for that.
* I want the app to upload these files to the site with a single "uploader" site account. The credentials will have to be securely stored in the app at build time.
**Questions:**
* Is it a good scheme to upload user files to my site?
* What credentials would I need to embed in the app upload files?
* Do I need a WP plugin to make it work?
* What is a good way to secure/obscure those credentials?
|
First I needed to set `define(‘ALLOW_UNFILTERED_UPLOADS’, true);` on `wp-config.php` to allow uploading JSON files to media.
I also created an "Editor" account that would be allowed to upload and delete media.
Then I played with the WP REST API, which is messy and badly documented. I was able to authenticate using basic Authorization in the header.
I was able to upload JSON files but I couldn't update/overwrite them later without deleting them first.
So after lots of small annoyances I decided to use Amazon S3 for this. I setup uploading in half an hour. I was stretching WP too much for this task.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios, wordpress, file upload"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.