INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Perpendicular Chord parabola
If $r_1,r_2$ be the length of the perpendicular chords drawn through the vertex of a parabola $y^2=4ax$, then show that $$(r_1r_2)^{4/3}=16a^2(r_1^{2/3}+r_2^{2/3})$$
|
Let $O=(0,0)$ be the vertex of the parabola, and $P_1=(x_1,y_1)$, $P_2=(x_2,y_2)$, the other endpoints of the chords. The perpendicularity condition yields $$ y_1y_2=-x_1x_2=-{1\over16a^2}y_1^2y_2^2, \quad\hbox{that is}\quad y_1y_2=-16a^2 \quad\hbox{and}\quad x_1x_2=16a^2. $$ We have then: $$ r_2^2=x_2^2+y_2^2=x_2^2+4ax_2={256a^4\over x_1^2}+{64a^3\over x_1}= {64a^3\over x_1^3}(4ax_1+x_1^2)={64a^3\over x_1^3}(y_1^2+x_1^2) =\left({4a\over x_1}\right)^3r_1^2 $$ that is $$ r_2^{2/3}={4a\over x_1}r_1^{2/3}. $$ It follows that $$ r_1^{4/3}r_2^{4/3}={16a^2\over x_1^2}r_1^{8/3} $$ and $$ r_1^{2/3}+r_2^{2/3}=\left(1+{4a\over x_1}\right)r_1^{2/3} ={x_1^2+4ax_1\over x_1^2}r_1^{2/3} ={r_1^2\over x_1^2}r_1^{2/3}={1\over x_1^2}r_1^{8/3}. $$ In conclusion: $$ {r_1^{4/3}r_2^{4/3}\over r_1^{2/3}+r_2^{2/3}}=16a^2. $$
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "conic sections"
}
|
Adding css border style
Can someone help me, please?. I want to add a border style in the link:hover, to a component of primefaces. I add like this:
.ui-contextmenu .ui-menuitem-link:hover{
font-weight: bold;
border-style: solid;
border-width: thin;
}
In a file calling **pfcrud.css.** The problem is that, the border style is not working/showing. Thanks!.
|
Use the shorthand method: `border: thin solid black;`
**CSS**
.ui-contextmenu .ui-menuitem-link:hover{
font-weight: bold;
border: thin solid black;
}
Note that this will change the box-model of the element in question, so when you hover over it this border will effectively increase the element size. You may need to consider accommodating for that change by declaring a rule for the element's natural/default state as well, usually a border with the same width, but `transparent` works in most cases.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "css"
}
|
How to run Android project from folder with gen and auto-gen files
It is kind of easy Q, but I am stick, I have the file ready with all files like java xml files every things, and I have Eclipse ready too, but HOW TO RUN thx
|
Open your existing project through the following path:
> File->New->Other->Android Project from Existing Code
Then click on the run button to run your code.
To generating an APK you need to follow this path:
> File->Export->Android->Export Android Application
Enjoy :-)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "android"
}
|
Find out if PHP ran out of memory
Is it possible to find out (programmatically) if the current PHP process is about to run out of memory?
**Some Background** :
I am the author of the Bulk Delete WordPress plugin, which allows people to delete posts, users etc in bulk.
One common complaint I get from my plugin users is that they get a blank page when trying to delete huge amount of posts. This happens because PHP runs out of memory.
If I can find out that the PHP process is about to run out of memory, then I can try to delete in batches or at least give a warning to the user, instead of just throwing a blank page.
|
After some more research I found a solution. The solution is to use register_shutdown_function
One drawback is that this function will get executed _after_ PHP ran out of memory and not _before_ (which is still fine with me, since I can just let the users know about it)
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "php, memory management, out of memory"
}
|
Naming an object that is an attribute of another object with the same getter/setter as Object Type
This is a fundamental question. When using objects as an attribute for an object, So Object2 has an attribute Object1.
Can you use the Object name as the type and name for the getter and setter or the second object.
Class Object1{}
Class Object2
{
Object1 Object1 {get; set;}
// OR
Object1 Object1_{get; set;}
}
As I've tried it using the same name for simple programs and it works (though I've not dare to venture into complex code with it). I understand that there could be ambiguity, but will this actually work for any project?
|
Yes, you can do it. In fact this is a very common pattern in C#
class Foo
{
Bar Bar {get; set; }
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c#, class, naming conventions"
}
|
How can I test views in a Rails plugin?
I'm writing a Rails plugin that includes some partials. I'd like to test the partials, but I'm having a hard time setting up a test that will render them. There's no associated controller, so I'm just faking one:
require 'action_controller'
require 'active_support'
require 'action_pack'
require 'action_view'
class MyTest < Test::Unit::TestCase
def setup
@renderer = ActionController::Base.new
@renderer.append_view_path File.expand_path(File.join(File.dirname(__FILE__), '..', 'views'))
end
def test_renders_link
result = @renderer.render(:partial => '/something')
assert ...
end
end
But that `:render` call always blows up. I've tried using an `ActionView::Base` instead of an `ActionController::Base`, but that gets even less far.
Has anyone had any success?
|
The final answer:
require 'action_controller'
require 'active_support'
require 'action_pack'
require 'action_view'
require 'action_controller/test_case'
class StubController < ActionController::Base
helper MyHelper
append_view_path '...'
attr_accessor :thing
def my_partial
render :partial => '/my_partial', :locals => { :thing => thing }
end
def rescue_action(e) raise e end;
end
class MyTestCase < ActionController::TestCase
self.controller_class = StubController
def setup
@controller.thing = ...
get :my_partial
assert ...
end
end
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 5,
"tags": "ruby on rails, ruby, testing, plugins, actionview"
}
|
How do make a zsh function in a way that I can enter a string without quotes, but it gets interpreted with quotes?
I want to make a function that would run something like this:
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' "
Currently, in .zshrc, I've been trying
downloadyoutube(){
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' "$1"
But it still wants me to add the quotes around the URL when I call it.
Instead, I would like to run
downloadyoutube
without quotes.
And not
downloadyoutube "
Is there a way to do this?
|
as Kusalananda said, `noglob` is the way to go; you can define your function as is and then use `alias` to include `noglob`:
downloadyoutube(){
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' "$1"
}
alias downloadyoutube="noglob downloadyoutube"
Anyways, what you're trying to do with these arguments is moot: `youtube-dl` defaults to it for years now; read the current `man` page!
* * *
I'd like to stress that Kusalananda is right:
1. you even need `'`, not only `"`, here, lest you want a few special characters to become problems,
2. even turning off globbing doesn't help against event/ redirect characters; since every Youtube URL will contain `&`, you better just configure your shell to automatically replace pasted `&` within a string (not at end of line) by `\&`; my zsh does that automagically, and I think I've got oh-my-zsh to blame for that.
|
stackexchange-unix
|
{
"answer_score": 1,
"question_score": 1,
"tags": "zsh"
}
|
Apache unable to write to files and folders on Fedora 16
I've recently installed Fedora 16 on a new PC, and I'm intending to use it for developing my websites. I've set up Apache to host multiple development sites on the machine.
Right now though, I am trying to install a PHP framework (Symfony2) and I'm unable to install it on to the web server. It comes back with an error saying that it's unable to write to the cache folder on the server.
I have checked and modified the folder so that it is writeable, but still the error keeps being displayed? What am I doing wrong?
|
Issues like these always seem to turn out to be SELinux. I'd try disabling it temporarily and see if that fixes it: `sudo setenforce 0`
I personally leave SELinux off right now; I'm developing with an oracle DB in a php program, and SELinux is horrible with php-ociconnect. Oracle's recommended solution is actually to turn it off. ociconnect has a similar issue to what you are having, exept for there's no errors during install, it just fails to install. It also won't start the module with it enabled when httpd is sta Security-wise that's probably not good, but I just haven't had the time or the need to make oracle play nice with SElinux
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "permissions, apache http server, fedora 16"
}
|
Do AWS Registered Domains support more than 6 Name Servers?
Does AWS support more than 6 name servers for a single domain? The UI (see attached image) appears to reject more than 6 name servers for a domain when trying to add a 7th. Google Cloud seems to allow up to 12. Is this intentional? Are there other methodologies or workarounds?

array([[1, 0, 1],
[0, 0, 0],
[1, 0, 1]])
I want an equal sized matrix where each element represent how many adjacent number it has. For the above matrix (both vertical and horizontal), it would be
array([[3, 5, 3],
[5, 8, 5],
[3, 5, 3]])
|
Implementation of @jaghana suggestion
x = np.array([[1,0,1], [0,0,0], [1,0,1]])
y = np.full_like(x, fill_value=8, dtype=int)
y[:, (0, -1)] = y[(0, -1), :] = 5 # edges = 5
y[(0, 0, -1, -1), (0, -1, 0, -1)] = 3 # corners=3
array([[3, 5, 3],
[5, 8, 5],
[3, 5, 3]])
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "pandas, dataframe, numpy"
}
|
How do I make html-like code in an XML file, so I can make things bold or bulleted, for instance?
I have some files in XML, within a forum that is .net 4 / c#. In particular, part of the English.XML file dictates the input of an e-mail that is sent to clients once they're approved for forum use.
I now know you can't use things like:
<b> or <ol><li> tags
in an XML file, because when I try, it doesn't work. So if I wanted to make text in an e-mail come out in **bold** , and if I want to **bullet a list** , **how would I do so in an XML file**? And if I do make a change, is there a way to prevent it from looking strange if the client doesn't have html e-mail enabled in their e-mail program? Thanks for any guidance you can offer!
|
As long as you can keep the format in valid XML format should be fine. For example
<b>Bold</b>
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
The above markup are both valid XML and HTML.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "asp.net, xml, email"
}
|
how virtual addresses assigned?
Take this C code for example
#include <stdio.h>
#include <stdlib.h>
int main() {
int x;
int* y = (int *) malloc(10*sizeof(int));
printf("%p\n",&x);
printf("%p\n",y);
printf("%p\n",&(y[1]));
while(1);
return 0;
}
Which will print virtual addresses that look something like this
0x7ffd4e96d214
0x908010
0x908014
The virtual addresses will be different every time you run the binary file which made me think how the virtual address are actually decided for a program ?
|
This is - probably - the effect of ASLR.
The decision should - as the name Address Space Layout Randomization tells - be random.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "c, operating system, virtual address space"
}
|
Automatically assign keyboard hotkey to application at startup?
## Background
My laptop keyboard is busted, so I use a USB keyboard. This keyboard has no designated calculator hotkey (such as Fn + Num Del on my laptop keyboard), so I like to assign my own (Ctrl + Num Del) under Start Menu → Calculator → Properties → Shortcut key. However, now and again (I believe on system reboot, but I haven’t checked for certain) this shortcut key is reset and I have to reassign it, which I end up doing this several times a week, which gets tiresome.
## The Question
Is there a way to automate this process so that the desired keyboard hotkey is automatically assigned, either via an app that runs at startup, or a batch file (which could then be scheduled to run at startup), etc.?
Please bear in mind I am no expert and have zero programming/coding/CMD knowledge, which is why I ask here. Thanks.
|
There is a free and open source software called `Clavier+`. It allows you to create new keyboard shortcuts.
You can install it from here. [<
Here is a screenshot of the application with keyboard shortcut creation.
 and the quantity demanded falls from 55 to 45 ($\frac{-200}{11}$% fall). So it should have an elasticity of $E=-0.27$ approximately. Simple application of the formula I was given, nothing crazy. This is exactly the same procedure for what is being done here.
However, the right answer was $-0.4$... After a quick look on internet, this seems to be the **arc** price elasticity of demand : $$E=\frac{(Q_1-Q_0)(Q_1+Q_2)}{(P_1-P_0)(P_1+P_0)}=\frac{(45-55)(45+55)}{(20-12)(20+12)}=-0.4 $$
So these two concepts are different things right ?
|
They are both related concepts and they are both price elasticities.
Price elasticity can be derived at a single point, for that we would use the point price elasticity of demand formula:
$$e= \frac{dQ/Q}{dP/P}= dQ/dP \cdot P/Q $$
An alternative to point elasticity is the arc elasticity which tells you what the elasticity is between the two points.
This is usually calculated using the midpoint formula.
$$e = \frac{(Q_2-Q_1)/((Q_2+Q_1)/2)}{(P_2-P_1)/((P_2+P_1)/2)}$$
If someone just states calculate price elasticity of demand it could be either the point or arc method, depending on context.
|
stackexchange-economics
|
{
"answer_score": 1,
"question_score": 3,
"tags": "microeconomics, elasticity"
}
|
JSONP не работает
Отправляю запрос следующим образом:
$.ajax({
url: 'Адрес сайта (кроссдоменный запрос)',
dataType: 'JSONP',
jsonpCallback: 'callback',
type: 'GET',
success: function (data) {
console.log(data);
}
});
В ответ получаю **JSON** : **{TEST: "TEST_MESSAGE"}**
Но в консоли браузера пишет: **Uncaught SyntaxError: Unexpected token :**
Как решить данную проблему и получить уже ответ в виде JSON, ну а потом соответственно распарсить его?
**Запрос кросдоменный**
|
**Небольшое отступление**
JSONP предполагает, что данные, возвращаемые с сервера оборачиваются в специальную функцию, имя которой передается на сервер в параметре `callback`.
Например, если клиент отправил на сервер JSONP запрос
GET www.example.com/something.php?callback=foo123
То сервер должен вернуть вот такой документ:
foo123({"test": "data"});
обратите внимание на функицю `foo123`
* * *
Если говорить о вашей проблеме, то конструкция
{TEST: "TEST_MESSAGE"}
является корректным JSON сообщением, однако это не JSONP (нет оборачивающей функции).
Как следствие, единственный способ решить вашу проблему -- дорабатывать ответ сервера.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery"
}
|
how to read hex in java to integer
This maybe is a simple question but I couldn't find an answer .
I'm trying to read the hex `7B`, and convert it to it's decimal integer (123), or at least receive the string `7B`.
my code :
byte[] content = new byte[numCharsToRead];
while ((numBytesRead = bufferedInputStream.read(content, 0,
numCharsToRead)) != -1) {
String temp=new String(content);
Log.d("RS232",""+temp);
output in logcat :
!enter image description here
|
You can try something like the following for converting to `int`:
String hexDigits = "7b"
int intValue = Integer.parseInt(hexDigits, 16);
Also, the reading part can be simplified to:
String temp;
while( (numBytesRead = bufferedInputStream.read(content, 0,
numCharsToRead)) != -1){
temp = new String(contents, 0, numBytesRead);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "java"
}
|
Salesforce Composite Connector Query Limitation
Suppose I'm using the Salesforce Composite Connector in Mule to query 3 different objects in Salesforce, What are the limits to the number of records returned by each query?
|
The connector doesn't impose limits. The limits are the ones defined by Salesforce for queries: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "salesforce, mule"
}
|
categorize by groupby-SQL
I have a table called list_details
listId tier
1 5
1 5
1 6
2 4
2 5
I want the following result:
listId tier
1 5(2), 6(1)
2 4(1),5(1)
I tried the following query:
SELECT ld.listId,count(ld.tier)
from list_details ld
group by ld.listId
and it gives me :
listId tier
1 3
2 2
But I dont know how I can put the condition or... to categorize based on the tiers.
Any help is appreciated
Thanks Mike:
Your query result is:
ListId tierData
1 5(2), 6(1), 4(1),5(1)
But I want:
listId tier
1 5(2), 6(1)
2 4(1),5(1)
|
I am assuming that you don;t really need the response in the format of `5(2), 6(1)` or if you did need that format for display, you could provide that format in teh application layer.
You should simply add multiple groupings:
SELECT
listId,
tier,
COUNT(1) AS `tierCount`
FROM list_details
GROUP BY listId, tier
ORDER BY listId ASC, tier ASC
If you need that EXACT text result, you can do something like this:
SELECT
a.listID AS listID,
GROUP_CONCAT(
CONCAT(
a.tier,
'(',
a.tierCount,
')'
)
) AS tierData
FROM (
SELECT
listId,
tier,
COUNT(1) AS `tierCount`
FROM list_details
GROUP BY listId, tier
) AS a
GROUP BY listID
ORDER BY listID ASC
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql, sql"
}
|
Is there a way to generate getters and setters in C# for a sql database?
I have a local database and I want to be able to retrieve and insert data into it from C# files. I have read about the INSERT INTO and SELECT FROM SQL commands, but what I want to do is create C# functions that I can call to insert, edit, and retrieve information from the the database. For example:
public void InsertAccountData(string Usrname, string passwd)
{
INSERT INTO Account(Username, password) VALUES(Usrname, password);
}
I have tried to find an answer, but have not found a solid solution. How would I do this is C#?
|
public void InsertAccountData(string Usrname, string passwd)
{
string qry = string.format("INSERT INTO Account(Username, password) VALUES('{0}','{1}')", Usrname, password);
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(qry, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",
reader[0], reader[1]));
}
}
}
This is how normally we access the DB. Current example is for MSSQL. <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, mysql, database"
}
|
list.get().method generate cast exception
I have written a code like this to fetch data from database using HQL:
Query qr=sess.createQuery("select i.contract_Vcode,i.installment_date from Installment i where i.vcode=:instalVcode").setParameter("instalVcode", installVcode);
qr.getNamedParameters();
List<Installment> li=null;
li=qr.list();
int coVcode=li.get(0).getContract_Vcode();
As I know the `contract_Vcode` is an integer. But when I want to run it, the followed error happens:
Error invoking Action using Hibernate Core Session / Transaction injection
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to information.Installment
More over when I want to see the exact element like this,
System.out.println("contract installDate is: "+li.get(0).getContract_Vcode());
Same error happens. How can I fix this?
|
You're currently only querying two parts of an installment. If you want to fetch the whole thing, I'd expect something like:
Query qr = sess.createQuery(
"select from Installment as i where i.vcode=:instalVcode")
.setParameter("instalVcode", installVcode);
If you fetch multiple properties (instead of whole entities), you just get back an `Object[]` for each row in the results.
So you could use your original query, but:
List<Object[]> li = qr.list();
int coVcode = (Integer) li.get(0)[0]; // 1st column of 1st row
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java"
}
|
Serve public executable from private GitHub repository?
I'm a contractor developing an app for a client and the code and exes are stored in a private github repository. They plan to sell the app through a WordPress-based store. I assumed or thought I read somewhere that files could be hosted on GitHub and in my tests it seemed to work – except it only worked because I was logged in to GitHub, with access to the private repo.
Is there some setting or "feature" on GitHub which will allow us to link to an exe (or zip) from another site or from a link in a "purchase confirmation" type email?
I've seen Hosting executable on github but it is quite old now and not really about private repos.
|
GitHub does allow you to host release assets as part of a release based on a tag, but these assets are controlled with the permissions of the repository. If the repository is public, then the release assets will also be public; if it is private, then they will also be private, with the same permissions of the repository.
If what you're trying to do is use GitHub with a custom access control system to allow only people who have purchased the software to download it, then that's not possible, and you'll need to set up your own server with the binaries. GitHub provides release assets so that folks can distribute binaries and other compiled stuff without needing to check them in, but it's not designed to be your CDN or web store.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "github"
}
|
Python: shutil.rmtree directory bug
im trying to get my %LOCALAPPDATA% path to work instead of hardcoding it, but it says it doesnt exist.
this works
dir_path = 'C:\\Users\\Hey123\\AppData\\Local\\Somefolder'
shutil.rmtree(dir_path)
but i want to use %LOCALAPPDATA% in my path, this is what im trying to get to work
dir_path = '%LOCALAPPDATA%\\Somefolder'
shutil.rmtree(dir_path)
it gives this error
|
`%LOCALAPPDATA%` is only valid syntax for use in cmd. That doesn't magically work in python. `'%LOCALAPPDATA%\\Somefolder'` is just `'%LOCALAPPDATA%\\Somefolder'` \- nothing more nothing less.
What you want, is `os.environ`, since `LOCALAPPDATA` is an environment variable-
dir_path = os.path.join(os.environ['LOCALAPPDATA'], 'Somefolder')
That will construct the directory path nicely for you
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, python 3.x, python 2.7, shutil"
}
|
Two upvotes for answer with obvious errors?
Just answered a really simple question. Someone else answered:
SELECT j.job_id, j.name AS job_name, a.name AS advertiser_name, j.time_added, j.active, j.moderated
jobs j join advertisers a
WHERE a.advertiser_id = j.advertiser_id
There are two obvious problems that will prevent this approach from parsing: no FROM clause, and no ON clause after the JOIN.
Yet the answer has two upvotes. Am I missing something?
|
You _are_ missing the obvious.
People will upvote anything that "looks" correct and then move on. They either want to feel hotshot about being able to spot code at a second's glance and pass even quicker judgement or just want to sockpuppet some upvotes.
Maybe they'll realise their mistake (maybe) and then come post on Meta about how they should be able to retract or change their votes and how the vote window is too small unless the post is edited.
|
stackexchange-meta
|
{
"answer_score": 5,
"question_score": 3,
"tags": "discussion, specific question, up votes"
}
|
How to center align button in Semantic UI React?
how can I center align a button in Semantic UI React
I have tried several approaches, using Grid, Grid Row, but no success
import {Segment, Button,Label,Sticky,Grid,Container} from 'semantic-ui-react';
import React, {Component} from 'react';
const GeneralSupportSegment =() => (
<Segment>
<Label ribbon color="blue" size="large">Support</Label>
<Button>contact us</Button>
</Segment>
);
export default GeneralSupportSegment;
|
Would be nice if you could share what you tried to do.
One solution might be:
<Segment>
<Label ribbon color="blue" size="large">Support</Label>
<Grid>
<Grid.Column textAlign="center">
<Button>contact us</Button>
</Grid.Column>
</Grid>
</Segment>
You can see it working here: <
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 9,
"tags": "reactjs, semantic ui"
}
|
The probabilities (PMF) of a Zipf Random Variable Does not Add to 1
PIC
Graphically, why do their total probability not add to 1? Their PMF should add to 1. This is a distribution of a Zipf Random Variable Variable X
$$ p_X(k)={1\over c_Lk} $$ for $k=1,2\dots ,L$ where
$$ c_L=\sum^L_{j=1} {1\over j} $$ Then $$ P[X>k]=1-P[X≤k] $$
This last equations corresponds to the value of 1 at $X≤k=1$ !
|
The value of the function is $P(X>k)$ as indicated on the left side of the graph. So the function is not a PMF, which it would be only if the value was $P(X=k)$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 1,
"tags": "probability"
}
|
Why are brackets required to print type information of .?
To print the type information of `.` I use :
λ> :type (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
If I omit the brackets , causes an error :
λ> :type .
<interactive>:1:1: parse error on input ‘.’
The same is not true for other types :
λ> :type 1
1 :: Num a => a
λ> :type (1)
(1) :: Num a => a
λ> :type True
True :: Bool
λ> :type (True)
(True) :: Bool
Why the special behavior for `.` ?
|
`.` without the parentheses only works in infix position. `:t` however takes an expression, e.g. a function, and to turn an infix operator symbol into an expression, you need to surround it with parens.
Consider:
3 + 4 = (+) 3 4 -- pseudocode
and
myPlus = (+)
which is the same as
myPlus a b = a + b
myPlus a b = (+) a b
And it applies equally to all other infix operators such as `*` or `>>=` or `&&&` etc.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "haskell, syntax, parse error"
}
|
How to install Xubuntu alongside Ubuntu Mate
I love both of these distros and I want them both. But I have no idea how you would do that. I bought a Ubuntu Mate cd which I used to install Mate but I also have a usb stick and I want to use that to install Xubuntu. How would I do that?
|
1. Obtain an image for Xubuntu
2. Verify the hash is correct
3. Apply the image to a media that you can boot from (Optical or Flash)
4. Boot from the live media - Choose Try Xubuntu
5. Select Install Xubuntu
6. When prompted, do as Zanna suggested in her comment and Choose the "Install Alongside" option.
Note: **This approach will work with any flavor of Ubuntu - Simply substitute the flavour of your choice for Xubuntu**.
Another option would be to add the XFCE dekstop environment to your current installation and choose desktop environments at login rather than dual-boot.
|
stackexchange-askubuntu
|
{
"answer_score": 4,
"question_score": 2,
"tags": "usb, xubuntu, live cd, mate, ubuntu mate"
}
|
How to search users globally on a multisite install?
I'm using the REST API to create/update/delete users on a multisite install in order to sync data with a 3rd party resource. When I am checking whether to update or create a user, I'm using the `search` parameter to search on usernames, which works fine on a single site, but if a user exists in the system on a different site, how can I tell beyond trying the insert, which triggers a _Username is already in use_ error? I've found this proposed change, which looks to be exactly what I need, but it hasn't made it into code yet. How can I achieve this? I don't mind writing a custom endpoint and doing it in PHP, but I can't find any functions that allows searching globally for users. Even `WP_User_Query` appears limited to one blog at a time.
|
It appears you can do this using a `blog_id` of `0`:
$args = array( 'blog_id' => 0 );
$users = get_users( $args );
var_dump( $users );
If you want to search for a specific user, the process is similar:
$args = array( 'blog_id' => 0, 'search' => '{username to search for}' );
$users = get_users( $args );
var_dump( $users );
I discovered this while poking around in the `wp-cli` source code (since I knew that `wp user list --network` would return a list of all the users on a Multisite network). It's corroborated by a user comment on the `WP_User_Query::prepare_query()` documentation.
|
stackexchange-wordpress
|
{
"answer_score": 3,
"question_score": 1,
"tags": "multisite, users"
}
|
Crontab not working (standard troubleshooting done)
SHELL=/bin/bash
* * * * * /home/VI/vserver/jira_extractor/bash_scripts/cronbg.sh
* I edit crontab with `crontab -e` as a local user.
* Cron is running `root 7296 1 0 17:28 ? 00:00:00 /usr/sbin/cron -f`
* My script runs when using exactly the same path as specified in the crontab
* There is an empty line at the end of the crontab script.
* I have specified that crontab will run in bash shell
Any hints on trouble shooting will be greatly appreciated
|
In my case, adding the environment variables in the bash scripts to my crontab file solved the problem
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "bash, ubuntu, cron"
}
|
Converting lines in chunks into tab delimited
I have the following lines in 2 chunks (actually there are ~10K of that). And in this example each chunk contain 3 lines. The chunks are separated by an empty line. So the chunks are like "paragraphs".
xox
91-233
chicago
koko
121-111
alabama
I want to turn it into tab-delimited lines, like so:
xox 91-233 chicago
koko 121-111 alabama
How can I do that?
I tried `tr "\n" "\t"`, but it doesn't do what I want.
|
$ awk -F'\n' '{$1=$1} 1' RS='\n\n' OFS='\t' file
xox 91-233 chicago
koko 121-111 alabama
### How it works
Awk divides input into records and it divides each record into fields.
* `-F'\n'`
This tells awk to use a newline as the field separator.
* `$1=$1`
This tells awk to assign the first field to the first field. While this seemingly does nothing, it causes awk to treat the record as changed. As a consequence, the output is printed using our assigned value for `ORS`, the output record separator.
* `1`
This is awk's cryptic shorthand for print the line.
* `RS='\n\n'`
This tells awk to treat two consecutive newlines as a record separator.
* `OFS='\t'`
This tells awk to use a tab as the field separator on output.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 5,
"tags": "csv, awk, sed, newline"
}
|
python post request using PIL Image
`<PIL.WebPImagePlugin.WebPImageFile image mode=RGB size=1600x1600 at 0x1F4E779BA00>` this is the file type when I do a post request I get this error `TypeError: a bytes-like object is required, not 'WebPImageFile'` . How do I convert it to a bytes-like object?
|
By saving it into some file format. You can't just push abstract pixels over the wire :)
This example assumes the remote end can accept PNG files.
import io
image = ... # However you get your image
bio = io.BinaryIO() # `BinaryIO` is essentially a file in memory
image.save(bio, format="PNG") # Since there is no filename,
# you need to be explicit about the format
bio.seek(0) # rewind the file we wrote into
requests.post(..., files={'file': bio})
To send a filename to the API too, you'll need to specify the file as a tuple.
requests.post(..., files={'file': ('image.png', bio)})
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, image, post, python requests, python imaging library"
}
|
How to bend a short piece of EMT conduit?
I need to make a 10 inch wide U type bend on a 1/2 inch EMT pipe. The piece is about 20 inches long. I got one end to bend 90 degrees fine. But I'm struggling with the other end. I got it probably at around 65 degrees and it won't bend any further. There is no lever. It just kind of rolls over at this point.
Any tips or tricks on how to get the second end to 90 degrees?
**EDIT:** I am using the klein bender tool. This is for electrical. I got a tip of a pipe sticking out and a box is about 10 inches away from it. The pipe is drywalled in. I can't get to it unless I start breaking the drywall. Another way would be to run a flex and be done with it. But I had this piece of conduit EMT which looked like it could get the job done. So just wondering, how can I get that perfect U out of it. It seems to be too short.
|
The general trick is to bend and then cut, rather than starting with a short piece that limits your ability to work the bender. You need a certain amount of "stub" for the bender to hold onto.
If you have enough to grab with the bender, but are having trouble controlling the tiny thing as you bend, which I infer from:
> It just kind of rolls over at this point.
Then clamp the bend on the other side in a vise to hold the bottom of the U upright, or hold it between two clamped boards if you lack a vise.
|
stackexchange-diy
|
{
"answer_score": 2,
"question_score": 0,
"tags": "electrical, wiring, conduit, emt"
}
|
Is inline JavaScript good or bad?
I've currently switched from WordPress to Yii framework and an external developer is rebuilding my site.
One thing I notice is that each time he invokes AJAX / jQuery the Yii way, it embeds ~~inserts JavaScript inline~~ in the web page. Although it seems the JavaScript code is placed below the footer, it's still inline.
In general, it seems that JavaScript code is more frequently being put inside the webpage. I've always been thought that JavaScript scripts should, as much as possible, be placed in JavaScript files. Is this a coming "new" trend? Or should I still try to keep JavaScript code in separate files?
|
Inline JavaScript increases download times for the page, which is not good. With a call to a `.js` file, at least these can be parallel calls and content download times decreased. Yes there are times where it is okay to put JavaScript directly in the HTML code, but you are often better off off-loading this as much as possible.
Keep in mind that page download times (that is, the HTML) and not all the resource calls affect the metrics that affect ranking (albeit as PageRank or in the SERPs it does not matter). The point is, it affects a sites performance for SEO however it manifests.
|
stackexchange-webmasters
|
{
"answer_score": 15,
"question_score": 20,
"tags": "html, javascript, inlining"
}
|
How do you use max_by with an enumerable if you need to filter out values?
How would I do this? Right now it's creating nil values when user is male, and then the <==> operation is failing.
@user.max_by{|user_id, user| user.height if user.female?}
|
You can chain these together, so do your selection before your aggregation
@user.select{|user| user.female?}.max_by{|user_id, user| user.height}
Also, you should be able to simplify (just a little syntax sugar):
@user.select(&:female?).max_by(&:height)
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "ruby on rails, ruby"
}
|
"Anonymous Animals" in Google Drive: for not-yet-accessed shared file?
I recently used Google Drive to share a file with `Anyone with the link` _("Anyone who has the link can access. No sign-in required.")_ , but did **_not_** yet distribute the link to anyone. Thus, I cannot imagine how anyone might be accessing this file yet.
When I double-checked what exactly recipients of the link will see, I was surprised to find "Anonymous Auroch" and a bunch of other weirdly-named critters visiting this page together with me.
A quick Google-search turned up some explanations on Blogger and on TechCrunch.
But these did not help me understand. Are there indeed anonymous users viewing this file that I have shared? How can this be, if I did not yet publicize the link?
|
One possibility is that the other "Anonymous" visitors are actually you visiting the page multiple times. Since it does not require authentication, it typically leaves people as anonymous until they do something that identifies them.
|
stackexchange-webapps
|
{
"answer_score": 6,
"question_score": 5,
"tags": "google drive, google drive sharing"
}
|
Time complexity of a loop with few operations
It is known that a while-loop(Ex: `while(n--)`) or a for-loop(Ex: `for(i=0; i<n; i++)`)'s time of execution depends on the variable n, i.e. `O(n)`. Also, on an online judge, 10^7 operations ≈ 1s. But I tried executing a while-loop and a for-loop for `n > 10^9` with few operations and it seems to run easily under 1 sec. I am curious why this is happening?
#include <iostream>
using namespace std;
#define ll long long
int main(){
ll t = 1e18;
ll cnt = 0;
while(t--){
cnt++;
}
cout << cnt << '\n';
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
Output: 1000000000000000000
Time elapsed: 0.003174 s.
|
The code you write is not instructions for your cpu, but instructions for your compiler to generate instructions for your cpu. In this specific case it is rather simple to see that this
long long t = 1e18;
long long cnt = 0;
while(t--){
cnt++;
}
cout << cnt << '\n';
can be replaced by
long long cnt = 1e18;
cout << cnt << '\n';
without altering the observable behavior of the program.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "c++"
}
|
React-native JSON files being cached?
I am reading json files into a react-native app using require. For example:
**myfiles.json:**
const myfiles = {
one: require('./files/one.json'),
two: require('./files/two.json'),
three: require('./files/three.json')
}
export myfiles
However, I have updated my JSON files and the updates are not showing in the IOS simulator. I have tried closing the simulator and running `react-native run-ios` but it is still showing the old data from the JSON files.
Are these being cached somewhere? If so, where? What do I have to do to see the updates?
|
I suggest these ways to reset emulator and clean iOS build if you use xcode:
* To reset the iOS simulator and erase all simulator data go to menu and Hardware -> Erase All Content and Settings
 bind to one model property
i want to put two radio buttons (witch are in one group) and bind the choice to one model propery.
my model has this property:
public bool is_active { get; set; }
my unsuccess try in view was:
@{ Html.RadioButtonFor(m => m.is_active, true )} active
@{ Html.RadioButtonFor(m => m.is_active, false)} inactive
|
You code needs to be
@Html.RadioButtonFor(m => m.is_active, true)
@Html.RadioButtonFor(m => m.is_active, false)
Without the leading `@`, the `RadioButtonFor()` method is executed but its result is not output (wrapping it in a `@{ .. }` code block does not do that and is unnecessary)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "asp.net mvc"
}
|
How to print with inline if statement?
This dictionary corresponds with numbered nodes:
{0: True, 1: True, 2: True, 3: False, 4: False, 5: False, 6: True, 7: True, 8: False, 9: False}
Using two print statements, I want to print marked and unmarked nodes as follows:
* Marked nodes: `0 1 2 6 7`
* Unmarked nodes: `3 4 5 8 9`
I want something close to:
print("Marked nodes: %d" key in markedDict if markedDict[key] = True)
print("Unmarked nodes: %d" key in markedDict if markedDict[key] = False)
|
You can use list comprehensions:
nodes = {0: True, 1: True, 2: True,
3: False, 4: False, 5: False,
6: True, 7: True, 8: False, 9: False}
print("Marked nodes: ", *[i for i, value in nodes.items() if value])
print("Unmarked nodes: ", *[i for i, value in nodes.items() if not value])
**Output:**
Marked nodes: 0 1 2 6 7
Unmarked nodes: 3 4 5 8 9
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 7,
"tags": "python, dynamic, printing, inline"
}
|
Select configuration file on creating WCF proxy instance
Is it possible to create WCF proxy by the given config file, not app.config?
Thanks a lot!
|
**Here** 's a thought
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "wcf, .net 3.5, configuration, wcf client"
}
|
using diagonals of the a trapezoid inside a triangle you can find the midpoint of the bases
In the following triangle, AB is parallel to DE. F is an intersection point of the segments BD, AE and CG. Is it true that AG = GB? .fadeOut(1000)">Убрать</button>
<button id = "show" onclick="$('#polska').fadeIn(1000)">Показать</button>
</div>
.animate({opacity:0},1000);">Убрать</button>
<button id="show" onclick="$('#polska').animate({opacity:1},1000);">Показать</button>
</div>
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, html, jquery, css"
}
|
Lambda expression Contain () method does not work in Advantage Database 9?
I am using Sybase Advantage Database 9.1
and I try to use Lambda expression Contain method to retrieve data ,but it does not work.
var order = order.Where(x => x.name == "James");
it return 10 rows data.
but If I change to
var order = order.Where(x => x.name.Contains("James"));
it return 0.
x.name is string field.
anybody know why it happened?
How should I do to use Contain method?
thanks
|
I believe that support for the canonical function `Contains` was added with changes for Entity Framework v4. That was in Advantage v10.x. Those changes were not merged back into the v9.x branch.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "lambda, advantage database server"
}
|
Scala can't find method even after import
I have been given a test in Scala:
import java.nio.file._
import PathImplicits._
import java.io._
test("Paths should have a .write method to create files") {
val p = Paths.get("test.txt")
val contents = "This should write a file"
try {
p.write(contents)
assert(new String(Files.readAllBytes(p)) == contents)
}
finally {
Files.deleteIfExists(p)
}
}
However when I run it, I get an error:
value write is not a member of java.nio.file.Path
[error] p.write(contents)
Which import am I missing? I thought that `java.nio.file._` would cover that.
|
There is no write method for both Path and Paths classes. I think you are looking for `java.nio.file.Files.write` method. Here is how to fix your code:
test("Paths should have a .write method to create files") {
val p = Paths.get("test.txt")
val contents = "This should write a file"
try {
Files.write(p, contents.getBytes) // consider using a charset here
assert(new String(Files.readAllBytes(p)) == contents)
}
finally {
Files.deleteIfExists(p)
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "scala, import"
}
|
Get letter corresponding to number in e (IEEE 1646)
I want to convert from integer values to string characters as follows:
`0` to `"a"`
`1` to `"b"`
and so forth up to
`26` to `"z"`
Is there a way to do this in _e_ without a big case statement?
Note: `e` is strongly typed and it isn't possible to do any type of arithmetic on string values. There also isn't any `char`-like type.
Another node: To all you C/C++ hotshots who keep down-voting my question, this isn't as easy a problem as you might think.
|
You can do something like this:
{0c"a"+my_num}.as_a(string)
`0c"a"` denotes the ASCII value of the letter 'a'. And an `as_a()` conversion of a list of numbers (actually, bytes) into a string creates a string where each character has the ASCII value of the corresponding list element.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "specman, e"
}
|
what are the components to ensure secure execution of code
In interview, interviewer asked me one question that, What are the components to ensure secure execution of code in .net. I tried in google but failed. Can any one give me the answer or link?
I found one word document. In that I found that components of secure code execution are Assembly loader, code verifier, JIT. Is this correct?
|
Have a look at the CLR security model. Microsoft has a good article about it.
Summary:
> The common language runtime of the .NET Framework has its own secure execution model that isn't bound by the limitations of the operating system it's running on. In addition, unlike the old principal-based security, the CLR enforces security policy based on where code is coming from rather than who the user is. This model, called code access security, makes sense in today's environment because so much code is installed over the Internet and even a trusted user doesn't know when that code is safe.
The Security Infrastructure of the CLR
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, .net"
}
|
Why i can not get this value in javascript?
Why I can not get this value in javascript ?
When I mouseover TEST , it's will alert `110`
Why not alert `111-1`
function xxx(value)
{
alert(value);
}
<div onmouseover="xxx(111-1)">TEST</div>
|
you have to put string in quotes
<div onmouseover="xxx('111-1')">TEST</div>
<script LANGUAGE="JavaScript">
function xxx(value)
{
alert(value);
}
</script>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -4,
"tags": "javascript"
}
|
Encoding string for apostrophe in asp.net
I am having a problem trying to resolve an apostrophe related issue.
I have searched SO, but could not find anything that would help me.
My clientside javascript code is:
var strUserText = uSettings.replace(/'/g, "'")
after the above line is executed, the form does a submit
document.form1.submit();
in code behind, a class retreives those values:
sUserSettings = request.form("strUserSettings ")
the result is a semi-truncated string.
Given the above code process flow, how can I save **"John O'Brady's ASP Blog"** in to a database?
I thought I was saving "John O'Brady's ASP Blog" but that isn't working.
|
Your question is quite vague. Why are you encoding the apostrophe? Is it breaking your output?
The best way to do it would be to submit your data AS-IS to the database... crappy JavaScript injection, apostrophe's, html markup, and all. Then you simply encode the output.
Server.HtmlEncode(strUserText)
Also, if you're using the latest version .NET, you can encode the output as follows
<%: strUserText %>
(assuming the strUserText string variable is set earlier in your view)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "javascript, asp.net, vb.net, apostrophe"
}
|
How to know if selection-screen is filled or not?
I have selection screen with **SELECT-OPTION** let say the name is `selection_kunnr` and I want to know if user filled that selection area or not
Note: this `selection_kunnr` is not a mandatory field. How can I deal with it?
I have tried so far
if selection_kunnr is not initial.
"do some action here
endif.
but I think it doesn't work at all.
Any suggestions?
|
SELECT-OPTIONS create an internal table (same as the RANGE statement) for a field. (It creates 4 fields: SIGN, OPTION, LOW and HIGH). You can check whether the table has any contents by using:
IF SELECTION_KUNNR[] IS INITIAL.
The [] operator specifies the contents (rows) of an internal table.
I am not sure anymore, because I am not in front of an SAP system right now, but if only the initial FROM/TO fields are filled, I am not sure whether this creates an entry in the table.
HINT: In the ABAP editor, you can place the cursor on any statement, and press F1 to get help on that statement.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "abap, sap selection screens"
}
|
Code Signing with VSTS and GitHub Sources
Like others I use GitHub for my open source projects. Now I want to use VSTS as build and release service instead of AppVeyor.
In future I want to sign all my NuGet packages.
but: where should I store my certificate file (pfx)?
* VSTS does not have a keyvault
* I do not want to store my pfx file on GitHub or any other public place
My Ideas
* I could store pem (base64) into a build var and create with openssl during the build the certificate (pfx)
* I could store the pfx file on a private and secured blob storage and download the pfx during the build
What is the best practise here?
|
Both your two ideas looks good for me. And since you are using VSTS which only support private repository, you can also create a private repository in your VSTS account to store the pfx file and then add a task in your build/release definition to get the file during the build/release.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "visual studio, nuget, azure pipelines, azure artifacts"
}
|
How do you setup project to use ini file in Developer Studio?
I use a ini file to setup fonts and colors (instead of the registry). I have linked the ini file like this:
Properties->ProgressOpenEdge->Startup parameters->
"-basekey ini -ininame C:\somepath\ini\progress11.ini"
If I make a small run file (and press run) the ini file is correctly loaded:
run start.w
But if I press run on the start file the ini file is not loaded (getting font errors). How to setup eclipse to load the ini file correct?
Edit: Had to have 2 more reputation to show images.
|
On the "run" button there's a "downarrow". Click on that, and then click on "run configurations" - that'll enable you to set the startup parameters for the run button.
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "eclipse, progress 4gl, openedge"
}
|
What is the difference between DVI-I and DVI-D
What is the difference between DVI-I and DVI-D? Which one is better?
If I buy a video card, which type is advisable to buy?
Very rarely I have even seen DVI-A. Where does that fit in?
|
`D` is digital-only. `A` is analog-only (and VGA compatible with a simple adapter). `I` is integrated, or both.
You rarely see `A` by itself; most of the time, if you get analog, it is included in `I`.
A card should provide `I`, in case you want to connect to a VGA monitor. But the monitor should support `D`, and you will often use a `D`-only cable.
|
stackexchange-superuser
|
{
"answer_score": 8,
"question_score": 4,
"tags": "dvi, graphics card"
}
|
Reading JSON Ajax response?
I have an ajax response from my server. Example below:
{"user_id":"93","status_message":"Cool Status","timestamp":"1305648702"}
I tried reading the response using:
var json = eval(response);
var userid = json.user_id;
The above does not seem to work though. Any ideas.
|
You should use the JSON parser that is built in to many browsers these days. If it's not available, you can use the JSON2 library, which provides the same interface, as a fallback.
var json = JSON.parse(response);
var userid = json.user_id;
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "javascript"
}
|
Add a line break after the title of an horizontal legend title
When `theme(legend.position = "top")`, the legend is horizontal and can be a bit too wide.
Here is an example:
library(ggplot2)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
geom_point() +
xlim(5,6) +
coord_fixed() +
theme(legend.position = "top")

In order to reduce the width of the legend, I'd like to add a line break after the "Species" title.
I'm aware of `guides(guide_legend(ncol=2,nrow=2,byrow=TRUE))`, it is very nice but it yeilds a different output.
|
We can use the `title.position` argument in `guide_legend` in `scale_colour_discrete`:
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
geom_point() +
xlim(5,6) +
coord_fixed() +
theme(legend.position = "top")+
scale_colour_discrete(guide = guide_legend(title.position = "top"))
;` and i wish to detect the esc key as well but i dont actually know what are the numbers that i should use so any help is appreciated.
#include <conio.h>
#include <stdio.h>
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
int c = 0;
_getch();
switch ((c = _getch())) {
case KEY_UP:
printf("Up\n");
break;
case KEY_DOWN:
printf("Down\n");
break;
case KEY_LEFT:
printf("Left\n");
break;
case KEY_RIGHT:
printf("Right\n");
break;
default:
printf("Null\n");
break;
each of the arrow keys is a combination of two characters of ascii code 224 and the defined ones (notice the first `_getch();`) but i dont know that for the escape key, i tried searching but didnt find them, a full list of those would be so helpful.
Thanks.
|
`Up,Down,Left,Right` is known as extended key and to detect them you have to read Two `Char` first one is `Null` and the second is the `ASCII` code but `ESC` is not extended key so you can detect it with only one `char`.
I hope that code will help you:
#include <stdio.h>
#include <stdlib.h>
#define esc 27
int main()
{
char ch;
do
{
ch = getch();
switch(ch)
{
case esc:
// your logic goes here
break;
}
}
while(exitflag != 1);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "c"
}
|
Ubuntu Software Center is crashing while trying to install psychonauts
I am having a problem installing Tim Schafers epic platform video game Psychonauts trough the Ubuntu Software Center.
I have bought the game on < and I have used the new redeem option introduced in this bundle: "redeem your bundle on the Ubuntu Software Center."
When I have downloaded approximately 2.1 GB of Psychonauts then Ubuntu Software Center starts to repeatedly crash and pop-up with a new crash report dialog every few seconds (before previous ones are closed and that will crash the computer after a few min, unless I stop the download).
I also have a file-size bug, where Ubuntu Software Center tells me that I have downloaded 880,2 MB out of 133,3 MB
I use the new Ubuntu 12.04 LTS and Ubuntu Software Center version 5.2.2.2 (©2009-2011 Canonical <\--- That is also a bug, should be 2012 I guess)
I hope someone can help me.
|
I had the same problem. Keeping ignoring the pop-up windows did not stop the installation. Psychonauts finally got installed and only at that moment I closed the Software Center and the bug windows.
|
stackexchange-askubuntu
|
{
"answer_score": 0,
"question_score": 1,
"tags": "12.04, software center"
}
|
How to apply CSS to "views-exposed-form--view-name.tpl.php"
I am theming a views exposed form which is a block. The views filters are displayed in a block and I am theming this using "views-exposed-form--view-name.tpl.php". I want to apply CSS to this template file.
How to do this.
|
You could add the CSS in `<style>` tags on top of your template. Most browsers will probably understand what you want, it does result in ugly HTML though.
You could also add the CSS in your main CSS file and use .view-id-viewname .div (etc.) to target elements specificaaly in that view
|
stackexchange-drupal
|
{
"answer_score": 1,
"question_score": 1,
"tags": "7, views"
}
|
Chrome Dev Tools - Unable to map network file to local file
In Chrome Dev tools, I am no longer able to map a localhost network file to the local source file for saving changes to disk. The problem occurs when I click on Map to file system resource.... It does not populate the next screen with local file choices as it used to. Any help or hints are much appreciated.
|
You should delete the "?ver=4.7.2" - these are query parameters which confuse the search for local files.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "google chrome, google chrome devtools"
}
|
Gimp - fast switching to eraser
I've been searching for this but all I find are annoying tutorials on how to click the eraser button.
Whenever I switch to the eraser it keeps the tool size I was using for the pencil, I'd really like it if it didn't.
|
Uncheck brush option in **Edit- Preferences - Tool options- Paint options shared between tools**
|
stackexchange-graphicdesign
|
{
"answer_score": 3,
"question_score": 1,
"tags": "gimp"
}
|
Rotating a path for a CAAnimation
I'm animating some stuff using CAAnimation, & it involves making a fairly complex path using CGPathAddCurveToPoint, maybe 10 - 15 of these per path. Is there a way, instead of recalculating every curve, I could just rotate the whole path once it's built? I don't want to rotate the whole graphics context, as it's just the animation path which needs to change.
(I've tried putting a CGAffineTransformMakeRotation into every curve element, but that just has weird effects, it's like it's not rotating the path as a whole)
Many thanks for any help!
|
You can apply a transform to the entire path, or to the drawing context.
See
- (void)applyTransform:(CGAffineTransform)transform
in the `UIBezierPath` documentation.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "objective c, path, rotation, caanimation"
}
|
What is the relation between $\int_1^\infty f<\infty$ and $\int_1^\infty f^2<\infty$ where $f\geq 0$?
What is the relation between $\int_1^\infty f<\infty$ and $\int_1^\infty f^2<\infty$ where $f\geq 0$?
The example $f(x)=1/x$ shows that ``$\int_1^\infty f^2<\infty$ implies $\int_1^\infty f<\infty$'' is wrong.
What about the converse statement? that is, whether ``$\int_1^\infty f<\infty$ could ensure $\int_1^\infty f^2<\infty$. Notice that here $f\geq 0$, and no decreasing assumption.
|
Let $f(x)=\frac 1 {\sqrt {x-1}}$ when $1<x<2$ and $0$ when $x \geq 2$. Then $\int_1^{\infty} f<\infty$ but $\int_1^{\infty} f^{2}=\infty$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "integration"
}
|
Executing Sql Server Stored Procedure and getting OUTPUT INSERTED value
I want to get inserted row key when inserting records.Then I wrote this Sample SQL SP.
CREATE PROCEDURE Temp
AS
BEGIN
SET NOCOUNT ON
insert into Farmer_landDetails
(oth_mas_key,
fmr_key,
anim_typ_key,
anim_count,
land_type_key,
land_availability) OUTPUT INSERTED.oth_det_key values(1,1,1,1,1,1)
END
GO
How to get this `OUT` value with C# ?
|
The Output clause of your StoredProcedure returns a single row with a single value.
So the correct method to get its result is through the ExecuteScalar method of an SqlCommand
using(SqlConnection cnn = new SqlConnection(....))
using(SqlCommand cmd = new SqlCommand("Temp", cnn))
{
cnn.Open();
cmd.CommandType = CommandType.StoredProcedure;
int result = Convert.ToInt32(cmd.ExecuteScalar());
}
Notice that I have no idea what datatype is `oth_det_key`. I assume an integer hence the Convert.ToInt32() on the return value of ExecuteScalar
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c#, sql server"
}
|
Displaying only a part of a line in Bash
I have a line of data. It contains both words and numbers.It is
15 F= -.33052537E+03 E0= -.33051414E+03 d E=.720942E-05 mag=24.6037:3
I need to extract the value -.33052537E+03 from this line.
|
### Using `bash`
$ read one two three rest <<<' 15 F= -.33052537E+03 E0= -.33051414E+03 d E=.720942E-05 mag=24.6037:3'
$ echo "$three"
-.33052537E+03
### Using `awk` and `bash`:
$ awk '{print $3}' <<<' 15 F= -.33052537E+03 E0= -.33051414E+03 d E=.720942E-05 mag=24.6037:3'
-.33052537E+03
### Using `sed` and `bash`:
$ sed 's/.*F= //; s/ E0=.*//' <<<' 15 F= -.33052537E+03 E0= -.33051414E+03 d E=.720942E-05 mag=24.6037:3'
-.33052537E+03
### Using GNU `grep` and `bash`:
$ grep -oP '(?<=F= ).*(?= E0=)' <<<' 15 F= -.33052537E+03 E0= -.33051414E+03 d E=.720942E-05 mag=24.6037:3'
-.33052537E+03
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linux, bash, unix"
}
|
Encog C# PNN does it even works?
I try PPN network in Encog:
PNNOutputMode mode = PNNOutputMode.Regression;
BasicPNN network = new BasicPNN(PNNKernelType.Gaussian, mode, 10, 1);
TrainBasicPNN train = new TrainBasicPNN(network, dataSet);
train.Iteration();
I thought class GlobalMinimumSearch in TrainBasicPNN should find optimal sigma. But if I look at sigmas after training, they have all the same value 0.001 which is very low and network doesnt predict correctly on new data (I get outputs which are all the same). If I try predict on training dataset then it works correctly, beacuse vectors are the same as centers in PNN and low sigmas are not a problem. I even tried to change starting low sigma:
train.SigmaLow = 3;
This is gave me final sigmas something like 0.004, which is still low. What am I doing wrong?
|
More about this bug < Bug is in both versions (C# and Java).
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "encog"
}
|
select file(s) with certain extension from disk
let's say that I want to check certain file exist on file system and I want to check if that file exist with certain file extension (those are image file extensions).
This file will always have string prefix `thumb-` followed with dynamic id value of type int.
I have
string[] fileExtensions = new string[] { ".jpg", ".png", ".bmp", "gif" };
I was thinking to use DirectoryInfo but I'm struggling with contains part
var f = from f in di.EnumerateFiles(string.Format("{0}{1}.*", "thumb-", id))
where f.Extension.Contains(fileExtensions)
select f;
obviously where f.Extension.Contains(fileExtensions) is where error is.
How to fix this?
|
Found a better solution:
var files = di.EnumerateFiles(string.Format("{0}{1}.*", "thumb-", id))
.Where(x => fileExtensions.Contains(x.Extension));
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, .net"
}
|
Disable future days at ui.bootstrap.datepicker Angularjs
I am using the datepicker of UI Bootstrap: (there is a Plunker there that disable the past dayswith a button).
Can anyone please help me to disable the future days without any button?
I tried change the function of the button like that, but it didn't worked:
`$scope.toggleMin = function() { $scope.options.minDate = $scope.options.minDate ? **new Date()** : **null** ; };`
And this is a button, I'd like to disable without a button.
|
Just set `maxDate` in `options` to the date you want to restrict to.
$scope.options = {
customClass: getDayClass,
maxDate: new Date(), // restrict maximum date to today
showWeeks: true
};
Otherwise, if you need to change it after the options are set you can just do:
$scope.options.maxDate = new Date(), // restrict maximum date to today
Here's the updated Plunker with days after today disabled: <
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "angularjs, ui.bootstrap"
}
|
Why doesn't $\pm a = \pm b \implies -a = b$?
The problem arises from $a^2=b^2$. Since each variables could be positive or negative it feels like all permutations should be valid equalities?
|
I think the problem lies in looking at $\pm a$ as some sort of object. $\pm$ is just a shorthand used. In reality, when you solve $a^2=b^2$, you say that $a$ and $b$ must have the same value squared, and that gives you your four solution pairs. There is no fundamental reason why a $\pm$ sign is used in equations like this. You just use it if the actual reasoning behind solving the equation permits it.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 1,
"tags": "algebra precalculus"
}
|
Is it possible to create the certificate to sign Apple Wallet Passes from a non-iOS system such as Ubuntu?
I'd like to create a certificate from Apple developer account and use it to sign Apple Wallet passes / passbook. So I can implement a server to generate the wallet passes to serve up my mobile app.
The challenge to me is I'm on linux (Ubuntu to be specific). There are a bunch of npm modules as far as I can see, that can be used to implement a server to generate the pass but the first step is to create a certificate from Apple. So my question is it seems to me that is not even possible without a Mac? Does anyone know if it is even possible to create that certificate from a linux machine like Ubuntu?
Thanks
|
You do not create the certificate yourself, you create a private key and certificate signing request and upload the certificate signing request to Apple. They then issue a certificate that matches your private key.
This can be done on any operating system using OpenSSL. When creating the CSR you can provide any values as Apple will ignore them and replace with the PassTypeIdentifier, Team Name and Team Id.
The OpenSSL commands you need are:
openssl genrsa -out /path/to/my-private-key.pem 2048
openssl req -new -key /path/to/my-private-key.pem -out /path/to/my-request.csr
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "ios, passbook, wallet, passkit"
}
|
Javascript uint32 math not working?
Something weird with uint32 math :
a = new Uint32Array([1103515245, 1103527590, 0]);
a[2] = a[0] * a[1];
console.log(a[2]);
Gives 2524872960, which is wrong I think, because in C :
#include <stdio.h>
int main() {
unsigned a[3] = { 1103515245, 1103527590, 0 };
a[2] = a[0] * a[1];
printf("%u\n", a[2]);
return 0;
}
Gives 2524872878 (and so does Windows Calculator)
So what's up with that? I'm using Firefox 45.0.1
**EDIT** : Oh and if that is expected, then how do I duplicate the "C" result?
|
That's because JS doesn't have an Integer type. So `*` does the multiplication in 64 bit floats. But these don't have enough precision for the result:
/* Exact math */ 1103515245 × 1103527590 = 1217759518843109550
/* JavaScript */ 1103515245 * 1103527590 === 1217759518843109600
Number.MAX_SAFE_INTEGER === 0009007199254740991
If you want to do integer multiplication, use `Math.imul`:
> The `Math.imul()` function returns the result of the C-like 32-bit multiplication of the two parameters.
a[2] = Math.imul(a[0], a[1]); // -1770094418
a[2]; // 2524872878
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "javascript"
}
|
Speeding up window resize function performance
I have some script similar to the following:
var breakpoints = [0,240,480,960,9999],
bpCount = breakpoints.length,
windowsize = 0;
window.onresize = function() {
windowsize = document.body.clientWidth;
for(var i=0; i<bpCount; i++) {
if(windowsize >= breakpoints[i] && windowsize < breakpoints[i+1]) {
doSomething(breakpoints[i]);
break;
}
}
};
However this seems to run pretty slowly, even in Chrome on a decent PC, and even when 'doSomething' is just performing a 'console.log', so I was just wondering if there was any better way of checking whether the screen size is between two values as it resizes?
Thanks
|
Don't poll for the size _every single time_. You're using way too much computing power.
Instead, make a timer and check for the size every so often (`10 ms` might be too fast):
var checkWindowSizeTimer;
function checkWindowSize() {
var windowsize = document.body.clientWidth;
if (windowsize >= breakpoints[i] && windowsize < breakpoints[i+1]) {
doSomething(breakpoints[i]);
clearInterval(checkWindowSizeTimer);
}
}
window.onresize = function() {
checkWindowSizeTimer = setInterval(checkWindowSize, 10);
}
When the window is resized past your bounds, the timer exits.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "javascript"
}
|
Saving form results to a CSV - Rails
I'm trying to save the results of a survey to a csv file, so every time the survey is completed it adds a new line to the file. I have code that exports database rows to a csv and lets you download it, but i don't know how to incorporate saving the survey to begin with, or if this is even possible? I have a csv file set up with the correct headers.
|
When your `create` function is called (the action in controller where form’s submit is directed to; create on REST controllers), you can just add some custom logic to there to convert the data from form into csv structure you want.
Ruby has CSV module builtin, which can be used to both read and write CSV files.
So you want something like following
require "csv"
CSV.open "output.csv", "a+" do |csv|
# example logic from another script how to populate the file
times.each do |key, value|
csv << [ key, value ]
end
end
You just need to define structure of rows how you want, this example throws two columns per row.
EDIT: a+ makes file to be written from the end (new rows) rather than original w+ that truncates the files.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, forms, csv"
}
|
Is it possible to reverse-engineer my iPhone application?
I have created an iPhone application, and I want to send the compiled .app file to my client, so he can install and test this iPhone application on his device.
Is it possible that he can view the contents of this .app file, like the resource files used in this application (images, sound files, etc.)? Could he reverse engineer the source code used to build this application from the compiled product?
|
On OSX an Application Bundle is just a directory named `.app` with some special meta-data files about the application, and the application executables and its resources. Right clicking and picking `Show Package Contents` will show the entire contents of the `Application.app` directory.
Any file resources, images, sounds, properties filed, etc. that are not using some application specific encryption will be plainly accesible.
That said, the application code, if a native Objective-C application, will be compiled and not easily reverse engineered, it would have to be decompiled, and if stripped of debugging information would take a dedicated hacker to grok the assembly output and modify it.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 11,
"tags": "iphone, objective c"
}
|
Should I unit test the model returned by DefaultModelBinder?
I'm having some trouble unit testing the model returned by DefaultModelBinder. I want to feed in a fake form collection and check the model that it returns to make sure model properties are being bound properly. In my research, I'm not turning up -any- resources on testing the DefaultModelBinder. Maybe I'm missing something. Maybe I shouldn't be testing this part of MVC? Your thoughts?
|
Byron, I really think you shouldn't be testing this. You have to focus on your controller actions and the interactions they may have with other components, like services, etc. The default model binder has already been tested by the MS team (I hope so :P). Just assume your action parameters have correctly been populated with the form posted values by the default model binder and test the actions in your controllers with objects built by yourself. This is what I usually do and what I have seen everywhere.
Regards.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "asp.net mvc, unit testing, defaultmodelbinder"
}
|
IIS manager rewrite all URLS after mysite.com/
I'm trying to rewrite all the urls for my website. For example, if the user types in mysite.com/index.aspx it'll change the url in the top to www.mysite.com/index.aspx
Any suggestions?
|
Try this one
<rewrite>
<rules>
<rule name="Enforce canonical hostname" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.mysite\.com$" />
</conditions>
<action type="Redirect" url=" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "url, iis 7, url rewriting, iis manager"
}
|
how to include jar file for oozie
I am trying to a sqoop action in oozie, but mysql-connector-java.jar is not present in /user/oozie/share/lib/sqoop, because of no permission I am not able to add the jar as of now,
Is there any way or workaround to include mysql-connector-java.jar in workflow.xml
I have placed the jar in sqoop apps / lib directory, but its not working
|
In general, the Hadoop administrator should keep all the common library in Hadoop distribution to make the usage more efficient, if not, give a try to the following -jarfile option
sqoop import \
-libjars /file/location/path/mysql-connector-java.jar \
--connect jdbc:mysql://localhost:3306:3306/retail_db \
--username root \
--password xyzpwd \
--table order_items \
--target-dir /user/cloudera/landing_zone/sqoop_import/order_items
as per sqoop documentation:
-libjars specify a comma separated jar files to include in the classpath. The -files, -libjars, and -archives arguments are not typically used with Sqoop, but they are included as part of Hadoop’s internal argument-parsing system.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sqoop, oozie, oozie workflow"
}
|
Java: New Generation Used 100%, Eden Space Used 100%, From Space Used 100%
jmap -heap gives me output that says:
New Generation Used 100%, Eden Space Used 100%, From Space Used 100%, To Space Used: 0%, Perm Generation Used: 38%
Is this 100% of New, Eden, From space - a problem?
My JAVA OPTS are: _-Xms10240m -Xmx14336m -XX:PermSize=192m -XX:MaxPermSize=256m -XX:NewSize=8192m -XX:MaxNewSize=8192m -XX:-DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=60_
I see a lot of quick Garbage Collection. But no memory leaks using tools like JConsole
The Memory Usage can be seen here:
JDK 1.6 is in use.
|
Well that is how generational collection works. You have young space (eden, from, to) and old space (tenure, perm). Young space is smaller. Once young space is full (your case) - thing called minor GC (young GC) is happening.
But minor GC should be quick. Once old space is full full GC is happening (which is more time consuming).
Idea is to have more frequent fast minor GCs and much less frequent full GCs.
You can read much more detailed explanation in this article
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 6,
"tags": "java, memory, garbage collection, heap memory, jmap"
}
|
binding to an object returned by a service function
I have the following function in an Angular service:
this.getTasks = function() {
return $http.post(endpoint, params)
.then(function (response) {
console.log(response.data);
return response.data;
});
};
I then try to bind the return value to a variable in my controller by first executing the service function, and using .then() to assign it to a variable:
vm.getTasks = function() {
LocationGraphService.getTasks()
.then(function (response.data) {
vm.tasks = response.data;
});
}
This doesn't work. I know the service function works as the console.log shows me the data I'm pulling. I need help with calling the function in the controller and assigning it to a variable. Would $q be appropriate here?
|
Since your service normalizes response object to be `data` property of the original `response`, you don't need to do it one more time in controller. Correct controller logic would be:
vm.getTasks = function() {
LocationGraphService.getTasks()
.then(function (data) {
vm.tasks = data;
});
};
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "javascript, angularjs"
}
|
Iphone safari browser taking lot of time to render charts in a dashboard
I have developed a webpage containing charts using HighCharts. It works fine on the PC safari browser, but takes a long tim to load on an iPhone. What could be the issue?
|
propably the highcharts library. JavaScript on the iPhone is not nearly as fast as on a desktop. You should take a look at this:
<
Here you can see that the iPhone 2G was almost 65 times slower as the macbook. And also the iPhone 3GS and 4 are faster, they're not nearly as fast as a desktop computer.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, iphone, highcharts"
}
|
Native binding Xamarin.Mac
I am trying to make native binding for Webrtc.a native library on mac when I include the binding library as reference to my Xamarin.Mac project I get this error : /MMP: Error MM5109: Native linking failed with error code 1.
I followed all these steps <
|
You'll need to dig into the build details on your project to see the specific error. It means we invoked clang to build the native launcher and it returned errors (very likely associated to the native library being bound).
You can find the build log via: View -> Pads -> Errors then selecting the "Build Output" button.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c#, macos, xamarin.mac"
}
|
Expect: How to iterate over files in a directory?
The following is a bash script which iterate over .csv files within a directory. The question is, I now have an expect script `#!/usr/bin/expect` where I want to use the same for loop. How could I achieve that?
#!/bin/bash
for f in /path/*.csv
do
echo $f
done
|
You would write:
#!/usr/bin/env expect
foreach f [glob /path/*.csv] {
puts $f
}
Expect is an extension of Tcl. In addition to the `expect` man page, a link to the Tcl command documentation will be helpful: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linux, bash, expect"
}
|
Would a widower observe Yahrzeit after remarriage?
If a Jewish man's wife died, he would naturally observe the Yahrzeit on the anniversary of her death. Would he continue to do so if he remarried?
My question comes from reading about the Yahrezeit today for the first time (I am not Jewish). It sounds like a beautiful custom that acknowledges the deceased's impact on a person's life.
While thinking about the custom, I began to wonder if a remarried man would continue the tradition as his new wife might be angered and see him as holding onto the past. On the other hand, his continued observance might encourage his new wife with his loyalty and she would know that their life together will not be swept aside should she die before he does.
|
HaRav Yechiel Yaacov Weinberg says here that he should, since it's normal human behavior, and if the second wife dislikes it she actually stats that he lacks that normal etiquette RE-EDIT: actually, Hrav Ovadia Yalkut Yosef - Avlut 23 14 also state the same thing implicitly. he says that in reversed situation (where the wife wants to make a memorial to her first husbend) she may not if others are able to do it, but he says nothing about a widower and and his late first wife.
|
stackexchange-judaism
|
{
"answer_score": 3,
"question_score": 16,
"tags": "minhag, marriage, yahrtzeit"
}
|
How to make my own domain name like abc.def?
I have seen some domain names like < how could i get a domain name like that. any help?
|
You can't create your own top level domain. Here is a list where you can choose from.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "web, dns"
}
|
Calculate date for particular day in Teradata
How to calculate date for current week Friday in Teradata? I need a general function that can calculate date for friday for any week. thanks
|
In TD14 there's Oracle's `NextDay`, to get the next friday:
NEXT_DAY(CURRENT_DATE-1, 'FRI')
Before you can calculate it based on a function named `day_of_week` (or `td_day_of_week`):
(CURRENT_DATE + 7) - td_day_of_week(CURRENT_DATE + 1)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "date, datetime, time, teradata"
}
|
Arredondamentos para cima
Eu tenho a seguinte lista de dicionários e as values correspondem ao valor de média , por exemplo , no 1º aparece 4 , mas na verdade da 4,6666. Gostava de saber como e que se arrendonda , já tentei com o round , mas fica igual.
[{'Nome do Dono': 'Eva', 'Media de Idade': 4}, {'Nome do Dono': 'Ana', 'Media de Idade': 53}, {'Nome do Dono': 'Ada', 'Media de Idade': 12}]
|
import math
valor = 4.6666
valor_arredondado = math.ceil(valor)
print valor_arredondado # 5.0
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, csv"
}
|
getting specific index from sql
I'm trying to pull from my sql database without having to load it into a var and pulling the items I want with a for loop.
How can I get the 5 items in the 5th index " " 5 " " 10th index...
This is what I'm doing not it's way to hackish.
function get_db(a) {
index_count=a
db.transaction(
function(tx) {
var rs = tx.executeSql('SELECT * FROM Greeting');
var r=""
if (up_check === 0){
index_count = index_count +4
}
r += rs.rows.item(index_count).salutation + ": " + rs.rows.item(index_count).salutee + "\t\t"
})
return r
}
I'd ideally want to get something like
var rs = tx.executeSql('SELECT * FROM index_count (and the next for items) Greeting');
|
If you're SQL Server 2005 or above you can use ROW_NUMBER().
Something like this (freehand):
SELECT *, ROW_NUMBER() OVER(ORDER BY [youordercolumns]) AS [RowNum]
FROM [youtable]
WHERE [RowNum] BETWEEN @index AND @index + 4
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "sql"
}
|
Properties of quantum torus group
Let $G = \langle x,y,q ~|~ xy=qyx,~ qx = xq,~ qy=yq\rangle$ is an abstract group.
1) Does this group have a common name? ("quantum tori" is the name of a certain related algebra)
2) What properties it has?
3) In particular, what subgroups it has?
Thanks.
|
This is the integral Heisenberg group, the group of upper unitriangular integer $3\times 3$-matrices. It is nilpotent of class 2, and has many other properties. All subgroups can be described completely.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 9,
"question_score": 3,
"tags": "gr.group theory"
}
|
sql query doesn't give me all the months
I have a "customers" table with many columns. I need to use only two of them. date(the date that the customer was registerd), referrer( how did the customer find us: google or facebook or friends). I need for each month to show how many customers added by each referrer. for example: 2016-8 4 customers by facebook, 10 customers by friends and 13 customers by google). of course it should give me for each month the result in the example.
I tried this query - but it doesn't give me all the months only 2 of the months and one of them is being shown twice. can someone please review my query?
SELECT referrer,date, COUNT(`date`)
FROM `customers`
GROUP BY `referrer`;
|
Try this:
SELECT referrer,date, COUNT(date)
FROM customers
GROUP BY Year(date), MONTH(date), referrer;
If you want to select the output for a certain year you can try this:
SELECT referrer,date, COUNT(date)
FROM customers
WHERE record_date.YEAR = 2016
GROUP BY Year(date), MONTH(date), referrer;
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "mysql, sql"
}
|
Extract every element except every n-th element of vector
Given a vector
A = [1,2,3,...,100]
I want to extract all elements, except every n-th. So, for n=5, my output should be
B = [1,2,3,4,6,7,8,9,11,...]
I know that you can access every n-th element by
A(5:5:end)
but I need something like the inverse command. If this doesn't exist I would iterate over the elements and skip every n-th entry, but that would be the dirty way.
|
You can eliminate elements like this:
A = 1:100;
removalList = 1:5:100;
A(removalList) = [];
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 8,
"tags": "matlab, indexing"
}
|
Why this PHP code not working through XAMPP?
No matter what Bengali number I provide in `$ben_num` variable, it always outputs 1, like with `1111111111`. Whatever the length of the `$ben_num` the output is the same length of ones (1s).
I tried to run the code in
1. WriteCodeOnline
2. PHPTester
It works perfectly fine in these sites. Output is whatever bengali number of strings I give (eg 1234567890).
Might PHP version be the problem?
$ben_num = "১২৩৪৫৬৭৮৯০";
bn2enNumber($ben_num);
function bn2enNumber ($number){
$search_array= array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
$replace_array= array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$en_number = str_replace($search_array, $replace_array, $number);
echo $en_number;
}
|
Make sure your source code file (.php file) is saved in UTF-8
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, xampp"
}
|
Fill DropDownList items by selected item in another DropDownList?
<table><tr>
<td>
Type:
</td>
<td>
<asp:DropDownList ID="ddltype" runat="server" OnSelectedIndexChanged="ddltype_SelectedIndexChanged">
<asp:ListItem Value="0">---select---</asp:ListItem>
<asp:ListItem Text="Setter" Value="1">
</asp:ListItem>
<asp:ListItem Text="Getter" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
Name:
</td>
<td>
<asp:DropDownList ID="ddlname" runat="server">
</asp:DropDownList>
</td>
</tr> </table>
If user select either `setter` or `getter` in first dropdownlist, I want to fill the related names in second dropdownlist. How can I write code in c# page for this requirement. Please help me anyone.
|
public void NamesToDropdownList()
{
objhatcheryPL.type = ddltype.SelectedItem.Text;
DataTable dtname = new DataTable();
dtname = objhatcheryBAL.dtnames(objhatcheryPL);
ddlname.DataTextField = "Name";
ddlname.DataValueField = "Name";
ddlname.DataSource = dtname;
ddlname.DataBind();
ddlname.Items.Add(new ListItem("--select--", "0"));
ddlname.SelectedIndex = ddlname.Items.Count - 1;
}
protected void ddltype_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddltype.SelectedItem.Text != "--Select--")
{
NamesToDropdownList();
}
}
with this my code is working perfectly....
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, asp.net"
}
|
Native proxies does not appear in application
I have created eclipse application using eclipse photon. I can see the native proxies in eclipse but i cannot see them in the application I have created.
Is there any extensions that needs to be added to make the native proxies appear in my application
**Edit:** The below image contains the native proxy appearing in eclipse
!Native Proxy The same does not appear in my application
|
A class called `org.eclipse.core.net.ProxyProvider` provides the native providers - this is loaded using `Class.forName` by `org.eclipse.core.internal.net.ProxyManager`.
It looks like this class is provided by a platform specific plug-in fragment, for example `org.eclipse.core.net.linux.x86_64` on Linux. So make sure you are including the appropriate fragment in your build.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "eclipse rcp"
}
|
Java and GUI options
I am pretty capable when it comes creating GUIS in Java using Swing, however I can't help feeling that what I am creating is a little too simple. I am getting annoyed when trying to make quick changes.
If I had more free time I would love to spend time becoming more familar with Swing however at the moment that is out of the question.
So my question for the community is, do you have any thoughts on an alternative way for me to make more attractive GUIs?
|
This is a very good thread discussing this. Swing is a very capable framework/library, and you can do many things with it and certainly attractive GUIs.
If you like, you can use a GUI designer, such as the one that comes with Netbeans.
If you don't want to stay with Swing, there is SWT, but, that adds your bloat to your code since it isn't standard, and it won't necessarily make your app look better.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "java, swing"
}
|
Precision of double after decimal point
In the lunch break we started debating about the precision of the `double` value type.
My colleague thinks, it always has 15 places after the decimal point.
In my opinion one can't tell, because IEEE 754 does not make assumptions about this and it depends on where the first `1` is in the binary representation. (i.e. the size of the number before the decimal point counts, too)
How can one make a more qualified statement?
|
As stated by the C# reference, the precision is from 15 to 16 digits (depending on the decimal values represented) before or after the decimal point.
**In short, you are right, it depends on the values before and after the decimal point**.
For example:
* `12345678.1234567D` //Next digit to the right will get rounded up
* `1234567.12345678D` //Next digit to the right will get rounded up
Full sample at: <
Also, trying to think about `double` value as fixed decimal values is not a good idea.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 7,
"tags": "c#, double, ieee 754"
}
|
cross browser stretch menu items actual items
I'm trying to stretch the menu, almost like it's been done here: Stretch horizontal ul to fit width of div
Only I'm trying to make it so that the actual texts, are to the very left and right (now their containing li are stretched, but the text is centered.
Any ideas och links to examples? :) CSS/or table doesn't matter, as long as it works in all browsers :)
like this: <
|
I have set up a jsfiddle for you which will achieve the style you want < I used extra classes of first and last. I could have used :first-child and :last-child but didn't want to overcomplicate it for you.
Let me know if this works and if not I'll help out some more.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "css"
}
|
How to turn a DataFrame column of binary variables into multiple columns of dummy variables
This should be an easy question, but for some reason I can't find the answer online. I have a DataFrame column that consists of dummy variables:
import pandas as pd
foo = pd.Series([6,7,8,3])
foo1 = bob.apply(lambda x: bin(x)[2:].zfill(4))
foo1
0 0110
1 0111
2 1000
3 0011
What I want is a 4x4 data frame that looks like
A B C D
0 1 1 0
0 1 1 1
1 0 0 0
0 0 1 1
I've tried using get_dummies to no results:
foo1.str.get_dummies()
0110 0111 1000 0011
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
str.split and making the column into a series of lists doesn't work either. What should I do?
|
You can try this:
# convert the series to str type;
# extract all characters with regex .;
# unstack to wide format
foo1.astype(str).str.extractall('(.)')[0].unstack()
 and you buy extra days
2. Where you have an **in game commodity** (or multiple commodities, like gold, silver, energy or mana) and you're buying extra ( _" topping up"_)
I've not heard this being referred to as a specific type of game, perhaps that someone was using it as an ad hoc label without much thought.
In any game that features microtransactions, there tends to be resentment towards those players who are 'paying to win' especially the proverbial 'whales' (the counterargument usually being that these fund the game's upkeep and development). This is probably the general sentiment of the statement. The specific term _'top up **game** '_ however seems to be uncommon at the very least (as Wondercricket has also pointed out in comments).
|
stackexchange-gaming
|
{
"answer_score": 5,
"question_score": 10,
"tags": "terminology"
}
|
How should I count beats while playing alternating bass on piano?
While playing alternating bass is it improper to count the I and V as eighth notes, i.e. (I-strum-V-strum-I-strum-V-strum) where the strum would be the 'and' of the beat? Would this be incorrect because it doubles the tempo?
|
Terms are confused in this question. I and V in key C, for example, are **chords** C and G. You probably mean **notes** C and G - quite different - and shown as 1 and 5.
In 4/4 it's common to play 1 - C chord - 5 - C chord. on the 4 beats in a bar. Doubling up, using quavers instead of crotchets, often sounds too busy, and would work better playability wise, in a slower tempo, but that would then make the piece sound too quick. So, improper isn't the word, impractical could be better.
Strumming is often confined to guitar playing, although it could be conceived that playing a chord, specially slightly arpeggiated, may be strumming on piano.
|
stackexchange-music
|
{
"answer_score": 1,
"question_score": 0,
"tags": "beats"
}
|
Accessing active symbol table in Common Lisp
I have heard that the active symbol table is accessible within the Common Lisp runtime. Have I misunderstood?
|
'Symbol tables' are called 'packages' in Common Lisp. See for example: Introduction to Packages, CL HyperSpec.
Several operations over packages are available in Common Lisp: The Packages Dictionary.
Symbols can be members of packages (being 'interned').
The variable *package* holds a package as a value, which is used by several operations that use a package as a default. An example is the 'reader', which by default does a look up in the package of *package*.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 6,
"tags": "lisp, common lisp, symbol tables"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.