INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Link works although page was moved to another location
I am a new to WordPress. Please help me with the following issue.
I created page A and set Parent to X, hence its permalink was displayed as "<
In page B, I reference to page A by the attaching the link "< there
I then changed Parent of page A from X to Y. The permalink of A thus was updated as: "<
I visit page B again and click on link "< it still works and brings me to link "<
I wonder how it could happen? I was expecting to see Page Not Found or something like that as link "< is no longer available.
There probably is something I don't know about how the link in WordPress works. Can somebody please help explain this to me? Thanks!
|
## That is called _canonical redirect_.
And it's done through `redirect_canonical()` which basically
> Redirects incoming links to the _proper URL_ based on the site url.
and
> Will also _attempt to find the correct link_ when a user enters a URL that does not exist based on _exact_ WordPress query.
(Those excerpts were both taken from the function's reference.)
So in your case, although the post parent of `A` has changed from `X` to `Y`, the post `A` (or a post with that slug) still exists, and therefore, when you visit the old URL:
(old URL - post parent is X)
with canonical redirect, you'd be redirected to the correct URL:
(new URL - post parent is Y)
and not being presented with a `404` (page not found) error page.
Try visiting ` and you'd see the canonical redirect being applied.
And if you visit ` assuming there are no post with `A123z` as the slug, then you'd see the 404 error page.
|
stackexchange-wordpress
|
{
"answer_score": 0,
"question_score": 0,
"tags": "permalinks"
}
|
Can someone explain to me why my Heroku app doesn't use the free dyno hours, but instead just immediately charges me money?
No, I don't have any add-ons that charge me. I tried reading how the free Dynos work but I didn't find anything regarding this issue. Here is an image
|
I'm no expert (just deployed my first app), but it seems that there's a clear indication of free or not in the overview tab for your app. For example, I see
!dyno formation
on my app page. Presumably one would turn paid features on and off using the Configure Dynos link.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "heroku, dyno"
}
|
Changing Articulate Storyline text color using jquery?
Here is the code that I'm using to animate a text in Storyline using jQuery:
var item = $('[aria-label="myText"] svg')
$(item).toggle( "puff" );
this code is working.
But when I tried to change the color of the text using jQuery nothing happens...
if I can use jQuery to animate a text why I can't use it to change the color of it?
Here are the codes I've tried: (Am I missing something?!)
var item = $('[aria-label="spinner"] svg')
$(item).attr('style','color: green;');
and also :
var item = $('[aria-label="spinner"] svg')
$(item).css('color', 'red');
|
I can guess an SVG.. normally an svg containing text has also a `<text></text>` and svg are not using `color` but `fill` instead in the CSS.
Changing to this should work:
var item = $('[aria-label="spinner"] svg text')
$(item).css('fill', 'red');
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, jquery, articulate storyline"
}
|
How to clear Firefox' console via javascript?
I have some functions that when executed show some info with _console.log()_.
There is no problem with that.
But, some times, the console looks strange... Because that, they sent me to clear the console when pressing 'l' (letter 'L' in lowercase).
I took it as a simple task, I just needed to use _console.clear()_ and all would be fine.
But... I only thought:
console.clear(); // doesn't work in firefox !!!
In chrome it works fine.
Fiddle here.
Does someone knows any technique to do this in firefox?
Thanks for your time.
|
Console is not standarized so they will have differences. Firefox offers some helper commands though:
clear()
(same as hitting `CTRL` \+ `L` in Chrome, and `ALT` \+ `R` in Firefox).
However, you can not call it programmatically. Only works in console itself. You could look into Firebug instead as an option.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "javascript, firefox, cross browser"
}
|
Checkmark with specific color
I am trying to include a checkmark in my table that has for example blue color. I have managed to do it using a solution i have found here by using: `\def\bluecheck{\tikz\fillscale=0.4, color=blue -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}`
end then calling `\bluecheck`
The problem is when i insert `\bluecheck` in the caption of my table i get a number of errors (even though it compiles and renders the expected pdf)
Is there a library that creates a checkmark that allows to set its color?
|
The original problem is that `\bluecheck` is not a robust command and breaks inside moving arguments like `\caption`. The caption title moves via the `.aux` file to the `.lot` file for the list of contents. The solution is to define the command with `\DeclareRobustCommand` or with `\protected\def`:
\documentclass{article}
\usepackage{tikz}
\newcommand{\bluecheck}{}%
\DeclareRobustCommand{\bluecheck}{%
\tikz\fill[scale=0.4, color=blue]
(0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;%
}
\begin{document}
\listoftables
\begin{table}
\caption{Blue check mark \bluecheck}
\end{table}
\end{document}
> 
import zipfile
m= zipfile.ZipFile("test.jar","w")
m.write("test.jar","bgt.class")
m.close()
|
You need to open the file in _append_ mode, using `a`:
m = zipfile.ZipFile("test.jar", "a")
You opened the file in `w` write mode, which clears the file before writing. From the `zipfile.ZipFile()` documentation:
> The _mode_ parameter should be `'r'` to read an existing file, **`'w'` to truncate and write a new file, or `'a'` to append to an existing file. If `mode` is `'a'` and file refers to an existing ZIP file, then additional files are added to it.**
Bold emphasis mine.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, file, jar, add, python zipfile"
}
|
When in the page lifecycle we can assign master page?
I know ViewState is available between InitComplete and Preload events in LoadViewSate method. Similarly, I want to know in which page lifecycle event can we assign a master page for a particular page?
|
> Because the master page and content page are merged during the initialization stage of page processing, a master page must be assigned before then. Typically, you assign a master page dynamically during the PreInit stage
On `Page PreInit` event
void Page_PreInit(Object sender, EventArgs e)
{
this.MasterPageFile = "~/MyMaster.master";
}
Read Working with ASP.NET Master Pages Programmatically
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 4,
"tags": "c#, asp.net, master pages, page lifecycle"
}
|
Barra de rolagem em um select
Como por uma barra de rolagem um "scroll" para rolar em um select ? Por exemplo:
<select>
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
<option>e</option>
<option>f</option>
<option>g</option>
</select>
Tem como por um scroll para a caixa que desce não ficar muito grande ? Enves de listar todos abaixo apenas 3 e depois poder ir rolando para baixo.
|
select{
overflow-y:auto;
}
<select size='3'>
<option>a</option>
<option>b</option>
<option>c</option>
<option>d</option>
<option>e</option>
<option>f</option>
<option>g</option>
</select>
ATUALIZANDO
Você pode usar o plugin bootstrap select, pelo o que entendi, você quer controlar o height da caixa que abre quando clica no select. Bootstrap select tem esse recurso, veja:
O atributo usado é o `data-size`
<select class="selectpicker" data-size="2">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
Exemplo rodando aqui: <
Bootstrap select possui dependências, são elas: Jquery e Bootstrap
Espero que agora resolva seu problema.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "html"
}
|
Why make a Copper Snake?
Why did Moshe have to make a Copper snake. Wouldn't it be simpler if the snakes went away? (or acted as they were before the plague)
|
In Likutie Torah, Parshas Chukas(61d-62b), this question is asked. The answer provided is Hashem creates nothing inherently evil,for example lets say Atheism what could possibly be good with that? the answer when someone comes for help and or charity you dont say G-d will help you, no you take it into your own hands.This point is illustrated with the copper snake there is a good Spritual source to **ALL** things.Moshe was telling them look upwards at the Snake look for its positive spiritual source from Hashem and recognize that the punishment was for the overall good of Klal Yisroel and when Hashem sees that you recognize this then you will be healed. (this is very much my adaption of the idea,feel free to argue if this is the intended meaning of the answer!!)
|
stackexchange-judaism
|
{
"answer_score": 6,
"question_score": 6,
"tags": "parshanut torah comment, chukas"
}
|
JavaScript: Sentence variations using the reduce function
For search purposes, given a string like `BBC Sport` I want to construct an array that looks like:
[ 'BBC', 'BB', 'B', 'Sport', 'Spor', 'Spo', 'Sp', 'S' ]
I've implenented it using 2 for loops:
const s = "BBC sport";
const tags = [];
const words = s.split(" ");
for (let word of words) {
const wl = word.length;
for (let i = 0; i < wl; i++) {
tags.push(word.substr(0, wl - i));
}
}
// tags now equals [ 'BBC', 'BB', 'B', 'Sport', 'Spor', 'Spo', 'Sp', 'S' ]
However, I'd like to implement it, if possible, with the reduce function instead of for loops.
How would you solve it?
|
Honestly I'd write the code the way you did. Two loops are readable, maintainable and fast.
If you really need a oneliner:
s.split(" ").flatMap(word => Array.from(word, (_, i) => word.slice(0, i + 1)))
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "javascript, algorithm, reduce"
}
|
Angular how to add one day of an object Date?
I get an object Date whith format ( YYYY-MM-DD) and I want to create an object and add one day to this object ( if my object is 2020-03-10, I would like to get 2020-03-11), how can I do ?
this.mypensionsort.dtFin //the object Date
const dateDayPlusOne = new Date(this.mypensionsort.dtFin.getDate() + 1); //Doesn't work
|
You can use javascript `getDate` and `setDate` function to achieve this. see the example
const mydate="2020-03-10";
const newDate = new Date(mydate);
const result = new Date(newDate.setDate(newDate.getDate() + 1));
console.log(result);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "angular, date"
}
|
get the integer representation value of a float type variable in C
I have the number 20 (0x14) stored in a 32-bit register. The register is allocated to a C float variable representing the value 2.8e-44. Now I want to get the hexadecimal representation of the float variable back and stored it into an integer variable in order to restore the original meaning of the information. Is there a better way to do that, apart from doing some pointer business? Here is the code:
#include <stdio.h>
int main()
{
float f = 2.802597e-44;
int nv,*pnv;
printf("f=%f\n",f);
printf("n=%d\n",f);
nv=(int)f;
printf("n=%d\n",nv);
pnv=(int*)&f;
printf("n=%d\n",(*pnv));
return 0;
}
I get what I want using the pnv integer pointer. Is there a better way to do that avoiding pointers and working in C?
|
You can achieve your need with a union:
#include <stdio.h>
int main()
{
union { int i; float f; } fi;
fi.f = 2.802597e-44;
printf("f=%e\n",fi.f);
printf("n=%d\n",fi.i);
return 0;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "c, floating point"
}
|
probability wheel, redistribution of probabilities
I have a contiguous ordered data structure (0 based index):
x= [1/3, 1/3, 1/3]
Let's say I selected index 1 and increased the probability by 1/3. Rest of the probabilities each decrease by 1/6 and the total probability remains P = 1.
x= [1/6, 2/3, 1/6]
Let's say I selected index 2 and increased the probability by 1/3. Rest of the probabilities in total need to decrease by 1/3 to make the total probability remain P= 1.
x= [1/10, 2/5, 1/2]
Is there a name for this kind of data structure? I'd like to research that name and use a library instead of my custom rolled code if possible.
|
This can be easily achieved by an array $A$ and an additional variable $m$. The entry $A[i]$ stores the probability of $i$ times $m$.
In your example you start with
A=[1,1,1], m=3
The you increase the probability of the second element by 1/3. This can be carried out by setting $A[2]=4$ and $m=6$, which gives
A=[1,4,1], m=6
In general you could set the probability of element $k$ to $p$ by solving the system $$\sum_i A[i] = m \text{ and } A[k]=p\cdot m,$$ for the unknowns $A[k]$ and $m$.
So all you need to do is to set $m$ to $$ m = \frac{\sum_{i\neq k} A[i]}{1-p},$$ and $A[k]=p\cdot m$ for the new $m$.
|
stackexchange-cs
|
{
"answer_score": 2,
"question_score": 2,
"tags": "data structures, probability theory"
}
|
Pass-through mouse click on label to the parent element
How to make label pass-through click event? For now I just disabled the label and it works fine but color of text has dimmed, though forecolor is pure black. Is there a way to set color to normal? Or maybe there is better way to pass-through clicks through label?
**Edit to clarify**
It's Windows Forms and i need to perform click on a control under the label.
Sorry, I will tag questions more clearly :)
|
Why not try this :
label.Click -= label_Click;
As you know `+=` crates an event , so , if i replace `+` with a `-`,the result is obvious right ?
**UPDATE**
I don't quiet get the term `pass through click` but if it is that u have a control beneath the label and u want to rather perform click on that,isn't it obvious to do something like this ?
private void beneathControl_click()
{
allCodesInAnotherMethod();
}
private void label_click()
{
allCodesInAnotherMethod();
}
private void allCodesInAnotherMethod()
{
///all codes here
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, .net, winforms"
}
|
Cost revenue profit function
Cost revenue and profit function-
A firm sales a single product for $ \$ 65$ per unit. The variable cost are $ \$20$ for material and $ \$27.50$ for labour. Annual fixed cost are $\$100000$.
A.) Construct the profit stated in terms of "$x$", where $x$ represents the number of units produced and sold.
B.) What profit is earned if annual sale is $20000$ units?
|
Assuming that the number of units produced and sold is the same, profit $\pi$ can be expressed as: $$ \pi(x)=\text{Revenue} - \text{Expenses} = 65x-[(20+27.5)x +100,000] = 17.5x-100,000 $$ If $x=200,000$ units per year, then $\pi=\$250,000$ per year.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "multivariable calculus"
}
|
Adverts for interesting question for a SE with a design appears as beta design
A recent side advert for a question on UX.SE (this question) appeared with the squared paper beta design background, is this because UX.SE is still in beta or does a site's design need to include these ads?
|
The ads are most likely computer-generated as they seem to be based on the hottest questions. The scripts probably take into account of the "beta-ness" of the site in question and render the beta design accordingly. And since UX.SE is in beta:
!ux.se beta screenshot
The ads for UX.SE ends up with the "sketchy beta" design as a result.
* * *
Although UX.SE seems to be the exception to this meta SO answer:
> That is the "Sketchy" beta theme for all beta sites. When a site makes it out of beta, they will choose their own logo and design.
|
stackexchange-meta
|
{
"answer_score": 5,
"question_score": 3,
"tags": "discussion"
}
|
Two doGet() functions in one GAS project?
Can I have two different doGet() functions in one Google Apps Script project? I'd save them in two .gs files. If it's possible, how do I publish the web apps separately?
|
You can make a second project attached to the same document by going to `File` > `New` > `Project` in the script editor. Putting doGet() functions in two separate .gs files is the same as putting two doGet() functions in the same .gs file as far as the compiler is concerned.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "google apps script"
}
|
Can you always add edges to a graph to make it regular?
Let $G$ be a finite graph with $n$ vertices and largest degree $k$. Assume that $kn$ is even. Then is it _always_ possible to add edges to $G$ to make it $k$-regular?
On the one hand, if we don't care about loops or multiple edges, then we can make $G$ into a $k$-regular multigraph just be repeatedly adding an edge between two vertices of minimal degree. But what if we do care?
The proof of König's line coloring theorem I saw in class starts like that, but maybe with bipartite graphs it is a special case where everything works fine...
|
So you are asking if it is possible to add ONLY edges and no additional vertices? If this is the question: No it is not always possible: Take a $k=4$ and a 4-regular graph $H$. Replace an arbitrary edge $uv \in H$ with a path $uu_1v_1v$ (so the endpoints of this path are $u$ and $v$ and $u_1$ and $v_1$ are two additional vertices not in $H$) and call the resulting graph $H'$. Then except for precisely $u_1$ and $v_1$ every other vertex in $H'$ has degree 4.
There is no way to add edges to $H'$ to bring $u_1$ and $v_1$ to degree 4 without either (a) making some of the other vertices degree 5 or larger, or (b) adding more vertices.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "graph theory"
}
|
Extract a line between two lines of a file in python
I have text file as shown in image.
. But while iterating not able to check previous and next line.
can someone suggest some idea how can i do this?
|
Try this approach:
headings = []
with open(filename) as f:
lines = f.readlines()
n_lines = len(lines)
for i, line in enumerate(lines):
if line.startswith("-----") and \
n_lines > i + 2 and iines[i+2].startswith("-----"):
headings.append(lines[i+1])
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python 3.x"
}
|
If the composition of a function with a curve gives you no local minima or maxima do I have a saddle point?
If I have a function $f$ with a critic point $P$ and a continuous curve $\alpha$ such that $\alpha(t_o)=P $ and $(f\circ\alpha)$has no local maxima nor local minima in $t_o$. Can I affirm that $P$ is a saddle point?
|
Let an arbitrary neighborhood $V$ of $P$ be given. Since $\alpha$ is continuous at $t_0$ there is a neighborhood $U$ of $t_0$ with $\alpha(U)\subset V$.
Since the function $\psi:=f\circ \alpha$ has no local maximum at $t_0$ the neighborhood $U$ contains a point $t_>$ with $\psi(t_>)>\psi(t_0)$. Similarly, since $\psi$ has no local minimum at $t_0$ the neighborhood $U$ contains a point $t_<$ with $\psi(t_<)<\psi (t_0)=f(P)$.
Now the points $P_>:=\alpha(t_>)$ and $P_<:=\alpha(t_<)$ are lying in $V$, and $$f(P_>)=\psi(t_>)>\psi(t_0)=f(P),\quad f(P_<)=\psi(t_<)<\psi(t_0)=f(P)\ .$$ Since $V$ was arbitrary this shows that $f$ has neither a local maximum nor a local minimum at $P$. Since $P$ is a critical point of $f$ we therefore have a saddle point.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "calculus, multivariable calculus, maxima minima"
}
|
What is the progress bar periodic update function return data?
In Drupal 7 from the function called with 'url/to/call/progressbar/update/function' (see below) you would return an array converted to JSON like this:
drupal_json_output($message);
I cannot find any examples for Drupal 8 and I suspect it's an object rather than an array that gets returned.
Does anyone know how/what to return from the progress bar update function?
The setup for the bar progress indicator would be something like this:
$form['some_item'] = array(
'#type' => 'submit',
'#value' => t('My action'),
'#ajax' => array(
'callback' => 'a_function',
'wrapper' => 'ajax-response-goes-here',
'method' => 'replace',
'progress' => array (
'type' => 'bar',
'message' => 'Starting...',
'url' => 'url/to/call/progressbar/update/function',
'interval' => '1000'
)
|
The core example is in `FileWidgetAjaxController::progress`. You need to return a JSON-encoded associative array with `message` and `percentage` keys. For example:
$progress['message'] = t('Uploading... (@current of @total)', ['@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])]);
$progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
...
return new JsonResponse($progress);
|
stackexchange-drupal
|
{
"answer_score": 2,
"question_score": 1,
"tags": "8, ajax"
}
|
Persistant name on Finder tabs
I'm looking for a way to always display a label on Finder tabs instead of the current folder name, to differentiate them when folder name is not relevant.
(Long story) I use tabs to switch between several projects which are in different folders. But when I'm not at the "root" folder of a project, the name of the Finder tab is not the one of the root folder project (but the subfolder name) and I can't quickly recognize where each project is.
I'd like to attach a project name on each tab of the same window (above the window, in the toolbar, under the tab, or better, instead of the tab name).
Any idea of an app that could do that ? (It has to be displayed everytime I ⌘-tab switch on the Finder, knowing that I always have windows under the Finder's one – so no, it can't be an text on the wallpaper).
Thanks!
|
DragThing made the trick! (And does a lot more.)
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 1,
"tags": "macos, finder, customization, tabs, third party"
}
|
pinterest button stopped working on Blogspot site
I had successfully implemented the pinterest pin it button on my site, but it has recently stopped working. Could anyone tell me why?
My website is < and I am using the following code
<div class='w2bPinitButton' expr:id='"w2bPinit-" + data:post.id' style='display: none;visibility: hidden;height: 0;width:0;overflow: hidden;'>
<data:post.body/>
<script type='text/javascript'>
w2bPinItButton({
url:"<data:post.url/>",
thumb: "<data:post.thumbnailUrl/>",
id: "<data:post.id/>",
defaultThumb: "
pincount: "horizontal"
});
</script>
|
Looks like you have managed to sort out your issue?
If not this link may be helpful or to others that want to implement it in their Blogspot site.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, blogger, pinterest, blogspot"
}
|
How to send array Object from NodeJS to Javascript?
I am trying to send my database output, which is an array to javascript file to display it in select options. I tried,
response.render('/entry.js',{output : outputArray});
In entry JS file,
var outputArray = "<%= output %>";
But it is printing as it is. Kindly help me on this
|
The way I would do it is a Ajax Call to NodeJS server which query the database and returns JSON output into your page.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, ejs"
}
|
javascript: add script that will be evaluated before body scripts?
I have a script foo.js that is included in `<head>`. Inside body I have an inline script. Inside it, I want to add to the document another script for bar.js that will be loaded and evaluated before the inline script.
<html>
<head>
<script src="foo.js" type="text/javascript"/>
</head>
<body>
<script type="text/javascript">
bar()
</script>
</body>
</html>
In foo.js I want to add a script pointing to bar.js
bar.js:
function bar() {
alert('hi');
}
What should be the code of foo.js?
NOTE: I know I can use onload in this trivial example. But in my real case, bar.js contains a function that is called several times and I want to be able to inline these calls in the right sections of the page (for code locality)
|
You have got two options:
1. Use `document.write('<script src="bar.js"></script>')` in `foo.js`.
2. Dynamically create and insert a `<script>` element within the head (since scripts in the head have to be loaded before the rest is parsed, this works):
!function(){
var s = document.createElement('script'),
currentScript = document.getElementsByTagName('script')[0];
s.src = "bar.js";
currentScript.parentNode.insertBefore(s, currentScript);
}()
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "javascript"
}
|
Update TSSTcorp CDDVD Drivers
I've got installed a DVD-Writer:
TSSTcorp CDDVDW SH-216AB
Windows says me that the installed Drivers are current (6.1.7600), but another website tells me the newest driver is more than 7.x and from 2012. Now if I tell Windows to download the newest drivers it says that these are already the newest.
So where are those new drivers downloadable?
|
Unless you have a specific problem with your DVD burner, and know that the new drivers will fix it, leave it alone. The drivers windows installed automatically should work just fine, and are likely to be stable and fairly bug free. Just because some website or utility says there are newer drivers, doesn't mean you need them.
Version 6.1.7600 is also the version number for windows 7, so I suspect that you are running windows 7, and these are the drivers from Microsoft to support a DVD burner. There is almost never a good reason not to use those drivers.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 0,
"tags": "windows, dvd, compact disc"
}
|
Is there a way to automate the [Y/N] prompts when installing packages from a linux script
I have a script that installs few apps that require the user to type Y about 5 times during the script. Is it possible to automate or bypass the Y so the script just runs through without the need for any user interaction?
|
Pipe `yes` to it.
yes | <command here>
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "bash, terminal, prompt"
}
|
Python enter a hidden password
I have a python script that I made to update and upgrade my Linux system, it is written in python but after I tell it to update it prompts me to enter a hidden password and I was wondering if there is a way to get Python to enter the hidden password for me. This is my code its simple and works I just need to know if there is a way to enter hidden passwords with python.
import os,sys
os.system("sudo apt-get update && sudo apt-get upgrade")
|
You can use the pexpect module. Take a look at this tutorial.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python"
}
|
Flash AS3 loading swf file into banner
I'm trying to make a flash banner that is less than 30K, so I want to create a dummy file, that will be the upper layer and the link to the website, and the lower layer will be calling the SWF file from my source.
I remember doing it once, but I've searched the web (maybe I just couldn't get my Google query right) and didn't find a solution.
Any suggestions?
Thanks in advance!
|
So you want a .swf to load another .swf into itself? Use the Loader class for that.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "actionscript 3, flash, banner"
}
|
Python - Convert epoch in object format to datetime
I'm pulling data from API that gives me date values in epoch in milliseconds, but the values are in this format:
`, but am getting the error
> ValueError: non convertible value 1,609,459,200,000.0000000000 with the unit 'ms'
I then tried to format the column into float with `df1["Curve Value"] = df["Curve Value"].astype(float)`, but get then get this error
> ValueError: could not convert string to float: '1,609,459,200,000.0000000000'
I've also tried various ways to remove the commas and convert to float, but get errors trying that, as well.
|
A bit unwieldy and requires importing datetime from datetime but it works as far as I can see.
df['Real Time'] = df['Curve Value'].apply(lambda t: datetime.fromtimestamp(int(''.join(t.split(',')[:4]))))
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, pandas"
}
|
MYSQL Merge rows based on occurence
I have the following table:
empid,paygrp,paycode,amount
1 A 1 200
1 A 2 300
1 A 3 500
1 B 4 600
1 B 5 700
is it possible to use sql statement to produce the following result?
1 A 1 200 B 4 600
1 A 2 300 B 5 700
1 A 3 500
|
You need to do two queries for this:
SELECT *
FROM table
WHERE paygrp='A';
SELECT *
FROM table
WHERE paygrp='B';
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mysql"
}
|
Removing annotation string from the NSmutableString
I am working on mapView project. My project will take only 5 annotations on the map. Once new annotation will be added, then first annotation will be drop. I am keeping all annotations latitude and longtitude into NSMutableStringArray. Is there any short way to implement this round robin fashion. First in last out.
for example my nsmutable string:
[12.99, 35.97: 35.85,94.53: 45.44,98.91]
How could I delete first object (each string separated by column operator :) from the string to acquire the following:
[35.85,94.53: 45.44,98.91]
|
I have got it work, my solution is below:
NSMutableString *absolute=[NSMutableString stringWithString:pinPoints];
NSLog(@"before absolute: %@",absolute);
NSArray *placemarks=[absolute componentsSeparatedByString:@":"];
if([placemarks count]>5)
{
//NSLog(@"%@",[placemarks objectAtIndex:0]);
NSMutableString *string1 = [NSMutableString stringWithString: [placemarks objectAtIndex:0]];
[absolute replaceOccurrencesOfString:string1 withString:@"" options:0 range:NSMakeRange(0,[pinPoints length])];
pinPoints=absolute;
}
NSLog(@"after absolute: %@",absolute);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "objective c, ios, data structures, android mapview, nsmutablestring"
}
|
How can I create dictionary specifying keys names as a input variable
I'm using a dictionary to create a list of variables:
def split_list(list_,size,name):
fragment_number = len(list_)/size + 1
d={}
for x in range(1,fragment_number+1):
d["north_carolina_cities{0}".format(x)]=list_[(x-1)*size:x*size]
return d
This function takes a list as input and split it in several items of a dict, but I'm not able to use the variable 'name' to regerate the keys of a dictionary so I have to change the name manually each time: "north_carolina_cities{0}"
How can I integrate this process into the function?
|
Try something like
def split_list(list_, size, name):
d = {}
for i, x in enumerate(list_):
d[name + str(i+1)] = x
return d
This is a simplified version of what you have because I'm not sure why you are obtaining fragment_number by dividing the list length, and then multiplying by list length to get your index.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, variables, dictionary"
}
|
What does "find someone well" mean?
I got some email from a stranger that contains:
> I hope this email finds you well.
So what does "find you well" means here? Does it mean "Are you well" or "The email find the right guy"? I'm a little confused here.
|
It means "I hope this email arrives at a time when you are well (healthy, happy, etc)"
In other words, "I hope you are doing well." It is not a question, it is just offering nice wishes.
|
stackexchange-english
|
{
"answer_score": 29,
"question_score": 15,
"tags": "sentence"
}
|
Word for sentences which read the with their words (not characters!) reversed
I am looking for a word for sentences which read the same forwards and when the order of words is reversed?
Just to clarify, I'm not talking about palindromes, in which individual characters are reversed. I’m thinking, instead, of sentences where the characters within words are left alone and the order of the words itself is reversed, for example:
> That is that.
|
After some research I found out that this could either be called a _palindrome_ , (This would be used when you want all letters to be the same when read backwards, even though I do believe this rarely occurs in sentences), or a _palingram_ (This would be used when the letters themselves do not matter). Ofcourse, in both cases the meaning of the sentence should be the same when read backwards.
I hope this helped you out a bit more.
|
stackexchange-english
|
{
"answer_score": 4,
"question_score": 2,
"tags": "single word requests, terminology, sentence patterns"
}
|
how do I "add an argument" to call to eclipse on mac?
I am running eclipse on a macbook pro and it is hanging now and then so I want to run the
> -clean
argument as described here. I would know how to do this on windows but how do I do it on a mac? I can't find the `eclipse.ini` file and in iTerm typing `eclipse -clean` doesn't find anything.
|
`eclipse.ini` is located inside the Eclipse application bundle next to the binary. Right-click `Eclipse.app` (the thing with the eclipse icon you double-click), choose "Show Package Contents", and navigate to `Contents/MacOS/`.
The file `eclipse` in the same directory is the actual binary you should be able to launch with the argument, e.g. `/Applications/Eclipse/Eclipse.app/Contents/MacOS/eclipse -clean`
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mac, eclipse"
}
|
Rotation on initial loading
I am having an issue my app not loading properly when it initially loads in an orientation other than `UIDeviceOrientationPortrait`. I support all orientations, and after the initial loading I can properly rotate into any orientation.
It also works to close and reopen the app in any orientation. It only seems to be the initial loading that is causing problems. Any ideas on what might be happening?
I don't even know what code to post to try to demonstrate the issue. Thanks!
|
It turns out the problem was due to having a "container" view controller and then additional view controllers on the screen that weren't taking up the entire screen. When loading my modal view, I was doing it from one of the smaller view controllers, not the container. Moving the modal view presentation into the container fixed the issue. Thanks for getting me thinking in the right direction.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "iphone, objective c, ios, ipad"
}
|
Is it always the case that the square root of a lagrangian gives the same equations of motion as the lagrangian itself?
Inspired by the Phys.SE post Geodesic Equation from variation: Is the squared lagrangian equivalent? I was wondering if it is always the case that the square root of a lagrangian gives the same equations of motion as the lagrangian itself? Are there specific counterexamples, or is there any way to derive a set of conditions the lagrangian has to satisfy, for it to have this particular property?
|
That is rarely$^1$ the case. Sufficient conditions and examples are given in this duplicate Math.SE post.
\--
$^1$ An instructive example is perhaps this Phys.SE post: The coefficients of each squared term in the Lagrangian have been carefully fine-tuned to make it work. It is not just $(T-V)^2$.
|
stackexchange-physics
|
{
"answer_score": 0,
"question_score": 1,
"tags": "lagrangian formalism, variational principle"
}
|
При включенных Advanced Custom Fields не работают встроенные
Скачал и установил на готовом проекте Advanced Custom Fields ( до этого уже был реализован функционал встроеных кастом филдов). Теперь встроенные не работают, а работают только от плагина. Когда деактивирую плагин - встроенные появляются в админке в постах. Подскажите пожалуйста, как это можно исправить ?
|
Видимо, речь о произвольных полях WordPress.
Плагин ACF может скрывать произвольные поля. Откройте настройки группы полей ACF, прокрутите вниз до настроек, увидите примерно такие настройки:
_
For those who downvoted: I can understand the frustration if I did something wrong when posting. I'm a new member, so if you downvote, please mention what bugged you so I can take that in mind for my next questions.
|
newlist = []
for sublist in yourlist:
already_in_list = False
for index, newsublist in enumerate(newlist):
if sublist == newsublist[:-1]:
newlist[index][2] += 1
already_in_list = True
if not already_in_list:
newlist.append(sublist+[1])
-
>>>newlist
[['personA', 'banana', 1], ['personB', 'banana', 2], ['personA', 'grape', 1], ['personA', 'lemon', 2]]
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -5,
"tags": "python, list, python 3.x, count"
}
|
Vim autoindents too far for anonymous R function with lapply
Vim autoindents too far (more than 4 spaces) for the following R code:
lapply(1:10, function(x){
Something here
})
How can I fix this?
Here is a picture:
sdfnjsd. fhhdfbsdfbdhhbdhfb.
Not Allowed-> hi there howareyou, **"()#jsdfhsdjfhjshdasdjasjdd34!fsdfsdfsddfsdfsdff* &**
What i have tried
This will allow only alphanumeric and certain special characters
^[a-zA-Z0-9 ,()!'".\-_:/\\-]*$
but not sure how to find continuous Words length greater than 25 chars without space
|
Add a negative look ahead for 26 non whitespace chars that is anchored to start:
^(?!.*\S{26})[a-zA-Z0-9 ,()!'"._:/\\-]*$
The hyphen char `-` was in your character class twice; this regex has one of them removed.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "regex, kotlin"
}
|
Pandas re-arange flat hierarchy from bottom up to top down
I am stuck with a challenge to re-arange a flat unbalanced hierarchy that is build bottom up, i.e. mapping a child element to parent and the parent's parent and so on, to a top down structure, i.e. starting from root and populating the structure downwards. Because the tree is unbalanced some end with a lower hierarchy level than others.
Example:
Source:
Child|Parent+0|Parent+1|Parent+2|Parent+3|Parent+4
Julia|Peter|Alice|Paul|Sara|Bianca
Chris|Jen|Bob|Fred|Bianca|NaN
Ben|John|Bianca|NaN|NaN
Target:
Parent-0|Parent-1|Parent-2|Parent-3|Parent-4|Child
Bianca|Sara|Paul|Alice|Peter|Julia
Bianca|Fred|Bob|Jen|NaN|Chris
Bianca|John|NaN|NaN|NaN|Ben
I've tried different ideas but so far had no luck. Appreciate your help or ideas.
|
`set_index` and flip the values. Then make use of the `justify` function that cs95 modified from Divakar.
df = df.set_index('Child').loc[:, ::-1]
pd.DataFrame(justify(df.to_numpy(), invalid_val=np.NaN),
index=df.index,
columns=[f'Parent-{i}' for i in range(0, df.shape[1])])
* * *
Parent-0 Parent-1 Parent-2 Parent-3 Parent-4
Child
Julia Bianca Sara Paul Alice Peter
Chris Bianca Fred Bob Jen NaN
Ben Bianca John NaN NaN NaN
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "pandas"
}
|
Was there any in-Universe mention of a technology to clone individual organs/limbs?
As part of answering " Why are Anakin and Luke fitted with cybernetic hands? ", I tried to remember any mention of a canonical (any canon) technology to grow a cloned organ or a limb - as opposed to a full cloned being.
I couldn't come up with any example but thought that it's worth asking about in case I was wrong.
**Was there any SW in-Universe mention of a technology to clone individual organs/limbs?**
|
I've read most of the novels set post-ROTJ (through the end of the Vong war), seen the movies, but have not watched all of 'The Clone Wars' or the CW movie. I haven't read any prequel (Clone War era or earlier) books.
I've never seen mention of this technology, even when it would have made sense for it to be used.
Honestly, medical tech in the SW Universe doesn't seem very advanced - if a dunk in bacta won't fix it, you live with it (or die).
|
stackexchange-scifi
|
{
"answer_score": 5,
"question_score": 10,
"tags": "star wars, clones"
}
|
Application crash after approved
I got my application approved on app store.
But due to some change in the feed I am using my app is crashing now. What am I supposed to do now?
Giving an update will take 7 days for apple to approve and I will get bad reviews if any one downloads it in between.
What am I supposed to do now?
|
You could:
1. Fix the feed.
2. Remove the app from sale until you fixed the bug and the update is approved.
3. Remove the app from sale until you fixed the bug and the update is approved and request a speedy review.
To remove a App from sale, go to the `Rights and Pricing` of that app in iTunnesConnect and set the `Availability Date` in the future. this will remove the app from sale. Just put the date back to now to make it available again.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "iphone, ios, app store, app store connect, itunes store"
}
|
Resample daily pandas timeseries with start at time other than midnight
I have a pandas timeseries of 10-min freqency data and need to find the maximum value in each 24-hour period. However, this 24-hour period needs to start each day at 5AM - not the default midnight which pandas assumes.
I've been checking out `DateOffset` but so far am drawing blanks. I might have expected something akin to `pandas.tseries.offsets.Week(weekday=n)`, e.g. `pandas.tseries.offsets.Week(hour=5)`, but this is not supported as far as I can tell.
I can do a nasty work around by `shift`ing the data first, but it's unintuitive and even coming back to the same code after just a week I have problems wrapping my head around the shift direction!
Any more elegant ideas would be much appreciated.
|
The `base` keyword can do the trick (see docs):
s.resample('24h', base=5)
Eg:
In [35]: idx = pd.date_range('2012-01-01 00:00:00', freq='5min', periods=24*12*3)
In [36]: s = pd.Series(np.arange(len(idx)), index=idx)
In [38]: s.resample('24h', base=5)
Out[38]:
2011-12-31 05:00:00 29.5
2012-01-01 05:00:00 203.5
2012-01-02 05:00:00 491.5
2012-01-03 05:00:00 749.5
Freq: 24H, dtype: float64
|
stackexchange-stackoverflow
|
{
"answer_score": 18,
"question_score": 8,
"tags": "python, pandas"
}
|
ASP.NET MVC 5 - redirect from view only once
Hy,
I'm trying to redirect users which has deactivated javascript with following code in the main layout (_Layout.cshtml):
<noscript>
<meta http-equiv="refresh" content="0;url=/Error/NoJavascript" />
</noscript>
Rather it works, but it refreshes every time. How can I redirect only once instead of every time?
I've found this code sample, but it doesn't let me compile (error message: can't implicite convert from void to object) I use this code sample in my view (_Layout.cshtml):
@Response.Redirect("/Error/NoJavascript")
Thanks for help :)
|
Use a simple static HTML file for this special case which `has not` this meta data:
<meta http-equiv="refresh" content="0;[email protected]("~/Content/NoScript.html")" />
Your returned view from the `Error/NoJavascript` action method has a reference to the layout page automatically or just set its layout to null.
@{
Layout = null;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "asp.net mvc, asp.net mvc 5"
}
|
how to unwrap only one parent in jquery
I have optgroup in select menu, I want get rid of from it. I am using jquery unwrap method to get it done but it is removing whole select menu. here is fiddle
$(function(){
$('select').find('option').not(':first').parent().unwrap()
})
## HTML
<select>
<option>select</option>
<optgroup label="state">
<option>new york</option>
</optgroup>
<optgroup label="country">
<option>us</option>
</optgroup>
</select>
|
`$('select').find('option').not(':first').unwrap();`
You have to unwrap the option not the _parent_ of the option!
Your updated fiddle: <
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "jquery"
}
|
Can I create iphone app (IOS) using web's languages ( HTML - CSS - jQuery )?
Can I create iphone app (IOS) using web's languages ( HTML - CSS - jQuery ) ? How can I star that ?
|
There are a number of different approaches you can take.
First, there's creating iPhone WebApps. This approach give you a number of different Mobile Safari APIs that expose internal capabilities through the Safari Browser.
Second, you can create a native application that contains a UIWebView. Other than this detail, the approach would be the same as the first, exclusively using the APIs for Mobile Safari.
Lastly, you can take an approach of using a third-party SDK, like Titanium or PhoneGap. This approach gives you a base set of APIs that you leverage for not only making iPhone webapps, but an app that works on other mobile platforms as well.
Good luck!
|
stackexchange-stackoverflow
|
{
"answer_score": 16,
"question_score": 8,
"tags": "ios, iphone, macos, ipad"
}
|
Letting people know they don't owe me directly
I've recently been able to afford things rather easily and I also live with flatmates (who are also coworkers). We all make the same amount and share a lot of stuff.
Whenever I feel like it, I just buy them things like a coffee when I'm having one at work or I pay for the week's groceries. They also do this at about the same frequency.
However, one of them still seriously asks me:
> "Hey I owe you _amount_ right?"
I'm not sure how to respond to that. I usually laugh and tell them to shut up, because I'm not expecting them to deposit cash my way. But, in retrospect, it would be a lie to say I'm not expecting camaraderie in some way.
**What would be a proper response to have others forget about keeping tabs without sounding pedantic or dismissive?**
|
I can offer you the viewpoint of the person asking you if they owe you anything back.
As someone that's fairly strict with money, I get slightly uncomfortable when someone buys me snacks even if I didn't ask them to because we had not discussed beforehand how would the bill be split.
Furthermore, it is polite to acknowledge that someone just spent money on you and you at least ask if they'd like to be compensated for that.
Generally, if you would not like a compensation for what you just bought you can just say
> it's fine, it's on me
When someone says this to me, I feel more comfortable because then I'll know for sure that they were okay buying me that item and they are not expecting anything in return.
|
stackexchange-interpersonal
|
{
"answer_score": 8,
"question_score": 2,
"tags": "friends, coworkers, roommates"
}
|
How to get this type of font?
I was not able to get the required font as shown below
 method?
When writing a query using C# LINQ syntax, is there a way to use the Queryable.SelectMany method from the keyword syntax?
For
string[] text = { "Albert was here",
"Burke slept late",
"Connor is happy" };
Using fluent methods I could query
var tokens = text.SelectMany(s => s.Split(' '));
Is there a query syntax akin to
var tokens = from x in text selectmany s.Split(' ')
|
Yes, you just repeat the from ... in clause:
var words = from str in text
from word in str.Split(' ')
select word;
|
stackexchange-stackoverflow
|
{
"answer_score": 137,
"question_score": 99,
"tags": "c#, linq, keyword, iqueryable"
}
|
SQLite Combine Value of Two Columns
I am trying `get` data from database based on some logic, here is the query
String sql = "SELECT pr.number, pr.u_id from pro_cap pr " +
"LEFT OUTER JOIN pending p " +
"WHERE p.mobile_id = pr.u_id+pr.infant_no ";
Where, `value` of **mobile_id** in _pending_ table is `4711`
And `value` of **u_id** is `471` and value of **number** is `1` in _pro_cap_ table
I suppose to get data from database where 4711 = 4711, but unable to get...
|
For concatenating two or more columns use `||` operator.
Change your query as below :
String sql = "SELECT pr.number, pr.u_id from pro_cap pr " +
"LEFT OUTER JOIN pending p " +
"WHERE p.mobile_id = pr.u_id || pr.infant_no ";
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -1,
"tags": "android, sqlite, android sqlite"
}
|
Listen to error in Service Provider in Laravel 5
I've been using Laravel 5 for some time now and I'm creating my own logging layer for my application.
Since I want to log my failed queries I decided to create a Service Provider for this.
In the Service Provider I got this code:
public function boot()
{
$this->app->error(function (QueryException $ex) {
dd('test');
});
}
This should work, but it doesn't. I get the following error:
`Call to undefined method Illuminate\Foundation\Application::error()`
Somebody knows whats changed here. Cause I can't find the `error` method in the Application or Container class. Haven't found anything on the forums/github repo yet.
|
In Laravel 5 catching errors works differently. Source
You do it inside `app/Exceptions/Handler.php` by editing the `render()` method:
public function render($request, Exception $e)
{
if ($this->isHttpException($e))
{
return $this->renderHttpException($e);
}
else if ($e instanceof QueryException)
{
dd('test');
}
else
{
return parent::render($request, $e);
}
}
**Documentation:<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, laravel, laravel 5"
}
|
How do I use a Lambda expression to sort INTEGERS inside a object?
I have a collection of objects and I know that I can sort by NAME (string type) by saying
collEquipment.Sort((x, y) => string.Compare(x.ItemName, y.ItemName));
that WORKS.
But I want to sort by a ID (integer type) and there is no such thing as Int32.Compare
So how do I do this? This doesn't work
collEquipment.Sort((x, y) => (x.ID < y.ID)); //error
I know the answer is going to be really simple. Lambda expressions confuse me.
|
try this
collEquipment.Sort((x, y) => y.ID - x.ID);
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "c#, collections, lambda"
}
|
Tracial states on $C_\text{r}^\ast(\mathbf{D}_\infty)$, $\mathbf{D}_\infty$ being the infinite dihedral group
Let $\mathbf{D}_\infty$ be the infinite dihedral group, i.e. the group generated by two elements $s$ and $t$ with $s^2=t^2 =e$ which are free with respect to each other. Consider the reduced group $C^\ast$-algebra $C_\text{r}^\ast (\mathbf{D}_\infty)$. There exist two canonical tracial states on this $C^\ast$-algebra, namely the state $\tau$ with $\tau(1)=1$ and $\tau(\lambda_s)=\tau(\lambda_t)=0$ and (since $\mathbf{D}_\infty$ is amenable) the character coming from the trivial representation of the group $\mathbf{D}_\infty$ (i.e. the corresponding state maps $1\mapsto1$, $\lambda_s\mapsto1$, $\lambda_t \mapsto 1$). Of course convex combinations of these two states are also tracial, but are these all the tracial states? If no, is there a complete description of all tracial states on $C_\text{r}^\ast(\mathbf{D}_\infty)$? How do they look like?
|
G. K. Pedersen proved that $C^*(D_\infty )$ is isomorphic to the subalgebra of $C([-1, 1], M_2)$ formed by all continuous functions $$ f:[-1,1]\to M_2, $$ such that $f(-1)$ and $f(1)$ are diagonal, via an isomorphism taking the two generators $s$ and $t$ to the functions $f_s$ and $f_t$ defined by $$ f_s(x) = \pmatrix{ 1 & 0 \cr 0 & -1}, \quad \text {and} \quad f_t(x) = \pmatrix {x & \sqrt{1-x^2} \cr \sqrt{1-x^2} & -x}. $$
If $\mu $ is any probability measure on $[-1, 1]$ then the functional $$ \tau (f) = \frac 12\int_{-1}^1 \text{tr}(f(x))\, d\mu (x) $$ is a trace. There are four other traces on this algebra, actually characters, not covered by the above class of examples, given by $$ \tau ^-_{1}(f) = f(-1)_{1, 1}, $$ $$ \tau ^-_{2}(f) = f(-1)_{2, 2}, $$ $$ \tau ^+_{1}(f) = f(1)_{1, 1}, $$ $$ \tau ^+_{2}(f) = f(1)_{2, 2}, $$ so there are many more traces than the ones described by the OP. On the other hand, I believe the above span all traces of $C^*(D_\infty )$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "group theory, operator algebras, c star algebras, dihedral groups"
}
|
Why are there so many oranges in Sheridan's quarters?
I've noticed that there are a very large number of oranges in Sheridan's quarters for some reason, and I also noticed a few in Garibaldi's (although Zach did ask, are you on a diet? hinting that it might not be ordinary). It doesn't seem that it was referenced in any special way or explained as I recall. Why is this?
|
John's obsession with oranges seems to stem from his childhood, eating oranges from his family's orchard.
> When I was 12, I used to sit in my dad's garden the air full of the smell of orange blossoms watching the sky, dreaming of faraway places.
>
> The Geometry of Shadows
And deprivation of them while he was out on the rim as captain of the Agamemnon.
> I haven't had an orange in almost two years. I used to dream about them. Grapes, nectarines, plums, the black ones, not the red ones. I mean, it's amazing what two years on the Rim can do to you. I have a hunch I'll be spending a lot of time in Hydroponics.
>
> Points of Departure
Obviously as captain of the station, one of the perks is access to stocks directly from the hydroponic gardens, including oranges.
|
stackexchange-scifi
|
{
"answer_score": 22,
"question_score": 12,
"tags": "babylon 5, food"
}
|
django categorizing model instances
When I run:
python3 manage.py makemigrations
after saving the below code, it shows error:
> todo.Task.status: (fields.E005) 'choices' must be an iterable containing (actual value, human readable name) tuples.
I want to categorize every Task instance according to todo, complete or incomplete. This property is to be specified while creating every Task instance. The tasks are to be shown on different columns on HTML page.
The code below does not work:
from django.db import models
STATUS_CHOICES = ('complete', 'incomplete', 'todo')
class Task(models.Model):
name = models.CharField(max_length = 128)
due = models.DateTimeField(blank = True, null = True)
status = models.CharField(max_length = 16, choices = STATUS_CHOICES)
def __str__(self):
return (f"{self.name}")
Please Help.
|
from django documentation : Field.choices
An iterable (e.g., a list or tuple) consisting itself of iterables of exactly two items (e.g. [(A, B), (A, B) ...]) to use as choices for this field. If this is given, the default form widget will be a select box with these choices instead of the standard text field.
The first element in each tuple is the actual value to be set on the model, and the second element is the human-readable name. For example:
YEAR_IN_SCHOOL_CHOICES = (
('FR', 'Freshman'),
('SO', 'Sophomore'),
('JR', 'Junior'),
('SR', 'Senior'),
)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, django, django models"
}
|
A function $f:\mathbb{R^+}→\mathbb{R}$ satisfies the condition $f(ab)=f(a)+f(b)$ for $a,b>0$. prove that $f$ is continuous on $\mathbb{R^+}$.
A function $f:\mathbb{R^+}→\mathbb{R}$ satisfies the condition $f(ab)=f(a)+f(b)$ for $a,b>0$. If $f(x)$ is continuous at $x=1$, then prove that $f$ is continuous on $\mathbb{R^+}$.
Attempt:
I have proved $f(1)=0$, $f(1/c)=-f(c),~~ c>0$.
Consider a sequence $\\{x_n\\}$ in $\mathbb{R^+}$ converges to $c>0$, then $$\lim_{n\to \infty}f(x_n)=\lim_{n\to \infty}f(\frac{x_n}{c}c)=\lim_{n\to \infty}f(\frac{x_n}{c})+\lim_{n\to \infty}f(c)$$
how to proceed further to use sequential criterion of continuity to prove that $f$ is continuous on $\mathbb{R^+}$.
> My aim is to use sequential criterion of continuity $x_n\to c$ and $f(x_n)\to f(c)$ implies $f$ is continuous.
Please help.
|
Using your desired approach, we have by conditinuity of scalar multiplication that $x_n/c\to c/c=1$. So, as $f$ is continuous at $1$ by hypothesis, we have, as you wrote, $$\lim_{n\to \infty}f(x_n)=\lim_{n\to \infty}f\left(\frac{x_n}{c}c\right)=\lim_{n\to \infty}f\left(\frac{x_n}{c}\right)+\lim_{n\to \infty}f(c)=f(1)+f(c)=f(c)$$ (as $f (1)=f(1\cdot 1)=f(1)+f(1)$ implies $f(1)=0$) and so $f$ is continuous at $c$ as for any sequence $\\{x_n\\}$ converging to $c$, we have that $f(x_n)\to f(c)$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "calculus, real analysis, continuity, functional equations"
}
|
Run JS code after user signed in with Devise in Rails 5
I want to run some javascript code after user is logged in.
I'm using this code to redirect a user to his profile.
def after_sign_in_path_for(resource)
profile_path
//call js code
end
It's possible to accomplish this?
|
try below code to run some js code after signin:
def after_sign_in_path_for(resource)
session[:js_code] = true
profile_path
end
# In profile view
<script type="text/javascript">
$(document).ready(function(){
<% if session.has_key?(:js_code) %>
session.delete(:js_code)
// write your js code here
<% end%>
})
</script>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, ruby on rails"
}
|
How to define clock input in Xilinx
Hey, I have almost no experience with Xilinx. I have a group project for a Digital Logic course that is due soon, where my partner, who was supposed to take care of the Xilinx simulations decided to bail on me. So here I am trying to figure it out last minute.
I have designed a synchronous counter using a few JK Flip Flops and I need to define the CLK input for the FJKCs.
I have drawn up the correct schematic, but I cannot figure out how to define a clock input.
Any help appreciated, and yes, this is homework. I just can't find any basic xilinx documentation/tutorials online and I honestly don't have time to learn the whole IDE.
I'm using VHDL
|
Check out this example.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all; -- for the unsigned type
entity counter_example is
generic ( WIDTH : integer := 32);
port (
CLK, RESET, LOAD : in std_logic;
DATA : in unsigned(WIDTH-1 downto 0);
Q : out unsigned(WIDTH-1 downto 0));
end entity counter_example;
architecture counter_example_a of counter_example is
signal cnt : unsigned(WIDTH-1 downto 0);
begin
process(RESET, CLK) is
begin
if RESET = '1' then
cnt <= (others => '0');
elsif rising_edge(CLK) then
if LOAD = '1' then
cnt <= DATA;
else
cnt <= cnt + 1;
end if;
end if;
end process;
Q <= cnt;
end architecture counter_example_a;
Source
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "vhdl, xilinx, digital logic"
}
|
How to make two UIImage sizes the same in swift?
I want to match the size of "yellow_noise.png" to the size of the "pickedImage" from the UIImagePickerController. What should I do?
originalImageView.image = pickedImage
overayImageView.image = UIImage(named:"yellow_noise.png")

overlayImageView.image = UIImage(named:"yellow_noise.png")
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "swift3, uiimage, uiimagepickercontroller"
}
|
Listing Number one records in a Simple SQL Database.
I have a small database with four tables arranged as follows;
TABLE band_members COLUMNS: band_id(PK), name, dob, country, sex
TABLE bands COLUMNS : band_id(PK), band_name
TABLE cds COLUMNS : cd_id(PK), rdate, title, position, weeks
TABLE releases COLUMNS : cd_id, band_id
What I'm trying to do is display the name of the band and the number of times they've had a number one record. (i.e. position = '1')
This is the code I've tried that doesn't seem to be working:
SELECT band_name
FROM cds
JOIN releases ON cds.cd_id = releases.cd_id
JOIN bands ON releases.band_id = bands.band_id
GROUP BY (position='1')
|
You should probably have a bandmembers_band table, as you are most likely eventually have to deal with band members that are part of multiple bands - this happens often these days.
To answer:
SELECT band_name, count(cds.cd_id)
FROM (select cds.cd_id, cds.position from cds where cds.position = 1 group by cds.cd_id)
JOIN releases ON cds.cd_id = releases.cd_id
JOIN bands ON releases.band_id = bands.band_id
GROUP BY band_name
having count(cds.cd_id) > 0
(pseudo - may work out of the box)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql, sqlite"
}
|
A graph with diameter $2$
Suppose that we have a graph $G$ having $n$ vertex with diameter $2$ ,
Let $M=max\\{deg(v_i) \\}$ where $v_i$ are vertex of $G$ then $M\geq n-3$.
I just made up this. It can be wrong but I could not find counter example.
Any counter example or proof is welcome.
|
A counter example : Let $\Sigma=\\{\sigma_1,\sigma_2,...,\sigma_k\\}$ a finite set. Define a graph $G$ such that
* The set of vertices is $\Sigma^2$
* Two vertices $xy$ and $zt$ are neighbours if and only if $x=z$ or $y=t$.
* Hence diameter of $G$ is 2, number of vertices is $k^2$ and $M=2k-2$
As soon as $2k-2\le k^2-3$ it is a counter example.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "graph theory"
}
|
Disabling form default behavior rails
I am trying to disable my default form behavior. I know typically to do this I am supposed to return false but that is not working. Does disabling default behavior only work after making a post request? I want to disable it because
**A) I want to see if my values are being serialized correctly.**
**B) I want to make a server request in the future without using post, but rather by using websockets**
Current code:
$(document).ready(function() {
$(".attack").submit(function() {
var values = $(this).serialize();
console.log(values);
return false;
});
return false;
});
|
Are you sure the CSS selector ".attack" applies to the form? Returning false is the right way of disabling the default behavior in this case, as you can see here.
Maybe ".attack" applies to your button? If that's the case, you can use `$(".attack").click` instead (but you still have to return false or receive the event as a parameter and call `event.preventDefault()` before exiting the function).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, ruby on rails"
}
|
Why does GotFocus event keep deleting itself from Designer?
I wanted to add a GotFocus event to a Windows Forms Textbox, so I used the method described in this question; it works, but after I run my application a couple of times the piece of code deletes itself and I don't know why.
This is the code that keeps deleting itself:
txtID.GotFocus += txtID_GotFocus;
|
It disappears because you don't use conventions that are used by WinForms designer when you add event handlers.
It doesn't matter whether you use `GotFocus` or `Enter` event. If you (in your Designer.cs) manually add event handler this way:
txtID.Enter += txtID_Enter;
then it would always disappear from designer next time you move control on designer surface.
**You must add event handlers this way:**
txtID.GotFocus += new System.EventHandler(txtID_Focus);
txtID.Enter += new System.EventHandler(txtID_Enter);
and nothing would disappear because it's the way designer expects code to be.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, winforms"
}
|
How do I compute speed based on acceleration and drag?
I'm interested in simulating the (one-dimensional) speed and position of a car.
How can I compute the speed $v(t)$ given initial speed $v_0$, acceleration $a(t)$ (I don't want to assume that it is constant) and a drag independent of the time and dependent only of the current speed in a quadratic way, i.e., $d(t) = d_0 \cdot v^2(t)$?
I'm stuck at $v(t) = \int a(t) dt$ and don't know how I can incorporate the drag.
|
I'm not sure I understood the question, is a(t) given?
If yes so write $ dV/dt+d_1V^2=a(t)$
now if a(t) is a constant you can separate variables and get $dV/(a(t)+d1_V^2)=dt$ and do integration from $V_0$ to V and $t=0$ to t here is the answer $V(0)=V_0, d_1=d_0/M$ M=mass of body
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "physics"
}
|
Utilities function in Google App Scripts not working
Function `Utilities.formatDate` in Google App Scripts is not working correct for date in year 2013
**Example-**
date = Tue Dec 31 2013 18:43:12 GMT+0530 (IST)
after formatting it in YYYYMMdd format
**using code-**
Utilities.formatDate(date, "IST" ,"YYYYMMdd"))
result was- 20**14**1231
In the above result year is expected to be 2013 as per above mentioned date.
The same code is working correct for date in 2012 and 2014.
|
Just change your pattern from YYYY to yyyy (lower case) and it will work, check this:
function myFunction() {
var date = new Date("Tue Dec 31 2013 18:43:12 GMT+0530 (IST)");
//after formatting it in YYYYMMdd format
var format = Utilities.formatDate(date,"IST", "yyyyMMdd");
Logger.log(format);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "google apps script, simpledateformat, date formatting"
}
|
How can I mark a message as read in MailKit
I use MailKit to read some messages from a GMail Account. Works great, but when my application has read a message, I want to mark the message as read, and save that state to GMail. Is this possible with MailKit? I have not found anything about it yet.
|
The way to mark messages as read using the IMAP protocol is to set the `\Seen` flag on the message(s).
To do this using MailKit, you will first need to know either the index(es) or the UID(s) of the messages that you would like to set the `\Seen` flag on. Once you have that information, you will want to call one of the `AddFlags()` methods on the `ImapFolder`. For example:
folder.AddFlags (uids, MessageFlags.Seen, true);
To mark messages as unread, you would _remove_ the `\Seen` flag, like so:
folder.RemoveFlags (uids, MessageFlags.Seen, true);
|
stackexchange-stackoverflow
|
{
"answer_score": 68,
"question_score": 37,
"tags": "c#, mailkit"
}
|
why different download way result in different display?
When i down the file on the web with my firefox,
<
it looks fine in my EXCEL.
!enter image description here
When i down the file with my python code,
from urllib.request import urlopen
url="
html=urlopen(url)
outfile=open("g:\\000559.csv","w")
outfile.write(html.read().decode("gbk"))
outfile.close()
it looks stange, when open it with my EXCEL,there is one line filled with proper content ,and one line filled with blank ,you can try it in your pc.
Why will different download way result in different display ?
!enter image description here
|
Add a 'b' flag to the file open, i.e. change this:
outfile=open("g:\\000559.csv","w")
To this:
outfile=open("g:\\000559.csv","wb")
Explanation here. The original file had a `\r\n`, and Python is converting the `\n` to `\r\n`, meaning you have an extra carriage return at the end of every line (`\r\r\n`).
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python"
}
|
Derive from Control and then allow others to apply a style
I have derived a new control from Control base class and set the DefaultStyleKeyProperty in the static constructor so that the appropriate style from Generic.xaml is used to defined the ControlTemplate. This all works fine and I get the expected appearance of several buttons etc.
Now I want to add some Style instances that customize the settings of my new control, such as the font and foreground color. But when I assign the style to the custom controls Style property it seems to remove the original default style and so it no longer has any appearance.
This doesn't seem quite right. The TabControl has a default style but you can still assign a Style to the TabControl.Style property that only modifies the Foreground color and it will not remove the rest of the TabControl appearance in the process.
Any ideas what I am doing wrong?
|
Declare your new style based on the default:
<Style TargetType={x:Type MyControl} BasedOn={StaticResource {x:Type MyControl}>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "wpf, styles, controltemplate"
}
|
User-icon at top left corner in Ubuntu 20.04
Is there some way to get rid of the 'user (home) icon' in the top-left corner of my Ubuntu 20.04 screen? Clicking on it just duplicates what I get when opening the Files management application which I keep in the Dock since I use it so frequently. Having recently upgraded from Ubuntu 18.04, I don't mind the Trash icon near the top-left corner but this new icon seems redundant. Is there some added advantage to it that I haven't discovered?
|
**GUI Option**
1. Launch the "Extensions" app.
2. Click on the settings (gear) icon next to "Desktop Icons".
3. The Desktop Icons configuration dialog will appear.
Note: If you don't see "Extensions" app, you can launch the Desktop Icons configuration dialog using the command:
gnome-extensions prefs desktop-icons@csoriano
4. On the dialog, toggle the "Show the personal folder in the desktop" switch.
`, con lo que obtendrás cadenas de texto con el formato deseado.
La función recibe dos parámetros, la longitud todal de la cadena y la cantidad de posiciones decimales que dejará al formatear el número, por ejemplo:
with X as (
select *
from (values (1, cast(1.25 as float), cast(1.25 as float), cast(2.5 as float))
, (2, 1.25, 1.25, 2.5)
, (3, 1.25, 1.25, 2.5)
) q1 (indicador, col1, col2, resultado)
)
select str(col1, 15, indicador), str(col2, 15, indicador), str(resultado, 15, indicador)
from x;
Nos da la salida:
--------------- --------------- ---------------
1.3 1.3 2.5
1.25 1.25 2.50
1.250 1.250 2.500
(3 rows affected)
|
stackexchange-es_stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "sql, sql server, sql server 2008"
}
|
Get the product with highest sales
I need a query to return the products that have been sold most often.
I have two tables to work with.
Product
IDPRO(PK) DESCRIP STOCK PRICE
4000 PIZZA 7 2000
4001 HAMBURGUESA 8 800
4002 PAELLA 1 1000
4003 CORDERO 5 3000
4004 COMIDA CHINA 9 500
4005 ALBONDIGAS 9 500
Details
IDPRO(FK) Amount
4002 2
4003 1
4004 1
4002 3
4002 1
4003 100
4004 50
4004 3
4005 10
The result would be something like this
CORDERO
Since it is the product with the highest amount of sold units.
|
If you need the total quantity you could use sum and group by on the joined tables
select t1.IDPRO, t1.DESCRIP, sum(t2.Amount) total
FROM Product t1
INNER JOIN DETAILS t2 on t2.IDART = t1.IDPRO
GROUP BY t1.IDPRO, t1.DESCRIP
ORDER BY total desc
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "sql, select"
}
|
Tab completion for filetypes in the commandline
If I want to set the filetype manually in vim, I would like to tab complete filetypes vim recognizes. However, right now vim just inserts a literal `^I`
:set ft=markd^I
Is this possible?
|
### Builtin command `:setfiletype`
For setting the filetype there is additionally a dedicated vim command `:setfiletype` which supports tab completion and `<C-d>`:
:setfiletype mar<tab>
:setfiletype <C-d>
The command can be abbreviated as following:
:setf mar<tab>
:setf <C-d>
### Plugin fzf.vim
The plugin fzf.vim provides furthermore the command `:Filetypes`.
:Filet[ypes]<CR>
> prompt
At the prompt you can enter a filetype with fuzzy matching e.g. `mkd` for `markdown` or `jsc` for `javascript`.
|
stackexchange-vi
|
{
"answer_score": 2,
"question_score": 1,
"tags": "command line, filetype, autocompletion"
}
|
how to install c++ fastcgi development library?
I can't seem to find anything on this.
I know `apt-get install`, but I don't know the name of the package for the standard c++ fastcgi development library.
What is it?
|
you will have to install boost first
sudo apt-get install libboost-all-dev
I am not aware of a fastcgi c++ package in ubuntu so...
download the library from nongnu.org
wget
extract archive
tar -xvf fastcgi++-2.1.tar.bz2
build
cd fastcgi++-2.1
./configure
make
make check
sudo make install
|
stackexchange-askubuntu
|
{
"answer_score": 7,
"question_score": 5,
"tags": "12.10, package management, c++, cgi"
}
|
Story about robots whose brains are slowing down
I'm looking for a story that I read a few years ago. I cannot remember if it was a short story in an anthology of other stories or stand-alone book, but here are some details I do remember.
* Definitely a book. This was not a TV show or movie.
* The story revolved around a robot/automaton who, in a series of journal entries, explains that he discovered that his race was dying off.
* The protagonist found through self experimentation that his brain was controlled by wind, and for some reason, there was less wind available.
* The protagonist experimented on himself to determine that his brain was essentially a system of gears which are turned by the wind.
* One plot point involved some sort of ritual which was supposed to take place at a certain time, but he noticed that it was slightly off
* I believe the story ends with the robot dying, but am not sure about this.
|
This is Exhalation by Ted Chiang. It is available online at Lightspeed Magazine.
The situation is:
> The machines exist in an artificial world. There is a reservoir of argon gas underneath the "ground," which is being depleted as they draw upon it and release it aboveground. They are slowing down.
P.S. After posting this I noticed it is a duplicate of this answered question: Searching for a short story about metallic lungs But I don't know how to denote that here.
|
stackexchange-scifi
|
{
"answer_score": 11,
"question_score": 8,
"tags": "story identification, books"
}
|
query result alias
Hi I've a query like this
select * from emplyees
result is
name dept status
emp1 Admin y
emp2 admin n
I'm going to bind it to gridview like mygridview.datasource = ds;
now here i want to display approve instead of y and disapprove instead of n
how can i write a query ?
thank you
|
You don't state what database you are using. If you are using SQL Server, then you could write this as:
SELECT name, dept, CASE WHEN STATUS = 'Y' THEN 'Approve' ELSE 'Disapprove' END AS STATUS
FROM EMPLOYEES
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "c#"
}
|
c++ sizeof operator - pointer to double
I have unexpected outcome with sizeof operator (C++). In main class, I have these lines
double * arguments_ = new double();
*arguments_ = 2.1;
*(arguments_+1) = 3.45;
cout << (sizeof arguments_) << ' ' << (sizeof arguments_[0]) << ' '<< (sizeof arguments_)/(sizeof arguments_[0]);
which give me output 4 8 0
Double size is 8 bytes, and (sizeof arguments_[0]) = 8. However, why is (sizeof arguments_) not expressed in bytes as well (2*8 = 16)? Is sizeof operator applica
|
Both values are expressed in the same units. You have a 32-bit system, so the size of an address is 32 bits, or 4 bytes. The size of double on your system is 8 bytes. The result of an integer division `4/8` is zero.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "c++, size, double, sizeof"
}
|
Can I click on file dialog using SikuliFireFoxDriver?
I understand that WebDriver cannot interact with dialogs, but since Sikuli compares images to interact is it possible to interact with file dialogs using SikuliFireFoxDriver?
|
Looking at < it seems to be possible to click on file dialog.
If above doesn't work for you, I would recommend you to go through:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, selenium webdriver, sikuli, selenium firefoxdriver"
}
|
Use of finally in java
Consider the code
try{
//code
} catch(Exception e) {
// handle
} finally {
// close open connections
}
and this
try{
//code
} catch(Exception e) {
// handle
}
// close open connections
since both are same what is the necessity of finally block?
|
The `finally` block will always be executed, even if you don't catch all the exceptions thrown by the `try` block in the `catch` block, or if the `catch` block throws a new exception.
In the second snippet, the code following the `try`-`catch` block won't be executed if either the `try` or `catch` blocks throw exceptions not caught by the `catch` block.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -4,
"tags": "java, try catch, finally"
}
|
How to fix a 2x4 table that is too heavy for its own good?
I made a table by gluing 2x4's together on the long side (4" side). This resulted in a table of abnormal weight. Now the table is sagging in the middle.
Overall table dimensions are 31"X50".
Can I fix this table by flipping it over and attaching the legs on bottom to make the bottom the new top - thus letting gravity do the work?
Would additional bracing be ideal?
Is there a chance this will tear itself apart?
.on( 'click', '.item', function() {
$(".item").removeClass('is-expanded');
$(this).addClass('is-expanded');
$(".item").each(function(){
$(".item").click(true).css("cursor", "pointer");
$(".is-expanded").click(false).css("cursor", "default");
});
however, I can still click on item with class `.is-expanded` while it shouldn't as we only click on all other items without that class
|
If i understand your logic, you want:
$(document).on( 'click', '.item:not(.is-expanded)', function() {
$(".item").removeClass('is-expanded');
$(this).addClass('is-expanded');
});
And set cursor in CSS, as you should:
.item {
cursor: pointer;
}
.item.is-expanded {
cursor: default;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jquery"
}
|
need help to fix spring boot project
I'm trying to add new name,lastName and email. After clicking save button I got an error message " Field error in object 'employee' on field 'id' " How can I fix this error . I'm using spring boot with thymeleaf and jquery.

@Column(name=id)
private Integer id;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery, spring boot, thymeleaf"
}
|
C# UWP set Tabpage backgroundcolor
I've created a Tabpage on a Microsoft.UI.Xaml.Controls Tabcontrol like this:
muxc.TabViewItem TabPage = new muxc.TabViewItem();
TabPage.Name = "MyTab";
TabPage.Header = "Title.txt";
TabPage.Background = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
MyTabControl.TabItems.Add(TabPage);
So now I tried to change the backgroundcolor of the Tabpage:
TabPage.Background = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));
But the tabpage backgroundcolor hasn't changed.
Does anyone know what i did wrong?
;
# @ is the literal "@" character
# and \w+ matches consecutive letters
You certainy might want to use `preg_replace` to transform them into links. Or better yet `preg_replace_callback` to move some logic into a handler function.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, explode"
}
|
Can TinyMCE strip out the surrounding html - doctype, html and body tags?
I want to save a snippet of HTML formatted text that will be merged into a larger HTML doc (for HTML email). TinyMCE is saving my snippet with doctype, html and body elements. I only want what the user types in with HTML formatting.
|
If TinyMCE is providing you an entire HTML document you likely have the `fullpage` plugin loaded:
<
If you don't want a complete HTML document removing that plugin should cause TinyMCE to only return the HTML inside the `<body>` tag of the editor.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "tinymce, tinymce 4"
}
|
Magento 1.9.x ORM query to get past successful orders with specific billing street, city, state and zip
I need an ORM query to get all past successful orders with a specific billing street address, city, state and zip code? ie:
$street = '999 west rd';
$city = 'my town';
$state = 'New York';
$zip = '90001';
//write ORM query to get all past
//successful orders with all those exact values
|
Note that the address components are not indexed in the DB, so the following query will scan all the success orders in the address table.
$collection = Mage::getResourceSingleton('sales/order_collection')
->addFieldToFilter('main_table.state', array('in'=>array('complete', 'processing'))) // successful orders, is 'closed' state success?
->addFieldToFilter('a.street', $street)
->addFieldToFilter('a.city', $city)
->addFieldToFilter('a.region', $state)
->addFieldToFilter('a.postcode', $zip)
->addFieldToFilter('a.address_type', 'billing'); // another type is 'shipping'
$collection->getSelect()->join(
array('a' => $collection->getTable('sales/order_address')),
'a.parent_id=main_table.entity_id',
array()
);
foreach ($collection as $item) {
$result[$item->getId] = $item->getData();
// etc.
}
|
stackexchange-magento
|
{
"answer_score": 1,
"question_score": 1,
"tags": "magento 1.9, orders, orm"
}
|
Android Wear Version number in 4 places
Every time I upgrade my Android Wear App version number I have to change 2 lines in 4 files to the exact same value
For clarity I am refering to `versionCode` and `versionName` in
1. mobile/src/main/AndroidManifest.xml
2. wear/src/main/AndroidManifest.xml
3. mobile/build.gradle
4. wear/build.gradle
It just doesn't feel right
Is there a standard way to centralize the version numbers?
|
I went through the same pain and have come up with the following;
Firstly you don't need to include the version details within your manifest files if they are in the build.gradle.
To centralise the version numbers in the two build.gradle files add your version details into the gradle.properties at the root project level, creating the file if it's missing:
# Project-wide Gradle settings: gradle.properties
VERSION_NAME=2.2.1
VERSION_CODE=207
Then in your build.gradle files within your wear and mobile apps change the versions to reference the project variables
android {
defaultConfig {
...
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
}
}
That way you only have to change your project level gradle.properties when you want to update the version details.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "android studio, android gradle plugin, wear os"
}
|
Using a variable variable name in Visual Basic
How to use a variable variable name in Visual Basic (.Net)?
dim test as String
test = "mysetting"
My.Settings.{test} = "something"
Which should be the same as doing:
My.Settings.mysetting = "something"
|
Eh?
My.Settings(test) = "something"
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "vb.net, variables"
}
|
PHP How To Show Hide DIVS based on Query String Value
Essentially, I'm completely new at PHP - using dreamweaver cs6 (its all i have)
I have to get the value of a query string (someurl.com/id=something). After i get the value, I need to show a single div based on the ID.
While I know there really isn't any REAL "page load" event for PHP, I'd like to have it when the page opens.
So, how do I accomplish this?
I started with this:
<?php
$stringId = $_GET['id']
?>
<script language="javascript">
document.getElementById('$stringId').style.display = "block";
</script>
<?
?>
Since I don't have a server setup, will something like this work? Would you suggest something else? Am I completely wrong?
Any input would be appreciated. Thank you.
|
You should set the style inline with out relying on javascript as some users may have javascript turned off.
<div <?php if($_GET['id'] == 'X'){ ?>style="display: block;"<?php } ?>>
your div content
</div>
with an else as requested
<div style="<?php if($_GET['id'] == 'X'){ ?>display: block;<?php } else { ?>display: none;<?php } ?">
your div content
</div>
you could also use a predefined css class
based on your comment about having way to many to do a switch if you need to mix it up just insert this
<script language="javascript">
document.getElementById('<?php echo $_GET['id']; ?>').style.display = "block";
</script>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, pageload"
}
|
Reviewing my previous questions
How do I view my questions that are tagged with a certain tag? Example: All the questions that I've asked that are tagged jQuery-mobile.
|
Have you tried clicking the jquery-mobile tag located at the bottom of your profile page? This will list all of your posts with that tag. You can do that with any of the tags listed at the bottom of your profile page (unlike the ones listed beneath each question on your profile page, which link to the tag proper).
It's actually a short cut for a search construct, `user:`, which lets you search for posts from a specific user. You can specify the user ID, or just `me` to refer to yourself. So in this example, the search would be [`user:me [jquery-mobile]`](
Find out about all the cool search operators on our Search Help Page, which you can use to further refine your search with, for example, `is:question` to specify only questions or `votes:1` to only find questions with at least one upvote.
|
stackexchange-meta
|
{
"answer_score": 5,
"question_score": 1,
"tags": "support, questions"
}
|
NAudio playing multiple sounds together gives exception "All mixer inputs must have the same WaveFormat"
I am trying to play multiple sound files at the same time using NAudio MixingSampleProvider's AddMixerInput method. I am using the AudioPlaybackEngine found at this page: <
However, when I tried to play different files, I get an exception while playing some sounds: "All mixer inputs must have the same WaveFormat" It is probably because the sound files I have do not have the same sample rate (I see some files have 7046 as sample rate, instead of 44100).
Is there a way to modify the CachedSound class so that the sample rates are all converted to 44100 when reading the files?
Thanks!
|
You cant mix audio streams together without converting them to the same sample rate. In NAudio there are three ways of accessing a resampler:
* WaveFormatConversionStream - this uses the ACM resampler component under the hood. Note that you may have issues resampling IEEE float with this one.
* MediaFoundationResampler - this uses MediaFoundation. It allows you to adjust the resampling quality.
* WdlResamplingSampleProvider - this is brand new in the latest NAudio, and offers fully managed resampling.
As well as matching sample rates, you also need matching channel counts. NAudio has various ways to turn mono into stereo and vice versa.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 3,
"tags": "c#, .net, vb.net, audio, naudio"
}
|
Conditions for expressing a system as difference equation
I have read when studying this subject that a system is LTI and causal if and only if it can be expressed as a difference equation (if it is in continuos time, as a differential one). I don't know if this is true, mayne I'm remembering it wrong.
The problem is that today I thought of the case of an IIR filter. It is not causal and it can be written as a difference equation.
So I have two questions about this:
1) Why does an LTI system have to accomplish the initial rest condition (causality?) in order to be expressed as a difference equation?
2) What about the IIR filters? They are not causal and they can be expressed as a difference equation. Why is that? What am I thinking wrong?
|
A difference equation _does not_ imply causality.
For example, consider this system, with input $x$ and output $y$:
$y[n] + 0.2 y[n-1] = x[n] + 0.5 x[n-1]$
You can solve it (recursively) forwards in time as $y[n] = x[n] + 0.5 x[n-1] - 0.2 y[n-1]$.
Or you can solve it backwards in time as $y[n-1] = 5 x[n] + 2.5 x[n-1] - 5 y[n]$.
These are 2 valid and different results for the same difference equation. These 2 results correspond to the 2 possible regions of convergence of the system response (Z transform). Inner ROC corresponds to the causal solution; outer ROC to the non-causal solution.
Systems of greater order will have more ROCs and more different solutions.
If you impose causality, then you are implicitly selecting the inner ROC.
For the second question, IIR filters can be causal. The example above is an IIR system. The causal impulse response will be $h_{causal}[n] = (-0.2)^n u[n] + 0.5 (-0.2)^{n-1} u[n-1]$. This is causal _and_ IIR.
|
stackexchange-dsp
|
{
"answer_score": 1,
"question_score": 0,
"tags": "filters, linear systems"
}
|
How can one use one's old FBAR form data to populate a new FBAR form?
How can one use one's old FBAR form data to populate a new FBAR form (Report of Foreign Bank and Financial Accounts (FBAR) on FinCEN Form 114)?
I tried exporting/reimporting the form data between some previous year's FBAR form and this year's form via Adobe Acrobat (Edit -> Form Option -> Export/Import), but when trying to submit the PDF on < I got the following message:
> IMPORTANT NOTICE: This form version is no longer accepted as of February 1, 2019. FinCEN is only accepting the latest discrete form version (open a new FBAR form to obtain the latest version) and batch XML files for the FinCEN FBAR. Please see Hot Topics at < for more information.
:
> 1. Export the data from the old form to XML
> 2. Edit the XML file in a text editor to change `FFBAR` to `FBARX`. [that was my issue]
> 3. Import the data into the new form from XML
>
Also, personally, I had to do a 4th action: add the `Part I - Section 5: Date of birth` in the new form, which for some reason didn't get imported.
* * *
Some screenshots:
To Import/Export the data to/from an XML file:
:
lockscreen
I am sure that its not from the picture itself that I am using, as this is just a tile (1 pixel width) that fills the picturebox!
If you want to see it on your computer, you can get the screensaver from here: iPhoneLS
Why does this "shadow" occur? Thanks for your help!
|
You probably set the `Image` property of the `PictureBox`? I believe the image scaling of the picture box in `StretchImage` mode is not very accurate and thus causes the artifact (which I just verified by taking a 1px wide part of your screenshot and scaling that to the entire width of my screen using a `PictureBox`). Try to set the `BackgroundImage` property instead (having `BackgroundImageLayout` set to `Tile`), which does not stretch the image. You don't need a `PictureBox` for that purpose though.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, picturebox, shadow"
}
|
Cannot invoke getGreen() on the Primitive Type int
So I'm continuing with my app to pick colors out of a picture taken by the user and returning the RGB values. The problem is that when I attempt to get the green value for the color, I get an error saying "cannot invoke getGreen() on the Primitive Type int". Here's the code I wrote:
Bitmap bitmap = ((BitmapDrawable)iv.getDrawable()).getBitmap();
int touchedRGB = bitmap.getPixel(x,y);
rgbvals.setText("Color Value" + "#" + Integer.toHexString(touchedRGB));
rgbvals.setTextColor(touchedRGB);
int gval = touchedRGB.getgreen();
I also attempted to write the final line as
String gval = Integer.toString(touchedRGB).getGreen();
But of course getGreen() can only be used on type int. Thanks in advance for the help guys!
|
You can use the static method `green` of the `Color` class :
> Return the green component of a color int. This is the same as saying (color >> 8) & 0xFF
`int gval = Color.green(touchedRGB);`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, android, image processing, colors"
}
|
TPT load operator to load relational tables to Teradata target
Can we use TPT load operator to load Oracle relational tables to Teradata target?
Since FLOAD only loads from flat files, can we use Tables here in TPT LOAD operators?
What can be the workaround this? We have the oracle tables which needs to be loaded to teradata target using TPT LOADER CONNECTIONS.
|
The high level functionality of TPT is such that any Producer operator can be used with any Consumer operator.
Load Operator is a consumer, it can be used with any producer operator. Some common options when loading from Oracle are
1. Data Connector Producer
2. ODBC Connector
In first option, you can extract data from Oracle and dump (spool) it on the disk, then use Data Connector Producer to create a script somewhat similar in functionality as the traditional Fastload utility.
Or the second option; you can use the ODBC connector to use an ODBC connection to extract data directly from Oracle and send to the Load operator for loading to Teradata.
I think the second option is what you are looking for.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "teradata"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.