INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Avoid cmd.exe start closing Windows terminal
I need to run a program of mine with a /realTime priority option. For that purpose I'm running on CMD:
cmd.exe /k start "MyProgram" /WAIT /RealTime "C:\Users\Me\bin\Release\MyProgram.exe" " option"
start will run the process MyProgram at the highest priority and when it finish however closes the window (the /WAIT parameter doesn't work in this case as it's not a matter of synchronizity). The /k parameter cannot catch in the same way the result of start command, as it closes itself. Do you know how can I use start command setting a priority without cmd closing my window terminal? Thanks a bunch.
|
Got it. The way to go is:
cmd /k start "C" /B /WAIT /RealTime "C:\Users\Me\MyProgram.exe" " option"
It's the only way I see to prevent start command closing windows. The /B param will run MyProgram in the same window, instead of opening a new one exlusively for the command. The cmd /k will do its work to prevent start closing the window when the program has finished.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows, batch file, cmd"
}
|
Get FontFamily from Font instance
As stated in the title i have a Font instance and i would get the FontFamily used to build that Font instance.
I need that specific FontFamily istance (or the ability to istantiate an equivalent instace).
Edited : As asked i used Winform (on windows mobile, so i use NetCF 3.5)
|
You can use this to get the `FontFamily` of a `Font`:
FontFamily ff = oldFont.FontFamily;
**Update** \- In .NET CF, all classes are optimized for minimal resource usage. The FontFamily property, thus does not exist in the `Font` class.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, fonts, font family"
}
|
Почему strlen неточно определяет количество символов?
char buffer[] = "<center>asdfsafasdfasdfasdfadfdfg4444444444444444444333333333333663333333333563453245gdfgaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa35234dkfgnskldjfgjsdfghsdfg 1</center>";
(char)strlen(buffer); // возвращает "-52"
Как такое вообще происходит?
|
char имеет диапазон значений от -127 до 128. А у вас вроде 208 символов (если BBEdit правильно посчитал). Попробуйте unsigned char или unsigned int.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 8,
"question_score": 0,
"tags": "c"
}
|
Chemical equilibrium constant problem
> In a equilibrium reaction $\ce{CO {(g)} + H2O {(g)} <=> CO2 {(g)} + H2 {(g)}}$, initial concentrations of $\ce{CO}$ and H2O are equal and are 0.3 mol/dm3. What is the equilibrium constant of the reaction if the equilibrium concentrations of CO2 and H2 are equal and are 0.1 mol/dm3?
I tried to solve it this way:
$$\begin{split} \ce{K_r} & = \ce{\frac{[CO2][H2]}{[CO][H2O]} \\\ & = \frac{(0.1)(0.1)}{(0.3)(0.3)} \\\ & = \frac{(0.1)^2}{(0.3)^2} \\\ & = \frac{0.01}{0.09} \\\ & \approx 0.11 mol/dm^3} \end{split}$$
But the correct answer is 0.25 mol/dm3
What did I do wrong? What is the right way of solving problems like this one?
|
0.1 is the _equilibrium_ concentration of $\ce{CO2}$ and $\ce{H2}$. 0.3 is the _initial_ concentration of $\ce{CO}$ and $\ce{H2O}$. Let's plug 0.1 into an ICE-box as $x$.
\begin{array}{|c|c|c|c|c|} \hline \text{Initial}:& 0.3 & 0.3 & 0 & 0 \\\ \hline & \ce{CO} & \ce{H2O} & \ce{CO2} & \ce{H2}\\\ \hline \text{Change}: & -x & -x & +x & +x \\\ \hline \text{Equilibrium}: & 0.3-0.1 & 0.3-0.1 & 0+0.1 & 0+0.1\\\ \hline \end{array}
_Mass action expression:_
$$K_\mathrm{c} = \frac{(0+0.1)^2}{(0.3-0.1)^2} = 0.25$$
|
stackexchange-chemistry
|
{
"answer_score": 2,
"question_score": -1,
"tags": "inorganic chemistry, equilibrium"
}
|
How to ignore the Nuxt.js starting question
When I run command `npm run dev` in a nuxt project, there'll be a question asked in the log,
> NuxtJS collects completely anonymous data about usage. 23:02:58 This will help us improving Nuxt developer experience over the time. Read more on < Are you interested in participation? (Y/n)
I want to know how to skip this question when running the project?
|
As documentation explain: <
> 1. You can disable Nuxt Telemetry for your project with several ways: Setting telemetry: false in your nuxt.config:
>
export default {
telemetry: false
}
> 2. Using an environment variable
>
NUXT_TELEMETRY_DISABLED=1
> 3. Using npx nuxt telemetry disable
>
npx nuxt telemetry [status|enable|disable] [-g,--global] [dir]
|
stackexchange-stackoverflow
|
{
"answer_score": 40,
"question_score": 16,
"tags": "nuxt.js"
}
|
3-coloring graph zero-knowledge proof
I was researching about zero-knowledge proofs and in this link < I've seen the exercise question:
* Currently, you can only select adjacent pairs of nodes to check. Would the proof still be zero knowledge if you could pick arbitrary pairs of nodes to check?
I think it would still be "zero knowledge" because it shouldn't leak information to verifier, but there won't be a proof if you select non-adjacent pairs since the reveal phase doesn't prove anything. Is this a trick question?
|
Yes, it would still be zero knowledge. However, it wouldn't be a proof of anything, since whether the colors matched or not, you still know nothing about whether the graph is actually 3-colored or not. It's not a trick question -- just a bad one.
|
stackexchange-cstheory
|
{
"answer_score": 3,
"question_score": 0,
"tags": "graph colouring, zero knowledge"
}
|
Quartz expression every hour
I wanted to clarify which of the below expressions are meant to execute the cron job every hour all the time? I have EXPRESSION_1 configured to run every hour but am noticing some weird behavior with the cron skipping the job for a few hours. Can someone clarify please
EXPRESSION_1=0 0 * * * ?
EXPRESSION_2=0 0/0 * * * ?
|
Your first expression looks correct and will execute every hour.
As your requirement is once per hour you could also use a quartz `SimpleTrigger` and avoid using a cron expression.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "java, quartz scheduler"
}
|
Reverse list of strings python [One Liner]
I am trying to reverse a list of strings. For instance
> one two three
will be output as
> three two one
I have tried this
[x for x in range(input()) [" ".join(((raw_input().split())[::-1]))]]
but I am getting an error:
TypeError: list indices must be integers, not str
|
To actually address your code and why it fails with an error, you are trying to index the range list with a `str` i.e `" ".join((raw_input().split()[::-1]))`:
range(input())[" ".join((raw_input().split()[::-1]))]
You would need to loop over the inner list for your code to run without error:
[s for x in range(input()) for s in [" ".join((raw_input().split()[::-1]))]]
Which would output something like:
2
foo bar
foob barb
['bar foo', 'barb foob']
And can simplify to:
[" ".join((raw_input().split()[::-1])) for _ in range(input())]
If you want a single string just call join on the outer list, I would also recommend using `int(raw_input(...` generally but I know you are code golfing.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, reverse"
}
|
How to fix program closing right after input statement
I'm making a simple text game in Python 3, and I tried to make an input statement, but when I answer it, the program closes. How can I fix this?
I've tried Googling it, but I just see "program closes straight after opening it".
def startgame():
print("####################")
ign = input("Type a name. ")
print("####################")
namedecision = input("You have picked " + ign + ".\nAre you sure you want\nto keep this name? (Y/N) ")
if namedecision == ['y','Y']:
# put game func
print("####################")
if namedecision == ['n', 'N']:
ign = input("Type a name. ")
namedecision = input("You have picked " + ign + ".")
print("####################")
# game func
startgame()
I expect that if I typed Y or N it would execute the proper functions.
|
Your `if` statements are always returning false because your input will always be a string, and you are comparing it to a list. Change your `==` for `in` in order to check if a string (or any other type) is in a list.
Corrected code:
def startgame():
print("####################")
ign = input("Type a name. ")
print("####################")
namedecision = input("You have picked " + ign + ".\nAre you sure you want\nto keep this name? (Y/N) ")
if nameDecision in ['y','Y']:
# put game func
print("####################")
elif nameDecision in ['n', 'N']:
ign = input("Type a name. ")
namedecision = input("You have picked " + ign + ".")
print("####################")
startgame()
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python"
}
|
Why is the 100*0.07 equal to 6.9999....?
One of my friends wrote the following in Matlab and the outputs are little weird:
for p=0.01:0.01:0.1
100*p
end
The following was the output:
1
2
3
4
5
6.000000000000001
6.999999999999999
8
9
10
I'd like to know why there is a slight error? Does this mean that, the accuracy in the general case is also as poor as it is in this case?
EDIT:
We compared the numbers -- `7==6.999999999999999` and the output was `0`. So, Matlab contradicts itself!
|
The problem is that 0.01 cannot be exactly represented in binary floating-point. Neither can 0.07.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 3,
"tags": "matlab"
}
|
Are Scala parallel collections better in some ways than the parallel collections already available in Java?
I've recently been learning about various libraries for concurrency in Java such as `ConcurrentHashMap` and the lovely non blocking one from Cliff Click
I don't know much about Scala but I've heard good things about the recent parallel collections library.
I'd like to know what are some major advantages that this library would give over Java based libraries?
|
The two collections are for different uses.
Java's concurrent collections allow you to use them from a parallel context: many threads can access them simultaneously, and the collection will be sure to do the right thing (so the callers don't have to worry about locks and such).
Scala's parallel collections, in contrast, are designed to run high-order operations on themselves without you having to worry about creating threads. So you can write something like:
myData.par.filter(_.expensiveTest()).map(_.expensiveComputation())
and the filter and map will each execute in parallel (but the filter will complete before the map starts).
|
stackexchange-stackoverflow
|
{
"answer_score": 26,
"question_score": 12,
"tags": "java, scala, collections, concurrency, parallel processing"
}
|
extract data from XML response w/PHP
When I get an API response containing this:
<?xml version="1.0" encoding="utf-8"?>
<response xmlns=" status="ok">
<client_id>17992</client_id>
</response>
I can get the results of the `<client_id>` using this.
$xml = simplexml_load_string($server_output);
$client = (string) $xml->client_id;
echo $client; // produces 17992 in this case
but if I add this below, I do not get a value assigned to $response.
$response = (string) $xml->response; // produces empty value
How do I write the PHP code to check if XML response "status" = OK?
|
This should work great for you :)
$xml['status'];
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 6,
"tags": "php, xml, variables, simplexml"
}
|
Getting uniform audio levels from AudioRecord across different devices
I am trying to put together a voice recording app, and I noticed a huge discrepancies in the audio samples levels returned by the AudioRecord when the same code is run on different devices (tried with LG G4, Samsung S4). Just FYI, I am targeting API Level 21.
Is there a way to make the returned values on different devices fall roughly within the same range?
Thanks
|
That is because microphones have different sensitivity and frequency response. You could:
* Obtain/measure those characteristics across variety of devices and compensate for them.
* Use some sort of calibration procedure. For example having a reference speaker, play the pink noise at given level, calculate the level and adjust the gain to the value that you want.
* Use Automatic Gain Control.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, audio, signal processing, audiorecord, audio processing"
}
|
Почему не работает код на C?
Начал изучать C. Элементарная программа:
#include <stdio.h>
#include <math.h>
int main(void) {
float a;
float b;
scanf("%f", a);
scanf("%f", b);
printf("Result: %f", pow(a, b));
}
`Exit status -1`. Почему не работает так, как я запланировал? Почему в выводе не указана ошибка? Что исправить?
|
Кратко:
scanf("%f", &a);
scanf("%f", &b);
Вы должны передавать _адрес_ переменной, куда писать считываемое значение. У вас пишет по случайному адресу, в который преобразуется значение из переменной `a` (а потом `b`, если до этого дойдет и программа не рухнет раньше).
Но не верится, что это не было написано большими буквами в учебнике, который вы читаете - что нужно передавать адрес переменной. И что компилятор вас не предупреждал о возможной проблеме...
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "c"
}
|
How can I put a value in a column of a Dataframe based on oher columns (Python)?
I have a dataframe df in pandas with the next data structure:
+------+------+
| col1 | col2 |
+------+------+
| 2 | 1 |
+------+------+
| nan | 3 |
+------+------+
| nan | nan |
+------+------+
There are some values for columns col1 and col2 that are nan, and the others are Integers. What I would like to do is to add a new column col3 to my df dataframe where the values of the other columns are considered.
In this case, if col1 and col2 values for a row are integer values, the new value of col3 would be 0. If col1 is nan and col2 is not nan, col3 would have 1 value. And finally, if both col1 and col2 are nan, col3 would have 2 value.
How can I do it?
|
Use `numpy.select` with conditions, default values is if col1 is not NaN and col2 is `NaN` values:
df = pd.DataFrame({'col1':[2, np.nan, np.nan, 5],
'col2':[1,3,np.nan, np.nan]})
m1 = df['col1'].isna()
m2 = df['col2'].isna()
df['out'] = np.select([~m1 & ~m2, m1 & ~m2, m1 & m2], [0,1,2], default=3)
print (df)
col1 col2 out
0 2.0 1.0 0
1 NaN 3.0 1
2 NaN NaN 2
3 5.0 NaN 3
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, pandas, dataframe, nan"
}
|
JQuery .slideDown() is sliding up
This works but I'm not sure why. In `function capIn()`, in my mind the line `$botcap.slideDown("slow")` should slide the div down. It slides it up. If I try using `.slideUp()` nothing happens as if it is trying to slide it down. Can anyone explain this to me?
$(".slide").hover(capIn, capOut);
function capIn(){
//slide top caption down
var $topcap = $(this).children(".topcap");
$topcap.slideDown("slow");
//slide bottom caption up
//!! Why does slideDown slide caption up here?
var $botcap = $(this).children(".botcap");
$botcap.slideDown("slow")
}
function capOut(){
//slide top back up
var $topcap = $(this).children(".topcap");
$topcap.slideUp("slow");
//slide bottom back down
var $botcap = $(this).children(".botcap");
$botcap.slideUp("slow");
}
|
jQuery's `slideDown` and `slideUp` functions are actually misnomers. As the documentation for `slideUp` puts it:
> Hide the matched elements with a sliding motion.
The hiding is achieved by modifying the height of the element; normally, this means that the lower edge of the element appears to slide up, hence the name. However, if the element is anchored at the bottom (e.g. by setting `position: absolute` and `bottom: 0`), the height modification will make the top edge appear to slide down.
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 5,
"tags": "javascript, jquery, hover, slidedown, slideup"
}
|
Prove that the sequence $\frac{1}{n}$ does not converge in $\Bbb R\setminus \lbrace 0\rbrace$
The definition of convergence is:
$(\exists x\in \Bbb R\setminus \lbrace 0\rbrace)(\forall \epsilon>0)(\exists N\in \Bbb N)(n\ge N\Rightarrow |x_n-x|<\epsilon)$.
I need to prove its negation:
$(\forall x\in \Bbb R\setminus \lbrace 0\rbrace)(\exists \epsilon>0)(\forall N\in \Bbb N)(n\ge N\land |x_n-x|\ge \epsilon)$.
Now I need an explicit construction of $\epsilon$ for each $x\in \Bbb R\setminus \lbrace 0\rbrace$. Could someone please help? Thanks in advance!
|
Fix $x\in\mathbb{R}\backslash\\{0\\}$. By Archimedes' axiom, there exists a natural number $N_x$ such that $\frac{1}{N_x}<|x|$. Put $\varepsilon=|x|-\frac{1}{N_x}$. Subsequently, for every $n>N$, one has: $$|\frac{1}{n}-x|\geq |x|-\frac{1}{n}>|x|-\frac{1}{N_x}=\varepsilon$$ so $\\{\frac{1}{n}\\}$ does not converge to $x$.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 0,
"tags": "real analysis, sequences and series, convergence divergence, cauchy sequences"
}
|
Error in SQL case statement when trying to create binary flag?
Here's my query where I'm testing my case structure:
SELECT TOP 1 CASE 130
WHEN '000000000000000' THEN '0'
WHEN '' THEN '0'
WHEN 'XXX' THEN '0'
WHEN 'RETIRED' THEN '0'
WHEN 'STUDENT' THEN '0'
ELSE '1'
END AS employed_flag
INTO #employedbeta
FROM CreditBureau.Experian
I'm just trying to make a new temporary table, but I'd like my case to work first. I keep getting the error:
Conversion failed when converting the varchar value 'XXX' to data type int.
In the database, the column 130 is a char, and I don't know why it thinks I want to make it a number. SQL server management studio, if it matters. The column name is 130, I left the '1' off because I rewrote it here but I get the error regardless in my actual query.
|
`130` is an integer literal. If that's really the column name, you'll have to escape it using double quotes. As a side note, you should probably return the same type (char) in the `else` branch too:
CASE "130"
WHEN '000000000000000' THEN '0'
WHEN '' THEN '0'
WHEN 'XXX' THEN '0'
WHEN 'RETIRED' THEN '0'
WHEN 'STUDENT' THEN '0'
ELSE '1'
END AS employed_flag
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "sql, select, case, ssms"
}
|
How to get and parse JSON using objective C?
Is it possible to get and parse JSON using objective C, then manipulate it within the cocoa framework for the iphone/pad? I'm specifically looking to do this for a couple of public APIs out there.
|
See here: how to do json parsing in iphone
Basically, you should look into the TouchJSON library (with CJSONDeserializer and CJSONSerializer).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "objective c, json"
}
|
How do I bind a closure to a static class variable in PHP?
<?php
class A
{
public $closure;
public static function myFunc($input): string
{
$output = $input . ' is Number';
return $output;
}
public static function closure(): Closure
{
return function ($input) {
return self::myFunc($input);
};
}
public static function run()
{
$closure = self::closure();
echo $closure(1); // 1 is Number
self::$closure = $closure;
echo self::$closure(2); // Fatal error
}
}
A::run();
I want to bind `self::closure()` to `self::$closure`, and use it internal, but it disappears somewhere. How do I bind a closure to a static class variable in PHP?
|
* Change your property to be static `static $closure;`
* Wrap your callable in brackets `(self::$closure)(2);`
<
<?php
class A
{
static $closure;
public static function myFunc($input): string
{
$output = $input . ' is Number';
return $output;
}
public static function closure(): Closure
{
return function ($input) {
return self::myFunc($input);
};
}
public static function run()
{
$closure = self::closure();
echo $closure(1); // 1 is Number
self::$closure = $closure;
// Wrap your callable in brackets
echo (self::$closure)(2);
}
}
A::run();
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "php, static, closures, bind"
}
|
Определение мобильного браузера
У кого есть готовое решение? И кто что может сказать по этому поводу?
|
Вот эта тема! Советую обратить внимание конкретно на ссылки! А конкретно в топике ТС'а.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php"
}
|
how to maintain text justification after forcing a new line
How to break a line of text (`\newline` or `\\`) and still maintain justification for its texts?
|
`\\` (which you should almost never use) is for leaving the line short. `\linebreak` (which you should almost never use) is the command to force a line and still justify the paragraph.
`\linebreak` has an optional argument, such that `\linebreak[3]` (or 2) will only break if the break makes the result not too spaced out.
Rather than force a linebreak it is better just to stop the break you do not want by ending the paragraph `blah blah blah~abc`. so it will not break before abc. That way if you edit the text and this is not needed at all it just acts as a space without affecting the paragraph breaking.
|
stackexchange-tex
|
{
"answer_score": 34,
"question_score": 25,
"tags": "horizontal alignment, line breaking, text decorations"
}
|
UITableViewCell - Change Visited/active background color
Is it possible to change the visited / Active style for a UITableView Cell?
I have styled the inactive state using the storyboard gui interface - but there doesnt seem to be options for the other possible states..
|
There's no default way to handle the different styles for tableView cells, but you should have no issue implementing that behaviour on your own by subclassing the UITableViewCell and adding the required behaviour by changing the backgroundView depending on an arbitrary state.
There's a good amount of information here: How do you load custom UITableViewCells from Xib files?
And a tutorial link from the same question: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "objective c, xcode"
}
|
Active directory automatic login to SSRS
I have a server running SSRS 2012 at address `server1.olddomain.com`. This is working fine.
My users will be accessing this server from another address (the server is not physically moving). The new address is `server2.newdomain.net`. I modified the UriRoot option in the config file, and it works fine, except users are now prompted for their username and password through AD rather than being logged in automatically. (Once they enter their username and password in the form olddomain\username, they are logged in successfully).
How can I configure this to log users in automatically? The users' domain hasn't changed, nor has the server moved physical locations. Is this possible to do?
EDIT: I wasn't sure whether to post on here or ServerFault. Let me know if you think it would be better suited there.
|
This may be a simple matter of Internet Explorer not automatically detecting server2.newdomain.net as an "intranet" site. By default, IE will only do automatic Windows authentication in the intranet zone.
To see if this is the case, you can add "server2.newdomain.net" to the list of trusted intranet sites. Open IE, and do this:
1. Go to Tools, Internet Options.
2. Go to the Security tab, click Local intranet, and click the Sites button.
3. Click Advanced to open the list of sites.
4. Enter the full name ("server2.newdomain.net") into the appropriate box, and click Add.
If this gets automatic login working, then you'll have to decide how you want to solve the issue. You can specify a list of sites for the trusted intranet zone via Group Policy, but this prevents users from being able to add or remove anything on that particular list. If there's a cleaner way to do it, I'd be interested in knowing too, as we run into this a lot with intranet sites on various DNS domains.
|
stackexchange-dba
|
{
"answer_score": 2,
"question_score": 1,
"tags": "sql server, ssrs, active directory, ssrs 2012"
}
|
jQuery change css right align when td data numeric (dynamic table)
$('tr > td:gt(0)').filter(function() {
return this.innerHTML.match(/^[0-9\s\.,]+$/);
}).css('text-align','right');
I am trying to loop through a dynamic table and right align every td that contains numeric data on each row EXCEPT the first td on each row.
It works on the first tr but not each subsequent row...
|
The reason this isn't working is that your jQuery selector is collecting all `td` elements (that are children of `tr`s), and _then_ sub-selecting all but the first one. To avoid this, you can iterate over the rows of the table, applying your filter to the `td` elements of each one:
$('tr').each( function () {
$(this).children('td:gt(0)').filter(function() {
return this.innerHTML.match(/^[0-9\s\.,]+$/);
}).css('text-align','right')
});
If you only want to apply this to a certain table, change the selector in the first line to `'#table-id tr'`.
Here it is in action: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "jquery, css, html table"
}
|
How to configure vim such that `_` is also counted as part of a word?
According to the Unicode standard, `_` (the underscore character) is part of a word. This means that when you skip your cursor to the next word (in many interfaces you can do this with Ctrl + the arrow keys) you will skip over all the `_` characters as well as the letters and numbers in-between.
However, vim (where moving to the next/previous word is done using `w` or `b` in normal mode) regards `my_variable_name` not as one word, but as five: `"my", "_", "variable", "_", "name"`.
I would like to configure Vim's behaviour such that `_` is also properly considered a word character. How can this be done?
|
In my `vim` the underscore character is considered part of the word, i.e. is skipped when moving back and forth with `w` and `b`. This behaviour can be altered with `:set iskeyword-=_` as described here.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 1,
"tags": "vim, unicode"
}
|
Add up numbers in a for loop
I got a very simple problem that I cant figure out.
This is what i want to do :
6 * (1/(1*1) + 1/(2*2) + 1/(3*3) + … + 1/(N*N))
And this is my code attempt, that does not work.
int eingabe = 5;
double c = 0;
for (int i = 1 ; i<=eingabe ;i++) {
c += 1/(i*i);
}
c *= 6;
System.out.println(c);
Please help me guys ! What do I have to do to make the code work?
|
change `1/(i*i)` to `1.0/(i*i)`, currently you're doing integer division
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": -2,
"tags": "java, for loop, numbers, add"
}
|
Finding current (I) in a basic circuit
!Schematic
This has been bothering me:
If I am told \$v_1 = -36\,\mathrm{V}\$ and \$v_2 = 18\,\mathrm{V}\$, how am I meant to find \$i\$?
I figured since \$v_1\$ is giving off a negative current it would be flowing in the opposite direction of \$i\$, and wouldn't the equation to find \$i\$ then become \$18-(-36)=i\$?
I thought about loop or nodal analysis but then I realized there aren't really any nodes, just loops.
|
There're nodes. Just use ohm's law/nodal analysis. If you find \$ \frac{V_1}{8} =I_8 \$ you have one current flowing out of the node where V1 is. Then \$\frac{V_1-V_2}{6} = I_6 \$ is another current flowing away from node V1 (and into node V2). Then you do \$\frac{V_2}{4} = I_4 \$is a current flowing out of node V2. Now you have all the currents flowing into and out of both nodes except for i itself. But \$i\$ flows into one node and out the other node so you could write it like this:
At node V1:
$$ I_8+I_6+i = 0 $$ At node V2:
$$ I_6+ i = I_4 $$
Then sub in the voltage/resistance equations into the node equations. Also note that you can simplify this if you realize that \$I_8 = -I_4 \$. That's one less variable to have to track down.
Use algebraic substitution or any other method you prefer to simplify your equations to solve for i.
|
stackexchange-electronics
|
{
"answer_score": 1,
"question_score": 0,
"tags": "circuit analysis, kirchhoffs laws"
}
|
Does blood that comes from your lips nullify your fast?
If a person fasts for a Kaffarah and during the day their lips cracked and started to bleed. The person put their tongue on their lip and tasted the blood. But this was not intentionally. Does this break their fast? Or do you think that they should do their Kaffarah again?
|
Technically, yes this is an issue (but there is a loophole of some sorts). It has happened to me before, and so I had decided to confront one of the Marja' about this (Makarem Shirazi).
What he told me is that in fasting, the "rule" is that you cannot drink any liquids nor eat anything. Blood is a liquid, and thus does nullify the fast if goes into your mouth. HOWEVER, if the blood goes into your mouth without you noticing it, and when you do notice it you immediately wipe the blood off your lips to make sure it does not enter your mouth again, this is considered legal.
Hopefully this helps you.
|
stackexchange-islam
|
{
"answer_score": 1,
"question_score": 2,
"tags": "sawm, oaths, kaffarah"
}
|
How to copy projects in Eclipse
When I copy the project in Eclipse, then a new project is copied named
copy of project
Now when I run it, then the URL bar still says the old project name in title.
Where is the reference stored so that I can run using new project name?
|
I believe you are referring to a copying a web project and the URL corresponds to the context root of the web app. You can change it at Project Properties -> Web Project Settings -> Context Root.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, eclipse, project"
}
|
At what pressure ratio did the fuel turbopumps of the F1 and J2 operate?
I would like to know the operating points of the fuel-turbo-pumps used in the Saturn rocket engine. (From what I could learn via google, the turbo pump went under the name Mark III) Is there any information on the pressure ratio of these pumps?
 :
The F1 fuel (RP-1) pump had an inlet pressure of 45 psi and an outlet pressure of 1856 psi.
The J2 fuel (Hydrogen) pump had an inlet pressure of 30 psi and an outlet pressure of 1238 psi.
|
stackexchange-space
|
{
"answer_score": 4,
"question_score": 6,
"tags": "rockets, engine design, engines, turbomachinery, turbopump"
}
|
How to store GOOGLE_APPLICATION_CREDENTIALS in an AWS ECS environment on Fargate?
We have an API app that uses Firebase Admin to send messages to devices. Earlier, we used to specify the service account key using environment variable like GOOGLE_APPLICATION_CREDENTIALS="path_to_file.json". But now, since we are shifting to AWS Elastic Container Service on Fargate, I am unable to figure out how to put this file in the container for AWS ECS.
Any advice highly appreciated.
Thanks
|
Solved it by storing the service key as a JSON Stringified environment variable & using `admin.credential.cert()` instead of defaultAppCredentials. Refer: <
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "amazon web services, environment variables, amazon ecs, google authentication, firebase admin"
}
|
Can I use public domain content in my CC-BY-SA-licensed work?
If I create a Creative-Commons-licensed work, say CC-BY-SA 4.0, and I include some CC0/public domain content:
1. Do I have to explicitly mark the public domain content as such?
2. Can the entire work be licensed as CC-BY-SA 4.0 given that some of the content has an even less restrictive license and **especially** given that I am not its original author?
|
If a work is in the public domain, then you have the right to do just about anything you can think of with it. The CC0 license tries to give you the same rights to the largest extent possible under the applicable law.
Those rights include incorporating the CC0/public domain work in a larger work, which is under a different license, without indicating that some parts are not created by you.
As you don't have to indicate that parts copied from a CC0/public domain source are not by your hand, you also don't have to indicate which content is CC0/public domain.
For all practical purposes, your entire work should be regarded as being under the CC-BY-SA license (or whichever other license you choose), but I would not litigate people who appear to have copied only the content that was under the CC0/in the public domain without following your license. For all you know, they obtained a second copy of that content under the original terms.
|
stackexchange-opensource
|
{
"answer_score": 5,
"question_score": 4,
"tags": "creative commons, public domain"
}
|
Regular expression validation for string [01:3:14/ 1:8:20]
I am pulling my head for below problem.
I have text box in my application that will take time in the format 1(days):23(hours): 15(minutes). I want to apply validation for this field so it will take string in the format [01:05:15/ 1:4:30] only.
Please tell me the workaround for this.
|
You can use separator like below.
^([0-2]\d?|3[01]):([0-1]\d?|2[0-3]):(00?|15|30|45)$
If you need more information check below.
<
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net"
}
|
Building PhoneGap/Cordova plugin with a non-redistributable library
The online PhoneGap/Cordova builder apparently requires that your plugin source and dependencies be accessible in a public GitHub repo. My plugin requires a vendor library that I'm licensed to distribute as part of an app, but I don't think I'm allowed to redistribute the library jar by itself.
Is there any way I can use the online builder without checking the jar into a public GitHub repo?
|
If by "online builder" you mean phonegap build, if you purchase a paid plan you can upload private plugins that only you can use.
<
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "cordova"
}
|
Accessing an external SQL database in iOS
I am writing an iOS application that needs to access data from an external SQL Server 2005 database. I already have a website that accesses the same data.
I usually access the SQL server database using .NET along with stored procedures for security reasons. I need to populate an array that will itself populate another `TableViewController`. As I'm fairly new to the whole iOS thing, kindly let me know how I can do this. If it's possible, please suggest the syntax or Google keywords for this.
|
I'd recommend making a simple WCF .NET REST Service that queries your database and returns what you need.
I'm pretty sure your iOS app will not be able to connect to it directly.
Check out the following; <
<
The code project tutorial is very easy to follow. And you can download the project code.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ios, sql server, xcode4, database connection"
}
|
If g and h agree on a set do they agree on its closure?
Let $X, Y$ be topological spaces. Let $A \subset X$. Let $f : A → Y$ be a continuous map. Assume that there exists a continuous function $g : cl(A) → Y$ such that $g|A = f$.
(a) Let $h : cl(A) → Y$ be another continuous map such that $h|A = f$ . Is $h = g$ always?
(b) Suppose in part (a) additionally we are given that $Y$ is Hausdorff. Then is $h = g$?
I have solved (b) but (a) seems too difficult. I tried giving a counterexample with Zariski Topology but can't.
|
Let $X=Y=\\{a,b\\}$ with the T$_0$ topology $\\{\emptyset,X,\\{a\\}\\}$. Define $g(x)=x$ and $h(x)=a$. The functions are continuous, and they agree on the open set $A=\\{a\\}$, but they do not agree on $\bar A=X$.
Here is a T$_1$ example. Let $A$ be a countably infinite set. Let $p,q$ be two distinct points not in $A$. Let $Y=A\cup\\{p,q\\}$ with the topology $$\tau=\\{U\subseteq Y:\text{ either }U\subseteq A\text{ or else }A\setminus U\text{ is finite}\\}.$$ Then $Y$ is a T$_1$ space but is not Hausdorff, and $A$ is a dense open subset of $X$. Let $X=Y\setminus\\{q\\}$ with the subspace topology; $X$ is a compact metrizable space, and $A$ is dense in $X$. Let $g:X\to Y$ be the inclusion map $g(x)=x$. Let $h:X\to Y$ be the same except that $h(p)=q$. Then $g$ and $h$ are continuous maps which agree on the set $A$ but not on its closure.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 4,
"tags": "general topology"
}
|
Where is the "Terminate all" button in Eclipse?
I can't seem to find (even in **debug mode** ) the following icon in eclipse: !Terminate All button . Is there a way to make it visible again (I suspect that I need to check some box in Window->Preferences but I can't find it...)?
!enter image description here
!enter image description here
|
It seems that the terminate all button is **not available in Kepler**. Hence, the best way I've found to terminate all current runs is (workaround):
* Open the Debug tab.
* Select all runs (Ctrl+A)
* Right click on selection and select option "Terminate/Disconnect All"
Here is a screenshot exposing this workaround:
!How to "Terminate All" runs
It is not as simple as using the button. Nevertheless this solution is good enough for my needs.
Kudos to @Velthune for pointing out that _"In versions [Luna, Kepler, Juno, Indigo, Helios ] I can't find that icon!"_.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "eclipse"
}
|
Can't get value of variable in HTML element ID, small syntax error probably!
<?php for ($i=1; $i<=(count($img_array))/4; $i++): ?>
<input type="hidden" id="img{$i}_name" value="<?php echo ${'image_src'.$i};?>" />
<?php endfor;?>
In the output, the 'id' is exactly as the code, ie: img{$i}_name, but I want the $i to be replaced offcourse, by its value...
Syntax error probably, any ideas how to write it?
PS: The value works!
|
<?php for ($i=1; $i<=(count($img_array))/4; $i++): ?>
<input type="hidden" id="img<?php echo $i; ?>_name" value="<?php echo ${'image_src'.$i};?>" />
<?php endfor;?>
You're outputting the $i variable outside of the php tags so the interpreter never outputs it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, html"
}
|
IN DART - toList() method is not converting an Iterable of int into list, but when it is applied inside print() it works fine. Why?
I have created a list 'numbers' then used 'map' method to loop over it and assigned the output to squares. Now I apply toList() method on 'squares' to convert it to a List type but in output it's printed as iterable of int. However when I do the same thing inside the print() method then it gives me the output as a list. So why is it not working outside the print() method?
void main() {
const numbers = [1, 2, 3, 4];
final squares = numbers.map((number) => number * number);
squares.toList(); // I've applied toList() method here
print(squares); // But I don't get a list from this output
print(squares.toList()); // But I get it from this output. Why?
}
OUTPUT (1, 4, 9, 16) [1, 4, 9, 16]
|
`toList()` convert the data to list but you have to assign the result to a variable like this:
List list = squares.toList();
Then you can use the new variable.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "flutter, loops, dart, oop, mapping"
}
|
How can I check the total played time of a character?
I want to know where or how I can see how long I have played, so far, a certain character. I tried "/played", like in World of Warcraft, but it doesn't work.
Is there a way to find out how long I've played in _Diablo III_?
|
To find out how long you've played a certain character, when you're on the character selection screen, select a given character. It says on the right how long you've played them:
!image for time played of character
You can also find out how long you've played a class. When you're on the screen just after the character selection screen (the one from which you start a game, change quest, etc), press P to bring up your profile.
You'll see a screen that looks like this:
!image for time played of class
Hover over the class to bring up a tooltip for how long you've played it.
|
stackexchange-gaming
|
{
"answer_score": 27,
"question_score": 23,
"tags": "diablo 3"
}
|
InvalidTokenException was unhandled by user code - "Unauthorized"
This is my code:
string accessToken = "##";
string accessTokenSecret = "##"; string consumerKey = "##"; string consumerSecret = "##"; string appToken = "##"; string realmId = "##"; //company id in quickbooks online
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(oauthValidator, appToken, realmId, IntuitServicesType.QBO);
I am receiving: **InvalidTokenException was unhandled by user code - {"Unauthorized"}** in the creating the new ServiceContext line. Not sure what the problem is.
Thanks for any help provided.
|
This error message:
> InvalidTokenException was unhandled by user code - {"Unauthorized"}
Occurs when the OAuth tokens you're using are no longer valid.
I would double-check that:
* You're using a valid set of OAuth tokens that you got from Intuit
* The tokens are not expired (the Developer Playground tokens are very short lived, longer-lived 6-month tokens are available if you set up your own actual OAuth endpoint)
Here is Intuit's documentation for setting up your own OAuth endpoint:
* <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "intuit partner platform, quickbooks online"
}
|
What preposition should I use? "Cartels lead to 20-30% higher prices in/on/at/for... public procurement"
> "Cartels lead to 20-30% higher prices in/on/at/for... public procurement"
What preposition should I use?
I mean, as a result, eventual prices are higher to that extent.
|
I think you want:
Cartels lead to 20-30% higher prices in public procurement.
This means "goods or services bought through public procurement will cost 20-30% more due to the presence of cartels".
Cartels lead to 20-30% higher prices for apples.
This means "the apples will cost 20-30% more due to the presence of cartels".
You don't want 'at' or 'on' here to say what you mean, though there are some idiomatic prepositional phrases in common use that could make sense in context and that start with those:
Cartels lead to 20-30% higher prices at market.
Cartels lead to 20-30% higher prices on average.
|
stackexchange-ell
|
{
"answer_score": 2,
"question_score": 2,
"tags": "prepositions"
}
|
How to execute operation in scala with timeout?
Context: I want to write scalding job(hadoop) to crawl pages and I want to set timeout on url extraction(without timeout on URLConnection, I want generic solution for other timeout cases) i.e. map function.
I'm think about futures which are killed after some timout with all resources released since it is memory critical code. Not sure what to use in scala API.
|
While Akka was suggested--and is superior to the following solution--Scala does have its own, built in Actor model much like Akka which can do you want you want. Examples can be found here:
<
You'll probably want either reactWithin or receiveWithin, the documentation for which can be found here:
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "scala, hadoop, timeout, futuretask, cascading"
}
|
Divisibility Question, a bit difficult(for me).
Taken from An Introduction to the Theory of Numbers by Niven et al:
**Prove that if $m\gt n$ then $a^{2^n}+1$ is a divisor of $a^{2^m}-1$. Show that if $a,m,n$ are positive with $m\ne n$, then:**
**$gcd(a^{2^m}+1,a^{2^n}+1)=1$ (if $a$ is even) or $2$ (if $a$ is odd)**
I just got that since $a^{2^m}-1$ is divisible by $a^{2^n}+1$ it is equal to $x(a^{2^m}+1)$ for some integer $x$. But that's all I got.
P.S.: Sorry, but I'm extremely poor in Number Theory and related problem-solving. If you could suggest some methods to get better, I'd be highly obliged. And a final request, please make the answer simple such that I understand it. Thanks a lot!
|
Since a$^{2^m}$ is even, $a^{2^m}$\- 1 is the difference of squares. So we have $$ a^{2^m} - 1=(a^{2^{m-1}}-1)(a^{2^{m-1}}+1)$$.
Notice the first term is again a difference of squares. Continue in a similar process and you will find that $a^{2^n}+1$ is a factor.
Whenever you see a expression that can be factored, you should generally do that to find factors.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "elementary number theory, divisibility, gcd and lcm"
}
|
Shabal256 code explanation
Can anyone please explain the code below with comments?
What are `pbegin` & `pend` ?
What is ( I believe it is data, where it comes from ?): `(pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0]))`
What is (I believe it is the size of data 80?) : `(pend - pbegin) * sizeof(pbegin[0])`
What is : `pblank[1]`
template<typename T1>
inline uint256 HashShabal(const T1 pbegin, const T1 pend)
{
sph_shabal256_context ctx_shabal;
static unsigned char pblank[1];
uint256 hash[1];
sph_shabal256_init(&ctx_shabal);
// ZSHABAL;
sph_shabal256 (&ctx_shabal, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
sph_shabal256_close(&ctx_shabal, static_cast<void*>(&hash[0]));
return hash[0];
}
|
> What are pbegin & pend ?
Pointers to the beginning of the data and one byte past the end of the data, respectively. The function it's wrapping takes a pointer to the beginning plus the the size, so it needs to do some math with the pointers.
> What is (I believe it is data, where it comes from ?)
Presumably, if you found this code in a Bitcoin derivative, the data is a block header. This function might also be used to build a merkle tree. (Shabal256 appears to be fast enough for that.)
> What is : `pblank[1]`
A zero-length string. Presumably, sometimes this function gets called as `HashShabal(NULL, NULL)`, so this is for avoiding a null pointer exception.
> Can anyone please explain the code below with comments?
The purpose of this function appears to be to wrap the Shabal256 functions from Projet RNRT SAPHIR to make them easier to use.
|
stackexchange-bitcoin
|
{
"answer_score": 0,
"question_score": 1,
"tags": "block, hash, algorithms"
}
|
Append changes and send text in a workflow triggered email
I have been struggling to create this workflow.
A list with a multiline text field with append changes needs to trigger a workflow that sends email to the creator.
It does not matter if the workflow sends the latest comment or all comments, I am fine with both.
The workflow is triggered only if the original creator writes the comments and not someone else (which is what I need).
The workflow gives me an error message saying that the message 'Retrying last request... Item does not exist. It may have been deleted by another user. '
It could be because as soon as you type a comment it immediately goes 'outside the box' and leaves the box empty. Still I do not get why it is sent when the author writes the comments.
I have tried to create a variable to copy past the comment in a non-append text field but I get the same result.
|
So it turns out that whatever the problem was I solved it by using a 2010 template and impersonation step. The workflow as it is now works and I do not understand why it was not working before since the people involved all had elevated rights.
|
stackexchange-sharepoint
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sharepoint online, workflow, append changes"
}
|
The set $A := \{ k \in G \; | \; \mu_G(S) = \mu_G(S \cap k S) \}$ forms a closed subgroup of $G$.
There is the following result:
> Let $G$ be a locally compact group with Haar measure $\mu_G$. Suppose $S \subset G$ is measurable with $0 < \mu_G (S) < \infty$. Then $A := \\{ k \in G \; | \; \mu_G(S) = \mu_G(S \cap k S) \\}$ forms a closed subgroup of $G$.
I do not see why it should hold that $\mu_G (S) = \mu_G( S \cap xy S)$ whenever $\mu_G (S) = \mu_G (S \cap x S)$ and $\mu_G (S) = \mu_G (S \cap y S)$ with $x, y \in G$, that is, why $A$ is closed under the group operation.
Any help or comment is appreciated.
|
Clearly $S\setminus xyS\subset(S\setminus xS)\cup(xS\setminus xyS)$, where $$ A\setminus B=\\{u\colon u\in A \text{ and } u\notin B\\}. $$ Hence $$ \mu_G(S\setminus xyS)\le\mu_G(S\setminus xS)+\mu_G(xS\setminus xyS) =\mu_G(S\setminus xS)+\mu_G(x(S\setminus yS))=0+0=0. $$ Here $$ \mu_G(x(S\setminus yS))=\mu_G(S\setminus yS) $$ because of the invariance of the Haar measure.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "group theory, measure theory, topological groups"
}
|
Skip the first element in list
Is it possible with django template tags to skip the first element in a list when doing the for loop? For example I want to begin from element 1 instead from 0.
|
builtin slice filter
{{ qs|slice:"1:" }}
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 7,
"tags": "django, django templates"
}
|
Level of SQL Server in the messages window
I have this message
> Msg 6603, Level 16, State 17, Line 38
in the result pane (`ctrl`+`r`) of SQL Server Management Studio.
What does `Level 16` really mean? And where I can find the scale of the all these numbers?
|
See this article Error Handling in SQL 2000 – a Background or a more up-to-date article on MSDN.
Anything less than or equal to 10 is informational rather than an error.
Between 11 -16 there are various categories of user correctable errors (not the case that the higher the number the worse the error in this group)
Above 16 there are errors not corrigible by the user. Any error with severity 20 or above will terminate the connection.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "sql server"
}
|
Sorting different rows based on multiple conditions
I have a contacts table having two columns priority and name. Consider I have some 500 entries. I need to sort by following conditions
* First order by priority and top 20 should be returned.
* After that remaining rows to be sorted based on name.
Can this be possible in a single query.
|
You can combine multiple queries with UNION. Additional subqueries are needed to be able to user ORDER BY/LIMIT (otherwise, ORDER BY would apply to the entire result of the UNION). The LIMIT 20 subquery must be repeated to exclude the top 20 rows from the second query:
SELECT *
FROM (SELECT *
FROM Contacts
ORDER BY priority DESC
LIMIT 20)
UNION ALL
SELECT *
FROM (SELECT *
FROM Contacts
WHERE ID NOT IN (SELECT ID
FROM Contacts
ORDER BY priority DESC
LIMIT 20)
ORDER BY name)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, sqlite"
}
|
Reset AutoInc counters with Slick database
After a `delete` on a table, the counter for `AutoInc` isn't reset back to 1. This is the right behaviour, not disputing that, but I wonder if there is any way to reset the Slick `AutoInc` counter as well?
The only way I've found is to delete the entire database.
|
The way to go here would be slick plain SQL and use a db specific SQL query to do it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "database, scala, playframework, slick"
}
|
What are All the Ways a Programmer Could use PHP to Send an Email?
I'm looking for a list of built in PHP functions that a programmer could use to send an email.
The obvious answer here is `mail()`, but I'm also looking for a list of functions someone might use to manually open a connection to an MTA, or spawn a process on the local machine which might in turn send an email using sendmail, postfix, etc.
The context here is I want to scan a large, unknown codebase for code that's sending out email (because we already located a call to `mail()`, and that's not doing it)
|
And as well as the backtick, also check for popen() and system execution functions... <
exec
passthru
proc_close
proc_get_status
proc_open
proc_terminate
shell_exec
system
`
IMAP may be another depending on how PHP was configured... <
fsockopen is most likely the other one
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "php, email, sendmail, postfix mta, mta"
}
|
Inequality with 5 cyclic variables
For postive real numbers $a$,$b$,$c$,$d$ and $e$, prove that
$$\frac{4a^3}{a^2+2b^2+\frac{2b^3}{a}} + \frac{4b^3}{b^2+2c^2+\frac{2c^3}{b}} + \frac{4c^3}{c^2+2d^2+\frac{2d^3}{c}}+ \frac{4d^3}{d^2+2e^2+\frac{2e^3}{d}} + \frac{4e^3}{e^2+2a^2+\frac{2a^3}{e}} \geq $$ $$ \frac{2ab^2+2b^3}{a^2+2b^2 + 2\frac{b^3}{a} } + \frac{2bc^2+2c^3}{b^2+2c^2 + 2\frac{c^3}{b} }+ \frac{2cd^2+2d^3}{c^2+2d^2 + 2\frac{d^3}{c} } + \frac{2de^2+2e^3}{d^2+2e^2 + 2\frac{e^3}{d} } + \frac{2ea^2+2a^3}{e^2+2a^2 + 2\frac{a^3}{e} }$$
Can this be solved directly by $ AM-GM $?
|
By AM-GM: $$\sum_{cyc}\frac{4a^3}{a^2+2b^2+\frac{2b^3}{a}}-\sum_{cyc}\frac{2ab^2+2b^3}{a^2+2b^2+\frac{2b^3}{a}}=2\sum_{cyc}\frac{2a^4-a^2b^2-ab^3}{a^3+2ab^2+2b^3}=$$ $$=2\sum_{cyc}\left(\frac{2a^4-a^2b^2-ab^3}{a^3+2ab^2+2b^3}-(a-b)\right)=2\sum_{cyc}\frac{a^4+a^3b-3a^2b^2-ab^3+2b^4}{a^3+2ab^2+2b^3}=$$ $$=2\sum_{cyc}\frac{a^4-3a^2b^2+2ab^3+a^3b-3ab^3+2b^4}{a^3+2ab^2+2b^3}=2\sum_{cyc}\frac{(a+b)(a^3-3ab^2+2b^3)}{a^3+2ab^2+2b^3}\geq$$ $$\geq2\sum_{cyc}\frac{(a+b)\left(3\sqrt[3]{a^3\cdot\left(b^3\right)^2}-3ab^2\right)}{a^3+2ab^2+2b^3}=0.$$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "inequality, summation, a.m. g.m. inequality, tangent line method"
}
|
Word/phrase to describe something popular due to its availability
How can I describe something (tool, method, etc.) that is common in use but not necessarily for its quality, unique features and effectiveness.
In fact, it is kind of popular because it's easy to obtain and highly available.
|
The word _ubiquitous_ describes something that is seen and used everywhere.
It doesn't have any connotations of quality that you seek. It simply derives from the Latin _ubique_ , meaning _everywhere_.
|
stackexchange-english
|
{
"answer_score": 5,
"question_score": 1,
"tags": "meaning, word choice, single word requests"
}
|
Plotting hours and Dates on chart using Highcharts
Can anyone point me to an example for creating a plot chart using highcharts were the xAxis consists of the hours of the day 00:00 to 23:59 and the yAxis contains list of dates i can't find an example of how to achieve from the documentation.
basically the data that drives the chart would be something like this
15/05/2017: 09:00, 13:00, 14:30, 17:00, 19:15
16/05/2017: 09:30, 11:20, 12:45, 15:10, 18:00
17/05/2017: 08:30, 10:15, 13:00, 14:05, 20:30
Any examples or direction would be great.
Thanks
|
To achieve chart similar to your requirements you can use datetime xAxis with scatter series. <
You can change your datetime label format to HH:MM:SS using dateTimeLabelFormats parameter: <
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
millisecond: '%H:%M:%S',
second: '%H:%M:%S',
minute: '%H:%M:%S',
hour: '%H:%M:%S',
day: '%H:%M:%S',
week: '%H:%M:%S',
month: '%H:%M:%S',
year: '%H:%M:%S'
}
},
Here you can see an example how it can work: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "highcharts, highcharts ng"
}
|
Is it possible to use custom font as math font?
I can use a custom truetype font (e.g. georgia) as main font in pdflatex thanks to this tutorial.
Now, I want to use this font as math font for the entire document. Is it possible?
Note: I don't care if some symbols are missing or not, I just want to use this font in mathematical statements.
|
You can load the `mathastext` package, which is done for that.
From the documentation:
> The mathastext package changes the fonts which are used in math mode for letters, digits and a few other punctuation and symbol signs to replace them with the font as used for the document text.
|
stackexchange-tex
|
{
"answer_score": 3,
"question_score": 3,
"tags": "pdftex, truetype"
}
|
How To Hide The Last Top Nav Tab in SharePoint 2010
I have found how to hide the first top nav tab, but I need to hide the last one as well. Is it possible? If yes, how can I do it?
|
Edit your masterpage and add the following css code:
/* Hides the top navigation links */
.s4-tn { display:none !important; }
Unfortunately there is no setting in the site settings where could hide it.
Here is my favorite overview of all css classes in sharepoint 2010: <
|
stackexchange-sharepoint
|
{
"answer_score": 0,
"question_score": 0,
"tags": "navigation, top link bar"
}
|
Why all lines dispear after executing the lines on edited file?
vim command.txt
key="123456"
openssl enc -des3 -a -salt -in /tmp/test -k ${key} -out /tmp/test.asc
In vim's command mode `:1,2!bash`,the file `/tmp/test` was encrypted into `/tmp/test.asc` ,but all the lines in command.txt dispear,where is my lines in the edited file `command.txt`?
 meaning absolutely nothing - probably coined because it alliterates with zero and zilch.
It tends to connote a complete absence of something expected.
|
stackexchange-english
|
{
"answer_score": 2,
"question_score": 0,
"tags": "meaning, word usage"
}
|
Django template check for empty when I have an if inside a for
I have the following code in my template:
{% for req in user.requests_made_set.all %}
{% if not req.is_published %}
{{ req }}
{% endif %}
{% empty %}
No requests
{% endfor %}
If there are some requests but none has the is_published = True then how could I output a message (like "No requests") ?? I'd only like to use Django templates and not do it in my view!
Thanks
|
Even if this might be possible to achieve in the template, I (and probably many other people) would advise against it. To achieve this, you basically need to find out whether there are any objects in the database matching some criteria. That is certainly not something that belongs into a template.
Templates are intended to be used to define how stuff is displayed. The task you're solving is determining what stuff to display. This definitely belongs in a view and not a template.
If you want to avoid placing it in a view just because you want the information to appear on each page, regardless of the view, consider using a context processor which would add the required information to your template context automatically, or writing a template tag that would solve this for you.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "python, django, django templates"
}
|
Is the exhaust from an electric dryer harmful?
We seem to have an exhaust leak from the dryer, as I can smell it when it's run.
**Is this an urgent issue?**
Since it's not gas, the exhaust should just be warm air, right? _(though in that case, why can I smell anything at all?)_
|
No, the exhaust from an electric dryer is not hazardous, at least if you're drying normal clothing and bedding. So, you are correct, it's just warm moist air.
Some companies make heat savers that direct some of that air in the house. They save heat, but now the house is more prone to grow mold and the damp air being sucked into the drier takes longer to dry. So, don’t purchase one of those as they are really a scam, but its not harmful to breathe.
|
stackexchange-diy
|
{
"answer_score": 5,
"question_score": 1,
"tags": "safety, dryer, appliances"
}
|
Properties of convex polytope of 0-1 matrices
**Problem setting**
Consider a set $ S = \big\\{ 1,2,\cdots,n \big\\}$. Now consider $k$ equal-sized subsets $S_i \subset S$ s.t of size $\big|S_i\big|=n' \;\forall i$.
Consider a $k\times k$ matrix $M$ s.t $\;M_{ij} = \big|S_i\cap S_j\big|\big/n'$, size of the intersection of the $i^{th}, j^{th}$ subset divided by $n'$.
**Question**
Does $M_{ij}$ lie in the polytope of _zero-one_ matrices? Paraphrasing the question - Can we express every $M_{ij}$ as a convex combination of _zero-one_ matrices?
|
Sasho already gave you a yes/no answer, but here's an actual convex combination for you: If $B_\ell$ is the $k \times k$ matrix which is $1$ when $|S_i \cap S_j| \ge \ell$ and zero otherwise, then $M = \sum_{\ell=1}^{n'} \frac{1}{n'} B_\ell$.
|
stackexchange-cstheory
|
{
"answer_score": 3,
"question_score": 1,
"tags": "reference request, matrices, convex optimization, submodularity, polytope"
}
|
Continuous spectrum is a subset of point spectrum
I have to prove that the continuous spectrum $\sigma_c(T)$ is a subset of the point spectrum $\sigma_p(T)$.
I started off by supposing that there is some spectral value $\lambda$ such that $\lambda \notin \sigma_p(T)$.
Then, this would imply that $(T-\lambda I)$ is invertible.
How can i proceed further to show that $(T-\lambda I)$ is not bounded so that $\lambda$ is also not in $\sigma_c(T)$, thus proving that,$\sigma_c(T) \subset \sigma_p(T)$ ?
|
This is not true !! to convince you, take $T$ the unilateral shift so : $$ \sigma(T)=\bar{\mathbb{D}}\\\ \sigma_p(T)=\mathbb{D}\\\ \sigma_c(T)=\mathbb{T} $$ proof page 6-7.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "operator theory, spectral theory"
}
|
What will be the final polynomial for this recurrence relation?
Given a recurrence relation: $$ax_n-bx_{n-1}-2x=(xa-b)x_{n-1}-ax_{n-2}-2x$$ where $a=x^3(x^2-3)-(x^2-1) \text{ and } b=x(x^2-3).$
What will be the final polynomial?
|
The given recurrence reduces to:
$$ \require{cancel} a\,x_n\cancel{-b\,x_{n-1}}-\bcancel{2\,x} = a\,x\,x_{n-1}\cancel{-b\,x_{n-1}}-ax_{n-2}-\bcancel{\,2x} \iff a\,x_n = a\,x\,x_{n-1}-ax_{n-2} $$
If $a=0$ then the above is satisfied by any sequence $x_n\,$ otherwise it further reduces to:
$$ x_n = x\,x_{n-1}-x_{n-2} $$
The latter is a linear homogeneous recurrence, which does not depend on $a,b\,$. Given some initial conditions $x_{0,1}$ it can be solved using the standard methods, though the solution will (generally) not be a polynomial in $x\,$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "real analysis, recurrence relations"
}
|
Ansible regex_replace
I'm trying to capture the main version number of a variable, and to do this I'm trying to remove the numbers after the main version number:
In `variable.yml`:
version: 3.9.5
main_version: "{{ version | regex_replace('^.*(..)$', '')}}"
This should give me `3.9`, however debug gives me nothing.
What's the correct way of doing this?
(And making sure that it would still be able to handle things such as `3.10.1`, so that would return a `main_version` of `3.10`, and also things such as `3.10.1-rcblah`, and that would return a `main_version` of `3.10`)
|
I guess your regexp should be something like:
'^.*(\.[0-9]*)$'
But why don't you use `version_compare`? <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "regex, ansible, yaml, ansible 2.x"
}
|
Add Value to Array Without Specifying A Key C#
Like in PHP and some other languages, is there a way to add a value to an array without specifying the index?
int[] aWhich = {};
aWhich[] = 1;
Thanks.
|
Not to an `Array` or any other type since the indexer operator must have at least one parameter (through it does not have to be an `int`).
You can add to the end of a `List`, though:
List<int> aWhich = new List<int>();
aWhich.Add(1);
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 2,
"tags": "c#, arrays"
}
|
PHP insert into MySQL and record position number
Goal: Record the position order of each form item on insert.
I'm allowing the user to dynamically add and delete form fields(that functionality is working with JS). For simplicity sake, the user designs their form to look like this:
**Form:**
Subtitle
Paragraph
Subtitle
Image
My database would contain a table for each field:
!enter image description here
I wrote a simple function to get the index number from an associatative array, I'm guessing I can record that in each table in a column called "position"?
function arrayValuePosition($value, $array)
{
return array_search($value, array_keys($array));
}
foreach($array as $key => $value) {
echo arrayValuePosition($key, $array);
};
What is the best way to record this position number and also loop through inserting into the various tables?
|
I think it could be more simple to use a single table:
Table: form_data
Fields:
id - INT - PRI auto_increment
fields_enabled - ENUM - possible values: 'subtitle', 'paragraph', 'image'
subtitle
paragraph
image
You can store the records as normal rows in this table, and the information regarding the form fields the user has enabled can be stored in the field fields_enabled.
It would also be easy to browse the existing records.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, mysqli, prepared statement"
}
|
django orm how to get the sum of the first element of an array field?
I have the following `django` model for `postgres`. Assume `metric_vals` are non-empty arrays. Is there a way of getting the sum of all first values of `metric_vals`?
from django.db import models
import uuid
from django.contrib.postgres.fields import ArrayField
class SampleModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
metric_vals = ArrayField(models.FloatField(null=False), null=False, default=list)
I tried the following but resulted in error:
from django.db.models import F
from django.db.models import Sum
SampleModel.objects.aggregate(Sum('metric_vals__0'))
`django.db.utils.ProgrammingError: function sum(double precision[]) does not exist`
|
For a table like
create table metrics_table
(
id serial not null constraint metrics_pk primary key,
metrics double precision[]
);
the SQL query
select sum(metrics[1]) from metrics_table;
works.
You will probably need the `RawSQL` annotation.
Based on this, off the top of my head, something like
SampleModel.objects
.annotate(first_metric=RawSQL('metric_vals[1]'))
.aggregate(first_metric_sum=Sum('first_metric'))
might do the trick.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, django"
}
|
Show "Log in" link all the time (even for logged in users)
I have a menu item "My Shop" which redirects to the `user/login` page. But custom Drupal behavior hides this link whenever a user is logged in.
I would like to show this menu-item **all the time**. Is there a way to do so?
The reason why I do this is the following. It's a site with a webshop-portal. To access this portal, users need to log in. Whenever they are on _their portal/webshop_ , he should keep seing the menu-link and when they return to the front-end of the site, the user should be able to go his webshop without loggin in again.
I hope I make myself clear on this one. If I don't, please let me know!
|
If you're trying to show a link called "My Shop" which takes anonymous users to the log in page and logged-in users somewhere else, you can just create a second menu item also called "My Shop" and set it to display only for users that have the authenticated user role. Then set the destination to whatever you want; that way both logged in users and anonymous users will have "My Shop" links pointing different places.
You can have multiple menu items on the same menu with the same name (Drupal doesn't check for uniqueness in order to allow for situations like this).
As long as you give the two "My Shop" menu items the same weight (or drag them so that they are next to each other), they will appear to be the same menu item.
|
stackexchange-drupal
|
{
"answer_score": 4,
"question_score": 0,
"tags": "7, users"
}
|
Что значит i в цикле for?
Есть пример:
for i in 'hello world':
print(i * 2, end='')
# hheelllloo wwoorrlldd
Что означает `i` в принципе?
В другом вопросе ответили, что это переменные. Но как я понял, здесь должны быть переменными `hello` и `world`. Или в питоне переменные являются буквами этих слов?
|
Цикл `for` при обработке строки '`hello world`' проходит по каждой букве в этой строке.
На каждой итерации цикла в переменную **`i`** попадает один символ строки.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": -3,
"tags": "python, переменные"
}
|
Properties of the $R$-module $M$ and $R/I$-module $M$.
Let $R$ be a commutative ring with $1$ and $M$ is an $R$-module.
Let $I$ be an ideal of $R$ contained in $\mathrm{Ann}(M)$.
Consider the $R/I$-module $M$.
I know the fact that the $R/I$-module $M$ is noetherian (artinian) iff the $R$-module $M$ is noetherian (artinian) because of the property that is submodule is still submodule when we change rings.
Here is my question:
> Is that true that the $R$-module $M$ has property $P$ iff the $R/I$-module $M$ has property $P$?
From my intuition, I would say that is true but can't find an explicit proof. I looking for the proof or a counterexample.
Thanks in advance.
|
In general no. For a counterexample, consider an $R$-module $M$, such that $\mathrm{Ann}_R(M)\neq\\{0\\}$, that is a non-faithful $R$-module. Then, if you take $I=\mathrm{Ann}_R(M)$ you will get a faithful $R/I$-module $M$, i.e., one for which $\mathrm{Ann}_{R/I}(M)=\\{0\\}$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "abstract algebra, modules"
}
|
Tracking with Google Analytics both a page and a file linked from it
I have a page located on a subdomain (downloads.easyjob.net) that links to an executable. The download of the executable is correctly tracked by google analytics (following these indications).
However, I'd like to track the page itself too. How can I do this?
|
If you put the tracking code for GA in the page then it will collect stats for the page itself when someone views it. You can also add the virtual link code to track the click on the download link. (source)
|
stackexchange-webmasters
|
{
"answer_score": 2,
"question_score": 1,
"tags": "google analytics, tracking"
}
|
Keys are exchanged in visual studio
My shift keys have stopped working suddenly in Visual studio. What could be the reason? All other keys are working fine and i'm using a new keyboard! How to cross check for keys working? It Works fine with the notepad MS word etc I want to have `(` in place of 9. When i press A it occurs Q. When i press z it Occurs A,When i press . it occurs : It worked fine after restarting the visual studio.What is the reason for this.
Dim Whole As String = lstMain.SelectedItem.ToString
Dim pid = Whole.Substring(Whole.LastIndexOf9
Catch ex As Exception
|
A similar thing has happened to me, and it was related to the contol keys, as mentioned in several comments. It stopped happening to me, which makes me think that some update or security patch fixed it on my system. Usually I could get it to stop happening by pressing one or the other of the control keys, sometimes I had to restart Visual Studio, and sometimes I had to restart my computer.
PS - I haven't had this problem for at least 2-3 months, so make sure you have all Windows 7 updates.
PPS - Sometimes pressing the **shift** keys several times makes the problem go away, other times the **control** key seems to be the problem. I have had it happen to me again, but not nearly as often as before.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "visual studio"
}
|
Thermal expansion: installing a hardwood floor and subfloor
I plan to add a subfloor in the unfinished attic, and lay down hardwood on top of it. The attic has large temperature swings, from about 50 to almost 100F (something will have to be done about that later), which makes me concerned about how to properly install the subfloor and then the hardwood planking on top to accommodate thermal expansion.
I will install at the highest temperatures in the range, so contraction is probably what I should properly worry about.
What is done to allow for expansion/contraction? Is there a preferred alignment of subfloor panels to the underlying joists? and is there a preferred alignment for the hardwood slats? I would like to make the hardwood direction match the rest of the house...
|
Upon further research, it was made clear that humidity/temperature need to be stabilized first, temperature excursion would damage a hardwood floor.
After the temperature excursion is addressed through proper heating and cooling, the primary concern for expansion is against the walls, where a 1/2" perimeter is to be left for expansion. If the Drywall is floating above the floor, the hardwood and subfloor can expand under it as needed.
The 8x4 boards of subfloor should be laid down orthogonally to the direction of the rafters.
|
stackexchange-diy
|
{
"answer_score": 0,
"question_score": 0,
"tags": "hardwood floor, subfloor"
}
|
what is conditional distribution function of Y given N = n, correlation coefficient of Y and N, and what is effect of lambda on mean of Y
Y is a random variable defined as the sum of N independent Bernoulli trials where the probability of every bernoulli trial equalling '1' is equal to p. The number of Bernoulli trials N is itself a random variable that behaves according to a Poisson distribution function with the parameter lambda.
for part 1) for P(Y | N=n) am I right to assume that I should substitute in the poisson function into the 'N' of the binomially distributed variable Y?
Is this somehow related to the correlation coefficient? Would the correlation coefficient be positive because after all Y is the sum of bernoulli trials thus as N=n increases Y increases?
What about the effect of lambda on E(X)? Should i define lambda as n.p so that as lambda increases, N=n must increase as p is constant?
|
**Hint:** $Y$ is the _sum_ of a series of $N$ Bernoulli($p$) random variables; each realising values in $\\{0,1\\}$, where $N$ is Poisson($\lambda$) Distributed. This then counts the "successes" among $N$ iid Bernoulli trials. Thus $Y$ is Binomially($N, p$) distributed conditional on $N$.
$$Y\mid N ~\sim~ \mathcal{Bin}(N,p) ~\iff ~\mathsf P(Y{=}y\mid N{=}n) ~=~\\\ N~\sim~\mathcal{Pois}(\lambda) ~ \iff ~ \mathsf P(N{=}n)~=~$$ ~~Can you now complete and continue?~~
However, you were asked _not_ to derive anything this way.
Instead, please use the Law of Iterated Expectation (sometimes called the Law of Total Expectation). $$\mathsf E(Y) = \mathsf E(\mathsf E(Y\mid N))$$
Use
$$Y\mid N ~\sim~ \mathcal{Bin}(N,p) ~\implies~ \mathsf E(Y\mid N) ~=~ \\\ N~\sim~\mathcal{Pois}(\lambda) ~\implies~ \mathsf E(N) ~=~$$
**Now, can you now complete and continue?**
$\Box$
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "probability, poisson distribution, binomial distribution"
}
|
Getting Math.pow to return a correct value?
how can I make this expression not end up being a zero.
double dBaseFitness = (double) baseFitness;
x.shortfitness = (long)(Math.pow(dbaseFitness, dbaseFitness/8.0)/100.0)
*(long)(Math.pow((double)x.genome.GSIZE, -.1)/100.0);
x.shortfitness is a long value. x.Genome.GSIZE is an int.
The only reason I am dividing each expression by 100 is so that the result doesn't exceed the max value of the long type.
|
Is `baseFitness` an integer? If so then `baseFitness/8` does integer division. For example `7/8` will yield `0`. Change your `8` and `100` to `8d` and `100d` to force floating point division.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, double, long integer, primitive types"
}
|
provide unit-testing for c++ code
I need to provide unit tests for an application written in c++, this is a very big application and content many sources (.h, .cpp) , actually I don't know where to start? How to process? ... So any help is more than welcome.
Thanks
|
Grab a good test framework.
I have used google test a lot with my last company, and it was pretty good, though there are likely better around. Reading: < Comparison of c++ unit test frameworks
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c++, unit testing, verification"
}
|
Picking equipment for learning Country Guitar in an apartment.
I want to learn to play country guitar. Right now, I'm at a point in my life where I can dedicate a few hours a day to practice. (3+ hours) But I'm a total newbie to music period and live in a dreaded apartment. I get that I should get an electric guitar, studio quality headphones and a low-wattage amp with headphone jack and/or a computer interface. In-order to practice without driving my neighbors to an untimely suicide. But I can't find anywhere that talks about selecting that equipment in relation to using it for country music. Probably an affordable acoustic guitar is in my near future. I have a place to play loudly but it's a 1-2 hour drive back and forth.
So is there anything I should avoid or look for in the above electric equipment given that I'm considering using it for country?? Or does it even matter?
|
In terms of technique, it doesn't matter.
In terms of sounding like you want to sound playing country music, I suggest you get a headphone amp that allows you to adjust the effects to the sound you're looking for. Alternatively you could buy a guitar multi-effects board that has a headphone jack. If you plan to play country music on an electric guitar you could also buy an inexpensive amp with built-in effects that has a headphone jack. The Roland Cube comes to mind.
Electric country guitar generally uses the same effects as classic rock or 1950s rock for that twang. Classic rock effects have a wide variety but a good starter would be low mids, medium overdrive, light chorus and a Fender or Marshall amp simulation. Twang guitar would have reverb, light slap-back delay and a clean tube amp simulation.
|
stackexchange-music
|
{
"answer_score": 1,
"question_score": 0,
"tags": "electric guitar, learning, beginner, country and western"
}
|
How to make OpenApi UI work in Payara Micro
I have followed this tutorial Swagger UI on MicroProfile OpenAPI but simply adding the below to a pom.xml file of a Payara micro application does not add `/openapi-ui`, only `/openapi` works. Is there something else that is required or is it not possible with Payara Micro to have OpenApi UI.
<dependency>
<groupId>org.microprofile-ext.openapi-ext</groupId>
<artifactId>openapi-ui</artifactId>
<version>1.1.2</version>
</dependency>
|
My problem was the Application config class. I had to change
from:
@ApplicationPath("/api/v1")
public class JAXRSConfiguration extends Application {
public Set<Class<?>> getClasses() {
Set<Class<?>> s = new HashSet<>();
s.add(MyResource.class);
return s;
}
}
to
@ApplicationPath("/api")
public class JAXRSConfiguration extends Application {
}
Somehow overriding the `getClasses()` method and adding `/v1` to the application path was messing with the openApi-ui configurations.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "maven, swagger, swagger ui, openapi, payara micro"
}
|
Resetting a DropDownList to its initial option after pop-up closes JQM
I'm having a DDL inside a popup but whenever I close the popup and reopen it, it keeps its last selected option. What I'm trying to do is to call the popupafterclose event and set the DDL to its initial option, but it does not seem to work..
$("#popup").on("popupafterclose", function (event) {
$('#ddl1').find('option:first').attr('selected', 'selected');
});
The initial option of the DDL is a disabled hidden selected option. What's the problem here?
|
You just need to **refresh the selectmenu widget** as well:
$("#popup").on( "popupafterclose", function( event, ui ) {
$('#ddl1').find('option:first').prop('selected', 'selected');
$('#ddl1').selectmenu("refresh", true);
});
# **DEMO**
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery mobile, popup"
}
|
Hyperthreading effects on gettimeofday and other time measurements
while I was benchmarking a CPU with hyperthreading with BLAS matrix operations in C, I observed a nearly exact doubling of the runtime of the functions when using hyperthreading. What I expected was some kind of speed improvement because of out of order executions or other optimizations.
I use gettimeofday to estimate the runtime. In order to evaluate the observation I want to know if you have thoughts on the stability of gettimeofday in hyperthreading environment (Debian Linux 32 Bit) or maybe on my expectations (they might be wrong)?
Update: I forgot to mention that I am running the benchmark application twice, setting the affinity to one hyperthreading core each. For example gemm is run twice in parallel.
|
I doubt whether your use of `gettimeofday()` explains the discrepancy, unless, possibly, you are measuring very small time intervals.
More to the point, I would not expect enabling hyperthreading to improve the performance of single-threaded BLAS computations. A single thread uses only one processor (at a time), so the additional logical processors presented by hyperthreading do not help.
A well-tuned BLAS makes good use of the CPU's data cache to reduce memory access time. That doesn't help much if the needed data are evicted from the cache, however, as is likely to happen when a different process is executed by the other logical processor of the same physical CPU. Even on a lightly-loaded system, there is probably enough work to do that the OS will have a process scheduled at all times on every available (logical) processor.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c, hyperthreading, gettimeofday"
}
|
How to write Pact contract that matches to key 'x' either object of type Y or Z
I try to write a pact contract test covering following scenario. I have a consumer calling an GET to receive an information about an animal, either a cat or dog.
response1:
{
"animal" : {
"type" : "Cat",
"meow" : true
}
}
response2:
{
"animal" : {
"type" : "Dog",
"barks" : false
}
}
In code both Cat and Dog are subtypes of an Animal class. Is there a possibility to write a contract expecting response to contain "animal" key with value **matching either cat (expecting properties "meow" and "type") or dog (expecting properties "barks" and "type").**
In other words. Is there a possibility inn Pact's Dsl to declare that under the key "animal" there can be either an object of definition X or an object of definition Y?
|
No, you have to write two separate tests to cover this scenario to prove that your code can actually handle both cases. Think of if you were to write a unit test that took an `Animal` as an argument, but behaved differently depending on the animal - you'd need to test it with all of the variants.
The argument is similar to why we don't support optional attributes (see <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java, pact"
}
|
Node.js Global Variables and using Require
Many people have suggested using "modules" that "export" an object, so that you can bring in variables to another file - because once you require a certain file name once, all future calls in other files to require that same file will immediately return the SAME exported object that was given the first time that file was required without reevaluating any code. This allows you to choose by requiring files which variables you want to share between files without using global, which is essential to maintaining state between files or split up code which needs to use the same variables.
My problem is: How can you modify those exported variables - or are they unchangeable - and if they are unchangeable then they are lacking functionality that you can only achieve using global variables... ?
|
There are no such things as exportable variables. The `require` function returns a usual Javascript object, and things you call "exported variables" are just properties of that returned object.
Internally, `require()` maintains a dictionary mapping module identifiers to these objects and guarantees that the same object is returned for the same module identifiers passed to it.
So you can modify those properties how you want. You can even do things like this:
var connect = require('connect')
connect.foo = 42
This code will effectively monkey-patch connect module and add `foo` "export" to it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, node.js"
}
|
How can I split file into several parts using javascript, and insert these details into a Mysql db on an external server?
I have a file which contains some sort of database, it's written like this :
`name = blah blah` `num = xxx xxxxxxxx` `addrs = xx , blah blah` `name = blah blah` `num = " xxx xxxxxxxx` `addrs = xx , blah blah` ..... ans do on.......
The file's extension doesn't matter (actually I created it)
Its a local file, so i want to insert these values into my website's DB ... and it should be inserted like this :
blah blah xx,blah blah xxx xxxxxxxx blah blah xx,blah blah xxx xxxxxxxx
what should I use , is it Javascript/php ?
|
The easiest way would be to have the file uploaded, and then let your server handle the importing using PHP.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, javascript, mysql, database"
}
|
Skype gtk style not working on debian squeeze 64
I have installed skype on my fresh squeeze 64bit system. It works fine except for the fact that the gtk theme isn't really working and the result is quite ugly:
!enter image description here
How can I fix this?
|
Skype is a proprietary 32-bit application, and cannot use 64-bit Gtk+ theme engines.
Try installing ia32-libs-gtk, which provides several engines. If that doesn't work, you'll have to change themes so that you are using an engine which is available in 32-bit.
|
stackexchange-unix
|
{
"answer_score": 3,
"question_score": 1,
"tags": "debian, gtk, skype"
}
|
How should a Facebook-Timeline system look on the database?
How would I store Users "Posts"? So that I can efficiently get them from the db and then process them to display chronologically when a specific users page is requested?
Do I store all Posts from All Users in a single table like so:
Post ID | Poster ID | Post Content | Posted to this Users Wall | Post Timestamp
Then when a user opens UserFoo's Page I just get all rows where `Posted to this Users Wall = UserFoo`?
Wouldn't the sample above make a table bulky?
|
The layout you propose looks reasonable. 5 columns (four `INT`'s and one `TEXT`), is not at all "bulky" a table.
If you have proper indexes, the query `WHERE "Posted to this Users Wall" = "UserFoo"` is virtually instant.
For your target query (display chronologically posts sent to the current user's wall), the best index is probably on `(Posted to this Users Wall, Post Timestamp)` (a two-columns index).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "php, mysql, database design"
}
|
Javascript splice not working
I may be wrong on what I think .splice() is meant to do, but I thought it removed one element of an array. All I want to do here is remove "pears", but it doesn't work:
var my_array = ["apples","pears","bananas","oranges"];
my_array.splice($.inArray("pears",my_array));
$.each(my_array, function(k,v) {
document.write(v+"<br>");
});
Also at <
|
You're missing two arguments:
* `$.inArray` wants the second argument to be the subject array
* `splice` accepts a second argument to specify the number of elements to be deleted
The code becomes:
var my_array = ["apples","pears","bananas","oranges"];
my_array.splice($.inArray("pears", my_array), 1);
$.each(my_array, function(k,v) {
document.write(v+"<br>");
});
Live example
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "javascript, jquery"
}
|
Garbage at compilation and output C++ (Atom/QtCreator)
After creating a console application and running it, a lot of garbage appears with the output, such as last login and a strange path to the directory:
> /var/folders/zd/...
If I write separately in the editor, and run it through GCC directly, there is no problem; there is a net output.
To the left of the output under the Atom, right Qt
 on the Ethereum blockchain, can other people see the names of the functions it contains? Assuming the abi.json file is not published.
If not, how does calling a specific external function work? How is the function distinguished from other functions in the same contract?
If yes, does the name length impacts the gas price?
|
No, functions' names are not visible. Functions are identified by something called the "function selector" which is made by taking the first 4 bytes of the Keccak (SHA-3) hash of the signature of the function.
The string representation of the name is not retrievable from the function selector.
See <
|
stackexchange-ethereum
|
{
"answer_score": 0,
"question_score": 1,
"tags": "solidity"
}
|
Initialising with "undef" for self-documenting code?
Sometimes I'd like to write:
my $var = shift // undef; # argument is optional
# or
my $var = $val{optional_value} // undef;
to indicate that it is ok to have the argument missing, otherwise `// undef` is useless, of course.
How expensive is this, is it optimized away by the compiler?
|
To answer your questions: Not and no.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "perl, undef"
}
|
Where are the db files? at /var/lib/mongodb I cant find any increase in size. I ran very big loop to create lakhs of objects
I am using UBUNTU, from /etc/mongod.conf, I found that /var/lib/mongdb is the path for data.
I have found some files like collectionname.0, .1, .ns in that directory. but when I run a very big loop(lakhs), I am able to get them back using mongo shell, but that mongodb directory size is not increasing, so there must be someother place where this data is being stored
What is that place?
|
There is no another place. As indicated by @itsbruce, in Ubuntu it's /var/lib/mongodb.
On a non-packaged installation (on Linux), i.e. without a /etc/mongodb.conf file, the default is /data/db/ (unless otherwise specified).
You can modify the switch "--dbpath" on the command line to designate a different directory for the mongod instance to store its data. Typical locations include: /srv/mongodb, /var/lib/mongodb or /opt/mongodb.
(Windows systems use the \data\db directory.) If you installed using a package management system.
I recommend using the `db.collection.stats` command as outlined here to monitor the size of your collection as you insert data. The link also explains what each field (in the output) means.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "mongodb"
}
|
mac OSX Yosemite, safe mode?
how do i launch safe mode on mac, with boot camp installed(windows 7)? Without boot camp u just press shift on the sound, but with bootcamp installed it always login in windows? help!!macbook air.
|
After a quick search I found this information:
> If you're in Windows, you can switch to the Mac OS X partition using the Boot Camp icon in the System Tray. Click the gray diamond-shaped icon, and click "Restart in Mac OS" from the pop-up menu. Then, confirm your choice to reboot to Mac OS X.
When you back in OS X you can change the startup disk via sys. pref. > startup disk
|
stackexchange-apple
|
{
"answer_score": 3,
"question_score": 1,
"tags": "macos, mac, macbook pro, safe mode"
}
|
How Laravel Eloquent references the right table
I'm currently watching the Laravel Tutorial Episode 7
<
I created the database and populated its data on the previous episode,
it is only this time, the tutorial introduces model, upon creating the model name "Task" via `php artisan make:model Task`, it automatically connects to my table "tasks" without any clue how it happened.
So how did a freshly out of the box model knows it?
|
It's general definition standard.
If you create a table with plural name and create model for this table as singular, then model automatically connects corresponding table, otherwise you should define table name in model like:
protected $table = 'task_table';
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "laravel, laravel 5.4"
}
|
Cloning an application with its full data store between devices
Given a generic application I would like to transfer it, full with its own data, to another device or to the emulator.
After restoring the application and its `/data/data/com.app` directory it should be supposed to work as normal, provided that its business logic doesn't take into account that the device ID has changed or other facilities (like accounts) are missing.
Copying `/data/data/com.app` brutally may result in data corruption when app is active.
How do I do that, with or without root?
|
## Solution one: TitaniumBackup
Both devices must be rooted and use TitaniumBackup application. I have found that Titanium doesn't start on Emulator 2.1
## Solution two: use adb backup options
Use `adb backup` and `adb restore` properly. This would mean to restrict the backup to the single app to be cloned, including its data, but nothing else. This is important as `adb restore <file.ab>` is an all-or-nothing, no selective restore possible. Full syntax for `adb backup` is:
adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|nosystem] [<packages...>]
So to only have our "Foobar" app included, we need to connect the device and:
adb backup -f MyBackup.ab -apk com.foobar.app
This done, and `adb` connected to the emulator, the generated backup file `MyBackup.ab` then can be restored using
adb restore MyBackup.ab
|
stackexchange-android
|
{
"answer_score": 2,
"question_score": 2,
"tags": "backup, android emulator, data transfer"
}
|
HTML form's input text starts from the middle
So in general I am working on my own portfolio, but I've ran into one issue. I've created a text entry box that is 140x40 but sadly the text starts from the middle.
It what it looks like:
!enter image description here
It shouldn't be starting fromt he middle, but top left
Any ideas? this is the default form with little to none styling.
form .form_button
{
margin-top: 5px;
color: rgb( 255, 255, 255 );
background-color: rgb( 241, 101, 76 );
border: none;
height: 20px;
font-size: 12px;
}
|
your message should be in a `<textarea></textarea>` not a regular input type text
see the difference here: <
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 2,
"tags": "html, css, forms"
}
|
Create shake animation for UIImageView that is possible to start and stop
I need to shake an UIImageView when an event occurs, I use the following code for the shake animation:
CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"];
[shake setDuration:0.1];
[shake setRepeatCount:INFINITY];
[shake setAutoreverses:YES];
[shake setFromValue:[NSValue valueWithCGPoint:
CGPointMake(_clockImg.center.x - 5,_clockImg.center.y)]];
[shake setToValue:[NSValue valueWithCGPoint:
CGPointMake(_clockImg.center.x + 5, _clockImg.center.y)]];
[_clockImg.layer addAnimation:shake forKey:@"position"];
The problem is that I can't stop the animation when I want to, I tried with `[_clockImg stopAnimating];` and changing the `[shake setRepeatCount:0];` but the animation keeps going. Is there a way to stop a CABasicAnimation like I want to?
|
Have you tried:
[image.layer removeAllAnimations]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "objective c"
}
|
Vertical and Horizontal Recyclerview in the same layout
I see a lot of apps using this layout but i never understand how to create something like this:
Recyclerview Layout
What i have to do?
* Create 3 recyclerview inside the same layout
* Use a main recyclerview and in adapter "inflate" the Horizontal and Vertical
* Something else?
I don't know if it's possible inflate different recyclerview(horizontal and vertical) in the same Adapter.
|
That's called a nested recycler view. you basically have a vertical recycler view in which you inflate your child recycler views and inside the child recycler views you inflate your final CardViews.
Here is a tutorial
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, android, kotlin, android recyclerview"
}
|
How can I convert to while loop
I wrote this code. It's like len() function.
def length_itr_for(list):
total = 0
for i in list:
total += 1
return total
print length_itr_for([1,2,3,4,5,6,7,8])
output is; 8. because in this list, there are 8 value. so len is of this list is 8.
but I don't know how can I write this code with while loop?
while list[i]: etc... I though a few things but I don't know what should I write it here.
edit: actually I tried this code too. but It's not good code. just tried and it didn't work.
def length_itr_whl(list):
total = 0
i = 0
while list[i]:
total = total + 1
i = i + 1
return total
print length_itr_whl([1,2,3,4,5])
|
If you really want to convert this code to a while-loop, you could always do something like this:
def length_itr_whl(list):
total = 0
i = 0
while list[i:i+1]:
total = total + 1
i = i + 1
return total
print length_itr_whl([1,2,3,4,5]) # prints 5
print length_itr_whl([]) # prints 0
This uses the list-slicing mechanism in Python and it does not require any `try-block`. When the indices are out of range the result will be `[]` (an empty list), which evaluates to `False` in Python.
However, why don't you just use the built-in `len`-function in Python?
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, loops, while loop"
}
|
How to make a node reference field that can also behave as a text field if no reference exists
I'm looking for a flexibly way to allow a user to input a a field, but also to have that field be a node node reference if the the node reference already exists. In other words, lets say I have a content type called dog, each dog has a node reference for favorite toy, if the toy exists, this field should be a node reference, otherwise the user should be allowed to fill it in. Conceptually I can think of two way to do this. One way, is just to make it a field, and then somehow link to another node if it exists. The other is to make it a node reference, and perhaps somehow auto - create the node when the user fills it in.
Recommendations? (using drupal 7)
|
instead of node references you could use term references and then use the Autocomplete Deluxe module to have the user select existing terms or add new terms.
Actually, they there is support for references with Autocomplete Deluxe for References.
|
stackexchange-drupal
|
{
"answer_score": 2,
"question_score": 1,
"tags": "7, nodes, ajax, entities"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.