INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Doctrine 2 association inheritance with different classes
I'm using Doctrine 2 and single table inheritance, my topmost entity hierarchy is:
JS_File --> [one to many] --> JS_File_Version
And then my sub-class entity hierarchy is:
JS_Image (extends JS_File) --> [one to many] --> JS_Image_Version (extends JS_File_Version)
The inheritance mapping works perfectly for JS_File and JS_Image, and the association mapping works perfectly for JS_File --> JS_File_Version. But, when it comes to map the "versions" association on JS_Image I get:
'Property "versions" in "JS_Image" was already declared, but it must be declared only once'
I understand why this is, the association is being inherited from JS_File and I can't overwrite it, but how do I achieve what I'm trying to do? Basically, with inheritance, how can I tell Doctrine to use a different `targetEntity` for the sub-classes association. | Looks like what I'm trying to do isn't possible (having both JS_File and JS_Image as concrete entities). I've followed the advice of someone from the doctrine-user mailing list instead:
> The way I solved this was to use an abstract base class and then define the actual mappings on the subclasses. For example, you could do something like:
>
> JS_AbstractFile with subclasses: JS_File and JS_Image JS_AbstractVersion with subclasses: JS_FileVersion and JS_ImageVersion
>
> AbstractFile and AbstractVersion can define the property (and getter/setters) but you shouldn't define any mapping information for the field. Then in your subclass you re-define the property along with mapping information (at least, thats how I did it since I used annotations)
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, inheritance, doctrine, doctrine orm, associations"
} |
קִדְשָנוּ versus קְדִשָנוּ
I've noticed a very common mistake that surfaces when people say Birchas HaMitzvos out loud. Instead of saying אשר קִדְשָנוּ במצותיו (kee-di-shu-noo) as written in all Siddurim, many people pronounce it "קְדִשָנוּ" (ki-dee-shu-noo) instead. Is there any source or reason for this change, or is it simply a widespread mistake? | See grammar and pronunciation rules from Jewish Virtual Library. From my understanding of the rules, the correct pronunciation should be "keed-di-sha'-nu". Since there is a dot in the daled, it is considered as if it is doubled, i.e. - ending the 1st syllable and starting the 2nd one, as well.
Offhand, I would say that sounding the 2nd syllable with a chirik has no grammatical basis, as that's not the conjugation of the verb "kadesh" in the present plural in Hebrew. Someone who does pronounce it this way, could be mistaken for using another verb which sounds like he's saying "ki-di-shay'-nu", which would be using a different verb "deshen" meaning "refine", as in the term we use in Shabbat musaf, "am medushnei oneg". | stackexchange-judaism | {
"answer_score": 1,
"question_score": 0,
"tags": "blessing, pronunciation"
} |
Setting Default font to Kendo UI Editor
I have a requirement to set the default font value to Impact when the user starts typing the text without selecting the font in the Kendo Editor. But, when the user selects a font and then starts typing in the text the Editor should honor the font selection. I was able to set the Inherited font to Impact by adding a new style sheet to the body element while initializing the editor. Now, the font of the text is Impact but, the font value which is shown in the Font Select combo box is still inherit font. Now, my question is .. Is there any way to change the font to Impact when there is no content in the editable area and no there is not font selected. Also, I don't want to bind this font change to either Keydown or Keyup events of the editor as it would effect the performance of the editor. | Found the solution ... Setting the default font in keydown event of the editor like this,
> keydown: function (e) { if (this.getRange().startOffset == 0 &&this.getRange).endOffset == 0 && this.encodedValue().localeCompare('')== 0) { this.exec("fontName", { value: 'Impact' }); } }
Since for every keypress there will be a loop to test the condition thereby impacting the performance of the editor. It's a patchy solution but, works :) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, kendo ui, editor"
} |
Global variable in all templates Laravel?
I was authorized under user and object `Auth::user()` is not empty. So using this object and relations between models therefore I can get status of user from `Users` table:
$profileStatus = Auth::user()->user->first()->status;
How to share this variable `$profileStatus` in all template in Laravel to show/hide HTML blocks depend this value (active/not active)? | Once User successfully logged in, you can set status in globally like
> View::share('user_status', $profileStatus);
then you can access user_status from your entire application including blade templates. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "laravel, laravel 5"
} |
Please allow tag editing when question is waiting for pending edit votes
Note that this is not the same as: Unable to edit posts with pending edits
Mistagged questions should be retaggable immediately. | Well I just _fixed_ this and a slew of similar requests.
If you would like to edit a post that has a pending edit and can't wait, you can click the `Improve Edit` button:
> P$ is a diagonal matrix, with $D$ a diagonal matrix and $D+A$ hermitian, is $P^{-1}AP$ also diagonal?
Suppose $D+A$ is hermitian matrix, and $D$ is a diagonal matrix. Then $A$ is a hermitian matrix as well.
Since $D+A$ is a hermitian matrix, there exists $P$ such that $P^{-1}(D+A)P$ is a diagonal matrix.
The question is, how do I prove that same $P$ also diagonalizes $A$ such that $P^{-1}AP$ is a diagonal matrix? Or is there a counterexample? | No. For any $n>1$, let $P$ be any entrywise nonzero unitary matrix, $S$ be any real diagonal matrix, $D$ be any real diagonal matrix with distinct diagonal entries and $A=PSP^{-1}-D$. Then
* both $D$ and $P^{-1}(D+A)P=S$ are diagonal, and
* $D+A=PSP^{-1}=PSP^\ast$ is Hermitian.
However, $P^{-1}AP$ cannot possibly be diagonal. Suppose the contrary. Then both $D$ and $\Lambda=P^{-1}DP=S-P^{-1}AP$ are diagonal. As they are similar matrices, the diagonal entries of $\Lambda$ are obtained from a permutation of those of $D$. Hence $P^{-1}DP=MDM^T$ for some permutation matrix $M$. It follows that $D(PM)=(PM)D$. However, by definition, all diagonal entries of $D$ are distinct. Hence $PM$ must be a diagonal matrix. In turn, $P$ is the product of a permutation matrix and a diagonal matrix. But this is impossible, because $P$ was chosen to be entrywise nonzero. Hence $P^{-1}AP$ is not diagonal. | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "linear algebra, matrices, diagonalization"
} |
How to use Robot.mouseMove() fix from openjdk?
As per this thread the bug is "resolved" and the fix is available here but I have no idea as to how to use it. I've tried copying over all .java files to my local project but I get errors related to missing Classes. There's also a C++ source file involved which I don't know what to do with. | The Bug is fixed in the OpenJDK itself. So you need to update the OpenJDK on the machine which is running your app and that's it. Be sure to install a version that includes the fix. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, mousemove, awtrobot"
} |
missing binary operator before token "("
error:
cxx.cpp:5:13: error: missing binary operator before token "("
cxx.cpp:7:15: error: missing binary operator before token "("
code:
#if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__)
const char * PORT = "COM1";
#elif definied(__linux) || definied(__linux__) || definied(linux)
const char * PORT = "dev/ttyS1";
#else
const char * PORT = NULL;
#endif
Questions:
1. the compiler is waiting an new `defined()` call?
2. it can detected any linux(and variants) or windows version?
thanks in advance. | You misspelled `defined`:
#if definied(_WIN32) || definied(_WIN64) || definied(__WIN32__)
#elif definied(__linux) || definied(__linux__) || definied(linux)
should be:
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__)
#elif defined(__linux) || defined(__linux__) || defined(linux) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": -7,
"tags": "c++, g++, preprocessor directive"
} |
Can I use casting to access multidimensional array by one argument?
I've a 3D-array and a Point helper class. Can I somehow access a specific cell in the array using only the Point, and not Point.x, Point.y, Point.z?
class Point {
int x, y, z;
public Point(int _x, int _y, int _z) {
x = _x; y = _y; z = _z;
}
}
bool[,,] arr = new bool[10, 10, 10];
Point pt = new Point(5, 5, 5);
// I have to do this:
bool[pt.x, pt.y, pt.z] = true;
// I'd like to do this:
bool[pt] = true;
Is there any way I could to that? I know I could use a wrapper around arrays. Is there something I could do with the Point class instead?
Thanks! | As stated in the comments, you can't do it exactly the way you requested. However, you could write something which looks just as nice by adding an index operator to `Point`:
class Point
{
int x, y, z;
public Point(int _x, int _y, int _z)
{
x = _x; y = _y; z = _z;
}
public bool this[bool[,,] arr]
{
get { return arr[this.x, this.y, this.z]; }
set { arr[this.x, this.y, this.z] = value; }
}
}
Which then allows you to assign True in the following way:
bool[,,] arr = new bool[10, 10, 10];
Point pt = new Point(5, 5, 5);
pt[arr] = true;
The only difference is that instead of `arr[pt]`, you have to do `pt[arr]`. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c#, multidimensional array, casting"
} |
can i set checked or unchecked checkbox reading a string value?
I have a string $str that should value 1 or 0 and a checkbox. When i read the string value i want to set the checkbox checked if $str value is 1 or unchecked if $str value is 0.
<?
if ($str == 1){
// checkbox checked
} else {
// checkbox unchecked
}
?>
<input type='checkbox' name='nome_posiz[]' /> | One way would be
$tst = '1';
$chk = $tst=='1' ? "checked='checked'" : '';
echo "<input type='checkbox' name='nome_posiz[]' $chk />";
RESULT
<input type='checkbox' name='nome_posiz[]' checked='checked' /> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -3,
"tags": "php, html, checkbox"
} |
Supabase with React Full Register / Login / Account website
I'm new to React and Full Stack, And I wanted to us Supabase as Database with Postrgree and i thought if i could make full registration form and In this case do i need to use Node, Express or something similar, can someone explain me how can i get into this. | You actually do not need to implement a backend server using express or any other alternative***, Supabase is a backend as a service.
If you want to use Supabase as your auth server you can use the official Javascript Supabase package supabase-js
You can find the docs here:
<
They have examples and code snippets.
Hoped I helped :)
*** for complicated unsupported thinks you will need to implement some backend server features, but for auth (signup and login) you can live without a custom backend | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "reactjs, supabase"
} |
wansview ip camera stream url for openCV
I have just bought an wansview IP camera model NCM630GB. I am able to play it video stream in browser but i am not able to open its in open CV using video capture object. I have tried different solution already present on stack overflow but the actual problem is getting url of video stream. Can anybody tell what is the videostream url of wansview IP camera or any method to find it. | According to their documentation (page 22), the url should be:
> < address:port/videostream.asf?user=user name&pwd=password
Try it with VLC to see if you can get the stream. If succeed, then in OpenCV, append x.mjpg to the url, like this:
> < address:port/videostream.asf?user=user name&pwd=password?x.mjpg | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "opencv, ip camera"
} |
WPF - Import custom fonts in C#
I would like to import custom fonts on my WPF application so that they work without having the client to install them.
All the answers I have found so far are in XAML, I would like to do it only in C#.
My fonts are in Resources/Fonts/.
I have already tried this :
Fonts.GetFontFamilies(new Uri("pack://application:,,,/Resources/Fonts/#"));
But it didn't work. | I did everything bluetoothfx said but it still did not work.
Then I changed the Build action of my fonts (it was to Content), to Embedded Resource, and it worked. Resource works also for me.
Thanks anyway. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c#, wpf, fonts"
} |
Calculating last ended week in PHP
I'm making a query on a database using the timestamp. Right now i'm using hardcoded dates for the query,
$dd1 = 20;//date("d",$ddb1);
$mm1 = date("m");
$yyyy1 = date("Y");
$dd2 = 26;//date("d",$ddb2);
$mm2 = date("m");
$yyyy2 = date("Y");
But i need the code to calculate last weeks data (Monday to Sunday), whenever i run the scrip. For example, i run the scrip today (Wensday) so the calculated time should be last week from (Monday to Sunday). The same result should be in any other days of this week untill 12:00:01 Sunday night.
Tried to do something like:
//$ddb1 = time() - ($argv[1] * 24 * 60 * 60);
//$ddb2 = time() - ($argv[2] * 24 * 60 * 60);
To substract a number of days from the current date, but there must be a automatic way to do this. | $first_day = strtotime('Last Week');
$last_day = strtotime('Last Sunday');
echo "Last Monday was ".date('m-d-Y', $first_day);
echo "Last Sunday was ".date('m-d-Y', $last_day);
#Last Monday was 08-27-2012
#Last Sunday was 09-02-2012 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "php, mysql"
} |
Showing geometric distribution is almost surely finite
Suppose $T \sim Geom(\rho)$, for some $\rho \in (0,1]$ . I would like to show that $\Bbb P(T<\infty)=1$, i.e $T$ is almost surely finite.
Here's how I tackle this problem:
Since CDF of Geometric distribution, denoted $F_x$ is equivalent to $\Bbb P(T \leq x)$ . So if I take the limit ($x \rightarrow \infty$), then
$F_x=\mathbb P(T\leqslant x) = 1 - (1-p)^{\lfloor x\rfloor}=1$ as $x \rightarrow \infty$. Hence $T$ is almost surely finite. Is this legitimate? | $P(x<\infty) = \sum_{t\in \mathbb{N}}{P(x=t)}=\sum_{t\in \mathbb{N}}{(1-p)^{t-1}\cdot p=p \cdot \sum_{t\in \mathbb{N}}{(1-p)^{t-1}}}$
The above can be calculated as a sum of infinity Geometric series:
$\sum_{k=0}^{\infty}{a\cdot q^k}$ for $0<q<1$ as in our case we get $\frac{a}{1-q}$
In our case $p \cdot \sum_{t\in \mathbb{N}}{(1-p)^{t-1}}=\frac{p}{1-(1-p)}=\frac{p}{p}=1$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "probability, limits, probability theory, probability distributions, random variables"
} |
Is Dart really a single-threaded programming language?
I'm very new to Dart and stilling learning it. As I understand, Dart executes code in different isolates. An isolate could start up another isolate to execute some long-running code. For each isolate, there is a thread and some memory allocated for it. These isolates are isolated like a bunch of little VMs.
I also read from the Dart document that Dart is a single threaded language. But, think about it, each isolate has its own thread. If isolate A has thread t1 and isolate B has thread t2, t1 and t2 are not the same thread, right?
If t1 and t2 are the same thread, then t1 and t2 can't execute code at the same time, which is ridiculous. So, t1 and t2 must be different thread.
If so, why we say Dart is a single-threaded language? | Yes and no.
"Yes" in the sense that you don't have to worry about locks or mutexes.
"No" in the sense that you list.
Dart tries to offer some of the benefits of multi-threading with isolates while avoiding all of the issues with shared memory multi-threading. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "multithreading, dart, dart isolates"
} |
Siri Kit custom intent
Is it possible to perform other actions outside the assumed actions supported by Siri's intents using Siri kit?
And a lot more importantly, even if I could hack and slash my way around using a messaging intent (or some other intent), would it actually be accepted by iTunes store?
Lets say in a scenario, I want my app to support **searching online for something** , or **sending emails** or simply searching through a data base in my app, could I use Siri without that kind of specific intent existing? | Siri uses the Intents to format how your phrases and actions are presented to users. Supported Intents listed here.
If your app doesn't fit into the supported Intents you can't create new ones. If you app fits the supported Intents you can define custom vocabulary specific to your app.
As for App Review, I think you will have to find who's been through this particular use case or make a small app and submit it to see. In my experience, reviewers aren't merciless dictators when features are well explained they do let some exceptions in. (a common example is allowing location services to enable background uploading like in google drive and dropbox). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 4,
"tags": "ios, siri, sirikit"
} |
Is $\phi(n) + \sigma(n) \geq 2n$ always true?
Suppose $\phi$ is Euler totient function and $\sigma$ is divisor sum. Is $\phi(n) + \sigma(n) \geq 2n$ true for every natural $n$?
I manually checked the inequality for all numbers between $1$ and $20$ - and it holds on them. I do not know, however, how to prove this fact in general.
Also, it is not hard to see, that for prime $p$, $\phi(n) + \sigma(n) = 2n$. That means, that if a counterexample exists, it has to be composite.
Any help will be appreciated. | Let $n = p_1^{\alpha_1}\cdots p_r^{\alpha_r}$.
$\dfrac{\phi(n)}{n} = \prod_{i=1}^{r} (\dfrac{p_i-1}{p_i})$
$\dfrac{\sigma(n)}{n} = \prod_{i=1}^{r} \Bigg(\dfrac{p_i-\dfrac{1}{p_i^{\alpha_i}}}{p_i-1} \Bigg) \geq \prod_{i=1}^{r} \Bigg(\dfrac{p_i-\dfrac{1}{p_i}}{p_i-1} \Bigg) = \prod_{i=1}^{r} \bigg(\dfrac{p_i +1 }{p_i} \bigg)$
So, $\dfrac{\phi(n)}{n} + \dfrac{\sigma(n)}{n} \geq \prod_{i=1}^{r} (\dfrac{p_i-1}{p_i}) + \prod_{i=1}^{r} \bigg(\dfrac{p_i +1 }{p_i} \bigg) = \dfrac{\prod_{i=1}^{r}(p_i + 1) + \prod_{i=1}^{r} (p_i -1)}{\prod_{i=1}^{r} p_i} \geq \dfrac{2.\prod_{i=1}^{r} p_i }{\prod_{i=1}^{r} p_i} = 2$ | stackexchange-math | {
"answer_score": 4,
"question_score": 4,
"tags": "elementary number theory, inequality, totient function, divisor sum"
} |
error : NameError: name 'subprocess' is not defined
#!/usr/bin/python3
username = 'joe'
# generate passphrase
pw_length = 6
phrase = subprocess.check_output(['pwgen', str(pw_length), '1'])
phrase = phrase.decode('utf-8').strip()
dev_null = open('/dev/null', 'w')
passwd = subprocess.Popen(['sudo', 'passwd', user], stdin=subprocess.PIPE,
stdout=dev_null.fileno(),
stderr=subprocess.STDOUT)
passwd.communicate( ((phrase + '\n')*2).encode('utf-8') )
if passwd.returncode != 0:
raise OSError('password setting failed')
how do i fix this error :
bash-3.00# python ./pass2.py
Traceback (most recent call last):
File "./pass2.py", line 6, in ?
phrase = subprocess.check_output(['pwgen', str(pw_length), '1'])
NameError: name 'subprocess' is not defined | Subprocess is a module. You need to import it.
Put this as the second line in your file: `import subprocess` | stackexchange-stackoverflow | {
"answer_score": 82,
"question_score": 44,
"tags": "python, solaris"
} |
remove space between lines, single page only
I want to remove the extra space between lines, but only for this part. Not on any other page. Basically I want the line starting with -- to appear directly under the text above it. I do need the padding for the tag to remain as well. I'm guessing this would be done via a class id, but not sure of the css code that I would use. Margin? Something along the lines of
<h3 class="removeSpace">
**HTML**
<h3><em>Some text here</em></h3><h3> – blah blah blah</h3>
<h3><em>Other text here</em></h3><h3> – yadda yadda yadda</h3>
<h3><em>More text here</em></h3><h3> – blah blah blah</h3>
**CSS**
h3 {
color: #7093DB;
padding-left: 300px;
} | To keep it kind of similar to what you have, you can do this. There's no need to have two `<h3>`'s in there.
h3 {
color: #7093DB;
padding-left: 300px;
}
h3 em {
display: block;
}
<h3><em>Some text here</em> – blah blah blah</h3>
<h3><em>Other text here</em> – yadda yadda yadda</h3>
<h3><em>More text here</em> – blah blah blah</h3> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, css"
} |
Optimize mysql query to select the values
I am having a table with following column names: audit_name, audit_choice and "slno" as auto increment primary key and no use with the output data.
The audit_name can be repeated and the audit_choice values are limited to certain values like "Passed", "Failed".
My query expected output is, getting the number of "Passed" counts and "Failed" counts for each "Audit_name".
Here is the query I tried but it takes around 3-4 minutes to execute for around 1,000 records.
SELECT audit_name,
(SELECT COUNT(*) AS Passed FROM audit AS p1
WHERE p1.audit_name=p2.audit_name AND p1.audit_choice="Passed") AS Passed,
(SELECT COUNT(*) AS Failed FROM audit AS p3
WHERE p3.audit_name=p2.audit_name AND p2.audit_choice="Failed") AS Failed
FROM audit AS p2
GROUP BY audit_name
Please suggest me how can I optimize the query. | SELECT audit_name,
SUM(audit_choice = 'Passed') AS passed,
SUM(audit_choice = 'Failed') AS failed
FROM audit
GROUP BY
audit_name | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "mysql, sql, group by"
} |
MySQL Query using data from other query
Say if I have the following tables:
Test
ID Name category_ID
1 My Test 1
Test_categories
ID Name
1 Math
How could I do a single query to get all the 'math' tests.
I could do:
SELECT * FROM Test WHERE category_ID = 1
But I was wondering if I could do something like the following:
SELECT * FROM Test WHERE category_ID = (SELECT ID FROM Test_categories WHERE Name = 'Math') | use the below query
select Test.*,Test_Category.Name from Test
join Test_Category on Test.category_ID=Test_categories.ID
where Test_categories.Name = 'Math' | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "mysql"
} |
Entity Framework INNER JOIN with "BETWEEN" date range
Is there a way with entity framework to do a "INNER JOIN" with a "BETWEEN"?
I have a table with a list of date of the first day of each month, and I want to associate all my record that are in the month so I can group by month after.
Anyway what I want to reproduce is something like that:
SELECT a.*
FROM Assignments as a
INNER JOIN monthList as m ON ( m.Date BETWEEN a.StartDate AND a.EndDate)
Here is what I tried but doesn't work...
var query = (from a in Context.Assignments
join m in monthList on (m >= a.StartDate && m <= a.EndDate);
One other thing to note is that `montList` is not part of my context. | Look at this answer: LINQ Join On Between Clause
In a LINQ to Entities query two `from` in a row also produce `INNER JOIN` in SQL statement.
In your case you would have the following.
var query = from a in Context.Assignments
from m in monthList
where m >= a.StartDate && m <= a.EndDate
select new { a.SomeProperty, a.AnotherProperty };
In your case, since `monthList` is not part of your `DbContext` object, `Context.Assignments` will be queried first to pull it into local memory and then this result will be _inner joined_ with `monthList` to produce `query` object. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "c#, linq, entity framework"
} |
Automatically fill in the login form for facebook.com
How to automatically fill in the Facebook login form: username and password using c# windows form application.
I want to make the work automatic with a single button and open my Facebook page into my text field or something else. Less work, less time. | Okay, you need to learn something called web browser automation. Their is a browser automation library/tool called as Selenium. Use it to achieve your goal. I did exactly the same thing around 6 years ago.
Code below mentioned steps in your code with selenium in order and you shall achieve what you deserve. You can get selenium and more resources from here.
1. Initialize selenium web driver for whatever browser you are using. I will recommend Firefox though.
2. Open the login page of Facebook.
3. Get user name textbox through its XPath and send key strokes of your user name.
4. Do the above step for password text box also.
5. Add code to simulate click on login button. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -5,
"tags": "c#, facebook"
} |
How do I track all the most recent file changes on my UNIX system?
Say, either for a Debian system or a Red Hat one. | For real time monitoring you can use inotify-tools. It can either wait until a certain event occurs, or to run endlessly and report events as they occur. After installing, see `man inotifywait` for details.
The Debian package has the same name, the Red Hat package too. | stackexchange-unix | {
"answer_score": 4,
"question_score": 1,
"tags": "files"
} |
How to control output from crontab?
I am trying to run a test case via automation testing (sahi) , so I am running it repeatedly after 1 hour (via crontab).
What I want is that **whenever my test case fails i should receive the email otherwise not.** Right now I am receiving mail whether it passes or fails.
In short, can I send mail to a person depending upon the output I get in terminal.
I am using Ubuntu 10.10. | Pipelineing works in cron just as well as in bash. You could pipe the output to a script, that examines it and sends the mail. Or even easier use grep:
# in /etc/crontab
[email protected]
SHELL=/bin/bash
# m h dom mon dow user command
30 * * * * confus /home/confus/bin/someCommand.sh | grep -A 11 -B 10 "Error:"
This will send an e-mail to [email protected] when the stirng "Error: " occures in the output of `someCommand.sh`. In this case the text of the e-mail will be the output from 10 lines before and 11 lines after the occurrence of "Error: " (hence the `-A` for after and `-B` for before).
The mail is only send if the computer running cron has a working mail-server installed. A script to process the output is of course more flexible and considerably more work. | stackexchange-askubuntu | {
"answer_score": 4,
"question_score": 2,
"tags": "command line, cron"
} |
Would or will - in a somewhat hypothetical situation
> At (my old company) I made translations on a daily basis. Thus, my experience in translation will help me to ensure timely provision of translated materials.
This is from a cover letter I'm sending. Since getting this job (and the second sentence) is a hypothetical situation, "would" seems appropriate, if I understand the rules correctly. However, "will" just sounds better to me. Which one is correct?
Thanks | Your experience will help you in any job that requires translation, not just the one you are applying for. So I think you can justify "will", which sounds better, in my ears, as being more positive and less tentative.
I remember once interviewing a prospective advisor. The interview had not gone well, and he knew it. His final remarks were "We would be able to help you, if you were to decide to employ us."
In your case, you would have to say "would" if you wanted to specify that your experience was relevant to that employer's particular tasks in the job you are applying for. | stackexchange-english | {
"answer_score": 0,
"question_score": 0,
"tags": "will would"
} |
Enumerate list - numbers with prefix
How to make enumerate list format numbers like this:
> REG/001 (content)
>
> REG/002 (content)
>
> REG/003 (content)
I already managed to do the following:
\begin{enumerate}[label=\textbf{REG/\arabic*},leftmargin=*]
\item content
\end{enumerate}
using
\usepackage{enumitem}
but I don't know how to add leading zeros. | \documentclass{article}
\usepackage{enumitem}
\def\threedigits#1{%
\ifnum#1<100 0\fi
\ifnum#1<10 0\fi
\number#1}
\begin{document}
\begin{enumerate}[label={\textbf{REG/\protect\threedigits{\theenumi}}},leftmargin=*]
\item content
\item content
\item content
\end{enumerate}
\end{document}
!enter image description here | stackexchange-tex | {
"answer_score": 13,
"question_score": 9,
"tags": "lists, enumerate"
} |
inequality on simple proccesses
I'm going trough my script and I'm not able to understand a step that involve an inequality.
Let $\pi_n: o=t_0^n<...<t^n_{k_n}=T$ with $|\pi_n|\to0$
Let $\phi^n(s)=\sum_{i=0}^{k_n-1}t_i\mathbb 1_{(t_i,t_{I+1})}(s)$
The following step is that one that I would like to understand:
$$\int_0^T(\phi^n(s)-s)^2ds \le |\pi_n|^2T$$ This step allow me to conclude that $ |\pi_n|^2T \to 0$
Thank you for your help | Presumably, $|\pi_n| = \sup_{i=0, ..., k_n-1} |t^n_{i+1}-t_n^i|$, or something like it. \begin{align*} \int_0^T (\phi^n(s) - s)^2 ds &= \sum_{i=0}^{k_n-1}\int_{t_i^n}^{t_{i+1}^n} (\phi^n(s)-s)^2 ds\\\ &= \sum_{i=0}^{k_n-1}\int_{t_i^n}^{t_{i+1}^n} (t_i^n -s)^2 ds\\\ & \leq \sum_{i=0}^{k_n-1}\int_{t_i^m}^{t^n_{i+1}} |\pi_n|^2 ds \\\ &= |\pi_n|^2 T. \end{align*} | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "integration, probability theory, inequality"
} |
Convert console/empty project to a Win32 project
I originally started a project in Visual C++ 2010, which was an empty/Blank project. How do I convert this to a Win32 project so that there is no console ? | You're looking for the `/SUBSYSTEM` setting under linker options.
!enter image description here
Be sure to get both the Debug and Release configurations (or, leave the console enabled for Debug builds and send some useful information there) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "c++, visual studio 2010, visual c++"
} |
Style app with ng-click
I have a list of blocks that are drawn inside an ng-repeat. I use the BootStrap grid to set the width of each block. I want to expand a block when clicked. By default, the blocks are drawn using col-lg-2. The idea would be to use col-lg-12 after the click event (ng-click).
Would anyone know how I apply this style to each block individually using the ng-class or ng-style directives?
Thank you. | It's pretty easy using a combination of `ng-click` and `ng-class` built-in directives:
<my-block ng-class="{'col-lg-12': item.clicked, 'col-lg-2': !item.clicked}"
ng-click="clickMe(item)"></my-block>
Then in your controller, you would make a scope function:
$scope.clickMe = function(item) {
item.clicked = !item.clicked;
}; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "angularjs, twitter bootstrap"
} |
why is split returning empty strings even tho capturing parenthesis are not present?
My code:
var str = '<td>a</td><td>b</td>';
console.log(str.split(/<\/?td>/g));
That outputs `["", "a", "", "b", ""]`.
Why are the empty strings present?
Quoting < ,
> If separator is a regular expression that contains capturing parentheses, then each time separator is matched, the results (including any undefined results) of the capturing parentheses are spliced into the output array. However, not all browsers support this capability.
That's clearly not relevant, however, because capturing parenthesis are not present. | Let's look at a more minimal example:
",a,,b,".split(",")
// ["", "a", "", "b", ""]
What does this have to do with your case? Well, if you have two delimiters next to each other, a leading delimiter, or an trailing delimiter, you'll get an empty string in the result, since that's what's between them (and in order to maintain the behavior that `x.split(a).join(a)` should equal `x`). In your case, both `</td>` and `<td>` in the middle are matched, which means there are 2 "delimiters" right next to each other, leading to the empty string in the middle. The `<td>` at the start and the `</td>` at the end lead to a leading and trailing delimiter, leading to the empty strings at the start and the end. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, regex, split"
} |
How to improve visibility of Omnibar on-the-fly search results?
With a recent release of Google Chrome, my extension icons have robbed the Omnibar of precious screen real estate. On-the-fly search results are now truncated.
Is there any suggestion to improve this situation? Can the extension icons be hidden, or moved to a lower row?
Screenshot:  menu:
 there is a long wait time before the task actually starts.
Even when the task has been previously launched and we would expect the docker image to already be available to the worker node, there is still a waiting time dependent on image size before the task actually launches. Using docker, you can launch a container almost instantly as long as it is in your images list already, does the mesos containerizer not support this "caching" as well ? Is this functionality something that can be configured ?
I haven't tried using the docker containerizer, but it is my understanding that it will be phased out soon anyway and that gpu resource isolation, which we require, only works for the mesos containerizer. | I am assuming you are talking about the unified containerizer running docker images? What is backend you are using? By default the Mesos agents use the copy backend which is why you are seeing it being slow. You can look at the backend the agent is using by hitting `flags` endpoint on the agent. Switch the backend to aufs or overlayfs to see if speeds up the launch. You can specify the backend through the flag `--image_provisioner_backend=VALUE` on the agent.
NOTE: There are few bugs fixes related to `aufs` and `overlayfs` backend in the latest Mesos release 1.2.0-rc1 that you might want to pick up. Not to mention that there is an autobackend feature in 1.2.0-rc1 that will automatically select the fastest backend available. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "docker, distributed computing, mesos, apache aurora"
} |
In Mule/Dataweave how do I transform a HashMap into a Array when both key & value are numbers
In Mule/Dataweave how do I convert/transform a HashMap into a Array. I have got a HashMap whose key & value are dynamic numbers.
Example:
{"3.2" : 1, "22" : 8, "2.0" : 1}
I want to transform it to this structure:
[
{
"name": "app-a",
"value1": 3.2,
"value2": 1
},
{
"name": "app-a",
"value1": 22,
"value2": 8
},
{
"name": "app-a",
"value1": 2,
"value2": 1
}
]
Solution (Thanks to @Sulthony H)
%dw 1.0
%output application/json
---
payload pluck $$ map {
value1: ($ as :string) as :number,
value2: payload[$]
} | In order to transform a HashMap into an Array, I will do the following steps:
1. Iterate the HashMap by its _key_ using **pluck** operator in DataWeave: `payload pluck $$ map {}`
2. Transform the _key_ as **number** : `value1: ($ as :string) as :number`
3. Get the value based on that _key_ : `value2: payload[$]` | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "java, mule, mule studio, anypoint studio, dataweave"
} |
Why is saturation region called so in BJT characteristics?
 linear relationship is lost in saturation region and collector current will be lesser than \$ \beta * Ib \$ . Hence,at max, we can call such a region as non-linear region.
Saturation literally means something remaining constant and not increasing further (upon variation of another quantity). **Which quantity is getting saturated in so called 'saturation region' of BJT ?** | The NPN transistor consists of two diodes the B-E diode and the B-C diode.
Assuming a B-E voltage of 0.7V the B-E diode is forward biased and electrons are injected from the emitter into the base region.
For a collector voltage of, say, 1V the B-C diode is reverse biased, a field exists in the depletion zone that pulls the electrons into the collector. If the voltage at the collector terminal is reduced fewer carriers are removed from the base and for some voltage the collector is unable to remove all the carriers from the base region. The base region is saturated with carriers.
The transistor is said to be saturated. | stackexchange-electronics | {
"answer_score": 6,
"question_score": 3,
"tags": "transistors, circuit analysis, analog, integrated circuit, circuit design"
} |
Return row from subselect
I have this MySQL DB scheme:
users (id, login)
coins (userid, value, curr)
I need to write select which will return result: login and max coin he have and currency of this coin.
I've tryed something like that:
SELECT login,
(
SELECT value, curr
FROM coins
WHERE coins.userid = users.id
ORDER BY value DESC
LIMIT 1
) AS ROW(value, curr)
FROM users
Its not working... I'll recieve error, that "Operand should contain 1 column(s)". I expected it, but I dont know any way, how to make it.
So i guess: Is there any way to return multiple-column-single-line (row) from subquery to parent query?
(Yes, I can use two subqueries, but its not effective.)
Thanks for your time. | SELECT u.login, g.MaxVal, c.curr
FROM users u JOIN coins c ON u.id = c.userid
JOIN (
SELECT userid, MAX(`Value`) MaxVal
FROM coins
GROUP BY userid
) g ON c.userid = g.userid AND c.Value = g.MaxVal
In a case of ties, the above query will return all coins with the highest value, if you want to only select 1 of the coins, you can add a `GROUP BY` to the outer query:
SELECT u.login, g.MaxVal, c.curr
FROM users u JOIN coins c ON u.id = c.userid
JOIN (
SELECT userid, MAX(`Value`) MaxVal
FROM coins
GROUP BY userid
) g ON c.userid = g.userid AND c.Value = g.MaxVal
GROUP BY c.userid | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "mysql, select, subquery"
} |
Google Authorship mark ups are perfectly implemented but not appearing on SERP
I have implemented Google Authorship mark ups to pages like these ( of my website and its been more than 2 weeks but still my website is not appearing with Authorship Snippets on SERP.
When i test my pages on Rich Snippet testing tool, then it shows perfect results. I am not able to figure out what could be the issue in this?
Testing Tool Link:
Please help.
Thanks | Just because your markup is valid doesn't mean Google will show your authorship information. It is at their discretion whether or not it will be displayed and when. This applies to all microdata schemas, sitelinks, etc.
FYI, it took a while for my authorship to show in Google's search but it did eventually happen. If your markup is valid then don't change anything and just wait it out. Making unnecessary changes at this point might set you back and make it take longer for your authorship to be displayed. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "seo, microdata, schema.org, rich snippets"
} |
Retrieve specific part of XML tree value
Have an Xml.XmlNodeList variable "xmlNodes", populated with data. The xmlNodes(0).InnerText contains the following:
<InitializePagedPull ShowCode="AR13dfD">
<TokenInfo PageToken="293845657-32-47" TotalRecords="1" PageSize="20" TotalPages="1" />
</InitializePagedPull>
I'd like to get the TokenInfo.PageToken value... without having to use some archaic method of "string.indexOf() string.substring(x,y)"
I've tried creating a child XmlDocument based on the current xmlNodes(0).InnerText... and then using GetElementsByTagName("TokenInfo")... which gets me a little closer... but I'm still unable to easily grab the PageToken value within. | The answer that is using XPath is still archaic. It is already more than a decade since LINQ to XML rules them all. Here we go.
> c#
void Main()
{
XElement xml = XElement.Parse(@"<InitializePagedPull ShowCode=""AR13dfD""><TokenInfo PageToken=""293845657-32-47"" TotalRecords=""1"" PageSize=""20"" TotalPages=""1""/></InitializePagedPull>");
string pageToken = xml.Descendants().Attributes("PageToken").FirstOrDefault().Value;
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "c#, .net, xml, vb.net, xml parsing"
} |
Remove first char of a field in groovy
I got a kind of _selfmade_ problem. I got a database where one field got his own porperty_type ("selfmade"...) and it is filled with a letter followed by a number.
What I need to do is, is to output the number in a "9 digit" version filled with zeros. (A value can be F234 as well as F12345678). For the filling I intend to use `myString.padLeft(8, '0')`
My problem is the starting letter. How can I get rid of it and convert the field into a string or int? All commands for java I found only work with strings or integers but not with such a mixed kind like I have. (deletecharat, substring etc.)
Any suggestions? Thanks in advance | Use `[]` operator:
assert 'F1234'[1..-1].padLeft(8,'0') == '00001234' | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "java, groovy"
} |
как поменять цвет фона и штрихов в python (python-barcode можно использовать и другую библиотеку) вместо pillow можно использовать другую библиотеку
import barcode
from barcode.writer import ImageWriter
from PIL import Image, ImageDraw
def barcodegen(text, encoding):
encoding = barcode.get_barcode_class(str(encoding))
img = encoding(str(text), writer = ImageWriter())
img.save('barcodes/barcode')
это работает, но только с белым цветом, а штрих код должен иметь жёлтый цвет фона, и зелёные штрихи сейчас сам штрих-код выглядит так причём цвет должен вызываться тоже в функции:
(< | Нужно задать опции `save`
import barcode
from barcode.writer import ImageWriter
#from PIL import Image, ImageDraw
def barcodegen(text, encoding):
encoding = barcode.get_barcode_class(str(encoding))
img = encoding(str(text), writer=ImageWriter())
img.save('barcodes/barcode', options={"background": "gold","foreground": "green"}) | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, python 3.x, pillow, barcode"
} |
what files are needed to use fabricjs
when I compare the css and js files that are included in a FabricJS demo to the files I get in the downloaded zip file from github, they are not the same.
for instance, from the source of one of the demos I find references to:
**1 -** "../css/" ... _but does not exist in zip from github_
**2 -** "../js/" ... _but does not exist in zip from github_
**3 -** "../lib/fabric.js ... _but does not exist in zip from github_
so what are the correct js and css files to include in my html5 page? | They just released version 1.0---happy birthday, FabricJS !
I think the github files are still version .9xx
So go to < and go to the bottom of the screen and click "download".
You just need this 1 script file: **"../dist/all.js"**
There are no associated stylesheets. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "github, fabricjs"
} |
Which processorshould I get for my dedicated?
I'm trying to decide between three different processors for my budget dedicated server. My web application downloads large text files and executes regular expressions/substrings/searches, etc on about a megabyte worth of text each time it is run.
For comparable monthly prices, I can get a dedicated server with any of these processors:
Single Core Pentium 4 2.4Ghz
Dual Core Pentium D 2.66Ghz
Dual Core AMD Athlon X2 3800
For a bit more I can get a Dual Core E3300 2.5Ghz Celeron if none of these are sufficient.
Which of the cheaper three is the best processor for the money? How much of a load can they handle? | You absolutely want one of the dual cores for overall processor performance and lower task switching overhead. You also want to look closely at RAM. Not so much the speed of it, but more the amount, i.e. do you have enough RAM to avoid swapping.
Regarding the Pentium D and Athlon X2 you can find them compared in this processor chart from 2007. Just pick one of the CPU intensive benchmarks, f.x. Winrar file compression or PCMark05 CPU, and you'll get a feel for their relative speeds.
> How much of a load can they handle?
There is only one way to tell, and you'll have to do it yourself: **Benchmark your application** , and then calculate which approximate load you can sustain for a given hardware configuration... | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 0,
"tags": "hardware, central processing unit"
} |
Name property of Folder is blank when folder is created using REST API
I tried creating a Folder in a SharePoint 2013 library using REST API. I used the examples provided in Microsoft MSDN site using "folders" end point as well as "add" end point. Folder was created successfully and I can see the folder in UI and also I can navigate to that folder.
Strangely, when I click on "View Properties" of the folder, Name property is blank. When I go to "Edit Properties" window of that folder, Name appears in the textbox and if I click on Save, it starts appearing in "View Properties" window.
Has anyone noticed this behavior? Why Name property is blank even though the folder is created successfully? | This issue occured due to October 2015 CU installation and persists not only for Folder content types but also for Videos and document sets.
This can be fixed by installing April 2016 CU update.
URL to download the April 2016 CU:
<
MORE INFORMATION:
<
< | stackexchange-sharepoint | {
"answer_score": 1,
"question_score": 1,
"tags": "2013, rest, folder, library"
} |
WinForms: How to avoid horizontal scroll bar with AutoScroll?
I'm writing a custom control that contains a list of items (child controls) that resize horizontally to fit the width of the control. If there are lots of items (or the control is resized so that it is not tall enough vertically) then a vertical scroll bar is necessary; but when the vertical scroll bar appears, the child controls are suddenly too wide, which causes a horizontal scroll bar to appear.
What's the proper way to guarantee that a horizontal scroll bar does not appear when it is not necessary, given that I am controlling the control placement manually (not relying on `AnchorStyles`)? (Note: I can't control the `VScroll` property manually because I'm on Compact Framework; and if an item's minimum width is wider than the client area then a horizontal scroll bar will be required legitimately.) | What I did in a similar situation was after every time I added an item to the list I detected whether the scroll bar was visible or not and adjusted my the width manually.
What I did to detect whether the scroll bar was showing was either:
1. Test for the WS_VSCROLL was set on the control via P/Invoke via GetWindowLong().
2. Scan the control's children for a vertical scroll bar control.
It depends on how the control handles scroll bars as to which one is correct.
Also this was on Windows, not in the CF so I'm not sure if this will work exactly the same way. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "c#, .net, winforms, compact framework, autoscroll"
} |
Change derivative and limit order
I want to find the derivative of a function $f$. If I manage to find a function $g$, whose derivative I know for all $n$ such that $$f(x)=\lim_{n\rightarrow \infty} g(x,n),$$ is it true that $$\frac{\partial f}{\partial x}(x)=\lim_{n\rightarrow \infty}\left( \frac{\partial g}{\partial x}g(x,n)\right)?$$
I'm asking this because I want to know $$\frac{\partial \theta}{\partial x_i}(||\vec{x}||),$$ where $\theta$ is the Heaviside step function. | Unfortunately, no. A counterexample is $f(x)=0$ and $g(x,n)=\frac1n\sin nx$. Just because two functions are close, that does not mean their derivatives are close. | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "limits, distribution theory"
} |
How to orchestrate a clustered Quartz job
Say I have a `BackendApp` that deploys as a WAR and is deployed to multiple nodes. I deploy it to multiple nodes for high availability. The app uses Quartz to schedule certain jobs being kicked off. Let's say one of these jobs should only be ran once a day.
If I have the app deployed to 5 nodes, it will get ran 5 times a day, once on each node.
Do any mechanisms exist to orchestrate certain jobs things that should only run once in a distributed/clustered environment, and not by each app instance in the cluster?
I did find this article but it seems to be a solution that is limited to one node:
> Never run clustering on separate machines, unless their clocks are synchronized using some form of time-sync service... | You can use a JDBC store and set clustered to true, make sure all the nodes are on the same database and make sure all the machine have a time-sync service.
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "java, quartz scheduler, distributed computing, orchestration"
} |
Count down date - Javascript
I'm using this below plugin with default countdown:
I've problem in setting the countdown time, the default countdown is:
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#defaultCountdown').countdown({until: newYear});
I need countdown like below, so show can I convert the above date into below. I just need countdown for 5 mints:
**0(days)-0(hours)-4(mints)-60(seconds)** | Just use `setMinutes` and `getMinutes` like this:
var d = new Date();
d.setMinutes(d.getMinutes() + 5);
$('#defaultCountdown').countdown({until: d}); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "javascript, jquery, countdown"
} |
How to prevent default when clicking on Fancybox Overlay div?
I want to keep Fancybox open when someone clicks outside of the content popup on the div with the id of "fancybox-overlay". In other words, I want nothing to happen when the user clicks outside the bounds of the popup. Any suggestions? | Should be just available in the API: <
I see a few different hiding options, such as "hideOnOverlayClick". Pass the relevant options into the fancybox function as a map, and it should work as you want.
$('.fancyLinks').fancybox({
'hideOnOverlayClick': false
});
Where `.fancyLinks` is just some selector I made up, put whatever your target selector is.
for the newer version of Fancy box. try this Fancybox v2 No Hide on Overlay Click - How? | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "jquery, fancybox, overlay, default"
} |
Dragunov after recent patch
I saw in the release notes for the most recent Xbox 360 that the Dragunov's recoil has been reduced. I've been using both it and the RSASS a lot with the suppressor attachment and kick proficiency. What is the new recoil comparison between the two? | Here is a MW3 in-depth video explaining the Dragunov's buff: | stackexchange-gaming | {
"answer_score": 2,
"question_score": 1,
"tags": "xbox 360, call of duty modern warfare 3"
} |
Can metal putty be used to repair stripped threads in aluminum castings?
I've been burnt by stripped threads on a couple of occasions now, so knowing that metal putty could be used to re-tap a brand new thread in aluminum would be reassuring.
I recently came across Liqui Moly Metal Putty. The data sheet says:
> Liqui Moly Metal Putty is a firmly adherent, 2-component epoxy resin putty with very high chemical resistance. Liqui Moly Metal Putty is ideally suitable for permanent, quick repairs such as sealing cracks or repairing damaged threaded holes in iron, cast iron and other surfaces. Also suitable for magnesium. After curing, the repaired site can be further processed by milling or grinding etc. and painted over.
The lack of mention of aluminum here is a bit little strange. I don't expect there to be any issues in using the product with aluminum, but as I haven't tried it I cannot be sure.
Am I being overly cautious, or is there a reason to be concerned here? | There is a lack of the word _aluminum_. I don't think you'd have any issue using it in aluminum though. I think that falls under _other surfaces_ portion.
As for the fix, if at all possible, I'd use something to the effect of a Helicoil instead. It will have a lot better longevity than the putty would. The kit in the link has several different sizes to work with. You can get kits of a single size. Also, Helicoil is just one brand ... there are others out there as well. Helicoil has been around a long time and has a great reputation. | stackexchange-mechanics | {
"answer_score": 3,
"question_score": 3,
"tags": "repair, stripped thread"
} |
ZIP password recovery
> **Possible Duplicate:**
> zip password crack possible?
I have a zip file to be password-recovered. I don't remember the password itself, but I remember what type (a capital or small letter or a digit) every symbol has.
What password recovery program supports this type of password masking? | <
> The program is very customizable: you can set the password length, the character set to be used to generate the passwords, mask character, and a couple of other options
More to read about | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "zip, password recovery"
} |
Strange behavior from Oracle current_timestamp
I have a scheduled process constantly update empty timestamp column with current timestamp, but interestingly I see such inconsistency:
? | It sounds as though you may have a DEFAULT value for that column. Rows were inserted where a value was not provided for the timestamp column, so it was populated with the default value.
Try `select data_default from all_tab_columns where table_name = 'YOUR_TABLE'`; YOUR_TABLE is the table name (remember to write it in uppercase). This will tell you if there is a default value for that column. You may add the column name in the where clause if you like, too - but if you don't you may find even more information you may not have been aware of. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "sql, oracle"
} |
Delete from table rows where any of the column field is null
Is there a way to delete a row from a table where any of the column field is null without specifying explicitly which column is null?
I am using postgreSQL.
Here's my relation schema:
Column | Type | Modifiers
--------------+---------+----------------------------------------------------------------------
id | integer | not null default nextval('aurostat.visitor_center_id_seq'::regclass)
date | date |
persons | integer |
two_wheelers | integer |
cars | integer |
vans | integer |
buses | integer |
autos | integer |
Thanks | I see two ways of doing that:
With plain standard SQL, simply list all columns and combine that with an OR:
delete from the_table
where date is null
or persons is null
or two_wheelers is null
or cars is null
or vans is null
or buses is null
or autos is null;
Another (Postgres specific) solution is the comparison of the whole row with `NOT NULL`
select *
from the_table
where the_table is not null;
will return only rows where **all** columns are not null. You want the opposite, so you need to negate that `where not (the_table is not null)` The condition `where the_table is null` is something different - that only matches rows where **all** columns are null.
delete from the_table
where not (the_table is not null); | stackexchange-dba | {
"answer_score": 23,
"question_score": 14,
"tags": "postgresql"
} |
Installing Nvidia drivers on ThinkPad w530
I am on a ThinkPad W530 and have just installed Ubuntu. Which one of these drivers do I install?
Does the command `sudo apt-get install nvidia-current` install current drivers?
!enter image description here
**EDIT** : I used `sudo apt-get install nvidia-current` and now there is a nvidia_304 driver activated in Additional Drivers:
If you have Optimus enabled in the BIOS, you either have to **disable** it or install **Bumblebee**
!enter image description here | I used `sudo apt-get install nvidia-current`. There should be a new driver that appears in the Additional Drivers GUI. Restart your computer.
If you have Optimus enabled in the BIOS, you either have to disable it or **install Bumblebee**. Otherwise, you will have grey icons on the dashboard. | stackexchange-askubuntu | {
"answer_score": 0,
"question_score": 0,
"tags": "graphics, thinkpad"
} |
GeoJson layer not visible on python Folium map
I am trying to add a GeoJSON layer to a Folium map but the layer is not visible in the map though it is visible in the layer selector of folium. I am able to view the data in Qgis so the data is correct. I also do not get an error in Spyder.
I also inspected the HTML in the browser and there seems to be a script added with all the coordinates etc. The browser does not display an error when inspecting the file.
Anyone an idea what I am missing?
import folium
m = folium.Map(
location=[-59.1759, -11.6016],
tiles='OpenStreetMap',
zoom_start=2 # Limited levels of zoom for free Mapbox tiles.
)
folium.GeoJson(
data=(open('./projects/test/data/breda_bus_route.geojson', "r").read()),
name='layerName',
).add_to(m)
folium.LayerControl().add_to(m)
m.save('index.html') | It might be case that GeoJSON layer is not visible since it's not fit within the given map view, try to dynamically fit GeoJSON layer to the map view:
layer = folium.GeoJson(
data=(open(path, "r").read()),
name='geojson',
).add_to(m) # 1. keep a reference to GeoJSON layer
m.fit_bounds(layer.get_bounds()) # 2. fit the map to GeoJSON layer
**Update**
It appears it was related with GeoJSON file projection `EPSG::3857`, Leaflet expects `EPSG:4326`.
Once GeoJSON reprojected, the layer will be rendered like this
;`
throws the error in the Subject of this post.
Any ideas? Maybe it's some config, but I am a PHP newbie and I'm not sure where to look.
Thanks! | From the docs:
> This PECL extension is not bundled with PHP.
You need to install it via PECL < To see how to install PECL, see (again) the docs.
If you haven't heard of PECL, read the Wikipedia page! | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 2,
"tags": "php, http"
} |
How do I call a function based on user input in Python 3?
I am currently trying to create a program that learns through user input, however it converts to a string automatically.
Here's the code. I use the **shelve** module to store the commands for the code.
ok = {str(name):func}
asd.update(ok)
print(asd)
data["cmd"] = asd
data.close()
The 'asd' list contains every command which has been extracted from the shelf. I want to update it and store it, so next time it updates when calling a command.
'func' is the variable that stores the name of the function am trying to call, but string objects cannot be called.
How do I solve this?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EDIT: This has been solved (I totally forgot about eval() ) | Not sure what you're trying to achieve here, but from what I've understood you should have a look to `eval()`
> The eval() function evaluates the specified expression, if the expression is a legal Python statement, it will be executed.
More information here | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 0,
"tags": "python, python 3.6"
} |
Нужно ли ставить запятую после слов "больше всего", "надеюсь" и "однако"?
Ставится ли запятая после слов "больше всего" во фразе "Больше всего мне нравятся пионы", после слова "надеюсь" во фразе "Надеюсь, вы мне поможете", а также после слова "однако"? | 1) **Больше всего, больше других** – наречные сочетания в значении обстоятельства не обособляются. Но: "больше того" может быть вводным словом.
Например: **Больше того** , эти условия он сам создаёт. [Владимир Войнович (1976)].
2) **Надеюсь** , вы мне поможете. Это обособленное вводное предложение.
3) **Слово "однако" может быть:** а) вводным словом (обособляется); союзом (не обособляется); в) междометием (обособляется).
Надо, **однако** , рассказать об этом подробнее.
**Однако** ужин задерживался. Работать с ним трудно, однако интересно.
Триста тысяч, **однако!** | stackexchange-rus | {
"answer_score": 2,
"question_score": 0,
"tags": "пунктуация, запятые, вводные слова"
} |
Joomla 3.0 Administrator Panel
I can't access to Joomla 3.0 on local host, I have changed the password to admin password in database, but when I tried to login Joomla says:
> Warning : Username and password do not match or you do not have an account yet.
How can I solve this issue? Thanks | Try this,
Access you phpmyadmin -> go to #__users table choose your admin user name.
Then update your password with this
08af319cdddbcac8d2949042a416ac61:447pZnWzKdAQ81R9kX4xNiPfZTM5JOwE
The above encrypted value is the password of 123456.
first you just update password in the DB then you will get access to admin panel. There you can change your admin user password. Users->users manager->edit
Hope this will works.. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "joomla, joomla3.0"
} |
HelperApp unable to read user defaults from PrefPane
My project is composed by a PrefPane to set user defaults and a HelperApp that's running in background. Both are accessing the shared preferences plist file through CFPreferences functions.
Basically the HelperApp is a CFRunLoopSourceRef: when it's triggered by power source events, it reads user defaults from the preferences plist and reacts.
The problem, is the following: if I modify user defaults from the PrefPane when the HelperApp is running in background, it's not able to read the modified settings even if it seems to read the preferences plist every time it's triggered. | Are you forcing a sync-to/from-disk? (Via `CFPreferencesAppSynchronize` or `CFPreferencesSynchronize`.) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "objective c, cocoa"
} |
.htaccess conditional application of rules and error redirection
I'm looking to put a web application in production and I was wondering a few things about htaccess.
Here is my htaccess (the default htaccess provided by Zend Framework) :
SetEnv APPLICATION_ENV production
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I would have liked to add two things in there, first a condition based on the **APPLICATION_ENV** to force SSL connection, but only in **production** (other possible values are development, testing and staging). The other thing I would have liked to set up is a redirection to the corresponding error action in the error controller based on the HTTP request error number.
I am not looking for a full answer, but at least where I need to start to be able to achieve my goals. | Here's a mod_rewrite cheatsheet and environment variable debugging HowTo for starters (nice supplement to the rather-sparse Apache mod_rewrite docs, IMHO).
Your solution to the production/https task may look a bit like this:
RewriteEngine on
RewriteCond %{ENV:APPLICATION_ENV} ^production$
RewriteCond %{HTTPS} !^on$
RewriteRule .* [R=301,L,QSA] | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 0,
"tags": ".htaccess, zend framework"
} |
Git: Where are my cherry-pick commits in bitbucket web page?
I needed to create a branch for a patch in our development. In that branch I had to execute "git cherry-pick xxxxx" on three commits because I needed to include them in the branch. But when I go to the bitbucket web page and click on the Commits button, I see my branch but where are my cherry picked commits?
I see them when I do "git log". The reason I ask this is because one of the commits that I cherry picked has a tag associated to it, and I do not see it in bitbucket. | Just push your commits then your tags :
git push
git push --tags
to reflect on the remote what you have in your local environment. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "git, bitbucket, bitbucket server"
} |
How to evaluate $ \int_0^{2 \pi} \sin((2n-1)x) \ln(\sin(x)+5/4) dx $?
Is there a closed form for
$$f(2n-1) = \int_0^{2 \pi} \sin((2n-1)x) \ln(\sin(x)+5/4) dx $$
Of course this comes from searching the fourier series of $ \ln(\sin(x)+5/4) dx $.
In fact, it is equivalent to searching for that Fourier series since
$\int_0^{2 \pi} \sin((2n)x) \ln(\sin(x)+5/4) dx = \int_0^{2 \pi} \cos(nx) \ln(\sin(x)+5/4) dx = 0$
I know $f(4n + 1)$ has the opposite sign as $f(4n + 3)$.
Maybe using the fourier series of $\sin(x)^n$ and the taylor series of $\ln(\sin(x)+5/4) $ helps.
Or maybe we can use formulas such as $\cos(nx) = 2 \cos((n-1)x) \cos(x) - \cos((n-2) x) $ and the sine analogue.
Many thanks. | _Without Fourier series._
Just a bit of patience with integrals to see obvious patterns. $$I_n=\int_0^{2\pi}\sin [(2 n-1) x]\, \log \left(\sin (x)+\frac{5}{4}\right)\,dx=\color{blue}{(-1)^{n+1}\frac{ 4^{1-n}}{2 n-1}\pi}$$ | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "calculus, definite integrals, fourier series, closed form, recursion"
} |
Inserting a Double Customer ID with session
i'm new in PHP and i've got a problem in inserting a cus_id = customer ID, and i want to save the customer id in both table in notification and reservation table. here is my code. please comment and suggest. because im new in PHP. please don't down grade me if im wrong thank you. by the way the " function addsched " it can already save the cus_id in databse the only problem is the "function notification " the cus_id is not inserting.
function addsched($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k)
{
mysql_query("INSERT reservation(type,fname,mname,lname,wfname,wmname,wlname,cfname,res_type,status,cus_id)
values
('$a','$b','$c','$d','$e','$f','$g','$h','$i','$j','$k')");
mysql_query("INSERT INTO notification (cus_id,notification)
VALUES('$k','Thank you for reserving in Saint Michael Parish. Your
Current Reservation is still ( PENDING ) ...')");
} | try this
mysql_query("INSERT INTO notification (cus_id,notification)
VALUES('$k','Thank you for reserving in Saint Michael Parish. Your
Current Reservation is still ( PENDING ) ...'"); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql, sql, function"
} |
Creating a Cluster Fileserver System
I Currently Have 3 Fileserver each has a raid 6 array of 24 disks.
The Question is this is there any way to make them work as one big drive rather that 3 seperate systems. I need more throughput and i was thinking this was a possibilty. Maybe a Distrubted Filesystem like Hadoop? | The answer depends on the intended usage of the data on this hardware. Hadoop file system HDFS - is something suited for very special need of the Map-Reduce processing. Main limitations, which are ok for its intended use, but problematic for others are:
a) Files can not be edited, but only appended.
b) There will be a problem to stoe many small files. It is designed for file of size 64 MB and more. The cause of this limitation that all metadata is stored in memory.
c) It is not posix compliant FS, so you can not mount it and use as regular file system by the application unaware of HDFS.
I would consider options like GlusterFS, Ceph or Lustre which are built for the cases similar to one you describe. More information is needed to give good advice of selecting one of them. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "filesystems, cluster computing"
} |
How to update the statusline continuously even if the window becomes inactive
I have a vim script function `MyFunction` that returns a string value. I want to display this output in the statusline and so I have set the statusline as follows `statusline +=\ %{MyFunction()}`.
I want this function to be called periodically (say every second) and display the updated value in the statusline.
Right now, If I'm in the window and move the cursor around, the statusline is updated but when the cursor is not moving or if the window is inactive, it just stays at one value.
How can I update it periodically? | There is an easy way to trigger re-evaluating your statusline. Simply reset the option value. E.g.
`:let &stl=&stl`
which basically means to set the statusline option to the current value. It should force a redraw then. You could plug this even into a timer, so e.g.
:call timer_start(1000, {-> execute(':let &stl=&stl')}, {'repeat': -1})
This sets up a timer that triggers every second and will re-evaluate your statusline.
Note, that redraws are sometimes not desired (because they might overwrite a status message or remove the intro screen). So I wouldn't not recommend this to do in general unless you know what you are doing. | stackexchange-vi | {
"answer_score": 3,
"question_score": 3,
"tags": "statusline"
} |
How can I get a gstreamer pipeline by name?
If a pipeline is created `GstElement *pipeline = gst_pipeline_new (session_id);` on my server whenever a user visits ** (mp4 videos are streamed to a RTMP server), how can I use the name of the pipeline **"123"** to set the pipeline state to not playing when the user visits **< Each visit to **< launches gstreamer in a new thread (because my webserver is asynchronous and I want multiple users to use the platform) then the different elements/pads are created and linked. | There is no way to get a pipeline by name generically in GStreamer, you should store the `name -> pipeline` map yourself if you need it. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "c, gstreamer"
} |
How to select unique rows followed by row with highest value in MySQL?
I have a MySQL database table containing information about places. I'm trying to fetch all unique categories followed by place with highest rating, but results returned by server does not seems to be accurate.
In database in one category can be few records scored 100 but MySQL would select one that have score 95 for example.
Here is a query:
SELECT category, score, title
FROM places
WHERE active = '1'
GROUP BY category
ORDER BY score DESC
is it possible to do that in single query?
**UPDATE**
I have rewrote my query as was suggested to use MySQL function MAX() however returned results are still wrong
here is example of new query
SELECT category, MAX(score) AS maxScore, title, score AS realScore
FROM places
WHERE active = '1'
GROUP BY category
ORDER BY score DESC | SELECT category
, MAX(score) AS maxScore
FROM places
WHERE active = '1'
GROUP BY category
If you want other fields too, besides the `category` and (maximum) `score`, you can use a subquery:
SELECT p.category
, p.score
, p.title
, p.otherfield
, ...
FROM
places AS p
JOIN
( SELECT category
, MAX(score) AS maxScore
FROM places
WHERE active = '1'
GROUP BY category
) AS grp
ON grp.category = p.category
AND grp.maxscore = p.score
WHERE p.active = '1'
ORDER BY maxScore DESC
As @zekms pointed, this will this will produce multiple rows (with same category) if there are several rows with the same category and max score. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mysql, select, subquery, unique"
} |
How to clear cache,swap and what are the limits?
I am trying to run Docker but I need more memory on my Ubuntu 16.04
free -m
total used free shared buff/cache available
Mem: 7914 4024 3072 83 817 3448
Swap: 8127 14 8113
When I run docker
Setting advertised host to 127.0.0.1.
Operating system RAM available is 3344 MiB, which is less than the lowest
recommended of 5120 MiB. Your system performance may be seriously impacted.
What should I do to get more RAM?Is this possible? | Use the below command to identify top 10 Memory consuming resources. so that you can trouble accordingly
ps axo %mem,command,pid| sort -nr | head
To drop cache use below command
sync;echo 1 > /proc/sys/vm/drop_caches | stackexchange-unix | {
"answer_score": 4,
"question_score": 3,
"tags": "ubuntu, memory, ram"
} |
Get list of all registered sidebars
I am registering sidebars automatically for each category (a separate widget space per category). The technique I'm using is **here**.
In the admin side I have an options page where I need to display a dropdown of all registered sidebars... Is there are way to dynamically get this list of registered sidebars? since they're being registered in functions.php I assume they're in memory, not in the database.
I could keep track of the sidebars I register in some global variable, but just in case plugins register their own sidebars, I'd like to account for them too.
I'll dig through the core if I have to, but thought someone might know off-hand:)
Thanks | Hmm... I'm not sure if this is the best way to do it but it's simple:
I looked in `register_sidebar()` and found that new sidebars are simply tacked onto an array:`$wp_registered_sidebars`
And I guess that's that. If they ever change the name of the variable, I guess I'd be screwed. | stackexchange-wordpress | {
"answer_score": 22,
"question_score": 17,
"tags": "sidebar, register sidebar"
} |
Is it possible to submit batch processing requests with the Python Youtube API?
I'm writing an application using Python that adds videos to a user's playlist on Youtube. Doing this one at a time causes Youtube to start throttling my requests.
There is a batch processing API that allows you to submit 50 requests at once, but I can't find out from the docs how to submit a batch processing request. The only information about it covers the XML content that needs to be sent for the request.
Does anybody know how to submit a batch processing request? | It looks like this is documented on the gdata-python-client wiki: < While the examples on that page are for Base and Spreadsheets, not YouTube, it should be fairly straightforward to apply the same techniques to the YouTube API. You will, I believe, need to be using the v2 API. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "python, youtube, gdata api, batch processing, playlist"
} |
Passing variable arguments to a delegate
I have the following delegate:
public delegate object DynamicFunction(dynamic target, params object[] args);
However, when I try to create it:
DynamicFunction func = new DynamicFunction((t) => {
//Handle t
});
The compiler throws an error saying that the delegate does not take 1 argument, even though I specified the last argument to be of type `params object[]`.
If I pass **exacly one** extra argument to the delegate, it works. For example:
DynamicFunction func = new DynamicFunction((t,a) => {
//Handle t
});
However, I don't want to specify that extra argument, as I intentionally wanted those arguments to be optional.
What is happening here? | `params` mean that compiler will do smart thing when you call the function to convert whatever arguments you've passed to array.
It does not mean that function itself takes 1 or 2 parameters, and it does not mean there are 2 version of function `f(dynamic target)` and `f(dynamic target, params object[] args)`.
Note that you still want to be able to call
func (1);
func(1, optional1, optional2);
So your delegate need to handle both. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c#, .net, c# 4.0, dynamic, delegates"
} |
DB2 Select - Replace STATES with two character code
I have a Users Table where it stores city, state and country along with other Users attributes. The states are stored as California, Alabama and so forth. Now I want to retrieve the user information for certain records but the state should get translated to two digit code. Say 'California' should be 'CA'. How should I go about doing this.
I was thinking to create a mapping table for state names with there abbreviation and then use some sort of replace function to do it.
Any ideas ? | I would probably make a table like this:
CREATE TABLE states (
abrv CHAR(2),
name VARCHAR(20)
);
INSERT INTO states VALUES
('CA', 'California'),
('AL', 'Alabama')
;
Then, you could just join to the table, to get the abbreviation:
SELECT
t.field1,
t.field2
s.abrv
FROM your_table t
JOIN states s
ON t.state = s.name
WHERE .... | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "db2"
} |
Showing All Messages https://github.com/Swinject/SwinjectStoryboard has no Package.swift manifest
Xcode12
swift package manager
<
Showing All Messages has no Package.swift manifest
* Package.swift
* | "Package.swift"
Swift.org - Package Manager
()
> Packages
>
> A package consists of Swift source files and a manifest file. The manifest file, **called Package.swift** , defines the package’s name and its contents using the PackageDescription module.
Issue
Add Swift Package Manager Support #147
> Why no package manager support?
1Issue Pull Request
"Package.swift" () | stackexchange-ja_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "swift, xcode"
} |
How to configure NGinx to point wildcard style urls back to the same filesystem path
I'd like to use a section of the url to help with cache busting and tracking versions of resources being used in my application
That is to say that I've got a web app that has it's resources kept separate and served by nginx. The resources are kept in folders:
app_name/img/sprites.png
app_name/css/compressed.css
app_name/scripts/mini.app.js
I'd like to then refer to these with uris of the form:
/app_name/#{version}/img/sprites.png
or perhaps
/#{version}/app_name/img/sprites.png
where #{version} is version of the resources to load.
I'd then want to always keep the resources in the same spot in the filesystem and use nginx to always point back to the same files. | Assuming you just want those three subdirs, and return a 404 if the resource isn't found, you can do this with a regex location and a try_files:
# /app_name/#{version}/img/sprites.png urls:
location ~ ^/app_name/[^/]+(?<resource>/(img|css|scripts)/.+) {
try_files /app_name$resource =404;
}
# /#{version}/app_name/img/sprites.png urls:
location ~ ^/[^/]+(?<resource>/app_name/(img|css|scripts)/.+) {
try_files $resource =404;
}
If you want the locations to match any dir instead of just the three listed, you can replace (img|css|scripts) with [^/]+. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "nginx"
} |
Custom Cell Textfield index changing on Scrolling
I have a `UITextField` in a custom cell. Once I entered the value in first and second cells and when I scroll the `UITableView` textfield index are changing (first cell value changing to last cell). Can any one help me to resolve my issue?
Here is my code:
static NSString *cellIdentifier = @"TableCellID";
CustomTableViewCell *cell = (CustomTableViewCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[CustomTableViewCell alloc] init]; // or your custom initialization
}
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.txt_TCelltext.tag=indexPath.row;
cell.txt_TCelltext.placeholder=@"0.00";
[cell.txt_TCelltext setDelegate:self];
!enter image description here | You can write below code in Viewdidload and cell for row at index path.
arrCells = [NSMutableArray new];
for (int i = 0; i < [[dic_demo objectForKey:@"Demo"] count]; i++) {
NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:self options:nil];
CustomTableViewCell *cell = [objects objectAtIndex:0];
[arrCells addObject:cell];
}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
CustomTableViewCell *cell = [arrCells objectAtIndex:indexPath.row];
}
Hope this will help you | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "ios, objective c, xcode, uitableview, uitextfield"
} |
Create HIVE Table with multi character delimiter
I want to create a HIVE Table with multi string character as a delimiter such as
CREATE EXTERNAL TABlE tableex(id INT, name STRING)
ROW FORMAT delimited fields terminated by ','
LINES TERMINATED BY '\n' STORED AS TEXTFILE LOCATION '/user/myusername';
I want to have delimiter as a multi string like "~*". | `FILELDS TERMINATED BY` does not support multi-character delimiters. The easiest way to do this is to use `RegexSerDe`:
CREATE EXTERNAL TABlE tableex(id INT, name STRING)
ROW FORMAT 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
"input.regex" = "^(\\d+)~\\*(.*)$"
)
STORED AS TEXTFILE
LOCATION '/user/myusername'; | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 9,
"tags": "hadoop, hive"
} |
How can I calculate this triple integral?
The formula is: $$ \iiint_G {|xy| \over{x^2}} dxdydz $$ $G$ is defined by the inequality: $\sqrt{x^2+y^2} < z < \sqrt{1-x^2-y^2}$
I tried to use this substitute: $$ \begin{cases} x = rsin(\phi)\\\ y = rcos(\phi)\\\ z = z \end{cases} $$
So $G$ transforms to $r < z < \sqrt{1 - r^2}$, but for me it's not much better. Other suggestions?
Thanks for any help! | $$G_1=\left\\{(\theta,r,z)\Big{|}\,\,\frac{\pi}{4}\le\theta\le\frac{3\pi}{4} ,\,0\le r\le 1 \, , r\le z\le\sqrt{1-r^2}\right\\}\\\ G_2=\left\\{(\theta,r,z)\Big{|}\,\,\frac{5\pi}{4}\le\theta\le\frac{7\pi}{4} ,\,0\le r\le 1 \, , r\le z\le\sqrt{1-r^2}\right\\} $$ We have $G=G_1\cup G_2$.Since $G$ is symmetric with respect $x-$ axes and $y-$ axes, thus $$ \iiint_G {|xy| \over{x^2}} dxdydz=4\int_{0}^{\frac {\pi}{4}}\int_{0}^{1} \int_{r}^{\sqrt{1-r^2}}\tan\theta \,\text{dz dr d}\theta $$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "calculus, integration, substitution, multiple integral"
} |
Property Declaration
OrderDetailsView.h
#import <UIKit/UIKit.h>
@protocol OrderDetailsViewDelegate;
@interface OrderDetailsView : UIViewController {
IBOutlet UITextView *OrderDetails;
NSString *selectedOrder;
id <OrderDetailsViewDelegate> delegate;
}
@property (nonatomic, assign) id <OrderDetailsViewDelegate> delegate;
- (IBAction)done:(id)sender;
@end
@property (nonatomic, retain) NSString* selectedOrder;
@end
@protocol OrderDetailsViewDelegate
- (void)OrderDetailsViewDidFinish:(OrderDetailsView *)controller;
@end
OrderDetailsView.m
#import "OrderDetailsView.h"
@implementation OrderDetailsView
@synthesize selectedOrder;
@synthesize delegate;
i am getting the error
property declaration not in @interface or @implementation context | @end
Must present only once in interface declaration, so remove redundant one (after done method) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "iphone, objective c, declaration"
} |
How to disable Xcode suggestion to change let into _
When Xcode suggests me to change `var` to `let` \- I can understand it.
But when I have over9999 warning just because of the fact that xcode suggests me to change all `let` into `_` \- I becomes angry. Where can I disable it? | As far as I know, there is no way to remove this warning. And you should **NOT** do this anyway. It's good to enforce best practices. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ios, xcode, warnings, var, let"
} |
What substance do they use to grease bottom bracket, crank, pedal bolts etc?
When watching bike assembly videos I wonder what substance do they use to grease carving of bottom bracket, fork, crank, pedals etc? Here is video and screenshot example:
;
if (result == CG_ERR_OK) continue;
if (result == CG_ERR_TIMEOUT)
{
break; // i'm here!
}
As in debugger i'm at `break;` I assume that `result == CG_ERR_TIMEOUT` is true. In Locals I do see:
result 131075 unsigned int
In Watch I do see:
CG_ERR_TIMEOUT error: identifier 'CG_ERR_TIMEOUT' out of scope
Going to definition shows me such code:
enum {
CG_ERR_OK = 0,
CG_ERR_INTERNAL = CG_RANGE_BEGIN,
CG_ERR_INVALIDARGUMENT,
CG_ERR_UNSUPPORTED,
CG_ERR_TIMEOUT,
CG_ERR_MORE,
CG_ERR_INCORRECTSTATE,
CG_ERR_DUPLICATEID,
CG_ERR_BUFFERTOOSMALL,
CG_ERR_OVERFLOW,
CG_ERR_UNDERFLOW,
CG_RANGE_END
};
So I just wonder why CG_ERR_TIMEOUT == 131075. What a strange magic number? | Because CG_RANGE_BEGIN is 131072 (which is 0x20000).
enum {
CG_ERR_OK = 0,
CG_ERR_INTERNAL = CG_RANGE_BEGIN, // == 131072
From now on every enum value is the previous one plus 1:
CG_ERR_INVALIDARGUMENT, // == 131072 + 1 = 131073
CG_ERR_UNSUPPORTED, // == 131073 + 1 = 131074
CG_ERR_TIMEOUT, // == 131074 + 1 = 131075
CG_ERR_MORE, // etc.
CG_ERR_INCORRECTSTATE,
CG_ERR_DUPLICATEID,
CG_ERR_BUFFERTOOSMALL,
CG_ERR_OVERFLOW,
CG_ERR_UNDERFLOW,
CG_RANGE_END
}; | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "c++"
} |
How to apply list of functions to list of corresponding parameters *fast*
Given is a list of function handles in Python, say:
f = [f1, f2, f3, f4]
and a corresponding list of parameters:
a = [a1, a2, a3, a4]
**Problem** I want to _quickly_ compute: [f1(a1), f2(a2), f3(a3), f4(a4)]. I tried list comprehension, but for my application it was too slow. Is there a more natural way/numpy-fast way to do this? I am thinking some sort of vectorization. | Use `zip` for associating elements of same index across two lists.
res = [func(x) for func, x in zip(f, a)]
From there, your bottleneck would probably be the function calls. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "python, performance, numpy"
} |
Updating div after full page refresh following AJAX request
I have an AJAX controller action which returns JSON. The returned JSON is handled via jQuery and contains a message displayed in an update div. The JSON also contains a flag which indicates a change in state. If this is true the entire page needs to be reloaded from a different url. This is currently performed in the jQuery using window.location.replace(url).
In the situation where a full page refresh occurs, I still want to display the message from the JSON in the update div, but after the page has fully reloaded.
How can I ensure the div is updated with the message after the window.location.replace call and the page has been completely reloaded?
Thanks.
(I realise AJAX is not intended for full page refreshes but I can't think of a simple way of avoiding it in this scenario. Normal behaviour here is updating the div with a status message.) | I couldn't find a sensible way of dealing with this so added the message contents to the controller logic for the action to which the page is redirected. Probably should have done this in the first instance. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net, javascript, jquery, asp.net mvc, ajax"
} |
SQL Server Compatibility level implications
A quick information question :
On my SQL Server 2008, I have databases migrated from SQL Server 2005 and the Compatibility level of the databases on SQL Server 2008 are set to `90` (SQL Server 2005).
What exactly are the implications of that?
It means that the migrated stored procedures, triggers and functions will work well on SQL Server 2008, but are there any disadvantages?
What could be the reason to set the compatibility level to `100` (SQL Server 2008) ?
Performance? Extra features?
Thanx | Compatibility mode is there to help people migrate applications that have functions that are no longer compatible with newer versions of SQL. If you have applications that require functions no longer supported in sql 2008 you would want to run them in compatibility mode; otherwise you would like use a current sql mode. Our business runs an application that due to the way it connects to the database requires SQL 2000 compatibility mode; but it is running on a SQL 2012 server.
Specific functions in code might impact performance as the required logic is different rather than the execution is specifically different. As a very generalised rule SQL code optimised for functions on 2012,2008 would be quicker than SQL 2000 or SQL 7 as they have added things like CTE and un/pivot both of which allow for simplified coding. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 13,
"tags": "sql server 2008, sql server 2005, compatibility"
} |
What is the cause of this BigQuery search error?
SELECT a.name, b.name, COUNT(*) as count
FROM (FLATTEN(
SELECT GKGRECORDID, UNIQUE(REGEXP_REPLACE(SPLIT(V2Persons,';'), r',.*', ")) name
FROM [gdelt-bq:gdeltv2.gkg]
WHERE DATE>20150302000000 and DATE < 20150304000000 and V2Persons like '%Tsipras%'
,name)) a
JOIN EACH (
SELECT GKGRECORDID, UNIQUE(REGEXP_REPLACE(SPLIT(V2Persons,';'), r',.*', ")) name
FROM [gdelt-bq:gdeltv2.gkg]
WHERE DATE>20150302000000 and DATE < 20150304000000 and V2Persons like
'%Tsipras%'
) b
ON a.GKGRECORDID=b.GKGRECORDID
WHERE a.name<b.name
GROUP EACH BY 1,2
ORDER BY 3 DESC
LIMIT 250
Here is the error message: Syntax error: Each subquery argument for table-valued function calls must be enclosed in parentheses. To fix this, replace SELECT... with (SELECT...) at [3:1] | The query in question is written in BigQuery Legacy SQL - so make sure you run it in Legacy mode. And secondly - below is version with few minor corrections (wrong use of double quotes instead of apostrophes in REGEXP_REPLACE)
#legacySQL
SELECT a.name, b.name, COUNT(*) AS COUNT
FROM (FLATTEN(
SELECT GKGRECORDID, UNIQUE(REGEXP_REPLACE(SPLIT(V2Persons,';'), r',.*', '')) name
FROM [gdelt-bq:gdeltv2.gkg]
WHERE DATE>20150302000000
AND DATE < 20150304000000
AND V2Persons LIKE '%Tsipras%'
,name)) a
JOIN EACH (
SELECT GKGRECORDID, UNIQUE(REGEXP_REPLACE(SPLIT(V2Persons,';'), r',.*', '')) name
FROM [gdelt-bq:gdeltv2.gkg]
WHERE DATE>20150302000000
AND DATE < 20150304000000
AND V2Persons LIKE '%Tsipras%'
) b
ON a.GKGRECORDID=b.GKGRECORDID
WHERE a.name<b.name
GROUP EACH BY 1,2
ORDER BY 3 DESC
LIMIT 250 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "google bigquery, gdelt"
} |
Вычитание словарей (фильтрация)
Есть 2 словаря
dic1 = {
'NAME': 'JACK',
'AGE': '20',
'ID': '10',
'FK_ID': '35',
'CONST_ID': '141',
'CODE_SK': 'LAST'
}
dic2 = {
'CODE': 'ID, FK_ID',
'CONST': 'CONST_ID'
}
Нужно из первого словаря (dic1) исключить пары ключ/значение, которые есть во втором словаре как значение (dic2), при этом значение во втором словаре могут быть через запятую, которые в первом являются ключом. Должно получится так:
dic3 = {
'NAME': 'JACK',
'AGE': '20',
'CODE_SK': 'LAST'
}
Пробовал словарь преобразовать в set и вычитать, но такой метод не сработал. | Предлагаю сначала сгенерировать список ключей, которые должны быть удалены из словаря. А потом отфильтровать ключи словаря по условию.
Для получения списка ключей можно проитерировать значения словаря и разделить каждое по запятой с помощью метода `split`. Лишние пробельные символы можно удалить с помощью `strip`.
_**Пример:**_
# ['ID', 'FK_ID', 'CONST_ID']
keys = [subkey.strip() for value in dic2.values() for subkey in value.split(',')]
result = {key: value for key, value in dic1.items() if key not in keys}
print(result)
_**stdout:**_
{'NAME': 'JACK', 'AGE': '20', 'CODE_SK': 'LAST'} | stackexchange-ru_stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "python, dict"
} |
Deleted App on Bluemix yet name not available on recreate
I deleted an app on Bluemix that was causing me some problems, basically to start over. However right after deleting when I try to recreate I get "The name is already used by another app."
How can I delete it completely and reuse the name?
I checked via the command line as well and "cf apps" does not list it. So the name is somehow still in use just not visible to me. | When an app gets deleted, the route (and thus the URL) is not released yet. The routes are reserved on a particular space, not on the organization level. Are you sure you are using the same space as before? If your app was installed on some other space before, you can go to that space and use the command
cf delete-route
to delete the unused route. One thing that you can check if that route is owned by that space is to do a
cf routes
to see if that route belongs to the space that you are currently using. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "ibm cloud, cloud foundry"
} |
Enque Javascript in Footer?
I currently enque jQuery like so - how do I move this to the footer instead?
// Enque: jQuery
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
} | The fifth parameter is `$in_footer`. You have left that out. Add that parameter, set it to `true`.
wp_register_script(
'jquery',
"http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js",
false,
null,
true
);
But I echo the concern expressed by @Andrew in a comment. You can cause yourself trouble by deregistering/replacing the core libraries.
## Reference
< | stackexchange-wordpress | {
"answer_score": 3,
"question_score": 0,
"tags": "jquery, wp enqueue script"
} |
Predicative logic implication, is it true?
I'm struggling to find a counterexample for this expression...
$\left(\forall x P(x) \longrightarrow \forall x Q(X)\right) \overset{is\ this \ true??}{\longrightarrow} \forall x (P(x) \longrightarrow Q(x)) $ | Let the universe be the set of integers and say
* $P(x)$ means "$x$ is even";
* $Q(x)$ means "$x$ is odd".
Then $$\forall x P(x) \longrightarrow \forall x Q(x)$$ is true, but $$\forall x (P(x) \longrightarrow Q(x))$$ is false. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "predicate logic"
} |
Endomorphism ring of a vector space
I have proof of this but not getting please help me. If $End_{K}(V)$ is a simple ring then $V$ is finite dimensional vector space. proof:- Let us assume that $V$ be not a finite dimensional vector space over field $K$. Define $I=\\{f \in End_{K}(V)\mid\dim_{K}f(V)<\infty\\}$ $0 \in I$ and $1\notin I$ $(0)\subseteq I \neq End_{K}(V)$ Now to show that I is both sided ideal we get contradiction. i am not getting it from my text book | Only the basic verification stands between you and the answer:
If the image of $f$ and $g$ are finite dimensional, show that the images of $-f$ and $f+g$ are finite dimensional also.
For any $h\in End_K(V)$, give a reason why $fh$ has finite dimensional image.
Finally, why should the image of $hf$ be finite dimensional? | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "linear algebra, abstract algebra, ring theory"
} |
WKWebView how to disable adjustedContentInset when keyboard is shown?
If I open the keyboard when displaying a WKWebView it automatically adds adjustedContentInset to the ScrollView. But the problem is, if I handle the keyboard myself it still adds the adjustedContentInset. How can I fix this? | If you remove the observers which handles the keyboard from the WKWebView it stops adding the adjustedContentInset:
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.removeObserver(self.webView, name: UIResponder.keyboardWillHideNotification, object: nil) | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 2,
"tags": "ios, wkwebview"
} |
How to retrieve all commits, committer and commit time for a complete project?
Is there any way to get the commit data for a project as follows:
commit1 committer commit_time
commit2 committer commit_time
commit3 committer commit_time . . .
git shortlog only gives the number of commits by user and git log gives multiple statements for each individual commit. | I think you want to use `git log` for this purpose. Something like:
git log --pretty=format:"%H %aN %ai" --all
Note: you said committer, but I think you mean author. So the above shows the author name and time. If you really mean committer, then you probably want this:
git log --pretty=format:"%H %cN %ci" --all
Look at the `git-log` man page in the "PRETTY FORMATS" section for more information on what options you can pass to format. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "git, github"
} |
mysqltuner: "MySQL started within last 24 hours - recommendations may be inaccurate." Why?
I'm new to db management and db tweaking. I'm using mysqltuner to get recommendations for how to improve db performance.
Mysql issues a warning message along with its recommendations: "MySQL started within last 24 hours - recommendations may be inaccurate." It is true that I started MySQL within the last 24 hours, but why does this matter? What does the database do over a 24 hour period that will change the results of mysqltuner? | It is a basic caution that a MySQL instance running under 24 hours (1 day) may not have seen the entire query workload and thus the recommendations might be affected.
Of course, 24 hours doesn't guarantee the entire workload either, as you might have scripts that run weekly or monthly.
On a separate note, I would caution you on taking the advice of mysqltuner too strictly. Specifically don't make any changes that you don't fully understand just because the script says to do so. | stackexchange-dba | {
"answer_score": 4,
"question_score": 2,
"tags": "mysql, mysqltuner"
} |
Upload files without FieldStorage
How could i upload a file to a server without using FieldStorage in python? | Here is a toy program snippet that should help get you started. Try reading RFC 1867 as well for more guidance.
#!/usr/bin/python
import os
import sys
buf = sys.stdin.read(512)
print "Content-type: text/html\n\n";
print '<html>'
print '''
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="f">
<input type="submit">
</form>
'''
print buf
print '</html>'
You can use os.environ.items() to get a list of environment variables, notably CONTENT_LENGTH and CONTENT_TYPE (specifically the boundary key/pair) so you know where the demarcation points are for the uploaded content. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, python 3.x"
} |
Why does git clean --dry-run shows more untracked files than git status does?
Ok so I forked a project, ran `git pull upstream master` and git status said working directory clean. I then ran some tests from the project
now `git status` shows
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# activemodel/log/
now `$ git clean -d -f -n` shows
# Would remove actionpack/test/temp/
# Would remove activemodel/log/
These are just directories for log files but I'm curious why `actionpack/test/temp/` shows up in the `git clean dry run` but didn't show up in `git status`
This could cause problems if all untracked files don't show up in `git status` and then `git clean` would delete files you didn't realize it would delete.
Anybody know why this happens? | Are they empty directories?
Git does not track empty directories (actually Git does not track directories at all, as you can read in the Git FAQ), so they will not appear in `git status`, but they would indeed be cleaned by `git clean -f -d`.
That's why a dry run of such `git-clean` command is showing directories that do not appear otherwise with a regular `git status`.
As a side note, this is also why some people add a placeholder file, sometimes called `.gitinclude` by convention, inside empty directories in order to make Git track them. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "git, github"
} |
Jquery find/Contains and replace table cell value
!enter image description here
I want to check all rows of a table's first column if a text exists and if it does I want to overwrite the value in the second cell of the same row. I tried a lot and couldn't get to it. I use jQuery 1.7.1.
<table id="tbl">
<tr>
<td>sakthi</td>
<td>1</td>
</tr>
<tr>
<td>pushparaj</td>
<td>2</td>
</tr>
</table>
$('#tbl >tr').each(function() {
if($(this).find('td:contains'+sakthi+''))
{
var oldVal = $(this).find('td:eq(1)').text();//find value from first td
$(this).find('td:eq(1)').text(+oldVal + +5);//replace the same value
}
$('#tbluom >tbody').append('<tr><td>' + UOMCaption + '</td><td>' + UOMQty + '</td></tr>');
}); | You can use `filter`
$("#tbl tr td:first-child").filter(function() {
return $(this).text().indexOf("sakthi") > -1;
}).next("td").text(function() {
var currentText = $(this).text();
console.log("Current Text: " + currentText);
return currentText + " changed";
});
`.text()` can accept a function callback. So, inside this callback, you can grab the current value, modify it, then return whatever you want your new value to be.
Demo: < | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "jquery, html table"
} |
Detecting dev env vs. prod env Elastic Beanstalk
I have a `Django` app and **two** Elastic Beanstalks envs: `dev` and `prod`. I want to make some kind of **if statement** in my Django app to **detect which env I am deploying** to (or running locally) and use **different settings accordingly**.
How can I do this? Thanks!! | One way would be to use EB environmental variables. On each of your EB environments, you could define `ENVIRONMENT` environmental variable in EB with values of either `prod` or `dev`.
Your Django app would check the `ENVIRONMENT` variable and load respective configuration. On your local workstation, the lack of `ENVIRONMENT` would indicate to your app that you are on a local workstation. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "django, amazon web services, amazon elastic beanstalk"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.