INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
What is $\frac{d}{dx}\left(\frac{dx}{dt}\right)$?
This question was inspired by the Lagrange equation, $\frac{\partial L}{\partial q} - \frac{d}{dt}\frac{\partial L}{\partial \dot{q}} = 0$. What happens if the partial derivatives are replaced by total derivatives, leading to a situation where a function's derivative with respect to one variable is differentiated by the original function?
|
Write $$\frac{d}{dx}\left(\frac{dx}{dt}\right)=\frac{d}{dx}\left(\frac{1}{\frac{dt}{dx}}\right)$$ and use the chain rule. $$\frac{d}{dx}\left(\frac{dx}{dt}\right)=\left(\frac{-1}{(\frac{dt}{dx})^2}\right)\frac{d^2t}{dx^2}=-\left (\frac{dx}{dt}\right )^2\frac{d^2t}{dx^2}$$
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 9,
"tags": "calculus"
}
|
What is the difference of Orchard CMS Input field vs Text field?
Would you help me to understand what's the difference of this two fields in Orchard CMS?
Many thanks,
Rocky
|
The InputField is newer than the TextField and has more options, such as the ability to set the type (e.g. text, tel, email), autofocus, autocomplete, placeholder text, editor css class and maxlength.
The TextField on the other hand supports a flavor, allowing you to turn the text field into a single line textbox, a textarea, a markdown editor, html editor, or any other flavor provided by any module.
In my opinion, we should consider getting rid of the Input Field and update the TextField in core with the capabilities found in InputField. This avoids confusion and at the same time offers greater flexibility.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 6,
"tags": "orchardcms"
}
|
How to set Countdown time format
I was use `runnable()` to make countdown timer on my game
i was set `int cd=30;`
and this is the method for run it
final Handler mHandler = new Handler();
final Runnable mUpdateTimeTasks = new Runnable() {
public void run() {
countdowntext.setText(String.valueOf(cd));
cd -=1;
if(cd < 10) {
countdowntext.setTextColor(Color.RED);
}
if(cd == 0) {
focus.stop();
}
};
// run this in a method.
mHandler.postDelayed(mUpdateTimeTasks, cd);
}
the code was work fine but the problem just the coundown timer run so fast, i just wonder how to make int cd=1 = 1 second too, so cd=30 = 30 second
can anyone help me?
|
> i just wonder how to make int cd=1 = 1 second too, so cd=30 = 30 second
then you should use `mHandler.postDelayed(mUpdateTimeTasks, 1000)`
final Runnable mUpdateTimeTasks = new Runnable() {
public void run() {
countdowntext.setText(String.valueOf(cd));
cd -=1;
if(cd < 10) {
countdowntext.setTextColor(Color.RED);
}
if(cd == 0) {
focus.stop();
mHandler.removaCallbacks(null);
return;
}
mHandler.postDelayed(this, 1000)
};
this will not give exactly 30 seconds but something really close to it
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, android, handler, runnable, countdowntimer"
}
|
Does Sphinx support a no wrap option for building the po files?
I am trying to create po files in sphinx using sphinx-intl update -p build/locale/ -l de.
However, the output it produces looks something like
#: ../../source/my-documentation.rst:16
msgid ""
"Far quitting dwelling graceful the likewise received building. "
"Unaffected remarkably get yet introduced excellence terminated led."
"But truth being state can she china widow."
msgstr ""
While what I want is:
#: ../../source/my-documentation.rst:16
msgid ""
"Far quitting dwelling graceful the likewise received building. Unaffected remarkably get yet introduced excellence terminated led. But truth being state can she china widow."
msgstr ""
Is there any way I can specify a no-wrap option? Any help will be appreciated. Thanks!
|
According to the source code of `sphinx-intl`, it is not possible to configure.
You can see it here. `sphinx-intl` calls `pofile` function without `wrapwidth` argument. However, polib library supports what you need, so you can either fork `sphinx-intl`, or monkey patch it, and call `pofile` function with e.g. `wrapwidth=150`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python sphinx"
}
|
Express this sum of radicals as an integer?
I have read somewhere that the radical $\sqrt[3]{2+\sqrt{5}}+\sqrt[3]{2-\sqrt{5}}=1$ and I don't understand it. How do you solve this(when the RHS is unknown)?
|
Let us consider the equation $ y^3+py+q=0 $. The theory of its solution tells, that we should consider $$ \Delta=\left(\frac{p}3\right)^3+\left(\frac{q}2\right)^2. $$ If $\Delta>0$, then $$ y=\sqrt[3]{-\frac{q}2-\sqrt{\Delta}}+\sqrt[3]{-\frac{q}2+\sqrt{\Delta}} $$ is unique real solution.
If you know this, the rest is simple. We guess $q=-4$, then $p=3$ and we have equation $$ y^3+3y-4=0 $$ with an obvious real solution $y_0=1$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "algebra precalculus, contest math, radicals"
}
|
Rails "wrong number of arguments (1 for 0)" in to_json method
> **Possible Duplicate:**
> Override to_json in Rails 2.3.5
lib/responses.rb
module Responses
class Response
def to_json
JSON.pretty_generate(self)
end
end
class ErrorResponse < Response
def initialize(cause)
self[:type]="Error"
self[:casue]=cause
end
end
class DataResponse < Response
attr_accessor :data
end
end
This is used by the controller:
response=Responses::DataResponse.new
response.data=someData
render :json => response
Now I am getting an error `wrong number of arguments (1 for 0)` in `lib/responses.rb:3:in to_json`. Why? There is no argument passed to the `to_json` which is implicitly called by `render :json`. So where is my mistake?
|
Its because in Rails when you render with json, the method to_json will receive options.
You probably want to do something like this:
def to_json(options = {})
JSON.pretty_generate(self, options)
end
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 6,
"tags": "ruby on rails, ruby, json"
}
|
IActionModelConvention registration in ASP.NET Core 3.1
How can I register `IActionModelConvention` in ASP.NET Core 3.1? I have a class that implements it:
class MyConvention : IActionModelConvention {
...
}
This is how to register it in .NET Core 2.1:
services.AddMvc(options => {
options.Conventions.Add(new MyConvention());
});
How can I use `MyConvention` with ASP.NET Core Endpoint Routing?
|
Try the following:
Within your startup class inside `ConfigureServices` method use this `services.'desired service lifetime'<IActionModelConvention, MyConvention>()`
Services life time can be either Transient, Scoped or Singleton, further information you can find in Service Lifetimes
Also take a look at the following article from Microsfto's documentation: Dependency injection in ASP.NET Core
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, asp.net core, asp.net core mvc, asp.net core 3.1"
}
|
is it possible to code my own application with medical material?
I'm currently doing an internship in a medical laboratory
They want to buy Ipad and medical device connected to it
example: diabet tester < blood pressure monitoring system <
I'm wondering if I can code my own application that gets the data from the medical device and then handle it?
thks for your answers
|
I think they're some step to success it .
At first you need a Hardware solution like said "Mundi".
You need to grab data from device and store them somewhere accessible (like in a BDD with online acces).
And then the iPad application just have to connecte to the data-Source and play with it
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "iphone, ipad, medical"
}
|
Get the total counts after faceting in solr4.0
I am using `solr 4.0` and have the following query :
`
This returns the following :
`<lst name="priority"> <int name="67JP 0041952">1</int> <int name="67SU 1140793">1</int> <int name="69SU 1328511">1</int> <int name="AU 2007 242957">2</int> <int name="AU 2008 201480">1</int> <int name="CN 1993 103001">3</int> <int name="CN 1997 106616">1</int> </lst>`
The field `priority` is multivalued. Now what i want to achieve is to get the total counts from the result returned after faceting i.e. 10. Is it possible to do?
|
To get the total count of the facets you need to check SOLR-2242
The fix version is Solr 4.0, so this should be available in the Current build.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "solr, facet"
}
|
Can I check with mockmvc if an endpoint exist?
I am trying to check if a particular endpoint of a controller exists. By now I am not interested checking the response or status codes. Is there a way to just check the existence?
|
This is not possible. It's emulating a web request, so unless you return that information in a standard request, you cannot check that an endpoint exists. The best you can do is check for a 404 status, but that doesn't necessarily mean that an endpoint doesn't exist.
You may be able validate an endpoint's existence another way, by looking at what endpoints Spring has mapped with `RequestMappingHandlerMapping`
See this answer.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, spring, controller, mockmvc"
}
|
LTSP client boots on busybox
I've installed an LTSP server on my linux desktop 12.04 (virtual machine), set all the necessary network settings.
Now I created a thin client using virtualbox, booted (after starting up the server obviously), the client connects to the ip address, boots, but all i see is a busybox.
Shoudln't there be a desktop??
I tried installing an LTSP server on a 10.04 desktop, this time the client booted in a busybox with this error: Error: failed to connect to NBD server.
I followed this guide : <
except for the client I created a "host only" NIC instead of a bridged one.
I've really been stuck with this for a long time, could somebody please help?
|
I figured out the problem. Turns out the nbd-server config had the wrong export path
go to /opt/nbd-server/config
under
[export]
exportname= /opt/ltsp/images/i386.img
port = 2000
restart the nbd-server witht he command
sudo /etc/init.d/nbd-server restart
Also, I'm not sure but I suspect that you have to chose a static IP address different from the gateway address.
and voilà solved.
|
stackexchange-askubuntu
|
{
"answer_score": 0,
"question_score": 1,
"tags": "boot, server, virtualbox, ltsp, ltsp client"
}
|
An epimorphism into a profinite group
Let $p$ be an odd prime number, $G$ a finitely generated nonabelian profinite group, $L \lhd_o G$ a pro-$p$ group with $[G : L] = 2$. Suppose that there is a continuous surjection from $G$ onto a free pro-$p$ group of rank $d(G)$. Must $L$ be free pro-$p$ ?
Here, $d(G)$ is the smallest cardinality of a generating set of $G$.
|
No.
Let $G = D_p \times F$, where $D_p = \langle a,b \mid\ a^p = 1,\ b^2 = 1,\ a^b \ (:=b^{-1}ab)=a^{-1}\rangle$ is the dihedral group of order $2p$ and $F$ is the free pro-$p$ group on two generators, say, $x,y$. Then $L = \langle a \rangle \times F$ is of index $2$ in $G$, pro-$p$, but not free, and there is a surjection $G \to F$. Since $H := \langle ax, by \rangle$ is clearly of rank $2$, it suffices to show that $H = G$, i.e., that $a,b,x,y \in H$.
As $b,y$ are of coprime (supernatural) orders and commute, $\langle b y \rangle = \langle b \rangle \times \langle y \rangle$, so $b, y \in H$. Thus $x a^{-1} = a^{-1} x = (ax)^b \in H$. Therefore $x^2 = (x a^{-1}) (a x) \in H$ and $a^2 = (a x) (a^{-1} x)^{-1} \in H$. As $2$ is prime to the orders of $x$ and $a$, we have $\langle x^2 \rangle = \langle x \rangle$ and $\langle a^2 \rangle = \langle a \rangle$, so $x, a \in H$.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 2,
"question_score": 2,
"tags": "gr.group theory, finite groups, profinite groups, free groups, p groups"
}
|
Help in solving Conditional Probability problem
I appreciate the help I have received in the past. Please help solve this problem. It holds the key to my understanding of other similar questions.
"A box contains 7 marbles, numbered from 1 to 7 inclusive. Three marbles are randomly drawn from the box, one at a time, and without replacement. Determine the probability that the marbles picked are alternately either odd, even odd or even, odd, even numbered."
|
There are $4$ odd-numbered marbles and $3$ even-numbered marbles. Thus, the probability of drawing an odd-numbered marble on the first draw is $\frac47$. That leaves $3$ odd- and $3$ even-numbered marbles, so the probability of drawing an even-numbered marble at that point is $\frac36=\frac12$. That leaves $3$ odd- and $2$ even-numbered marbles, so the probability of drawing an odd-numbered marble at that point is $\frac35$. The overall probability of this sequence of events is therefore
$$\frac47\cdot\frac12\cdot\frac35=\frac6{35}\;.$$
Now reason similarly to calculate the probability of drawing an even-odd-even sequence. How should you combine these two probabilities to get the probability that you want?
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "conditional probability"
}
|
What does "RA" mean in the FAA Terminal Constraints?
I'm trying to interpret the Terminal Constraints listed on the Operations Plan Advisory (< RA seems to be used in the context of weather, but I haven't been able to find a definition for what "RA" means other than "Resolution Advisory" which I don't think is applicable in this context.
Example:
TERMINAL CONSTRAINTS:
NY METS/PHL/DC METS-RA/LOCIGS
CTL/ATL/MCO/TPA/FLL/MIA-RA/TSTMS
|
-RA is the METAR code for light rain.
LOCIGS is low ceilings, and TSTMS is thunderstorms.*
* * *
* Air Traffic Management Glossary of Terms (faa.gov).
|
stackexchange-aviation
|
{
"answer_score": 3,
"question_score": 2,
"tags": "weather, terminology, faa, air traffic management"
}
|
Generating analog signals
is there a way to make the Arduino act as a voltage source, by generating sinusoidal, triangular and other kinds of signals? If so, can it be done using LabVIEW? (I've already managed reading analog signals using VISA)
Thank you!
|
The Due (and similar SAM based boards) have a DAC built in which can be set to different voltages (I forget the range off hand, maybe 0-Vcc at 12-bit resolution). Change that voltage fast enough, and you have a waveform.
Other Arduinos have PWM outputs which, when filtered through a low-pass filter, give a voltage proportional to the duty cycle of the PWM. Again, change the duty cycle fast enough and you have a waveform (limited by the _carrier frequency_ of the PWM).
Can you do it from LabVIEW? Who knows? I have never used it.
|
stackexchange-arduino
|
{
"answer_score": 1,
"question_score": 0,
"tags": "arduino uno, analogwrite"
}
|
Empty dynamic array in c++
Let's say I have an object called `Square` with the constructor `Square(int rx, int ry)`, i want to create a dynamic array of Squares, with different arguments in the constructor:
Square *squares = new Square[10];
for (int i = 0; i < 10; i++)
{
squares[i] = new Square(i, i);
}
However this fails, saying _no appropriate default constructor available_. So how do i create an empty or NULL array and then do constructions **later**?
**EDIT:** This has to be an array, due to other things in code, to hard to explain here.
|
You could make an array of _pointers_ to `Square`:
Square **squares = new Square*[10];
for (int i = 0; i < 10; i++)
{
squares[i] = new Square(i, i);
}
As others have pointed out, it is a good idea to consider using `std::vector` instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "c++, dynamic arrays"
}
|
Segmentation fault (core dumped) - C Error
Thank for your answers everyone, it works now
|
Correctly pointed out by downhillFromHere, `teamtemp` should be of type `char *` and not `char`.
Do the following changes:
1) Change `char teamtemp` to `char *teamtemp`. Instead of storing a single character this will store string.
2) Change `char teamtemp=teams[j];` to `strcpy(teamtemp,teams[j]);`. To copy strings
OR you can also do following changes:
1) Change `char *teams[5]={"A","B","C","D","E"};` to `char teams[5]={'A','B','C','D','E'};` Store values as char instead as array of strings.
2) Change `printf("%s\t%d\t%d\t%d\t%.2f\n",teams[j],player[j],goals[j],gamesPlayed[j],ppg[j]);`
to
`printf("%c\t%d\t%d\t%d\t%.2f \n",teams[j],player[j],goals[j],gamesPlayed[j],ppg[j]);`. Print the `char` values, as `teams` is now declared as array of char.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "windows ce"
}
|
Jquery disable form button until click on a non form element
i have a simple list, that is not included in a form, and a form.
What i want to do: i want that the submit button of the form to be enabled only when someone clicks on one element of that list. Is this possible using jquery?
thank you!
|
You can do like this HTML
<ul id="list">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<form>
<input id="btnSubmit" type="submit" disabled="disabled" value="Submit"/>
</form>
Javascript
$(document).ready(function() {
$('#list > li').click(function() {
$('#btnSubmit').removeAttr('disabled');
});
});
Demo: <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, jquery, forms, click, submit"
}
|
Create a global variable to store time from NSDate?
I want to store the time during the run of the program to a global variable when it satisfy a if condition, So when new time is received it should be stored in the global variable,
Here in my if condition i want to check?
NSDate* CurrentTime = [NSDate date];
// less than 30 seconds
if ([CurrentTime timeIntervalSinceDate:TimeStoredinglobalvariable] < 30.0f)
{
//do something
//Reset the new time to
TimeStoredinglobalvariable = CurrentTime;
}
Is this way of implementing a if condition possible to implement my task? And how to get this global thing done with NSdate ?
Thank you!
|
You could create an class method with a static variable:
.h
@interface YourClass : NSObject
@property (nonatomic, strong, readonly) NSDate *storedTime;
@end
.m
#import "YourClass.h"
@interface YourClass()
@property (nonatomic, strong, readwrite) NSDate *storedTime;
@end
@implementation YourClass
static NSDate *_storedTime;
@synthesize storedTime;
- (NSDate *)storedTime {
if (!_storedTime) {
_storedTime = [NSDate date];
}
if ([_storedTime timeIntervalSinceNow] < -30.0f) {
//Do you stuff...
_storedTime = [NSDate date];
}
return _storedTime;
}
@end
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "ios, xcode, global variables, nstimer, nstimeinterval"
}
|
Add Android Specific external library
A short backstory, I am trying to use the flutter platform channels to run some platform specific code and return the results back to flutter.
I am trying to add some dependencies in my android build.gradle file however after I do so, there is no option to "rebuild" or "download" these dependencies like it used to show when developing pure java android applications.
Am I missing something? How to properly import external libraries to be used in the native code that I write when I call a platform channel method?
for example: `compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1' `
I can't find a build option in gradle.
|
Using command line or Terminal (on Mac), cd to your **android** folder and run this command: **./gradlew build** or **./gradlew assembleDebug**
Or you can also import/open the android project only (open android folder directly, instead of open flutter project folder)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android, gradle, dart, flutter"
}
|
convert integer to date and time in R
I have an int column with values like `30, 2230, 130` is there any function that I could convert them in time format like `30` to `00:30` and `130` to `01:30`? I used:
format(strftime(col,format="%H:%M"), format="%H:%M")
but it returned an error:
as.POSIXlt(x, tz=tz)::'origin' must be supplied
I also need to add **_yy-mm-dd_** in before the time after the time conversion so the ultimate output could like `"1980-05-28 00:30"`, `" 1980-05-28 22:30"`, and `" 1980-05-28 01:30"`.
Can anyone help?
|
You can try using `as.POSIXct` and `sprintf` along with `paste` to create date/time:
as.POSIXct(paste("1980-05-28", sprintf("%04d",c(130, 2030, 1120, 30,0120)),sep = " "),
format = "%Y-%m-%d %H%M")
# [1] "1980-05-28 01:30:00 BST" "1980-05-28 20:30:00 BST" "1980-05-28 11:20:00 BST"
# [4] "1980-05-28 00:30:00 BST" "1980-05-28 01:20:00 BST"
**Note:** The solution is something similar to what suggested by @r2evans. I tried to simplify it a bit.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "r, date, time, type conversion"
}
|
Python seed with a list?
I have seen that sometimes list is given to `numpy.random.seed(list)`, please explain what happens when list is passed? What is the advantage of list vs. just an integer?
|
I'd assume it's because historically NumPy used a Mersenne Twister RNG. Allowing the seed to be an array/list allowed the state (i.e. the 624 32-bit ints) to be explicitly specified while seeding.
The newer RNG interface abstracts out the underlying RNG bit-generator (while also being significantly faster in the cases I've tested) and hence seeding has been abstracted as well.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python 3.x, list, random, seed"
}
|
Put two different variable integers into another variable
I have to numbers saved into variables.
int a = 1; int b = 1;
and then I want to put these numbers together in another variable like:
int c=ab; // so the value here would be then 11.
|
int c = (int) Math.pow(10, Math.floor(Math.log10(b))+1)*a + b.
Complete program
class Main {
public static void main(String[] args) {
int a = 1234;
int b = 567890;
int c = (int) Math.pow(10, Math.floor(Math.log10(b))+1)*a + b;
System.out.println(c);
}
}
Test
1234567890
You can try it online.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -2,
"tags": "java"
}
|
How to get heroku server timezone using command in Ubuntu
I am using heroku server. I want to know the heroku server timezone. I there any command available for that in Ubuntu?
|
Try this in command line:
date +%Z
Or in node.js you can get the timezone offset:
console.log((new Date()).getTimezoneOffset());
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "node.js"
}
|
Why is the month changed to 50 after I added 10 minutes?
I have this date object:
SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd HH:mm");
Date d1 = df.parse(interviewList.get(37).getTime());
value of d1 is `Fri Jan 07 17:40:00 PKT 2011`
Now I am trying to add 10 minutes to the date above.
Calendar cal = Calendar.getInstance();
cal.setTime(d1);
cal.add(Calendar.MINUTE, 10);
String newTime = df.format(cal.getTime());
Value of `newTime` changes to `2011-50-07 17:50` but it should be `07-01-2011 17:50`.
It adds minutes correctly but it also changes month, don't know why!
|
The issue for you is that you are using `mm`. You should use `MM`. `MM` is for month and `mm` is for minutes. Try with `yyyy-MM-dd HH:mm`
Other approach:
It can be as simple as this (other option is to use joda-time)
static final long ONE_MINUTE_IN_MILLIS=60000;//millisecs
Calendar date = Calendar.getInstance();
long t= date.getTimeInMillis();
Date afterAddingTenMins=new Date(t + (10 * ONE_MINUTE_IN_MILLIS));
|
stackexchange-stackoverflow
|
{
"answer_score": 203,
"question_score": 120,
"tags": "java, date, calendar, simpledateformat, java.util.date"
}
|
jquery set cursor to first character of textarea
I have custom placeholders in a textarea and I would like every browser to move the cursor to the first character of that placeholder as soon as the user clicks it or focuses in on it.
How can I achieve that? I have no idea so no code posted.
Thanks!
Dennis
EDIT 1
This is the textarea:
<textarea id="posttext"> Post something...</textarea><br/>
And this is the code to remove " Post something...":
//Placeholder in posttext
$('#posttext').keydown(function(){
if($(this).val()==' Post something...') $(this).val('').css('color','black');
}).blur(function(){
if($(this).val()=='') $(this).val(' Post something...').css('color','grey');
});
|
$('#posttext').on('focus', function() {
if($(this).val() == ' Post something...') {
$(this).val('').css('color','black');
}
}).blur(function() {
if($(this).val() == '') {
$(this).val(' Post something...').css('color','grey');
}
});
<script src="
<textarea id="posttext"> Post something...</textarea>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "jquery, focus, textarea, character"
}
|
FreeBSD 10.0-RELEASE: No lagg0 after reboot
I have a server running Freebsd 10.0-RELEASE. I'm trying to create bridge interface with three participant interfaces, ix0, ix1 and lagg0. Lagg0 is virtual interface made from ix2 and ix3. My problem is that lagg0 is not created on boot. I can create it after the boot and it automatically takes over ix2 and ix3. After that I can manually add it to the bridge0.
I have this in my /etc/rc.conf:
if_lagg_load="YES"
ifconfig_ix0="mtu 9000 UP"
ifconfig_ix1="mtu 9000 UP"
ifconfig_ix2="mtu 9000 UP"
ifconfig_ix3="mtu 9000 UP"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto roundrobin laggport ix2 laggport ix3 up"
cloned_interfaces="bridge0"
ifconfig_bridge0="addm ix0 addm ix1 addm lagg0 up"
What am I doing wrong?
|
There are two things that are wrong with this configuration. First of all, you have defined the cloned_interfaces variable twice. The second one will be overriding the first. You should use something like
cloned_interfaces="lagg0 bridge0"
The other thing is a minor note like arved said. if_lagg_load="YES" belongs to /boot/loader.conf. However, personally, I prefer using the kld_list variable in /etc/rc.conf for performance reasons:
kld_list="if_lagg"
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 5,
"tags": "networking, freebsd, bonding"
}
|
Is there a way to specify a leftover queue in RabbitMQ?
Is it possible to define a binding between an exchange (direct or topic) and a queue so that the queue receives only those messages that are sent to the routing keys that have no explicit binding with any other queue?
E.g. there is an exchange X and queues A and B. The queue A is bound with 'black' and 'white' binding keys. The queue B is defined as a leftover queue (if it is possible at all, which is the point of my question). So when we send a message to the exchange X with either 'black' or 'white' routing key, then it is delivered to the queue A. If we send a message to the exchange X with any other routing key then it is delivered to the queue B only.
|
Sure, just use RabbitMQ's Alternate Exchange feature. That's exactly what it has been designed to do.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "rabbitmq"
}
|
Can some parts of svg element be rendered outside SVG element itself by a browser?
I have a d3.js chart which is SVG consisting of many elements. Tooltips being shown on user mouseover. Most right and left tooltip are partly hidden with plot edges (they are cutted by svg element edges, similar how overflow:hidden will cut absolute positioned elements when they go outside parent with overflow:hidden).
So can i show them anyway ouside of SVG broders?
|
Set overflow:visible on the outer `<svg>` element. SVG uses the same CSS property as html here.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "html, css, svg"
}
|
Detecting drag position on an element
I am building a wysiwyg editor to build html emails. I want to be able to add row layouts to the editor by drag and drop.
If a row is dragged and dropped above the halfway point of the drop target, I want to prepend a row before the drop target; and if it is dropped below the halfway point, I want to append a row after the drop target.
Is there any way to do this?
|
You can use `getBoundingClientRect()` to get coordinates of the element while mouse button pressed and moving simply like this
element.onClick = function() {
element.onmousemove = function() {
var x1 = element.getBoundingClientRect().left,
x2 = x1 + element.getBoundingClientRect().width,
y1 = element.getBoundingClientRect().top,
y2 = element.getBoundingClientRect().height;
}
}
and now you can do whatever you would like with these coordinates.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "javascript, jquery, html, html email, wysiwyg"
}
|
Jquery. If a url in certain div contains something, then something
Trying to set up an alert window pop up for certain links via jquery. My code
$(document).ready(function(){
var url = a.link_imagelibrary
if ("url:contains ('#hidden')") {
$("url").click(function(){
alert("yes!");
});
}
});
What where is my mistake?
|
It seems like what you are trying to do is to find links with a class of "link_imagelibrary" and if their `href` property contains the string "#hidden", bind a click handler to them.
If that is correct, then the following code will do that:
$('a.link_imagelibrary[href*=#hidden]').click(function () {
alert('yes!');
})
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "jquery"
}
|
Android - saving an image to card throws an error
I'm trying to save an image to card and I get the error "< file path > (IS A DIRECTORY)" altough the file's absolute path is correct and the file is an image and not a directory. What am I doing wrong here? I need to mention that I create all the necessary directories before saving the image to disk and I have all the permissions.
file.getAbsolutePath() //returns something like this:
/mnt/sdcard/app_name/folder/image.jpg
.. I construct the picture file like this: `File img = new File(dir, image.jpg);`
public static void saveImg(File pic, Bitmap picture) {
try {
FileOutputStream out = new FileOutputStream(pic);
picture.compress(Bitmap.CompressFormat.JPEG, 100, out);
} catch (Exception e) {
e.printStackTrace();
}
}
|
First step is to check your sd card to see if you really have a directory with that name (in case you are calling mkdirs() on the image file before creating the stream by any chance).
Then, you can try using this code to create your stream:
String fileName = "image.jpg";
File path = Environment.getExternalStorageDirectory();
File file = new File(path, fileName);
path.mkdirs();
OutputStream os = new FileOutputStream(file);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "android, file"
}
|
separable diff eq question issue
So a group and I from class are completely stuck on a step from this problem and I hoped to come here for maybe some direction.
> So the question starts as
>
> $\sqrt{1-y^2} dx - \sqrt{1-x^2} dy = 0 \ ; \quad y(0)= \sqrt{3}/2, $
we separated and integrated and eventually got the equation
$y=\sin(\sin^{-1}(x)+C)$
I believe we may have taken a wrong turn as the final answer does not contain any trig at all. should we have plugged in the value earlier to find $C$?
|
You're on the right track. While it doesn't seem so, the solution is actually algebraic since $\sin\arcsin x=x$ for values in the appropriate range. Here, the constant $C$ complicates things a little, but it's still doable.
So, set $\sin(\arcsin x +C)=\sin y,$ so that $y=\arcsin x + C.$ The goal is to express $\sin y$ as an algebraic expression in $x.$ Now since $y=\arcsin x + C,$ it follows that $x=\sin(y-C).$ Expanding gives $$x=\sin y\cos C-\cos y\sin C=a\cos y+b\sin y,$$ where I have written $a$ and $b$ for the constant factors. Thus, we have that $a\cos y=x-b\sin y.$ Recall that we're trying to solve for $\sin y.$ If you now set $\cos y=\sqrt{1-\sin^2y}$ in the previous equation, you have a quadratic in $\sin y,$ which you may solve to find what is wanted.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ordinary differential equations"
}
|
splitting a huge text file based on line content
Help me guys, I'm really lost here. I have a big text file, full of links, and I'm trying to separate them based on which website the link belongs. I was trying to do it with the csplit command, but I'm not really sure how I would do it, as it would depend on the text content.
Text example:
www.unix.com/man-page/opensolaris/1/csplit/&hl=en
www.unix.com/shell-programming-and-scripting/126539-csplit-help.html/RK=0/RS=iGOr1SINnK126qZciYPZtBHpEmg-
www.w3cschool.cc/linux/linux-comm-csplit.html
www.linuxdevcenter.com/cmd/cmd.csp?path=c/csplit+"csplit"&hl=en&ct=clnk
So in this example the first two links would be in one file, and the 2 left would be in one file each. How would this work? I really don't have any idea if this is even possible. (novice programmer)
|
try :
awk 'BEGIN{FS="/"} {print > $1}' [your file name]
output:
cat www.unix.com
www.unix.com/man-page/opensolaris/1/csplit/&hl=en
www.unix.com/shell-programming-and-scripting/126539-csplit-help.html/RK=0/RS=iGOr1SINnK126qZciYPZtBHpEmg-
cat www.linuxdevcenter.com
www.linuxdevcenter.com/cmd/cmd.csp?path=c/csplit+"csplit"&hl=en&ct=clnk
cat www.w3cschool.cc
www.w3cschool.cc/linux/linux-comm-csplit.html
`{print > $1}` will redirect output to separate files based on `$1`, in this case, the domain name.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "bash, awk, sed, split, csplit"
}
|
How to insert identity value in Oracle using Entity Framework using a sequence
In an Oracle database, that has an ID column defined as a number:
){
var user= new User(){ first_name = 'Abe', last_name = 'Lincoln'};
//Do something here with the sequence and set the ID?
db.User.Add(user);
db.SaveChanges();
}
I am using the latest Oracle.ManagedDataAccess and Oracle.ManagedDataAccess.EntityFramework + EF6x.
|
This is not an EF issue, as there is no auto increment in oracle. You will have to either get the sequence value manually, or create a trigger to set it for you.
# Update
In order to get the sequence value you have two options - either create a stored procedure, that returns the value - or create a .Net function ( doesn't really have to be in a function, it's just simpler) that calls raw SQL like this:
`Database.SqlQuery<int>("SELECT SEQ_SOMESEQ.NEXTVAL FROM dual");`
I personally had many issues with oracle functions and EF, so I would go with the raw sql.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "c#, oracle, entity framework, oracle manageddataaccess"
}
|
Are there any Symmetric Groups that are cyclic?
Are there any Symmetric Groups that are cyclic?
Because I have been doing some problems and I tend to notice that the problems I do that involve the symmetric group are not cyclic meaning they do not have a generator which generates the set.
So are there any cases in which any of the symmetric group is cyclic? If not, then why are none of them cyclic?
|
There are a number of ways one could answer this, so here's my shot:
First, it is true that $S_1$ and $S_2$ are cyclic—these have only $1$ and $2$ elements respectively, so nothing surprising here. So let's consider the symmetric group on three or more elements.
> **Claim** : $S_n$ is not cyclic for $n \geq 3$.
To begin, it is a good exercise to show that subgroups of cyclic groups are necessarily cyclic. Given this, prove that $S_3$ is not cyclic and note that $S_n \subset S_m$ for all $n \leq m$.
As others are saying, another (probably easier) way to prove the claim is to show that cyclic groups are abelian$^\dagger$ and to show that subgroups of abelian groups are abelian. Then it suffices to show that $S_3$ is not abelian.
* * *
$^\dagger$Not only is the symmetric group not abelian—worse, it has trivial center). See here.
|
stackexchange-math
|
{
"answer_score": 10,
"question_score": 6,
"tags": "abstract algebra, group theory, permutations, symmetric groups, cyclic groups"
}
|
How to compare a value and then return that value instead of 0 or 1?
I have this node setup here:
 & !(A & B)`), and I reached `(A || B) & (!A || !B)` and `!((!A & !B) || (A & B))` using 2 different paths, and I know that the results of the 2 paths are the same because of the de morgan's law, yet I just can't figure out how to get to `!A & B || A & !B`.
EDIT: Just thought I'd explain my use of symbols. I'm not familiar with MathJax, and while I could use the proper symbols of ¬, ∧, ∨, it's just easier for me to type !, &, ||.
|
I will use notations you used for your comfort..These are used in programming, not on logics and mathematics (as far as I know).
We will start from `A XOR B = (A || B) && (!A || !B)` which you have already found. The trick is to add terms such as `(A || !A)` where it does not change value of logic.
`(A || B) && (!A || !B) = ((A || B) && (!B || B)) && ((!A || !B) && (!A || A))`
For the first term, `((A || B) && (!B || B)) = (A && !B) || B`.
For the second term, `((!A || !B) && (!A || A)) = !A || (!B && A)`.
Combining these two gives `((A && !B) || B) && ((A && !B) || !A)`. By simple boolean algebra you may see this is equal to `(A && !B) || (B && !A)`, which you wanted.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "boolean algebra"
}
|
How to make json_encode fail
Trying to test a method that is doing a `json_encode` and throwing an exception if the encode fails. However, whatever I throw at `json_encode` it successfully encodes. Any idea what would be something simple to have it fail?
|
I think the smallest values to fail `json_encode` would be:
json_encode(NAN);
json_encode(INF);
Other candidate:
$a = array(&$a);
json_encode($a);
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 9,
"tags": "php, json, testing"
}
|
i am looking for svn admin like "VisualSVN Server" for remote server?
i am looking for svn admin a desktop application like "VisualSVN Server" only for remote server the svn server will run on Linux but i need the admin tool to run locally on my window matching i wont to be able to create user group and change security setting create new repositories and not by writing commands
is there is a tool like this out there? and if so which one do you recommend thanks
if it was hard to understand i just wants to be able to admin a subversion server remotely thanks again
|
there is no desktop application like i am looking for at list not for free
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 0,
"tags": "svn, admin, visualsvn server"
}
|
Bijection from finite (closed) segment of real line to whole real line
Is there a bijection from a finite (closed) segment of the real line to $\mathbb{R}$? For example, is there a bijection from $[0,1]$ to $\Bbb{R}$?
If so, is there a straightforward example? If not, why?
|
There are many bijections from an _**open**_ interval $(a, b)\to R$, e.g.
$g(x) = \cot(\pi x)$ is a bijection $g: (0, 1)\to \mathbb{R} $.
Now, we need to find a bijection from the _**closed**_ interval $[a, b]\to R$, by showing that there exists a bijection from the closed interval $[a, b]$ to the open interval $(a, b)$.
Taking the interval: $[0,1]$. Define $f(x)$ as following: $$f(x) = \left\\{ \begin{array}{1 1} \frac{1}{2} & \mbox{if } x = 0\\\ \frac{1}{2^{n+2}} & \mbox{if } x = \frac{1}{2^n}\\\ x & \mbox{otherwise} \end{array} \right.$$
Then $f: [0, 1] \to (0, 1)$ is a bijection.
Now, compose: $g(f(x)): [1, 0] \to \mathbb{R}$, and you have your bijection.
|
stackexchange-math
|
{
"answer_score": 21,
"question_score": 7,
"tags": "elementary set theory, functions"
}
|
DC geared Motor 20 NM 25 RPM small dimensions.
My application requires a DC geared motor with torque of 10 NM - 20 NM and low speed (25 RPM at most) and a small dimensions (120 mm length at most). I failed to find my specs at eBay, and Alibaba targets only mass production. Can you recommend me certain models of Gear, Stepper or even Servo motors that met the above specs from any online store?
|
You can find DC gearmotors on Amazon with roughly those specs.
This one, set with 30rpm and 24v, is fairly close:
This one has higher RPM, but more power, and you can add an extra 2:1 gear reduction:
That's the smallest you'll find in fairly cheap motors. Otherwise, you'd need to custom order one, or talk with a manufacturer/supplier, which will probably be more expensive.
|
stackexchange-robotics
|
{
"answer_score": 0,
"question_score": -1,
"tags": "motor, servomotor, brushless motor, stepper motor, gearing"
}
|
Adding a script tag using virtual path not working
**This works:**
<script src="Scripts/angular.js"></script>
**But not this one:**
<script src="~/Scripts/angular.js"></script>
Can anyone explain why the second one not's working?
|
If you're referring to the "Scripts" directory in MVC app from the layout you can just reference as `<script src="/Scripts/angular.js"></script>`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "angularjs"
}
|
Turn off DMARC report for pass
I would like to receive reports only for DMARC quarantined mail and failures, but I still receive mails for every successful e-mail that has been sent from my server.
Configuration in dns looks like this
v=DMARC1; p=quarantine; rua=mailto:XXXXXXX
Is there any way to stop receiving reports without quarantine ?
|
**No** , such configuration is only available for the (now mostly defunct) _forensic_ reports, for the _agggregate_ reports (`rua`) you can only take what you can get.
Instead of looking for a way for people to send you _less data_ , **consider using one of the commercially available DMARC processing software or services** to have your data _parsed & visualized_ to better showcase the interesting data.
XML was never that good for human consumptions anyway. And after some short implementation phase where you look at aggregated tables, you should _prefer_ to only receive a notification when something important was reported, likely not even on _most_ reports referring to _quarantine_ decisions.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 1,
"tags": "dmarc"
}
|
What does xp_qv do in SQL Server?
Last night one of our SQL servers developed some major problems and after a colleague stopped, started, and all the usual things it started checking and rebuilding databases and is now running an extended stored procedure called "xp_qv".
The internet seems to be very short of information on what this procedure does or anythign like that so I was hoping somebody here might be able to help.
I should add that I assume it is meant to be running so the question isn't "Can I stop it" or anything like that, its just curiosity in what it is doing in the hope that it will help determine how long before things are usable again...
|
This is the only information I could find..
> xp_qv, hosted in xpsqlbot.dll is a wrapper around functionality in sqlboot.dll, which returns information about the SKU type, licensing etc It is not documented that is why you can not find a reference.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 7,
"tags": "sql server, sql server 2000"
}
|
set turtles in specific location netlogo
Right now i have the following code for initial planning of "plants" and i want them to be in a grid formation and not randomly (something like a real field, like in the picture attached):
. I also slightly changed your variable names to add the ? at the end, which is a NetLogo convention for true/false variables.
to setup-plants
set-default-shape plants "plant"
ask n-of initial-number-plants patches
[ sprout-plants 1
[ set color green
set is_susceptible? true
set is_infectious? false
]
]
end
Note that this code will break if you have more plants than patches. Your diagram has exactly one plant per patch so I wasn't sure what you wanted.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "netlogo"
}
|
C# / apsx.net - Dynamically created button doesn't work
Here is my problem: I had dynamically created some buttons in my page (in the Page_PreInit method), all linked to the same event handler. But those buttons don't fire the event when I click on them... Can someone help me?
Here is some of my code:
Button creation (on a foreach loop on the Page_PreInit method):
Button b = new Button();
field.Controls.Add(b);
b.Text = "Download";
b.ID = tmp_out[type] as String;
b.Click += new EventHandler(Download_Click);
The OnClick method:
private void Download_Click(object sender, EventArgs e)
{
//doing some stuff
}
|
Ok I solved my problem.
The ids of the buttons was containing some '\'. I just removed those '\' and it works just fine.
Thanks all for your reply!
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, .net, button, buttonclick, preinit"
}
|
How Get The Clicked Line Number Android TextView
I have a string of text items I want displayed in a textview. If line 3 is clicked I'd like to know that. Is that information passed in an eventarg?
|
yourTextView.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event){
if(event.getAction() == MotionEvent.ACTION_UP){
int lineHeight = yourTextView.getLineHeight();
int clickedLine = (int)(event.getY() / lineHeight);
}
return true;
}
});
Do some thing like this. Did not evaluated the code but hope this will help. You can also try adding ClickableSpan for each line in the TextView.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "android, textview, xamarin"
}
|
Legal Form Between Two People Starting Company
I'm starting a company with someone, however, we are working on creating a finalized beginning product first. What form(s) should I go about having us sign to essentially make it so neither of us can screw each other?
So I can't ditch the project with the product and neither can he?
|
What you need is called a partnership deed. There is nothing special about it; just write down the rights and obligations of both partners and put "signed as a deed" above your signatures.
|
stackexchange-law
|
{
"answer_score": 2,
"question_score": 2,
"tags": "contract law, contract"
}
|
How to iterate over basic blocks?
I want to add an instruction to each of my basic blocks, I can use LLVMAppendBasicBlock for that once a bloc is specified. But how to iterate over all basic blocks in a function ? Are there iterators for that in the LLVM API ?
|
you can simply use iterator over function like :
for (Function::iterator b = func->begin(), be = func->end(); b != be; ++b) {
BasicBlock* BB = b;
....
}
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 7,
"tags": "llvm"
}
|
New features in Kohana 3? Is it a wise decision to use ver 3 instead of 2?
I have used ver 2 before but i'm thinking of using ver 3 for my new project. Is it advisable to use ver 3 at this point event when it's not yet stable?
|
It depends on your situation.
**New projects** will usually go this way.
Kohana 3 -> 3.0.1 -> 3.0.2 -> 3.0.3 etc ...
**Old projects** using Kohana 2.3.4 will _probably_ use this path instead:
Kohana 2.3.4 -> 2.4 (API Change) -> 2.4.1 etc ...
I'd personally choose Kohana 3 for a new project as it has new features such as reverse routing, HMVC and some other stuff that's vanished from my head at this time.
It's production ready and I've already used it on a few projects.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "kohana, kohana 3"
}
|
How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe?
How can I execute a large number of scripts with IronPython and avoid the startup cost of ipy.exe? By large I mean over 100. Each script is a simple acceptance test for a service application and will run very quickly.
The simplest approach I can think of is a cmd file that loops through the *.py files calling:
ipy <filename1>.py
ipy <filename2>.py
...
However each script would then incur the overhead of starting ipy.exe. Some research on < turned up the exec function. A master python script that loops through each of the test script files and calls exec with the file contents looks like a viable alternative - is this a reasonable approach?
Edit: this was far simpler than I realized - see 2 lines below. Python is awesome!
for filename in list_of_files:
exec(open(filename).read())
|
Try execfile.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ironpython"
}
|
QTimer stops and starts by itself
Here is how I use QTimer:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->setInterval(1000);
timer->start();
Program monitors update() function and prints the current time in it. Normally it works as expected, it prints time at every second, but when program starts to process other jobs, there would be some breaks like 5 to 8 secs.
Qt Documentation mentions about accuracy issues like 1 ms, obviously I have another problem. Any ideas ?
|
QTimer (and all event-base message deliveries) is not interrupt driven. That means you are not guaranteed you will receive the event right when it's sent. The accuracy describes how the event is triggered, not how it's delivered.
If you are not doing threaded process on long job, call `QCoreApplication::processEvents()` periodically during the long process to ensure your slot gets called.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c++, events, qt, qt4, timer"
}
|
Opening a cash drawer using C/C++ or Java
I need to open a cash drawer using C/C++ or Java. It is a POS-X cash box with a USB connection. I've never done anything like this before. I noticed the cash box was linked to the "COM3" port. I know Java does not have a USB API so I turned to C/C++.
|
Forum post about it here.
In a nutshell, install the driver, change the COM3 baud rate to 9600, and send a "1" to the COM port.
Check out `javax.comm` for a method of communicating with a com port on java.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "java, c++, c, com, usb"
}
|
Prefix filename with sequential number. Be prompted (powershell)
I am trying the **insert a number** as a prefix "`n__`" for each filename in the `CWD` (not recursively). `n` is a number with increments of +1, user needs to enter the first value. To number, the files **must** be pre-sorted in lowest-value-first order based on the filename.
$i = Read-Host 'Enter first file number'
$confirmation = Read-Host "Re-enter first file number"
if ($confirmation -eq '=') {
# proceed
}
Get-ChildItem | Sort-Object | Rename-Item -NewName { "$i+1" + "__" + $_.Name }
What I am missing at the i+ and in order to ensure that the files are sorted for numbering?
Intended result:
101__121.ext
102__211.ext
103__375.ext
|
# putting [int] before the variable will insure that your input is an integer and not a string
[int] $i = Read-Host 'Enter first file number'
[int] $confirmation = Read-Host "Re-enter first file number"
# Your if statement seemed to not make sense. This is my take
if ($confirmation -eq $i)
{
Get-ChildItem | Sort-Object | Foreach-Object -Process {
$NewName = '{0}__{1}' -f $i,$_.Name # String formatting e.x. 1__FileName.txt
$_ | Rename-Item -NewName $NewName # rename item
$i ++ # increment number before next iteration
}
}
else
{
Write-Warning -Message "Your input did not match"
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows, powershell, powershell 2.0, powershell 3.0"
}
|
GUID: varchar(36) versus uniqueidentifier
I'm working with a legacy database that stores GUID values as a varchar(36) data type:
CREATE TABLE T_Rows (
RowID VARCHAR(36) NOT NULL PRIMARY KEY,
RowValue INT NOT NULL
)
INSERT T_Rows (RowID, RowValue) VALUES (NEWID(), 1)
I would assume that storing a GUID as a uniqueidentifier would be preferable since it's only 16 bytes in size as opposed to 36.
Are there any advantages to storing a GUID as a varchar?
|
Perhaps only the fact that you can 'read' them from a SELECT statement (although I don't think that's particularly useful as you can use a function in a select to make Uniqueidentifiers displayable).
If the table is large, saving 20 bytes per row is considerable.
|
stackexchange-stackoverflow
|
{
"answer_score": 17,
"question_score": 17,
"tags": "sql server, performance, sql server 2008, database design, guid"
}
|
How to make a boolean index in numpy for multiple integer types without a loop
I would like to create a boolean index of an array that has true values whenever any integers in a given list appear in the array. Right now I do this by looping through the list of test integers and constructing a seperate boolean mask for each which I bitwise `or` together like this:
boolean_mask = original_array == list_of_codes[0]
for code in list_of_codes[1::]:
boolean_mask = boolean_mask | (original_array == code)
Is there any shorthand numpy notation to do the equivalent without the loop?
|
You have `np.in1d`:
boolean_mask = np.in1d(original_array, list_of_codes)
should do it. Note that `np.in1d` flattens both arrays, so if your `original_array` is multidimensional you will have to reshape it back, e.g.:
boolean_mask = boolean_mask.reshape(original_array.shape)
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "numpy"
}
|
Analytics broken on Marshmallow?
I'm using analytics and while compiling I get this proguard warnings:
Warning: com.google.android.gms.internal.zzw$zza: can't find superclass or interface org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.NameValuePair
Warning: com.google.android.gms.analytics.internal.zzam: can't find referenced class org.apache.http.client.utils.URLEncodedUtils
and much more.
I'm using these dependencies:
compile 'com.google.android.gms:play-services-base:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
Is this a bug? Is there any workaround for that?
|
Adding to proguard
-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**
seems to fix
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 10,
"tags": "android, google analytics, google play services, android 6.0 marshmallow"
}
|
Python: Print list sequence
Is it possible to write a clean code in python to print something like:
Introduce the number of lists you want to have: 3
Introduce how many numbers you want it to have: 3
Number: 1
Number: 2
Number: 3
[1,2,3]
Introduce how many numbers you want it to have: 4
Number: 1
Number: 2
Number: 5
Number: 9
[1,2,5,9]
Introduce how many numbers you want it to have: 5
Number: 1
Number: 7
Number: 2
Number: 8
Number: 3
[1,7,2,8,3]
This is my try at it, but it only works for a list, as I don't know how to add multiple lists:
v1=[]
n=input ("Introduce how many numbers you want it to have: ")
def introdTast():
print("Introduce the numbers: ")
for i in range(0,n):
v1.append(input())
introdTast()
print "v1 =",v1
print "\n"
|
Your answer is here: **The Python Tutorial**
However, here you go:
lists = int(raw_input('Introduce the number of lists you want to have: '))
for i in xrange(lists):
numbers = int(raw_input('Introduce how many numbers you want it to have: '))
l = []
for j in xrange(numbers):
l.append(int(input('Number: ')))
print l
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -6,
"tags": "python, list"
}
|
stripe is not defined but I have clearly defined it in my angular project
in my stripecreditcardcomponent.html
<script src="
<script type="text/javascript">
const stripe = Stripe('removed secret');
const elements = stripe.elements();
</script>
my stripecreditcardcomponent.ts
async createStripeToken() {
const {token, error} = await stripe.createToken(this.card);
if (token) {
this.onSuccess(token);
} else {
this.onError(error);
}
}
but when my `createstripeToken()` command is called I get the following error:
`ERROR Error: Uncaught (in promise): ReferenceError: stripe is not defined ReferenceError: stripe is not defined`
|
What I usually do is install npm package, import them in component and use them. For example to use moment I install moment.js npm package, import it in component say `MyComponent` like `declare var moment: any;` then I can use moment in my `MyComponent` like `let date = moment().now()` etc. Refer this -><
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "angular, stripe payments"
}
|
Change CSS properties of non-existing elements
I want to change the dimensions of a set of elements that are not created yet. They will be created by a JavaScript script that I don't have access to. JQuery's _css()_ function would apply the changes only on existing items, while I want the code to work like if I had set CSS properties in a CSS file.
Can anyone help me do it?
|
One option would be to dynamically create a style element:
$("<style type='text/css'> .redbold{ color:#f00; font-weight:bold;} </style>").appendTo("head")
$("<div/>").addClass("redbold").appendTo("body");
Taken from here: Create a CSS rule / class with jQuery at runtime.
Here's a possible IE alternative (see Creating a CSS class in jQuery):
document.styleSheets[0].addRule('body', 'background: green', -1);
For reference, see the documentation for addRule.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 7,
"tags": "javascript, jquery, html, css"
}
|
Possible to always hide a subset of a table?
I have a shop set up with lots of tables that are joined together in various ways, as per usual.
In my products table, I have a field called 'status'. If the status = 4, then the product is archived.
I want to ensure that no queries ever return anything with a status of 4. Right now I'm about to add a `AND status <> 4` to every SQL query I can find.
Is there a better way to do this, or is that the only way?
|
You can create a view that doesn't show status = 4 and use that view in your query's instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "mysql, sql"
}
|
Embed advertisements in a windows application
I'm developing a free application and would like to make some money by embedding advertisements in it. Initially I had planned to embed ads in a webbrowser control (AdSense, Google Ads) but found that this isn't allowed. Does anybody have experience with this?
The program is coded in C# and will run on PCs not windows mobile
|
(Although I hate these,) one option for you might be to bundle toolbars? For example, InstallShield 2009 allows you to bundle the Yahoo! toolbar with your app's installer. You join the Acresso Value-Added Services program and get paid everytime the toolbar is used.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "c#, windows, embed, ads"
}
|
Google analytics not showing referrer from internal links on event label set by Google Tag Manager
I've set up an trigger in GTM that tracks a 404 event. This shows the 404 page as the event action and the page the 404 was found on as the page label.
This works perfectly excluding the fact that any 404's found within my own website don't show the referrer in the label.
Presumably this is an issue with analytics rather than tag manager but why do my own pages not show as a referrer and how can I get it to do so?
 = {}
val option: Option[() => Unit] = Some(foobar)
Whereas this is legal:
def foobar() = {}
val intermediate: () => Unit = foobar
val option: Option[() => Unit] = Some(intermediate)
In the first example, the compiler complains that the right side of the assignment is of type `Option[Unit]` rather than `Option[() => Unit]`.
I suspect this has something do with `foobar` being evaluated rather than being passed as a variable to `Some()`, but I'm unsure.
|
It's because parentheses are optional when evaluating an empty-parens method. By convention, they're left off for pure methods, but that's just convention. So you're right, it's actually evaluating foobar instead of eta-expanding it to a function. You can fix your first example by explicitly invoking eta expansion with the underscore operator:
val option: Option[() => Unit] = Some(foobar _)
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 4,
"tags": "scala, functional programming, higher order functions"
}
|
Remote Desktop Connection for Mac not being able to connect?
I have the latest version of Remote Desktop Connection client form Mac (2.1.1), the one that is also included in Office 2011 but I am not able to connect to the Windows machine.
I checked the logs on the Windows machine and found nothing.
It keeps asking me for user/password/domain... and I am entering them properly.
FYI, the computer is on domain.
|
Solved the problem by leaving the domain, joining it back and rebooting the machine (Windows).
|
stackexchange-apple
|
{
"answer_score": 0,
"question_score": 0,
"tags": "remote desktop"
}
|
Como esticar um elemento até o final da tela?
Como esticar um elemento até o final da página levando em consideração a posição que ele se encontra?
ex:
<div class="caixa1">CAIXA 1</div>
<div class="caixa2">CAIXA 2</div>
.caixa1{background-color: red;}
.caixa2{background-color: blue;}
Como fazer para que a caixa2 se estique até o final da tela?
Note que não estou procurando um exemplo de rodapé!
Preferencialmente sem uso de javascript
|
Viva,
Podes ver o exemplo aqui: <
Apenas tens de usar:
height: 100%;
position: absolute;
Abraço e boa sorte ;)
|
stackexchange-pt_stackoverflow
|
{
"answer_score": -1,
"question_score": 0,
"tags": "html, css"
}
|
How to restore SQL Server 2014 backup in SQL Server 2008
Were there any changes in this area with SQL Server 2014? I’ve seen this post Is it possible to restore Sql Server 2008 backup in sql server 2005 and I know that this was not possible as a scenario for 2012 -> 2008 but I wonder if MS made any changes here with the 2014 version.
We are evaluating 2014 version and we have a fairly large database in testing. We’d like to restore a backup of that database to SQL Server 2008 because that physical machine has more space, RAM,…
I’m getting standard error message when I try to restore backup but I was wondering if there is something else in SQL Server 2014 that I might be missing.
|
Not really as far as I know but here are couple things you can try.
Third party tools: Create empty database on 2008 instance and use third party tools such as ApexSQL Diff and Data Diff to synchronize schema and tables.
Just use these (or any other on the market such as Red Gate, Idera, Dev Art, there are many similar) in trial mode to get the job done.
Generate scripts: Go to Tasks -> Generate Scripts, select option to script the data too and execute it on 2008 instance. Works just fine but note that script order is something you must be careful about. By default scripts are not ordered to take dependencies into account.
|
stackexchange-stackoverflow
|
{
"answer_score": 18,
"question_score": 12,
"tags": "sql server, sql server 2008, sql server 2005, sql server 2008 r2, sql server 2014"
}
|
Printing all columns after 5th with awk
I'm using this to filter a logging file and I'm trying to squeeze as much relevant detail as I can onto the console:
awk -F " " '{$1=$2=$4=$5=$6=$7=""; print $0}'
This is my raw input:
149.177.5.87 - [08/Feb/2017:18:14:20 +0000] 18:14:20:408 18:14:20:435 11140 "GET /2/forecast/KBBL/lastSave HTTP/1.1" 200 43 27 27
and this is my awk'd output:
[09/Feb/2017:11:27:01 "GET /2/data/load/KBBL/2017-01-25/daily?startDate=2017-01-01&endDate=2019-12-31&firstWeekday=0 HTTP/1.1" ?startDate=2017-01-01&endDate=2019-12-31&firstWeekday=0 401 - 1 1
It's not so obvious on this web page, but on the console it's clear that awk is adding blank spaces to separate the columns that I have set to `""`.
i.e. there's a bigger gap at the start of the line and between the timestamp and the info.
Can I get rid of it with a better awk command?
|
It's possible to do in awk but this is imo easier
nifle@xanadu ~/tmp
$ L='149.177.5.87 - [08/Feb/2017:18:14:20 +0000] 18:14:20:408 18:14:20:435 11140 "GET /2/forecast/KBBL/lastSave HTTP/1.1" 200 43 27 27'
nifle@xanadu ~/tmp
$ echo $L | cut -d ' ' -f 3,8-
[08/Feb/2017:18:14:20 "GET /2/forecast/KBBL/lastSave HTTP/1.1" 200 43 27 27
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "bash, awk, cut"
}
|
initialize javascript array value from c#
I want to initialize JavaScript array value from c# in asp.net application. I have below code which i iterate through the loop,
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "assignGroupParty" + i, string.Format("javascript:SetProspectGroupPartyID({0},{1});"currentIndex, currentQueue.PartyID), true);
here
> javascript:SetProspectGroupPartyID
is function which sets the array value at the currentIndex position.
O/P:- [undefined, 37316]
it always assign at only one index and the other remains undefined. Can any one help me out on this. Thanks
|
You could use `JavaScriptSerializer` class for this:
int[] numbers = new int[] { 1, 2, 3, 4, 5};
var serializer = new JavaScriptSerializer();
var jsArray = string.Format("var jsArray = {0}", serializer.Serialize(numbers));
and then register it by using e.g. `ClientScriptManager.RegisterStartupScriptBlock` method:
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(
this.GetType(),
"arrayDeclaration",
jsArray,
true
);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c#, javascript, asp.net, scriptmanager, registerclientscriptblock"
}
|
SQLite/WPF - TextColumn binding a new header text
I am trying to change the header name of the column by binding, and it’s just adding me a new column with the correct data but keeps the original column with the original SQLite column name.
XAML code
<DataGridTextColumn Binding={Binding sReportNo}” Header=“Number”></DataGridTextColumn>
CS code
using (SQLiteConnection conn = new SQLiteConnection(location))
{
SQLiteCommand code = new SQLiteCommand(“SELECT * FROM Reports”, conn);
conn.open();
SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
myDataGrid.ItemsSources = dt.DefaultView;
cmd.Dipose();
conn.close();
}
|
the best way to handle this i to simply make the `AutoGeneratedColumn = "false"` in the xaml and define every column manually. Plus with this method you can easily make a few improvement on the visual aspect and if you have Date for exemple, display in the format you want to. However, this may involve that you create a class to load your data and define the ItemsSource to the list of the object created. If you need more precision ask and i'll make it more clear for you. Hope it will help you.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, wpf, sqlite, datagrid"
}
|
Using ID as a variable
I'm trying to find the text of the span with the class name "link" but i have problems.
<div id="item-0" class="box">
.......
</div>
<div id="item-1" class="box">
<p><strong>Link: </strong><span class="link">
<p><input type="submit" value="submit" class="load-button2"></p>
</div>
<div id="item-2" class="box">
.......
</div>
$(".load-button2").click(function(){
var id = $(this).closest('.box').attr('id');
alert(id); // showing the right box ID
var linkp = $(/*** what should i put here? ***/ "#" + id + " .link").text;
});
|
You should just be able to do:
$(".load-button2").click(function(){
var id = $(this).closest('.box').attr('id');
alert(id); // showing the right box ID
var linkp = $("#" + id).find(".link").text();
});
Although, a more elegant solution would be:
$(".load-button2").click(function(){
var linkp = $(this).closest('.box').find(".link").text();
});
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "javascript, jquery"
}
|
How to read in lines of unequal length CSV doubles
I have a file where each line is a list of CSV doubles, i.e:
80,81,179,180,181,182
114,115,27,31,34
16,17,18,25
63,64,35,58,73,75,76,94,95
67,68
I need to read in each line, temporarily store it as a 1 x n double array for some calculations, then move onto the next line.
The idea I had was:
fid = fopen('fileName.txt');
tline = fgets(fid);
while ischar(tline)
% Update with solution I came up with
values = cellfun(@str2double,regexp(tline,',', 'split'));
tline = fgets(fid);
end
|
You can search for the commas contained in each line and the either use the indexes of their location in the string or their amount to loop till the end of the line.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "matlab, csv"
}
|
I do not know where the Deepmind code resides?
I am reading Skilful precipitation nowcasting using deep generative models of radar. The code is on Github. As I am not familiar with Github, I am confused about where the actual code is. I see neither any file with postfixes such as .py or .cpp. Can someone shed some light on this?
|
If you click on the `<> code` button on the top left you can see various sub-projects.. Some of them have code and some of them don't. There are no additional branches, so I'd say that the code for those sub-projects is not pushed to the repository.
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "github"
}
|
Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
I have successfully installed Laravel, but after running `php artisan serve` and going to `localhost:8000` I get this error:
> Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
I have checked `phpinfo()` on `localhost:8888` and it says that `mcrypt` is properly installed. However the only thing I can think of is that maybe my path is wrong?
in my `.bash_profile` I have
PATH=/usr/local/bin:$PATH
Every time I try to run Laravel commands I have to type this in the terminal:
export PATH="~/.composer/vendor/bin:$PATH"
I am running on a Mac. Is there a simple way I can set up my `bash_profile` so that I can consistently change between localhost addresses and still have all the proper PHP functions working?
|
More simple way on ubuntu
* `apt-get install php5-mcrypt`
* `mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/`
* `php5enmod mcrypt`
* `service apache2 restart`
Note: if you don't have "/etc/php5/conf.d" just skip that step and it will work ok
check <
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 13,
"tags": "php, laravel, localhost, mcrypt"
}
|
How do I remove all unique values with certain amount of observations?
Sample data
date1 = seq(as.Date("2019/01/01"), by = "month", length.out = 29)
date2= seq(as.Date("2019/01/01"), by = "month", length.out = 29)
date3 = seq(as.Date("2019/01/01"), by = "month", length.out = 29)
date4 = seq(as.Date("2019/01/01"), by = "month", length.out = 10)
subproducts1=rep("1",29)
subproducts2=rep("2",29)
subproductsx=rep("x",29)
subproductsy=rep("y",10)
b1 <- c(rnorm(29,5))
b2 <- c(rnorm(29,5))
b3 <-c(rnorm(29,5))
b4 <- c(rnorm(10,5))
dfone <- data.frame("date"= c(date1,date2,date3,date4),
"subproduct"=
c(subproducts1,subproducts2,subproductsx,subproductsy),
"actuals"= c(b1,b2,b3,b4))
Question: How can I remove all sub products with observations 10 or less?
|
We can do a group by 'subproduct' and `filter` those groups having number of observations (`n()`) greater than or equal to 10
library(dplyr)
dfone %>%
group_by(subproduct) %>%
filter(n() >= 10) %>%
ungroup
* * *
Or without any package dependency
subset(dfone, subproduct %in% names(which(table(subproduct) >= 10)))
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "r, dplyr, data manipulation"
}
|
Using database for python telegram bot
I'm creating a bot using python-telegram-bot. I'm using a third party application in the bot and user have to login into that app to further use the bot commands, I've hosted the bot on heroku.
Now the problem is, my heroku application sleeps after 30 minutes of inactivity and because of that user loses the access tokens and have to connect again to the application.
I was thinking to store the access tokens within a database, and I found that heroku has 3 database options. My preference is redis but I want to know will the database be available even during the sleep or will the database get refreshed?
Also if someone has a better solution that is more than welcome!
|
Just an update, I was able to solve this problem using Redis. Answering to the question, the database does not get refreshed even when the dynos are sleeping. Also, it was very easy to integrate Heroku Redis with python.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "heroku, python telegram bot, heroku redis"
}
|
$\sum_{n=1}^\infty \frac{a_{n+1}-a_n}{a_{n+1}}$ diverges
Let $(a_n)_{n\ge 1}$ is an increasing sequence of of positive numbers such that $a_n \to \infty$ as $n \to \infty $. Then $\sum_{n=1}^\infty \frac{a_{n+1}-a_n}{a_{n+1}}$ diverges.
|
Verify that the Cauchy criterion isn't satisfied: Since $(a_n)$ is monotonically increasing,
$$\sum_{n=k}^m \frac{a_{n+1}-a_n}{a_{n+1}} \geqslant \sum_{n=k}^m \frac{a_{n+1}-a_n}{a_{m+1}} = \frac{a_{m+1}-a_k}{a_{m+1}}.$$
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "real analysis, sequences and series"
}
|
Place elements in custom places in Android
I want to make an application that draws a layout with some background and then adds an Imageview and then adds some Image buttons on the Imageview in a specific places (x, y).
Can anyone tell me how to do that or a simple tutorial that may help me as I'm new to Android?
|
To place an element at a specific position, use an AbsoluteLayout
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "android, android layout, imageview, imagebutton"
}
|
Serve PHP page mapped as part of Django's (Python's) virtualhost
I have a question similar to this: Apache : Map one virtualhost to a subdirectory of another virtualhost
Except mine is about serving PHP within Django's domain like that:
* `example.com` serves Django, uses WSGI etc.,
* `example.com/some_app` needs to be fully based on PHP, cannot go through Django,
How can I do that? I believe this is possible, but could you give me any clues about how to accomplish that?
|
The Alias directory takes precdence over WSGIScriptAlias, so define Alias directive for /some_app to directory which is setup with PHP files.
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 0,
"tags": "apache 2.2, php, virtualhost, django, wsgi"
}
|
Printing not being logged by Kubernetes
I have simple python 2.7 program running in container off Kubernetes (AKS) which is printing debug information to standard output
response = requests.post(uri,data=body, headers=headers)
if (response.status_code >= 200 and response.status_code <= 299):
print 'Accepted ' + log_type + ' on ' + rfc1123date
else:
print "Response code: {}".format(response.status_code)
I don't see it with `kubectl logs container_name`, output is empty (but I know it is fine because of successful post). I tried to add `"-u"` to `CMD ["-u","syslog2la.py"]` in Dockerfile, but it didn't help. How to get the python print in ' _kubectl logs_ '?
|
Add the following to your Dockerfile:
ENV PYTHONUNBUFFERED=0
|
stackexchange-stackoverflow
|
{
"answer_score": 15,
"question_score": 7,
"tags": "python, logging, kubernetes, python 2.x, kubectl"
}
|
List the installed marketplace products
I have a project in GCP and there are other users as well using my project.
I just wanted to know the list of marketplace products that are currently installed.
_I tried searching for documents related to it, but I could find most of documents about deploying a product or managing our own product in marketplace._
Is there a way to find this list?
|
When you use marketplace on GCP, at the same time Deployment manager is used.
So in order for you to get a sense of all products created through Marketplace, please do the following
1. Menu
2. Deployment Manager
3. Deployments
Now if you want to know who deployed what, do this
1. Menu
2. Home
3. Activity
4. Filter choose deployment for resource type
5. Go
Here is another way, and you just need to put your project ID and execute.
Through gcloud command:
gcloud deployment-manager deployments list
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "google cloud platform, cloud, google cloud marketplace"
}
|
Empty angle brackets in template definition
This question was at the interview: _Does this code causes any compile/linking errors and why so?_
template <int T> void f();
template <> void f<0>() {}
void test()
{
f<1>();
}
Please explain the behaviour. Thanks a lot.
|
template<> void f<0>() {}
is specialization of function template for argument `0`, if you call `f<0>()` this version of function will be called.
This code is incorrect, it cause linking errors, since there is no specialization for `f<1>` and template version of function is not `defined`.
|
stackexchange-stackoverflow
|
{
"answer_score": 24,
"question_score": 21,
"tags": "c++, templates"
}
|
How to fetch the value of body.data[0].images.fixed_height.url?
<script src="
<script type="text/javascript">
var xhr = $.get("
xhr.done(function(data) { console.log("success got data", data); });
</script>
This is the response body from giphy:
 {
console.log( data.data[0].images.fixed_height.url);
});
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, json, console"
}
|
Select statement in SQLite recognizing row number
I want to write SQLite statement something like this:
SELECT * FROM Table WHERE RowNumber BETWEEN 1 AND 10;
but i don't have such column RowNumber. I have primary key in my table. But is there row number by default that i could use ?
Also i am searching info about writing more complicated SQLite statement. So if you have some links in bookmarks please share.
Thanks.
|
You want to use LIMIT and OFFSET
SELECT * FROM Table LIMIT 10 OFFSET 0
Which can also be expressed with the following shorthand syntax
SELECT * FROM Table LIMIT X,Y
Where `X` represents the offset, which is exclusive, and `Y` represents the quantity, so for example
SELECT * FROM Table LIMIT 50,50
Would return rows 51-100
|
stackexchange-stackoverflow
|
{
"answer_score": 32,
"question_score": 12,
"tags": "sql, ios, sqlite"
}
|
Integrate Adobe Reader X to Google Chrome
I am using Google Chrome as the default program to execute PDF file because it can be opened in tab and I can bookmark it for easy access later. But I do not use the default PDF viewer of Google Chrome, I want to use the Adobe Reader plugins instead because it has more convenient features than the default viewer. This works great with Adobe Reader 9. But when I update to Adobe Reader X, Chrome renders PDF files using its default PDF viewer, not the plugin. Anybody knows how to fix it?
|
Type `chrome://plugins` into the address bar, find the `Chrome PDF Viewer`, and click `Disable`.
If it doesn't work, follow these steps.
_However_ , if the your Adobe Reader's version is 10.1.3: it seems like there's an ongoing problem with Adobe Reader 10.1.3 for Google Chrome - see this thread. Some people have suggested several workarounds, but there is no solution yet.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 4,
"tags": "google chrome, adobe reader"
}
|
How can I get the layout dimensions of a children inside an HOC?
Considering this dummy pieces of code :
import React, { useState, useEffect } from 'react';
import { View, Text } from 'react-native';
import styles from './Shadow.style';
const MyHOC = ({children}) => {
return (
<View>
{children}
</View>
)
};
export default MyHOC;
How can I get the children's style properties like width, height, borderRadius from the HOC ?
|
I came up with that solution:
const [dimensions, setDimensions] = useState(null);
return (
<View
onLayout={(e) =>
setDimensions({
height: e.nativeEvent.layout.height,
width: e.nativeEvent.layout.width,
})
}
>
{children}
</View >
So when the children is rendered, the wrapping view set the children dimensions.
Not sure this is the best solution but it works.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "reactjs, react native"
}
|
Python Changing module variables in another module
Say I am importing the module 'foo' into the module 'bar'. Is it possible for me to change a global variable in foo inside bar?
Let the global variable in foo be 'arbit'. Change arbit so that if bar were to call a function of foo that uses this variable, the updated variable is used rather than the one before that.
|
You should be able to do:
import foo
foo.arbit = 'new value'
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 2,
"tags": "python, module"
}
|
Usando hexadecimais como ID no banco de dados
Pela barra de navegação, percebemos que o Google utiliza valores hexadecimais para identificar registros:
> , binário, outro?
|
> Qual a vantagem de se utilizar valores hexadecimais ao invés de inteiros?
Hexadecimal é uma representação ligeiramente mais curta. Por exemplo, os dois valores a seguir são idênticos:
999999999 DEX
3B9AC9FF HEX
Você também tem uma melhor visão da distribuição dos bits, já que cada posição em hexadecimal equivale a 4 bits:
3 B 9 A C 9 F F HEX
0011 1011 1001 1010 1100 1001 1111 1111 BIN
> Que tipo de coluna é apropriado nesse caso: string (varchar), binário, outro
Usualmente numérico, mas pode ser binário. Hexa é apenas uma representação; é o caso do tipo GUID, que o SQL Server armazena como um `varbinary(16)`.
Para um exemplo deste tipo de conversão, veja essa resposta no Stack Overflow (inglês): <
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "sql, banco de dados, chave primária"
}
|
Access main page elements from a separate page (PageSlide)
I am using the jquery PageSlide plugin as a menu on my site (< This opens a separate page on the side of the main page to act as a menu of sorts. But I was wondering how I could access the main pages elements from this side bar. For example I have an Iframe I want to manipulate from the side page, but I don't know how to accomplish this because they are on separate pages! Thanks, any help is appricated.
|
Iframes are evil IMHO and should be avoided as much as possible. As I mentioned in my comment earlier, you can not run JS from an Iframe that can act on the main page. That would be a VERY scary world if that was possible.
If you want to have menu that slides from the side like many current mobile apps.
**I would recommend considering those options:**
1. You can do that with pure jQuery with no extra plugins. There are many resources online and one is a question discussing this in detail as well as a simple demo for it.
2. You can look for plugins that can help you with what you are trying to do, with a quick search, I came across this. But I am sure there is more.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, css"
}
|
Excel Workday not excluding Thanksgiving
!enter image description here
In 2002, Thanksgiving was on the 28th of November. So two working days before Monday, Dec 2nd should be Wednesday Nov 27th.
But
WORKDAY(A1,-2) Where the cell A1 has the value 12/2/2002 stored
gives me 11/28/2002
Is there a command or option that keeps track of the days financial markets are closed in the US?
|
No, but =WORKDAY can be modified to take account of days to exclude to suit.
Syntax is `WORKDAY(start_date,days,holidays)`
> **Holidays** is an optional list of one or more dates to exclude from the working calendar, such as state and federal holidays and floating holidays. The list can be either a range of cells that contain the dates or an array constant of the serial numbers that represent the dates.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "excel"
}
|
ActiveRecord error converting rails app from Sqlite to PostgreSQL
I moved my app from sqlite to postgresql so that I could use RGeo and PostGIS. I deleted all the data in my database and started from scratch. Everything is working fine except one particular area of the site. I have an association that links Tourstops and Venues that appears to be not working. No code was modified in this area since the switch. Unfortunately I'm still sort of new to rails and don't know enough to diagnose this error.
The error I'm getting is:
**ActiveRecord::StatementInvalid in ToursController#show**
PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer LINE 1: SELECT "venues".* FROM "venues" WHERE (1) LIMIT 1 ^ : SELECT "venues".* FROM "venues" WHERE (1) LIMIT 1
def show
@tour = Tour.find(params[:id])
@tourstop = Venue.find_by(params[:id])
end
Parameters: {"id"=>"1"}
|
Your problem, as stated in the comments, that you're using `find_by` without any :key in the hash
To be clear, ActiveRecord should be able to translate between SQLite & PGSQL, so the difference has to be with your use of the ActiveRecord methods:
* * *
**find**
Finds individual element by primary_key:
Model.find(id)
* * *
**find_by**
Finds by value other than primary_key:
Model.find_by name: "Rich"
Model.find_by({name: "Rich"})
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "ruby on rails, ruby, postgresql, activerecord, ruby on rails 4"
}
|
require_once failed to find file
I try to use my own classes in the ratchet main class but I fail at the require_once
See the image of my files structure.
!enter image description here
|
Try using `require_once __DIR__.'/../../UserManager.php'`
@dasdasd here is my commented converted into an answer... thanks ;)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php"
}
|
Organisation of folders on NEXTGIS
I am trying to set up a folder called 'November' on NEXTGIS such that I can add multiple web maps into subfolders called 1,2,3,etc over time. I want to give a web address to a coworker for the folder 'November' which will include links to all subfolders. They can monitor this page to see updated maps throughout November.
3. program completely new frontend (REST API is available)
**Disclosure** : I am a developer at NextGIS.
|
stackexchange-gis
|
{
"answer_score": 1,
"question_score": 0,
"tags": "qgis 2.18, nextgis"
}
|
All tree orders are lattice orders?
Say that a set is _tree ordered_ if the downset $\downarrow a =\\{b:b\leq a\\}$ is linearly ordered for each $a$. In a comment, Keinstein says that such sets are also semi-lattices, provided they are connected. This doesn't seem true to me.
Consider e.x. this tree:
a c e
\ / \ /
b d
$b\wedge d$ does not exist, so it is not a lattice.
Am I missing something?
|
Your example is not tree-ordered since ${\downarrow}c$ is not linearly ordered.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 3,
"tags": "abstract algebra, graph theory, order theory, lattice orders"
}
|
What is this 3D Model?
I have come across this model many times.
 apart, there will be one peak each 1/6 of a cycle, or every 60°.
This is a rare case where a simulator might actually be useful.
Simulation of 3 sines 120° apart and its input and output waveforms.  in SQL Server?
I implemented the "HelloWorld" sample of a CLR stored procedure, and it worked.
I then changed the code, recompiled, and re-ran it, and got the old results, not the new results.
Example Code Change (all other code is in above link):
Before:
SqlContext.Pipe.Send("Hello world!\n");
After:
SqlContext.Pipe.Send("Hello world new version!\n");
Is there anything short of recycling SQL to get the new assembly loaded?
|
Say you have created a CLR Function `HelloSQLCLR()` in C#
You will need the following steps before you can call it in Sql Server
**Enable SQLCLR**
sp_configure 'clr_enabled', 1
GO
RECONFIGURE
GO
**Install and register HelloSQLCLR**
**Install (change the directory to the actual location)**
CREATE ASSEMBLY MyUDFsLib
FROM 'C:\Path_To_Your_DLL\HelloSQLCLR.dll'
GO
**Register**
CREATE FUNCTION dbo.HelloSQLCLR()
RETURNS NVARCHAR(50)
EXTERNAL NAME MyUDFsLib.MyUDFs.HelloSQLCLR;
**Test it**
SELECT dbo.HelloSQLCLR()
**Edit**
If you have changed the code try something like this
ALTER ASSEMBLY MyUDFsLib
FROM 'C:\Path_your_changed_Recomplied_DLL\.dll'
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 3,
"tags": "sql server, sql server 2008, sqlclr, clrstoredprocedure"
}
|
Why is my Dwarf Jade plant dropping more than dozens of leaves?
My Dwarf Jade plant has been dropping dozens of leaves (both good and bad leaves) every day for the past few days. It receives bright indirect light. What is the case? Is it overwatering or underwatering or some disease?
Click for full size image:

Sales
* Product ID (FK)
* Sale date
I'm trying to come up with a query that will result in a data table that shows the total number of sales per category, like:
Cat ID | Name | Total Sales
-------|------|-------------
1 | Red | 35
2 | Blue | 25
For bonus points, add a WHERE clause to select within a specific date range on the 'Sale Date' column.
I'm using SQL Server.
|
For SQL-Server could be something like that:
SELECT c.CategoryID AS [Cat ID],
c.Name AS [Name],
COUNT(s.ProductID) AS [Total Sales]
FROM Categories c
LEFT JOIN Products p
ON c.CategoryID = p.CategoryID
LEFT JOIN Sales s
ON p.ProductID = s.ProductID
WHERE s.Saledate BETWEEEN startDate and endDate
GROUP BY c.CategoryID, c.Name
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "sql, sql server"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.