INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Perl run function on script exit/die
I have a question and could not find the answer i need. I have a perl script that works with several files. At the beginning of the script a given file is renamed and backed up, at the end of the script it is renamed back, so the original file is not touched at all. But what if the script dies while running, e.g. if a file is missing or if the user exits the script via "cmd + c" on the keyboard? Is there a method to define a function that is always executed when the script dies or the user wants the script to die? I found the "END"-block from perl, but it don't think that will work in my case.
Thank you!
-Alex | The END block works for `exit` and `die`. If doesn't work for signals, though, you'll have to create a signal handler. Setting it to an empty sub would pass the control to the END block:
local $SIG{INT} = sub {}; | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "perl, function, exit, die"
} |
Shell Script filter Output Value
I want to filter the output of "docker network ls". My command with output
# docker network ls | grep "nw-MariaDB"
a29be99ba348 maindb_nw-MariaDB bridge local
What can I do if I only want to output maindb_nw-MariaDB? | I would use the following :
docker network ls --filter name=nw-MariaDB --format "{{.Name}}"
Explanation :
* `--filter name=...` allows us to restrict the output of `docker network ls` to network whose name contain a specific keyword
* `--format` allows us to have each line only return the name of the network | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "bash, docker, shell"
} |
Turn NSString into integer
Sorry guys, I'm a noob. I know that some languages support type casting, but when I tried to do that here it failed, miserably. I've got an UITextField with number only pad, so I'm only getting numbers, and I need the output from that in my int, diff. Here's what I tried:
NSString *outputNumber = [NSString stringWithFormat:@"%d", [textBox.text]];
diff = [outputNumber intValue]; //Not so much
What happens is my diff goes to some incredibly high number instead of the single digets I tested with. Any help I could get is great. Thanks :) | Why are you using [ ] around textBox.text? And you dont need temporary outputNumber string .
Try this :
diff = [textBox.text intValue]; | stackexchange-stackoverflow | {
"answer_score": 27,
"question_score": 8,
"tags": "iphone, objective c, nsstring, int, ios4"
} |
Removing NA rows where all column values are also NA
Hi I want to remove All nan values where all rows are NA and colums are also na for that row
for example
L1 L2 L3 L4
nan 1 2 na
nan nan nan nan
1 2 3 4
nan nan nan nan
5 6 7 8
na na 9 10
i.e I dont want 3, 4 row from dataframe from my above data how do i do it?
My expected output is:
L1 L2 L3 L4
nan 1 2 na
1 2 3 4
5 6 7 8
na na 9 10 | Check out pandas `df.dropna(axis=0, how='all')` < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, na"
} |
Intergrate 3rd party app for Cocos Creator games
I am new to Cocos Creator (and Cocos2dx, too). I'm planning to develop a game for iOS, Android and Web platform.
Is it possible to integrate these apps to game developed by Cocos Creator:
* Appflyers, Google Analytics, Firebase (for tracking user)
* In-app purchase (for Android and iOS) | SDKBOX may help you. Intro: <
You can read this manual for integrating SDKs
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "android, ios, cocos2d x, cocoscreator"
} |
Determine if a JavaScript property has a getter or setter defined?
Is it possible, given an object and property name to determine if that property is defined using either a getter or setter, or is it completely transparent? I only want to define a getter/setter if there is not already one defined on the property.
I need it to work in WebKit/Firefox. | I think you're looking for `getOwnPropertyDescriptor`? | stackexchange-stackoverflow | {
"answer_score": 44,
"question_score": 52,
"tags": "javascript, properties, getter setter"
} |
Building SpiderMonkey with Cygwin
I need to build SpiderMonkey so that I can use it with emscripten. I succeeded in building version 1.8 (using the hack from here: < But unfortunately version 1.8 lacks JSON support and apparently that came into existance with version 1.8.1.
Unfortunately I don't see any 1.8.1 tag/branch in CVS and I cannot use version 1.8.5 because the above hack no longer works with that version.
Any ideas for getting this to work in Cygwin? | You can use the following guide for building Spidermonkey in Cygwin.
SpiderMonkey Build Documentation
Windows build prerequisites
I have used the instructions to build the 1.8.5 version and it worked fine. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "cygwin, spidermonkey"
} |
Selenium IDE using storeText variable as id of some other field
In Selenium IDE, we have a page that writes a different number every time. There's a checkbox on that page I need to check, whose id is 'ldev_####', where '####' is the number that changes. Is there a way I can use the storeText command to store the number that changes each time and then somehow make that part of the id on the click command? I tried this, and it didn't work:
storeText | //table[@id='xxxxx']/tbody/tr/td[5] | ldev_var
click | id=ldev_$ldev_var
The id above usually comes out like this: id=ldev_1234
it's the '1234' that changes. Am I overthinking this, or is there an easier way to do this?
thanks so much for any help, Ed | You can use xpath expression to solve this problem:
//input[starts-with(@id,'ldev_')] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "selenium"
} |
Custom number format for NULL
I have an excel sheet that I populate from a database. What is the custom number format that I can use to replace NULL values in the excel by a hyphen '-' ? I know that I can use the following formula
#,##0_);(#,##0);–_);_(@_)
in order to display it for a zero. But I don't know how to handle a null value. | The simple answer is that the number format strings do not have a section for NULL values. See ECMA-376 section 18.8.31 for an explanation:
> Up to four sections of format codes can be specified. The format codes, separated by semicolons, define the formats for positive numbers, negative numbers, zero values, and text, in that order. If only two sections are specified, the first is used for positive numbers and zeros, and the second is used for negative numbers. If only one section is specified, it is used for all numbers.
One workaround is to check for null values, emit a text value, and set the text format. For example, using the formula `0;0;0;"-"`:
VALUE FORMATTED
#NULL! -
NULL -
1 1
2 2
3 3
4 4
Note that this only works if you expect the result to be numerical. If you expect a string value, you can do the opposite (`"-";"-";"-";@`) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "excel, formatting, excel formula"
} |
How make daily data transfer from AWS s3 to GCP GCS?
I have a client who wants their data to be transferred daily to GCP bucket from their S3 to Google Cloud Storage bucket. Is there any way to create schedule transfer or recurring transfer from s3 to GCS. | you can use the service called **Storage Transfer** service: <
you can create a pipeline and schedule it as per requirement and run to clone all data from AWS S3 to GCP.
here main service URL: <
You can use `storage transfer service` to the transfer bucket data
* AWS S3 to GCP & vice versa
* Azure to GCP & vice versa
* GCP to GCP & vice versa
it also supports the TSV file.
You can configure this service to run at a specific time daily. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "amazon s3, google cloud platform, data transfer"
} |
Joint density of Independent and identically distributed Exponential random variables
Suppose that $X_1,X_2,…,X_{10}$ are iid exponential random variables. What is the joint density of $X_1,…,X_{10}$ at $x_1,…,x_{10}?$ Is it the product $$f_{(X_1,\dots,X_N )}(x_1, \dots , x_n) = f_{X_1}(x_1)f_{X_2}(x_2)\dots f_{X_n}(x_n)$$ or is it different for an exponential? | For any independent random variables $X_1, \dots, X_n$ with respective probability density functions $f_1(x), \dots, f_n(x)$ their joint probability density function is $f(x_1, \dots, x_n) = \prod_{i=1}^n f_i(x_i)$. Note that $X_i$ do not need to be exponential and do not need to have the same distribution. Instead, the form of the joint distribution is the defining property of _independence_). | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "probability, probability distributions, random variables, density function, exponential distribution"
} |
Close connection to a database after finishing the query
So, basically,someone was telling me today that the way I Query my database was bad before I never close the connection after finishing and thus I probably had many open connection with the database running simultaneously.
I looked online however, I did not get a straight answer. I am using MySQL Mariadb. and this is how I am doing it
db = mysql.connector.connect(host='localhost', username, passwd, db='mydb')
# and actually call this function and pass query
def db_execute(query):
cursor = db.cursor()
cursor.execute(query)
db.commit()
is this decent? how can I close the connection after I finish? what's better? | db = mysql.connector.connect(host='localhost', username, passwd, db='mydb')
# and actually call this function and pass query
def db_execute(query):
cursor = db.cursor()
try:
cursor.execute(query)
db.commit()
#You can also catch any exceptions you are interested in here
finally:
cursor.close()
db.close()
`Finally` block gets executed even if you code throws an exception, hence your connection is always closed even if something unexpected happens. If you do not use finally and there is an exception in your code before the close statement, the connection remains open, which is undesired. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, mysql, mariadb"
} |
How to get type from scope in template class?
Here I have some interesting code. Does anyone know how to get subtype from `myClass` without auxiliary parameter in template?
* * *
**_Note:** Maybe `myClass` template too._
class myClass
{
public:
struct tPacaje
{
int data;
};
};
template <class T>
class executorClass
{
public:
void todo(T::tPacaje ob)
{
...
}
}; | You are trying to use a type so need to tell the compiler you are using a `typename`:
template <class T>
class executorClass
{
public:
void todo(typename T::tPacaje ob)
{
//^-------
//...
}
}; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++11"
} |
BigQuery compare Date
In BigQuery table what I using some date stored in DateTime typed columns with value like "2016-01-20T00:00:00". I want to run query that for example show row which included in some range (lets say from 2016-01-01 to 2016-02-28).
So problem is that when I put
`...Where data < TIMESTAMP('2017-01-30 00:00:00')...//less then`
it show me nothing but when I change it to opposite value like
`...Where data > TIMESTAMP('2017-01-30 00:00:00')...//greater then`
it returns me even those values that logically should be excluded (like 2017-01-20)
I have tested that TIMESTAMP('2017-01-20 00:00:00') returning '2017-01-26 00:00:00 UTC'.
So which method from bigQuery DateTime I should use to be able to compare dates that I have? May be I need to convert both of them into some kind 'milliseconds since' value?
Thanks | Thank you all for help. Your answers and link has leaded me to solution.
where data<cast('2017-01-23 00:00:00' as datetime)
`cast('2017-01-23 00:00:00' as datetime)` provide `'2017-01-23T00:00:00'` value and bigQuery are happy with it and give me wanted result. | stackexchange-stackoverflow | {
"answer_score": 18,
"question_score": 15,
"tags": "sql, datetime, google bigquery"
} |
ActiveRecord .select(): Possible to clear old selects?
Is there a way to clear old selects in a .select("table.col1, ...") statement?
Background:
I have a scope that requests accessible items for a given user id (simplified)
scope :accessible, lambda { |user_id|
joins(:users).select("items.*")
.where("items_users.user_id = ?) OR items.created_by = ?", user_id, user_id)
}
Then for example in the index action i only need the item id and title, so i would do this:
@items = Item.accessible(@auth.id).select("polls.id, polls.title")
However, this will select the columns "items. _, items.id, items.title". I'd like to avoid removing the select from the scope, since then i'd have to add a select("items._ ") everywhere else. Am I right to assume that there is no way to do this, and i either live with fetching too many fields or have to use multiple scopes? | Fortunately you're wrong :D, you can use the `#except` method to remove some parts of the query made by the relation, so if you want to remove the SELECT part just do :
@items = Item.accessible(@auth.id).except(:select).select("polls.id, polls.title") | stackexchange-stackoverflow | {
"answer_score": 68,
"question_score": 33,
"tags": "ruby on rails 3"
} |
Getting (400) Bad Request in response while try get access token for docusign
I am able get JWT access token with account id#10540382, which I created for our company e-signature implementation. I done JWT implementation with this account and everything goes well. But now company provided my new account id#11024495. But with this new account I am not getting access token. Token API < now return "The remote server returned an error: (400) Bad Request."
Can someone from DocuSign help me, what is issue with new account id#11024495? | The reason is missing consent.
Your client will need to provide consent by calling this url from the browser window
` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "docusignapi"
} |
Obfuscating Android activity names
Is there any way I can obfuscate the names of my Android activities? I would like to be able to hide them from view, if someone were to attempt to reverse engineer my APK. Of course, I could simply manually rename them all with nonsense names and change the manifest as well, but is there any other way? | I think what you're looking for is ProGuard. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "android, android activity, obfuscation, android manifest"
} |
Sentences What for/For What need
Both sentences sound right? And do they have a different meaning?
> For what needs life?
or
> What is life for? | **Both sentences sound right? And do they have a different meaning?**
I presume you mean
**Do** both sentences sound right? And do they have a different meaning?
Item 1 Sounds wrong and is wrong. **For what needs life?**
Item 2 is good. **What is life for?**
The definition of ;
> **needs** plural noun US; the things you must have for a satisfactory life:Link C.E.D.
I can only make a guess at what you are trying to say, so, as item 1 is wrong I cannot compare them. | stackexchange-ell | {
"answer_score": 1,
"question_score": 0,
"tags": "grammar, sentence construction, construction"
} |
Storing a complete graph in a RDBMS
I have several types of entities, each with their own fields, which are stored in separate tables.
Each record in such a table may be connected to zero or more records in a different table, i.e., linked to records from different entity types.
If I go with lookup tables, I get (m(m-1))/2=O(m^2) separate lookup tables that need to be initialized.
While still feasible for 6 or 7 different entity types, would it still be relevant for 50+ such types?
In particular, a given record would need to have links to most other entity types so theoretically speaking I would be dealing with a nearly-complete, non-directed, n-sided graph.
Can anyone shed some light on how to store this structure in a relational DBMS?
(I'm using Postgresql if it matters, but any solutions for other DBMS's would be equally helpful).
Thank you for your time!
Yuval | This is Object-Relational Mapping, a classically hard problem. You really need a ORM tool to do this properly, or it'll drive you nuts.
The connection problem you refer to is one of the pitfalls, and it needs very careful optimisation and query tuning, else it'll kill performance (e.g. the N+1 SELECT problem).
I can't be any more specific without knowing what your application platform is - the actual DBMS used isn't really relevent to the problem. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "database, graph theory"
} |
Magnitude of n-th factorial
In connection with a riddle on The Riddler, I would like to know how to evaluate even crudely the order of magnitude of an iterated factorial like $$(\ldots(9\underbrace{!)!\ldots)!}_{n\text{ factorials}}$$ Using Stirling's approximation does not get me very far: \begin{align*} 9! &\approx 3^9\\\ (9!)! &\approx (3^9/3)^{3^9}=3^{8\times 3^9}\\\ &... \end{align*} | First, let me explain why the numbers in a power tower don't matter. Let us compare these two:
$$3^{5^{5^5}}=10^{10^{10^a}}$$
$$5^{50\times5^{5^5}}=10^{10^{10^b}}$$
Clearly, we will have $a<b$, but by how much? Well, take the log of each thrice, and you will find that
$$a\approx2.7$$
$$b\approx2.7$$
Indeed, the only things that truly matters is how tall the power towers are, which is why may use a crude Stirling approximation:
$$k!\approx k^k$$
Also, a quick symbolization:
$$k!_n=k\underbrace{!!!!\dots~ !}_n$$
And furthermore,
$$k!_n\approx k^{k^{k^{\dots}}}\bigg\\}(n+1)\text{ powers}$$
In terms of Knuth's up-arrow notation:
$$k!_n\approx k\uparrow\uparrow(n+1)$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "factorial, recursion, approximation theory, stirling numbers, big numbers"
} |
DevOps Center - Promote fails. Where to see details?
I'm trying to promote a work item and it fails. The only error I see is "4 tests failed". Is there anyplace I can get details? Logs of some kind?
. | stackexchange-salesforce | {
"answer_score": 2,
"question_score": 1,
"tags": "devopscenter"
} |
What is the difference between copy and paste a file using command line terminal and GUI copy paste?
What is the difference between copy and paste a file using command line terminal and GUI copy paste ? Which one is fast ? I think both are same because of same program will execute in background .
What am i asking is, in windows or linux ...i want to copy a directory from one directory to another. To do that i may use command line (cp command in linux or copy command in windows) or directly i can copy the directory by right click and paste in destination directory right click-> paste. Now my question which process is fast/efficient. Or both are same? | Which process is fast/efficient depends on whether it's faster for you to type the command in command line or faster to drag and drop files around. They are identical in they way the files are transferred as far as speed and efficiency. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 1,
"tags": "linux, windows, command line, terminal, c"
} |
Automapper CreateMissingTypeMaps property Warning
I think this is a repeated Question but i am unable to resolve it. here is my mapping.
UserProfileVM model = AutoMapper.Mapper.DynamicMap<UserProfileVM>(objUser);
But here `AutoMapper` gives warning.
I tried to add `MapperConfiguration`, but i have no idea how to use it in `DynamicMap<>()`.
var config = new MapperConfiguration(cfg => { cfg.CreateMissingTypeMaps = true; });
Now how to use my **config** variable for dynamic map?
Or is there any global setting for these issue because i used mapper for many times in my application. | Initialize static AutoMapper using a certain configuration (recommended for the usage you have show):
Mapper.Initialize(cfg => cfg.CreateMissingTypeMaps = true);
Or create instance of AutoMapper from a configuration:
var config = new MapperConfiguration(cfg => { cfg.CreateMissingTypeMaps = true; });
IMapper mapper = config.CreateMapper();
AutoMapper Static and Instance API | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c#, asp.net mvc, automapper"
} |
Cannot push onto Github repository
I am having trouble pushing code from my machine to github. I have setup the repos:
git remote add origin [email protected]:hugeeee/demo_app.git
I get this error when type the command `git push -u origin master`:
ssh: Could not resolve hostname github: Name or service not known
fatal: The remote end hung up unexpectedly
Can anybody please direct me towards the solution? | Run this:
git remote set-url origin [email protected]:hugeeee/demo_app.git
Make sure you actually say "github.com". You probably left out the ".com" when you created the remote. | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 10,
"tags": "git, github"
} |
Two problems on solving equations in rational and integers
> prove that $x^2-2y^2=7$ has infinitely many solutions in integers.
>
>> $a$ and $b$ are two non-zero rational numbers.Then if the equation $ax^2+by^2=0$ has a nonzero rational solution $(x_0,y_0)$ then for any rational $t$, $ax^2+by^2=t$ also has a non zero rational solution $(x_t,y_t)$.Prove this. | Define the sequences $(x_n,y_n)$ recursively by ($x_1=3$ and $y_1=1$) \begin{eqnarray*} x_{n+1}=3x_n+4y_n \\\ y_{n+1}=2x_n +3y_n. \end{eqnarray*} It easy to show by induction that the pairs $(x_n,y_n)$ will satisfy $x^2-2y^2=7$. \begin{eqnarray*} x_{n+1}^2-2y_{n+1}^2=(3x_n+4y_n)^2-2( 2x_n +3y_n)^2 \\\ =9x_{n}^2+24x_ny_n+16y_{n}^2-2(4x_{n}^2+12x_ny_n+9y_{n}^2)=x_{n}^2-2y_{n}^2=7. \end{eqnarray*} | stackexchange-math | {
"answer_score": 0,
"question_score": -3,
"tags": "diophantine equations, pell type equations, algebraic equations"
} |
jquery animation tray
please have a look at an example here.
I am trying to animate it so that the grey tray slides down but the 'more' tab should move down at the same time. I can't figure it out. Can someone help me? What am I missing?
Thanks in advance | Add it's own animation. Or correctly nest it inside the #tray.
$('.pull').click(function(){
$("#tray").hide("slide", { direction: "down"}, 3000);
$('.pull').animate({'top':'120px'});
}); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, jquery animate"
} |
how to retrieve oracle 10G license key in windows?
Is it possible to retrieve oracle license key in windows? It was supposed to be in the cd but the cd is missing.
any thoughts and advise?
Thanks | There is no such thing as a license key for the Oracle database. All that's relevant is
* how many licenses you bought (for your Customer Support Identifier)
* what machines you're running Oracle on
To find the number of licenses you own, you should log in to _My Oracle Support_ and check your information there.
See Oracle forums for more details. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "oracle, oracle10g"
} |
order of records in result set
May order of rows in unordered query (like `select * from smth`) be different in different queries (in the same and not same session) if there are no updates to database table? | The order or rows returned from a query should never be relied upon unless you have included a specific `ORDER BY` clause in your query.
You may find that even without the `ORDER BY` the results appear in the same order but you could not guarentee this will be the case and to rely on it would be foolish especially when the `ORDER BY` clause will fulfill your requirements.
See this question: Default row ordering for select query in oracle
It has an excellent quote from Tom Kyte about record ordering.
So to answer your question: Yes, the order of rows in an unordered query may be different between queries and sessions as it relies on multiple factors of which you may have no control (if you are not a DBA etc.)
Hope this helps... | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "oracle"
} |
What technology or framework should I use to build something like this?
.
> What frameworks should I use which will be easiest to do and setup
Popular:
* React (my preference for something simple like you want)
* Angular
* Ember
Or roll your own. Or pick one from : google search | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "javascript, html, css, ajax, frontend"
} |
Is there a climber chest piece?
Climbing is awesome, and climbing fast is better! I bought the Climber's Bandanna and Climber Boots, but can't find the third part of this set. Where can I find/buy it? | **Yes**. Climbing Gear, the chestpiece of the Climbing Set can be found in Chaas Qeta Shrine in the Necluda sea. Chaas Qeta Shrine is a Major Test of Strength, and the Climbing Gear is found in the chest at the end of the shrine. | stackexchange-gaming | {
"answer_score": 8,
"question_score": 3,
"tags": "zelda breath of the wild"
} |
Is possible to win a game of Yankee Doodle in the Vita version of the game? (touchpad usage)
On the PS3 version of Project Diva f 2nd, you play Yankee Doodle by moving the analog sticks and pressing L3/R3 when required. On the Vita version, you have to slide or tap the screen which makes it almost impossible due to the speed on levels 2 and 3.
Is possible to win a game of Yankee Doodle in the Vita version of the game? If so, Does it requires a specific trick or something like that? | There is a very simple trick that can be used to easily win rounds 2 and 3 versus any character as long as you don't miss.
You just need to ignore all of the swipe input and just tap the dots. Just tapping the dots will give you 4 bars and a half, which is over the minimum required to win each round (4 bars required). | stackexchange-gaming | {
"answer_score": 1,
"question_score": 2,
"tags": "ps vita, project diva f 2nd"
} |
How to install Adobe Reader X in Ubuntu?
I want to install Adobe Reader X (10 or 11) in my system. But there is no native application available for Linux. After doing Google I have seen that Adobe Reader 10.1.14 is given gold rating with Wine 1.5.19. But when I have tried, the installation is going fine without any error, but I could not find the Adobe Reader in menu. So I have tried it through PlayOnLinux and getting error that "wine crashed". I really need the Adobe Reader x as Adobe Reader 9 does not support lots of commenting and writing tools of Adobe Reader x. Please help me to install it.
I am using Ubuntu 12.10 64 bit. I have tried to install Adobe Reader 10.1.14 and 11.0.01 with Wine 1.4 and 1.5.19 through PlayOnLinux. | Finally Foxit reader with wine working perfect. It has all the feature that I am looking for. Installing flawlessly and working like a native linux app. | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 9,
"tags": "12.10, wine, 64 bit, pdf, adobe reader"
} |
How to deploy to Salesforce Custom Object metada using python?
It seems I can communicate with Salesforce Metadata API just using SOAP python client (suds?)
Is there any more elegant way? I know about
* salesforce-python-toolkit
* salesforce-beatbox
but I could not find any example or documentation reference..
Any suggestion, reference or example would be appreciated!
Thanks | Salesforce does have a REST API but as far as I'm aware at this stage, the metadata operations are limited and also read-only, so using SOAP is the way forward.
The two projects you've linked to appear to be wrappers for the regular salesforce API and the bulk data API, that said, the source is available so maybe you could adapt one? Or wait for Superfell to answer, looks like he wrote the beatbox one! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, salesforce, suds"
} |
storing double values in SQLite: how to ensure precision?
i have a problem with double values i need to store in an android homed sqlite database. since these double values represent gps values (lat & lng), i really `NEED` an absolute precision down to the 9th number after the comma.
now i have a table like this:
CREATE TABLE x REAL lng;
and insert sth (hardcoded) like:
INSERT INTO x lng = '1.0';
and when reading lng from this table into some (java) double variable, i get a value like "0.999956837" - this renders the values pretty useless to me.
is there a way to enforce the precision i need other than storing the values as "text" fields (what would make expensive casts neccessary) or storing them as integers (meaning i need to multiply/divide at each write/read-op)? | SQLite is typeless, that means all representation is written as text, probably the wrapper api does some converts you don't know of, that you get those results.
If you need to store the data as string **do it.**
Just when you read out the double make sure you saved in the right format, you can use `getDouble` on the column. | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 9,
"tags": "android, database, sqlite, double, precision"
} |
The nice and round sequence
I have thought up a sequence, and I name it the nice and round sequence. Its first 10 numbers are
> 15773, 29694, 165083, 276316, 496325, 498512, 702504, 719466, 808667, 826245
>
> What is its pattern?
* * *
Hint 1:
> More numbers of the sequence can be found in this spreadsheet <
Hint 2:
> I do not think there is a formula to compute the terms.
Hint 3:
> What number is considered nice by the internet denizens? What number is related to round things? | The pattern is made up of the
> positions of the sequence `69420` (nice) within the digits of Pi after the decimal place (round).
The next number in the sequence (excluding those in the hint within the question) is
> 3022306, as the 3022306th, 3022307th, ... and 3022310th digits of Pi after the decimal place are `69420`. | stackexchange-puzzling | {
"answer_score": 3,
"question_score": 0,
"tags": "mathematics, number sequence"
} |
Assigning dynamic executed query to variables
Is there any way in SYBASE to store the values which is returned from (EXECUTE IMMEDIATE) dynamic query to variables
EXECUTE IMMEDIATE SQL
INTO x, y | Not sure if this is what you are looking for, but for what it's worth... BEGIN
DECLARE x int;
DECLARE y int;
EXECUTE IMMEDIATE
'SET x = 5';
EXECUTE IMMEDIATE
'SET y = 3';
SELECT x,y;
END | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "sybase"
} |
How to POST multiple images to FastAPI server using Python requests?
I would like to send multiple images to FastAPI backend using Python requests.
**Server side**
from fastapi import FastAPI, UploadFile, File
from typing import List
app = FastAPI()
@app.post("/")
def index(file: List[UploadFile] = File(...)):
list_image = []
for i in file:
list_image.append(i.filename)
return {"list_image": list_image}
**Client side**
Currently, I can only send a request with a single image. However, I would like to be able to send multiple images.
import requests
import cv2
frame = cv2.imread("../image/3.png")
imencoded = cv2.imencode(".jpg", frame)[1]
file = {'file': ('image.jpg', imencoded.tostring(),
'image/jpeg', {'Expires': '0'})}
response = requests.post(" files=file) | Use as below:
import requests
url = '
files = [('file', open('images/1.png', 'rb')), ('file', open('images/2.png', 'rb'))]
resp = requests.post(url=url, files=files)
or, you could also use:
import requests
import glob
path = glob.glob("images/*", recursive=True) # images' path
files = [('file', open(img, 'rb')) for img in path]
url = '
resp = requests.post(url=url, files=files) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "python, request, fastapi"
} |
Creating a fake internal network for virtual machines
I have a production application that consists of
An app server VM1 - 192.168.0.4
A database server DB - 192.168.0.5
VM1 connects to the DB using its IP address.
I want to mimic production VM1 on my development machine. So it should connect to the db using the same IP as on production, but reach my development machine DB instance.
Ideally, I would not have to hardcode my development machine IP to make this work. Any ideas? | Try rinetd, you can set up a redirect from the production IP address to your own. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "networking, ubuntu, virtual machine, virtualbox"
} |
Plot dataframe index
I have the below dataframe with index: DateTime
ghi dni dhi ... Ws wind_speed temp_air
DateTime ...
2015-01-31 63079.57 37115.92 25963.65 ... 1589.20 0 14860
2015-02-28 68303.53 34683.19 33620.34 ... 1796.91 0 13440
2015-03-31 138789.55 88291.41 50498.14 ... 1647.59 0 14880
2015-04-30 135415.64 70234.19 65181.45 ... 1474.14 0 14400
I used the following and it works:
df1.plot(kind='bar',x='**gni**',y='ghi')
but if I do the following, it doesn´t:
df1.plot(kind='bar',x='**DateTime**',y='ghi')
Could you explain me why? | Very similar question here. You could either omit `x=...` or use `.reset_index()` to get a column to plot as x:
import pandas as pd
# dummy df:
df1 = pd.DataFrame({'ghi': [1,2,1,3,1,4],
'DateTime': pd.date_range('2015-01', '2015-06', freq='MS')})
df1.set_index('DateTime', inplace=True)
# don't specify x=...:
ax = df1.plot(kind='bar', y='ghi')
# or use the index as a column:
ax = df1.reset_index().plot(kind='bar', x='DateTime', y='ghi')
# nicer x labels, e.g.:
ax.xaxis.set_ticklabels([i.strftime('%Y-%m-%d') for i in df1.index], rotation=45) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "datetime, plot, indexing"
} |
Extracting hashtags out of a string.
If I had a string as such
var comment = "Mmmm #yummy #donut at #CZ"
How can I get a list of hash tags that exist in the string variable?
I tried using JavaScript split() method but I have to keep splitting all strings created from the initial split string. Is there a simpler way of doing this? | This will do it for anything with alphabetic characters, you can extend the regexp for other characters if you want:
myString.match(/#[a-z]+/gi); | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 11,
"tags": "javascript, hashtag"
} |
WooCommerce REST API - Filter Orders By Date Modified
I'm using the WooCommerce REST API (< and can download Customers, Orders, etc successfully.
I'm now trying to get a filtered list of Orders where the Date Modified for the Order is after a certain date, but haven't been able to get this to work so far. The response to get GET request for an Order includes:
"date_modified": "2016-12-21T00:33:38",
I've tried the following:
wp-json/wc/v1/orders?filter[modified]=2017-02-14
but that just returns all orders. I would like to change the = to be a >= so it gets all Orders after the specified date, but haven't been able to find an example of how to structure the request URL for this? | I was able to get this working using the following request format:
wc-api/v1/orders?filter[updated_at_min]=2017-02-22&filter[updated_at_max]=2017-02-25 | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 8,
"tags": "wordpress, rest, woocommerce, woocommerce rest api, wordpress rest api"
} |
How to connect to mysql UNIX server from java windows application using jdbc?
I am working on java windows application. I am trying to connect to mysql server(Localhost via UNIX socket) using jdbc. But it is displaying an error message as
`"Access denied for user 'root'@'ipaddress'.`I didn't get what is the problem.Is it the problem connecting to unix server from jdbc? If so how can I resolve this issue.Please help me regarding this.
!enter image description here
Thanks in advance | You need to set up mysql to allow remote connection for any users. The default syntax is:
grant on to @ identified by
eg grant all on test.* to root@ipaddress identified by root
Will allow 'root' to connect from that IP using that password and give all permissions on all tables in that database. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java"
} |
Using "adjustPan" or "adjustResize" specific to a fragment
I'm wondering if it's possible to specify **programatically** or in the **xml** a way to use a `windowSoftInputMode` specific to a `Fragment`.
Let's say I have just one `activity` that contains two `fragment`, one fragment should use `adjustPan` and the other one `adjustResize`. How should I manage this?
Thanks! | You can change the behavior programmatically, see this answer for that.
So what I would do: if fragment A is resumed, use `getActivity()` to get a reference to its parent activity, and then use the command from the question to change the behavior.
Then do the same with fragment B, but use the other parameter when setting the soft input mode behavior.
* `adjustResize` would be: `WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE`
* `adjustPan` would be: `WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN` | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 10,
"tags": "android, android fragments"
} |
Automatically step over types with no source code attached
While debugging and keep pressing F5, if the source code does not exist, eclipse will open a new window declaring that the source was not found.
How can I make eclipse to only try to step in the code (while I am pressing F5 all the time) if the source code exist and if it does not exist, it would just automatically step over it instead of this "Source not found page". Is this possible? | The best you can do is to use **Step Filters**. Step filters prevent the debugger from suspending in specified classes and packages when stepping into code. Step filters are established with the Java > Debug > Step Filtering preference page. => i.e. you need to manually exclude types or packages for which you do not have source.
A quick way to keep adding step filters as you go along - in the Debug view, the selected stack frame's package or declaring type can be quickly added to the list of filters by selecting Filter Type or Filter Package from the stack frame's context menu. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "eclipse, debugging"
} |
Using C# or jQuery to cause Outlook window to open with a templated body...
Is it possible, and if so how, to use C# or jQuery in an MVC web application to have a button or a link on a page cause Outlook to open up with a set body and subject?
Basically, I want the user to be able to choose a template from a dropdownlist and then click a button or link saying 'Send Templated Email' and have the button/link open up the client's Outlook or default email application with the subject and body populated by the template that they chose.
How could I do that? | You can do this:
<a href="mailto:[email protected]?subject=Subject&body=Body Text">
...
// something like this
$('#btn').click(function () {
$('#link').attr('href', 'mailto:' + $('#email').text() + '?body=' + template[idx].body + '&subject=' + template[idx].subject);
}) | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 1,
"tags": "c#, jquery, model view controller, email, templates"
} |
If tag x then show y + tag name(s)
I would like to have on my `single.php`:
_Tag: Tag1_
Or if more than one Tag:
_Tags: Tag1, Tag2_
The `Tag1` and `Tag2` should link to a custom URL.
I found this, but don't know how to get exactly what I want.
if( has_tag() ) {
// somehow echo "Tags" + Tagnames with custom links seperated by commas.
}
else{
// show nothing
} | you can use the `get_the_tags` function, something along the lines of:
$posttags = get_the_tags();
if ($posttags) {
echo (count($posttags) > 1) ? 'Tags: ' : 'Tag: ';
$links = array();
foreach($posttags as $tag) {
$links[] = sprintf('<a href="%s">%s</a>', get_tag_link($tag->term_id), $tag->name);
}
echo implode(', ', $links);
}
Reference: < | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "tags"
} |
How to implement MD5 check into Inno Setup installer to get 'like NSIS integrity check'?
How to implement MD5 check into Inno Setup, so that it could verify base installer files (exe + bins) on `InitializeSetup` \- this is standard NSIS functionality, which is quite useful as it informs if the installer is OK or corrupted?
In case of IS that would probably require to embed MD5Summer or other MD5 checker and to create MD5 sums during/after the compilation. | What about creating md5 hashes for all .bin files? This should be done in 2 steps:
1) creating md5 hashes from compiled .bin(s) - hashes will be stored as text files inside setup.exe [so this is a 2 step compilation: create .bins, create hashes for .bins and compile again to include hashes into setup.exe]
2) at runtine in InitializeWizard() function using plug-in.
You can easily compare hashes with some Pascal string comparison function or simply '='. If hashes do not match you can exist the installer before any window is shown.
It is important to have small setup.exe - hashes must be always in the same place somewhere near the top of the [Files] section to have fast uncompress. And everything must be solid so adding hashes into setup.exe will not modify the md5 of .bins. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "md5, inno setup, nsis, integrity"
} |
Iterating diagonally through a 2d array
I have to iterate through an 2D array of chars. I already have the code to iterate / but I'm lost when it comes to .
Here is my 2d array:
a,v,i,o,n,l
t,o,t,o,l,l
m,a,r,c,o,e
s,a,g,r,c,i
o,e,n,z,o,g
s,t,r,a,r,u
I already have:
a
tv
moi
....
and I need:
l
nl
ole
....
Here is the code to iterate / :
int size = 6;
for (int k = 0 ; k < size ; k++) {
for (int j = 0 ; j <= k ; j++) {
int i = k - j;
System.out.print( lista[i][j] + " " );
}
System.out.println();
}
for (int k = size - 2 ; k >= 0 ; k--) {
for (int j = 0 ; j <= k ; j++) {
int i = k - j;
System.out.print(lista[size - j - 1][size - i - 1] + " " );
}
System.out.println();
} | Try this:
public class Matrix {
public static void main(String[] args) {
char[][] arr = {
{ 'a', 'v', 'i', 'o', 'n', 'l' },
{ 't', 'o', 't', 'o', 'l', 'l' },
{ 'm', 'a', 'r', 'c', 'o', 'e' },
{ 's', 'a', 'g', 'r', 'c', 'i' },
{ 'o', 'e', 'n', 'z', 'o', 'g' },
{ 's', 't', 'r', 'a', 'r', 'u' } };
for (int n = -arr.length; n <= arr.length; n++) {
for(int i = 0; i < arr.length; i++){
if((i-n>=0)&&(i-n<arr.length)){
System.out.print(arr[i][i-n]);
}
}
System.out.println();
}
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, arrays, loops, 2d"
} |
How to improve the performance of emulator in Android studio?
Whenever I run my small application in Android studio it takes more time to boot in emulator .
My system config as follows
* RAM 4GB
* PROCESSOR dual core
* GPU intel integrated graphics | Intel’s x86 Emulator Accelerator Manager allows developers to run an emulator which performs much faster than a typical emulator running on an ARM-based CPU architecture. It should be noted that this technology only works on Intel VT (Virtualization Technology) enabled systems.You can also enable your emulator to use your machine’s GPU which should make rendering of animations or graphics much faster than it would otherwise be. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "android emulator"
} |
Is there a timer control for Windows Phone 7?
I'm trying to write a win phone 7 app for the first time - is there a timer control similar to the one for winforms? Or is there a way to get that type of functionality? | You can use System.Windows.Threading.DispatcherTimer.
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 500); // 500 Milliseconds
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
void dt_Tick(object sender, EventArgs e)
{
// Do Stuff here.
} | stackexchange-stackoverflow | {
"answer_score": 46,
"question_score": 23,
"tags": "windows phone 7"
} |
How to receive broadcasts when other apps are opened or closed
I want to receive a broadcast intent in my app when other apps are opened or closed or just put aside by pressing the back button.Is there any broadcast intent to do that? | There are no `Intent`s that are broadcast for this. You will need to use the `AccessibilityService` to do this. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "java, android, android broadcast"
} |
Interact with texture / flat surface (Unity)
I don't know exactly how to put this into words, so googling did nothing really for me.
Imagine a bowling game. On the oldern bowling lanes there was only a scheme of the pins above the lane, lighting up all the pins that are still standing, while the ones that already fell, were not lit anymore.
How can I achieve this in Unity? Is there any way to do this, without having to make something stupid like creating hundreds of textures, with all the possible combinations and swap them out?
I'm still very new to Unity, so I'd love to know the best approach to something like this.
Thank you very much in advance | This depends very much on how you are displaying the pin status to the user. If you are using the UI features it could be as easy as setting up a prefab using a game object with an Image Component and a custom script that controls the Image component's image based on the status of an associated pin.
In a 2D Game you can create a prefab with a sprite for the pin statuses and render them over a background at the appropriate location.
If you are attempting to create a texture that gets applied to a mesh, you could do something similar and render that to a texture to be applied to the mesh whenever the pin status changes.
References:
* Unity UI Documentation
* Intro to 2D Games
* Render Textures
* Prefabs | stackexchange-gamedev | {
"answer_score": 1,
"question_score": 0,
"tags": "textures, unity"
} |
Does the method of computing feature weights for linear kernel SVM also works for radial Kernel SVM?
I searched for how to find feature weights and found this stackoverflow answer. It gives the following equation to get the weights:
w = t(model$coefs) %*% model$SV
The answer mentions that the method is for SVM with **linear** kernel. Can I use the same equation for **radial**? Why or Why not? | No you cannot, because for the RBF kernel $\mathbf{w}$ can never be computed explicitly since it is infinite dimensional.
$\mathbf{w}$ is the separating hyperplane _in feature space_ , which for the linear kernel happens to be input space. The only thing you can compute is an inner product between $\mathbf{w}$ and some test instance _in feature space_ via the kernel trick. | stackexchange-stats | {
"answer_score": 2,
"question_score": 1,
"tags": "r, svm, kernel trick, linear"
} |
jQuery Callback function won't take name of function(), must have an anonymous function
This works:
$("#formbottom").slideUp(speed,'swing',function(){
openSubmitting();
});
This doesn't:
$("#formbottom").slideUp(speed,'swing',
openSubmitting()
);
When you have a callback, do you always have to have an anonymous function in there? Can't you just put the function you want to call? | `openSubmitting()` calls your function. You don't want the result of your function. You want your _actual_ function, which is why you write `function() {...}` instead of `(function() {...})()`.
Since you want to pass a reference to your function, remove those parentheses:
$("#formbottom").slideUp(speed,'swing',
openSubmitting
); | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 5,
"tags": "jquery, jquery callback"
} |
mysql import vertical csv data
I have a spreadsheet that is currently formatted improperly for a mysql import. The data are organized by column rather than by row. So, the first column has the field names, the second column contains record 1, and so on.
Is it possible for mysql to understand this data? If not, any ideas on how to import these data besides redoing the spreadsheet?
The data are currently in a google doc.
Edit: I write php, if that helps the matter at all, though I was planning on importing using sequel pro. | You tagged this "import-from-excel"; you could simply select the data in excel, copy, and then use "paste special" to transpose the data (it's a checkbox near the bottom of the "paste special" window; see image).
!alt text | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "mysql, spreadsheet, import from excel"
} |
Grammatik in Konjunktiv mit Passivform
Aus dem _Spiegel-Magazin_ :
> Würde Deutschland die Sterbehilfe so umsetzen, würde dem Sterbetourismus zusätzlicher Aufwind beschert.
Weil der zweiter Teil des Satzes ein Passivsatz ist, müsste man nicht
> ..., würde dem Sterbetourismus zusätzlicher Aufwind beschert **werden**.
schreiben? | Es sind beide Varianten möglich. Der Indikativ lautet ja
> Aufwind wird beschert.
Die verschiedenen Konjunktivformen sind:
> **Konjunktiv I:** Aufwind werde beschert.
> **Konjunktiv II:** Aufwind würde beschert.
> **würde-Konjunktiv:** Aufwind würde beschert werden.
In der Irrealis-Verwendung können nur Konjunktiv II und der würde-Konjunktiv verwendet werden. Stilistisch ist meines Erachtens die Konjunktiv-II-Variante zu bevorzugen, um eine Verdoppelung des Verbs _werden_ zu vermeiden. | stackexchange-german | {
"answer_score": 7,
"question_score": 5,
"tags": "grammar, subjunctive, passive"
} |
Execute ng-include when a button is clicked - Angularjs
I want to execute a `ng-include` and show the content only after a button is clicked. I tried to use the `ng-if` directive and show the div when the `ng-model` is `true`, but his value is not changed in the `myFunction`function.
<div ng-controller='myCtrl'>
<div ng-if='include==true' ng-include='"path"'></div>
<input type="button" ng-click='myFuntion()'/>
</div>
.controller('myCtrl', function($scope){
$scope.include = false;
$scope.myFunction = function(){
$scope.include = true;
}
}) | There is a typo in your `ng-click` function. `myFuntion` should be `myFunction`. You can also just use `ng-if='include'` instead of `ng-if='include==true'`.
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.include = false;
$scope.myFunction = function(){
$scope.include = true;
}
});
<script src="
<div ng-app="myApp" ng-controller="myCtrl">
<div ng-if='include'>Clicked</div>
<input type="button" ng-click='myFunction()'/>
</div> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "javascript, angularjs"
} |
Insight Into A Loop
Hey I got this from StackOverflow, It counts the common values between two dictionaries but I'm hoping someone can take the time to break down the process as it's not explained in the answer section of the topic.
I think I get that;
dictionary1[key] for key in dictionary1 if key in dictionary2 and dictionary1[key] == dictionary2[key]
shared_items = {k: x[k] for k in x if k in y and x[k] == y[k]}
print(shared_items)
Does it only match where the key, value in both dictionaries match? also, why the k: at the start?
Anyway I know it's a random question but this type of iteration is really neat especially when you change the == to <= and >= it can be really useful and hopefully someone can take the time to break it down so I can wrap my head around it. Thanks. | This is known as 'dict comprehension', similar to 'list comprehension'. Basically, the line
shared_items = {k: x[k] for k in x if k in y and x[k] == y[k]}
is equivalent to:
shared_items = {}
for k in x:
if k in y and x[k] == y[k]:
shared_items[k] = x[k] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, dictionary, for loop, iteration, theory"
} |
Recorded video visible on device, but not other media players once uploaded
When I record videos with the rear-facing camera on my Archos 43 Internet Tablet, I am able to watch those recordings on my device, but when I attempt to upload them to online video sharing sites like youtube or blip.tv, they aren't properly recognized or converted. Likewise, when I transfer them to my computer, I can't play the video file correctly. If I transfer the file back to my device, it plays just fine.
I know that the device produces *.mp4 video files.
How can I convert these (corrupted?) videos so that I can see them on my computer and upload them to video sharing sites?
Thanks. | MP4 is a container that can contain different video codecs, it sounds like your device is creating its videos using an unusual codec that not many other devices have loaded by default. As Seth and Hcpl have said VLC Player can play almost any format and should be able to play your videos.
If you want to know what codec is being used, then try opening the video in a codec identifying app like GSpot, this should tell you exactly which audio and video formats and codecs are in your videos. | stackexchange-android | {
"answer_score": 2,
"question_score": 2,
"tags": "video, archos gen8, video recording"
} |
Multiline timeseries plot in Bokeh
How to plot multiline timeseries in `Bokeh`? I got an empty chart with no plots using the two pairs of x and y below:
x1 = ['2017-03-15', '2017-03-16', '2017-03-17', '2017-03-18', '2017-03-19']
y1 = [0.02, 0.02, 0.02, 0.01, 0.0]
x2 = ['2017-03-20', '2017-03-21', '2017-03-22', '2017-03-23', '2017-03-24']
y2 = [0.23, 0.24, 0.25, 0.25, 0.27]
#converting x-axis to datetime
x1 = [datetime.strptime(date, "%Y-%m-%d") for date in x1]
x2 = [datetime.strptime(date, "%Y-%m-%d") for date in x2]
# create a new plot with a title and axis labels
p = figure(title="my Chart", x_axis_label='date', y_axis_label='percentage', x_axis_type='datetime',tools=TOOLS)
p.multi_line(xs = [x1, y1] , ys = [x2, y2], color=['red','green'])
html = file_html(p, CDN, "my plot") | You have your xs and ys arguments set incorrectly in the p.multi_line method.
Try this instead:
p.multi_line(xs = [x1, x2] , ys = [y1, y2], color=['red','green'])
. <
You could also disable any indexes on the table while inserting the data to speed things up, then enable/rebuild the index once you are done inserting. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c#, .net, ado.net, sql server ce, bcp"
} |
look for specific sql requests in java project using regex
What is the best regex to use in order to search all queries in my project with following pattern :
select count(*) as count from ( select .... )A
that is, all queries with one nested sql request ? | This will match a multi line select statement
select((.|\n)*)from((\n|\s)*)\(((\n|\s)*)select((.|\n)*)\)\w
1. select
2. any characters including new lines
3. from
4. spaces and new lines
5. opening parenthesis spaces and new lines
6. select
7. any characters including new lines
8. closing parenthesis
9. a word | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sql, regex, eclipse"
} |
python mbox unlock not working
I am using this script to remove messages from an inbox.
if(not debug):
logging.debug("removing messages")
all_mail.lock()
for message in all_mail:
all_mail.remove(message)
all_mail.flush()
all_mail.unlock()
all_mail.close()
After running this script once, I notice that there is still a lock file in `/var/spool/mail`. If I try running the script again, I get a fairly predictable exception: `mailbox.ExternalClashError: dot lock unavailable`
So it seems like all_mail.unlock() is not working, but I'm not really sure what more to do. | You script should raise an exception at `all_mail.remove(message)` and because of it never reaches the `unlock` call. A `mbox` as important differences from a normal dict, and here is your problem:
> The default Mailbox iterator iterates over **message representations, not keys** as the default dictionary iterator does.
That means that `for message in all_mail:` makes `msg` contains a `mboxMessage` instead of a key and the `remove` raises a `KeyError` exception.
Fix is simple:
for message in all_mail.iterkeys():
all_mail.remove(message) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, email, mbox"
} |
How to change the layout of an iOS app programmatically from LTR to RTL and vice versa?
So, I tried changing the app language programmatically from `English` to an `RTL` language. The text is localized but the layout is still `LTR` until I restart the app that `RTL` takes effect.
Is there a way to make this happen without restarting the app? | I ended up forcing RTL in runtime using the `setSemanticContentAttribute` method like bellow:
if ([NSLocale characterDirectionForLanguage:languageCode] == NSLocaleLanguageDirectionRightToLeft) {
if ([[[UIView alloc] init] respondsToSelector:@selector(setSemanticContentAttribute:)]) {
[[UIView appearance] setSemanticContentAttribute:
UISemanticContentAttributeForceRightToLeft];
}
}
else {
if ([[[UIView alloc] init] respondsToSelector:@selector(setSemanticContentAttribute:)]) {
[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, localization, right to left"
} |
Is there a way to use Xamarin code in a Java Android app or in an Obj-C iOS app?
Pondering the opportunity of writing some libraries in Xamarin rather than having Android and iOS versions.
However, these libraries would be used in third party applications, some of which may be written in Java.
Is it possible to write a Xamarin library in a way that allows it to be integrated in a Java application?
(Same question goes for iOS?) | No, you cannot. Xamarin allows you to consume native libraries via bindings, but you cannot consume Xamarin libraries from native code. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "java, android, ios, xamarin"
} |
how to find first input/select in jquery
I used the following line to do so, but it fails when a select comes on the form. It lefts select and then it stops working even for inputs.
var $ele = $("select,input[type='text'],input[type='password']:visible[required]").filter(function ()
{ return this.value.trim() == '' || this.value.trim().indexOf('--') != -1 ;
}).eq(0); | You may looking for below code.
$('form').find('input[type=text],select').filter(':visible:first') | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "jquery"
} |
Validating user's API credentials - PayPal DoDirectPayment
Hello I am working on a site that accept PayPal API Credentials for every restaurant owner so that amount could be transferred to their account directly.
The problem that I am facing, some times restaurant owners add wrong API credentials so when any order is placed the error "Security Header is not valid" appears means their API credentials is wrong.
The solution I want is that the API Credentials could be verified when they are added by restaurant owner, so that order could be placed by end user.
Is there any way to Verify/Validate PayPal API Credentials(User Name, Password, Signature), Please help.
Thanks in advance! | PayPal Don't have any External API to validate the API Credentials alone. instead. You can Use the Express Checkout SETEXPRESSCHEKOUT API to call with very Minimal data and the API credentials, which will validate the API credentials and will generate a Token. If you get a Token it means the API credentials is correct. This will not do any money Movement with this API Call. PP have this API available in both NVP and SOAP format. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "api, paypal, credentials"
} |
Setting listen() backlog to 0
When listening on a socket, I would ideally like to limit the backlog to zero, i.e.
listen( socket, 0 );
However, based on the following post, listen() ignores the backlog argument?, this wouldn't work. Is there any way I can reliably achieve a backlog of 0? | The closest you can get is to `listen()`, `accept()` and `close()` in one step. This should provide the same overall effect as a backlog of zero, except that you must re-create and bind the socket each time.
int accept_one(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
int result;
result = listen(sockfd, 1);
if (result >= 0)
result = accept(sockfd, addr, addrlen);
close(sockfd);
return result;
}
I am not sure why you would want this, though. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c, linux, sockets, listen"
} |
Extent reports - Image not displayed when html page is opened with Intellij IDEA
In Intellij IDEA 2019.3.3, I have a java project with selenium, testng and extent reports which runs automated tests on a website. The code generates html reports for the tests and saves screenshots of test failures to display them in the reports. The code puts the absolute path for screenshots in the html code of the failed tests in these reports.
When I open a html test report via Intellij (report > right click > open in browser > chrome), the thumbnail of the screenshot is not present. There is no placeholder either. Is this bug? If not, then do I need to change any setting in Intellij IDEA for the thumbnail to show up?
PS - I tried to open the report with chrome and firefox and faced the same issue. I have not tested this with a simple java project having an html page in a folder in that project. You can try it. | I don't know if this is a bug or a feature in Intellij IDEA. But, the simple solution is to open your html report directly with your browser. The image thumbnails show up there. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "intellij idea"
} |
How do I pass Rails' cycle() an array of values to cycle through?
I'd like the cycle method to take an array of values which I compile on the fly, but it seems to be interpreting it not as I'd have hoped.
(In this example it's a static array, but I want it to work so that I can use arrays that are constructed variably)
- some_array = ['one', 'two', 'three']
- colors.each do |color|
%a{ :name => color, :class => "#{cycle(some_array)}" }
That applies this as a class to each element:
"three"] "two", ["one",
...looks as though it's calling `to_s` on the array or something.
How am I supposed to be doing this? | `cycle` takes multiple arguments and cycles through them. You're passing a _single_ argument, an array.
You can use the splat operator to change the array into these multi arguments:
cycle(*some_array)
This will act as if you did:
cycle("one", "two", "three")
Rather than:
cycle(["one", "two", "three"]) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "ruby on rails"
} |
Django Custom Template Tags
Boa tarde, recentemente estou com um problema no framework Django, estou com um problema em meu custom template tag, eu faço o método em um arquivo.py chamo ele no templates e não exibe o resultado que quero, podem dar uma olhada fazendo favor?
Seguem os arquivos:
**time_tags.py**
from django import template
from datetime import date
register = template.Library()
@register.filter
def informa_data(value):
today = date.today()
weekday = today.weekday()
if weekday == 4:
return str(today)
else:
return 'nao e sexta'
**template.html:**
Inseri `{% load time_tags %}` logo abaixo dos:
{% extends 'base/base.html' %}
{% load staticfiles %}
E em algum determinado lugar dentro do `<body>`:
<p>
{{ instance.content|informa_data }}
</p> | Após um diálogo, e entendendo o real problema chegamos na seguinte solução:
# views.py
def from_friday_to_friday(now=datetime.now()):
days_from_friday = (now.weekday() - 4) % 7
first_friday = now - timedelta(days=days_from_friday)
myfridays = {
'first_friday': first_friday,
'second_friday': first_friday + timedelta(weeks=1)
}
return myfridays
def home(request):
ctx = {'myfridays': from_friday_to_friday()}
return render(request, 'index.html', ctx)
e o template
# index.html
<p>{{ myfridays.first_friday|date:"d/m/Y" }} à {{ myfridays.second_friday|date:"d/m/Y" }}</p> | stackexchange-pt_stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, django, template, html tags"
} |
How can i determine the position of textarea cursor relative to the window in x,y?
I am trying to create a javascript code editor just for learning and I am doing a great job so far. The only thing is that I wanna place the autocomplete box in a position relative to the text cursor in textarea. So how can I determine the cursor position relative to the upper left corner of the window ?
Something else please, how can i capture the tab & enter keys press in a textarea ?
I am using a semi-transparent textarea (semi to keep the cursor blinking) with underlying div to enable code highlighting later on. Is this the best technique to do that ? Or there is a way to make textarea accept rich text or HTML ? | I suspect that you can do all that without a textarea. Read up on the contentEditable property. Here's a demo. This is how the Google Docs editor is implemented, incidentally. And here's a stackoverflow question dealing with finding the cursor position in a contentEditable div. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript"
} |
CakePHP - Html->link - why use controller=> and action=> instead of just controller/action
**Why this:**
echo $this->Html->link('Add a User', array('controller'=>'users', 'action'=>'add'));
**Instead of just this:**
echo $this->Html->link('Add a User', 'users/add'); | The second example will always generate a url of 'users/add'. The first provides the potential of using reverse routing to form a bespoke url, as defined by the rules in your routes.php file.
In practice I often find that there's no difference between the first and the second style. However, if you later decide to make changes to your routes, you might find that doing things the first time saves time in the long run, so you don't have to go back and change the path for every link... | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 4,
"tags": "php, cakephp, cakephp 1.3"
} |
how to redirect https requests to http
I have a site on my machine (localy).
Users used to access it using both HTTP and HTTPS. Now there is a problem with HTTPS configuration.[ It is not working]
**Is it possible to redirect HTTPS requests to the HTTP port temporarly?** | in your .htaccess file paste this code:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) [R=301,L] | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "apache, http, https"
} |
How do you check if user typed the specific word inside a textarea?
How do you check if user typed the specific text inside the textarea tag? Here is an example
</head>
<body>
<textarea>
</textarea>
<div class="box">
</div>
<script>
(this is just example)
if = user typed inside textarea this =("display (hi)")
do = build element inside .box the user typed inside the () of the text "display"
</script>
I really don't know how to do it i try to search it but none appeared and if you're confused with code it just glitched | I hope it will give you idea. If use type any text and includes hi in textarea. It's will show all text in box container.
let textarea = document.querySelector("textarea");
let box = document.querySelector('.box');
textarea.addEventListener('keyup', (e) => {
if (e.target.value.includes("hi")){
box.innerHTML = "";
box.append(`${e.target.value}`);
}
})
<textarea></textarea>
<div class="box"></div> | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 1,
"tags": "javascript, html"
} |
`published` / `unpublished` webhooks sent before content is available
So I'm trying to build a content pipeline with Kentico Cloud. One of the requirements is that pressing the big green Publish is not the final step of the process. The published content then has to be collected, its representation transformed and forwarded elsewhere. Subscribing to `publish` / `unpublish` webhook events then processing the related content looked like the way to go, but apparently these are sometimes firing before the content is available via the Delivery API.
What are my options? I really don't want to do polling - the nested structure of the content combined with the inability to filter by parent items makes it far from trivial. | As it turns out, the answer is right there in the API docs: <
> _X-KC-Wait-For-Loading-New-Content_
>
> If the requested content has changed since the last request, the header determines whether to wait while fetching content. This can be useful when retrieving changed content in reaction to a webhook call. By default, when the header is not set, the API serves old content (if cached by the CDN) while it's fetching the new content to minimize wait time. To always fetch new content, set the header value to `true`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "kentico kontent"
} |
How to make rsync to use relative path?
I want to sync remote database copy using command
rsync --relative user@remote:/backup/databases/*.sql /backup/snapshots/
As it's result command creates file `/backup/snapshots/backup/databases/mysql.sql`. How can I force it to put file in `/backup/snapshots/mysql.sql`? It's mandatory that source must be remote (it's part of more complex script). | I think you **don't** want to use the `--relative` flag, as this creates subdirectories in the target location. Have you tried this?
From the man page:
-R, --relative use relative path names | stackexchange-superuser | {
"answer_score": 8,
"question_score": 8,
"tags": "linux, ubuntu, rsync"
} |
Show that $\langle v,w\rangle ^2 =\langle v,v\rangle\langle w,w\rangle$ if and only if $v$ is parallel to $w$
Let $ \langle.,.\rangle$ be the usual scalar product, show that $\langle v,w\rangle ^2 =\langle v,v\rangle\langle w,w\rangle$ if and only if $v$ is parallel to $w$.
this was asked after proving that every scalar product satisfies the inequality, which i managed to do. any help on this please]
just to clarify, I'm having troubles proving the forward part, so I have proved that if $v$ is parallel to $w$ then the equality holds, just can't do the other way. | This basically comes from the proof. You're expanding $\langle u-tw, u-tw\rangle$, and noticing that $0 \leq \langle u-tw, u-tw\rangle$, then picking a normalizing $t$ to give you the inequality. It's clear then that to get _equality_ you need $u=tw$, no matter what $t$ you chose, i.e. linear dependence. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "real analysis, cauchy schwarz inequality"
} |
A twice differentiable function $ f(x)$ is such that $f(a) = f(b) = 0$ and $f(c) \gt 0$ for $a\lt c\lt b$
> Prove that there is at least one point $\varepsilon$, $a\lt \varepsilon \lt b$, for which $f''(\varepsilon) \lt 0$.
My approach : By Rolle's Theorem , $ \exists \alpha \in (a,b)$ such that $f'(\alpha) = 0$.
And as $f(x)$ is differentiable in $[a,b]$ it is also differentiable in $[a,c]$ then by Lagrange Mean value theorem, $\exists \,\beta \in (a,c)$ such that $f'(\beta) = \frac{f(c)-f(a)}{c-a} \gt 0$ since $f(c)>0$, $f(a) = 0$ and $c>a$.
Now assuming $ \alpha \gt \beta$ , and since $f(x)$ is twice differentiable, applying LMVT on $f'(x)$ in the interval $(\beta,\alpha)$, we get that there exists an $\varepsilon \in (\beta,\alpha)$ such that $f''(\varepsilon) = \frac{f'(\alpha)-f'(\beta)}{\alpha - \beta} \lt 0$.
I have assumed $\alpha \gt \beta$, is there a concrete way to prove without assuming? Thank You. | As you suspect, your argument is flawed. Here is a simpler way:
$f(c) > 0$, so by the Mean Value Theorem, there exist $\alpha \in (a,c)$ and $\beta \in (c,b)$ such that $f'(\alpha) > 0$ and $f'(\beta) < 0$.
Now use the Mean Value Theorem on the function $f'$ and the interval $(\alpha,\beta)$. | stackexchange-math | {
"answer_score": 4,
"question_score": 0,
"tags": "real analysis"
} |
If $A,B$ are real symmetric $n\times n$ matrices with $A^{2k+1}=B^{2k+1}$, then is $A=B$?
Let $A,B$ be two $n\times n$ real symmetric matrices with $A^{2k+1}=B^{2k+1}$ for some integer $k\geq0$, then is it necessarily the case that $A=B$? We require the exponent to be odd since for any matrix, $(-A)^{2k}=A^{2k}$ so this statement is trivially false.
I know that $A,B$ must both have a basis of orthogonal eigenvectors, so $A=Q_1\Lambda_1Q_1^T$ and $B=Q_2\Lambda_2Q_2^T$ with $\Lambda_i$ diagonal and $Q_iQ_i^T=I_n$ ($i=1,2$), so the equation is equivalent to $Q_1\Lambda_1^{2k+1}Q_1^T=Q_2\Lambda_2^{2k+1}Q_2^T$. I'm not sure how to continue from here except to write $(Q_2^TQ_1)\Lambda_1^{2k+1}(Q_2^TQ_1)^T=\Lambda_2^{2k+1}$.
Moreover, can we somehow generalize this? | $\newcommand{\diag}{\mathrm{diag}}$ You made a good attempt. To continue, let $\Lambda_1 = \diag(\lambda_1, \ldots, \lambda_n), \Lambda_2 = \diag(\mu_1, \ldots, \mu_n)$. Then you have reached \begin{align*} Q_2^TQ_1\diag(\lambda_1^{2k + 1}, \ldots, \lambda_n^{2k + 1}) = \diag(\mu_1^{2k + 1}, \ldots, \mu_n^{2k + 1})Q_2^TQ_1. \end{align*} Denote $Q_2^TQ_1$ by $P = (p_{ij})_{n \times n}$, then comparing the $(i, j)$ entries of both sides of $$P\diag(\lambda_1^{2k + 1}, \ldots, \lambda_n^{2k + 1}) = \diag(\mu_1^{2k + 1}, \ldots, \mu_n^{2k + 1})P$$ yields $p_{ij}\lambda_j = \mu_ip_{ij}$, i.e., $$P\diag(\lambda_1, \ldots, \lambda_n) = \diag(\mu_1, \ldots, \mu_n)P.$$ That is, $A = B$.
Similar argument is also used in showing the square root of a positive semi-definite symmetric matrix is unique. | stackexchange-math | {
"answer_score": 3,
"question_score": 3,
"tags": "linear algebra"
} |
Possible to specify boot partition size during the installation?
I would like to install Ubuntu 14 as the only OS on my laptop. I will be installing from a USB stick. Learning from my recent experience, I would like to specify a boot partition size much larger than the default (which is about 250MB, leading to problems with system updates).
Is it possible to specify boot partition size during the installation? | You can choose the "something else" option and set up your partitions just the way you like, but it is best to simply not have a boot partition at all. This is normally the default, unless you enable full disk encryption, then you have to have one. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "partitioning, system installation"
} |
C++ non platform-dependant sound
I need this: A c++ function that can output sounds onto a speaker, that is not platform dependant(like Beep()). I also need something that can output some real-time generated sounds, not a .wav file or so.
Thanks for the support! | I like: <
It attempts to be a cross platform alternative to direct X. The zlib license it uses is very permissive. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c++, audio, cross platform"
} |
How to place columns of data set from excel file into numeric arrays
I have an excel file that I grab by:
ds = dataset('XLSFile',fullfile('file path here', 'waterReal.xlsx'))
It looks like this:
!Dataset content
I want each column in its own numeric array though! Like how when I load an example dataset: load carsmall, I get a bunch of individual numeric arrays. But I can't figure out how to do that.
I can do this individually by writing:
A = ds.TEMP, B = ds.PROD, ...
Bu what if I had BIG excel file? What then? | You can convert a dataset to a struct or a cell like this:
To struct:
s = dataset2struct(ds, 'AsScalar',true)
To cell:
fnames = fieldnames(ds);
c = cell(1, numel(fnames));
for i = 1:numel(fnames)
c{i} = ds.(fnames{i});
end
By the way: use `table`s instead of `dataset`s. They're newer and better. Use the `readtable` function to read your Excel file into a table. And tables are nicer enough that you might not want to bother converting them into a simpler cell array, because you can just grab the columns out with `t{:,i}` where `t` is your table and `i` is the index of the column you want. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "matlab"
} |
AngularJS get DOM element after push
i'm using ng-repeat to display some array values (messages). How do i get the corresponding DOM element after pushing it to the messages array?
I want to add and remove a class(es) from the added dom element.
Thank you, Bernhard | The Angular way is not to directly manipulate the DOM but to use the directives provided to you by the framework. To change the CSS classes applied to an element, use ngClass, ngClassEven, and ngClassOdd.
<div ng-repeat="item in items">
<span ng-class="{active: isActive(item)}">{{item}}</span>
</div>
The parameter to ngClass is a JavaScript object which keys are the names of the CSS classes, and values are expressions. For each key-value pair, if the expression results in true, the class is added, otherwise it is removed.
ngClassEven and ngClassOdd can be used to apply classes only to even or odd elements of the repetition. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "angularjs"
} |
form processing with javascript
Is there any way to completely process a form using only javascript & html ? I need to process a form for a school project but using only JS & HTML with no use of cgi scripts, php,… I don’t want anyone to actually make my homework for me, just a pointer in the right direction :)
edit: With processing the form i mean the onSubmit action, submit the info to the administrator either through mail, write it to a file, ... I have already made a script to validate the inputs. | Form Processing which I am assuming at the very least will be adding the form data to database and validate ofcourse.
You can validate using jQuery[a js Library] Validate
Also you can post form data using jQuery Ajax | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "javascript, html, forms"
} |
Flot Grid with Customised Borders
Flot enables us customise grid borders. This is documented here with the following:
grid: {
borderWidth: number or object with "top", "right", "bottom" and "left" properties with different widths
borderColor: color or null or object with "top", "right", "bottom" and "left" properties with different colors
}
However, I couldn't manage to come up with a successfully working example. To create a custom grid with top and left border with white color I tried the following, but it didn't work:
grid: {
borderWidth: {top: 1, right: 0, bottom: 0, left: 1},
borderColor: {top: "#FFF", left: "#FFF"}
}
Can anyone provide a working example? | Which version of flot are you using? The borderWidth property did not accommodate an object as the value until version 0.8. Make sure you are using the latest version (0.8.1) and give it another shot. The only other thing I notice is the missing comma after the borderWidth values. Should be "left: 1 } **,** borderColor..." | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 3,
"tags": "javascript, flot"
} |
how to allow all users to get download link from firebase_Storage
I am trying to allow all users to get download links of files in firebase_storage , but when I send request for a file I get permission denied
here is my firebase_Storage rules
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if false;
}
}
} | I changed the "false" to "true" And it worked | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "firebase, flutter, firebase storage"
} |
Is there any tool/library/api (or anything at all) to categorize youtube videos
I am trying to categorize videos on Youtube e.g. Entertainment, Nature, Educational, etc etc. Because many Youtube channels don´t use helpful hashtags, any video would be hard to categorize. I am trying to create a filter where I watch YouTube videos only based on my mood /need and categorizing them would help. Is there any automatic way? | There is a YouTube API already that has this. Read through the documentation bellow for more details
< | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": -3,
"tags": "python, web scraping, filter, youtube api, categorization"
} |
How can I make my desktop quieter?
My computer is very loud, how do you recommend I make it quieter?
What steps can I take to make it sound softer? | Install silicon washers on disk drive and fan mounts, to dampen vibration. Replace components with quieter ones. Underclock your PC. Clean your PC (as SS said). Move the PC farther away. Get sound dampening cushions and install then between line-of-site(sound) between you and the PC (make sure it does not block airflow). | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "audio, desktop computer"
} |
If a spell that is junctioned is used, when does the stat become affected
in Final Fantasy VIII some of the more useful spells have the best boosts/effects when junctioned, however in battle where you would want to use certain heal/positive stat spells or in the Adel battle where using GF's is a bad idea thus kinda forcing you to use Magic you can still use these spells
so i am wondering, when a spell that is junctioned is used, when does the stats become affected, is it during the battle or after, i'm not just talking about base stats but also resistances (ie. using Protect/Shell/Reflect to boost multiple elemental/status resistances) | The stats are affected IMMEDIATELY. (This is a common criticism of the battle system - it encourages you to hoard spells/never cast magic). | stackexchange-gaming | {
"answer_score": 4,
"question_score": 3,
"tags": "final fantasy 8"
} |
How to get a href of drag and drop
checking this sample. <
i was wonder how to get when You drop a < li >. (by href) | If I understand you correctly: You want to get the href attribute of the element being dropped? If so you can view source on that page and look on line 131.
var el = document.getElementById(e.dataTransfer.getData('Text'));
the `el` element has an `href` attribute so you can do: `el.href` and that will give you the href you are asking for and in this case it will return `html5demos.com/drag#` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, html, drag and drop"
} |
Trying to call this method in my view and pass the input to the method argument
Here is my method in my user controller:
def donation_custom(amount)
@user = current_user
@user.amount_donated += amount
@user.save
redirect_to root_path, :alert => "thanks for donating"
end
I just need a simple input form in my view so i can call this method and pass the user input to my "amount" argument.
thanks in advance! | Why not just stick with the RESTful way of doing this? Create a custom setter method in your User model:
validates :add_amount, numericality: {greater_than_or_equal_to: 0}
def add_amount=(value)
self.amount_donated += value
end
then create a simple form that captures this:
<%= form_for @user do |f| %>
Amount to donate <%= f.text_field :add_amount %><br>
<%= f.submit "Donate!" %>
<% end %>
and then use your `UsersController#update` method to set this:
def update
@user = User.find(params[:id])
# you'll probably want to add some error checking here
@user.update_attributes(user_params)
redirect_to root_path, notice: "Thanks for donating!"
end
private
def user_params
# you'll probably want to whitelist other parameters here
params.require(:user).permit(:add_amount)
end | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, ruby, methods, view, simple form"
} |
Primefaces Lightbox: How to call hide()-method
I have a lightbox with only one image. Yes, I know its not really inteded for that.
<p:lightBox styleClass="imagebox" widgetVar="light">
<h:outputLink value="#{imageBean.getImageResourceLink(id)}" title="#{name}" onclick="light.hide();"/>
<h:graphicImage library="thumb_lib" name="#{id}" width="165"/>
</h:outputLink>
</p:lightBox>
Now I want the lightbox to be closed/hided when I click inside the opened lightbox. This doesn't work as expected. Only when I click the lightbox navigation-arrows the lightbox hides. Good, hiding somehow works. But how can I hide it by just clicking inside the lightbox?
How can I achieve this?
Jonny | Don't see any "onclick" events inside the `p:lightBox`
So I guess you could use the help of jQuery...
The following should work just fine (add to your js file or script tag)
jQuery(document).delegate(".imagebox", "click", function (event) {
light.hide();
});
or
jQuery(document).delegate(".ui-lightbox-content-wrapper", "click", function (event) {
light.hide();
});
if your lightBox got an id you can use `....delegate("#idOfLightBox ",....` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "jsf 2, primefaces"
} |
Name of Googles Syntax Highlighting
I wondered what the name of googles syntax highlighting is, that they use on their googlesource.com page and for example Chromium. | Have a look here, prettify might be a candidate.
And here it says
> Powers code.google.com and stackoverflow.com
However if I look at the Chromium site, it mentions gitiles, But I fail to spot more than a
> `import syntaxhighlight.ParseResult;`
In the code. It might be the Java port of prettify: java-prettify
**Update:**
The COPYING file lists prettify.
**Update:**
The WORKSPACE file lists java-prettify.
> `artifact = "com.github.twalcari:java-prettify:1.2.2",` | stackexchange-softwarerecs | {
"answer_score": 0,
"question_score": -1,
"tags": "chrome, chrome os"
} |
Add element to arraylist inside haspmap in java 1.4
I need to work in java 1.4 which doesn't support generics. This is the code I wrote in java 8
LinkedHashMap<String, ArrayList<String>> m = new LinkedHashMap<>();
ArrayList<String> vals = new ArrayList<String>();
m.put("a", vals);
m.get("a").add(var_name);
After reading jdk 1.4 docs, I managed to get write the below code but how do I add an element to ArrayList inside the map? I don't want to add the values to ArrayList first and then add the ArrayList to map.
LinkedHashMap m = new LinkedHashMap();
ArrayList vals = new ArrayList();
m.put("a", vals); | You have to cast beforehand
((ArrayList)m.get("a")).add(var_name);
Of course, if you want to use that value later, you'd have to cast that as well. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "java, arraylist, hashmap, java1.4"
} |
If I appear offline on steam and play a game like that, will the game appear under "recently played" on my profile?
I want to be "offline" at times to everyone and while "offline", I want to be able to play something. If I play a game while in this "offline" state, will it come up under the "recent activity" section on my profile? | **Yes, it will**. Setting your status to "offline" is related to the Steam chat only. It won't hide your activity, it will even show you as "Now Playing" on the game's store page, achievements you earn will be shown to friends, etc.. If you are actually in offline mode, the activity and achievements will update once you go online. | stackexchange-gaming | {
"answer_score": 4,
"question_score": 4,
"tags": "steam"
} |
What is dom for in the lib array in the tsconfig.json file in Angular?
In my Angular 6 project, in tsconfig.json and ts.config.spec.json I have this part:
"lib": [
"es2016",
"dom"
]
What is `dom` for?
Official documentation here says: "... you can exclude declarations you do not want to include in your project, e.g. DOM if you are working on a node project using --lib es5,es6."
But I am not sure what this means in practice. We do not specify "any declarations you do not want."
My tests were totally broken until I added `dom` to the `lib` array in tsconfig.spec.ts. What does this do? | `dom` lib is a set of JavaScript Web API interfaces, including DOM, DOM Events, Audio, Canvas, Video, XHR API... You can see full source code here
Of course you should include this library if you are developing frontend web. For backend Node.js development, it is optional. However, there is some Node.js package that is used for both frontend and backend. And you will meet type missing error when compiling without including it | stackexchange-stackoverflow | {
"answer_score": 13,
"question_score": 13,
"tags": "javascript, angular, typescript, config"
} |
How to grow/shrink a TextBlock (Font Size) to the available space in WPF?
I've seen this question asked a lot, however, to the opposite of what I'm looking for. While other people want a control to size itself based on the size of text, I'm trying to figure out is if there is a way to grow the size of text to the amount of space available.
Take the idea of a digital clock window and you want the numbers stating the time to grow (or shrink) based on the size of the window the clock is in. If there isn't a way to automatically do this any pointers to a programmatic way I can get this accomplished? | The WPF Viewbox control will grow / shrink its contents to the available space:
<
Just place your TextBlock within a ViewBox:
<Viewbox Stretch="Uniform" Width="50" Height="50">
<TextBlock Text="Test" />
</Viewbox>
Of course, your Viewbox is typically scaled by its container, but hopefully you get the idea! | stackexchange-stackoverflow | {
"answer_score": 57,
"question_score": 32,
"tags": "c#, wpf, font size, textblock, wpf 4.0"
} |
How can I add a new host to an existent Oracle ACL?
I cannot find what command to use to add a host to an existent ACL on Oralce. Let's assume my ACL is called users.xml, how can I add host "remote.host.net" ? Notice I'm on Oracle 11gR2 | I believe what you what you'd want to do is this:
BEGIN
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
acl => 'users.xml',
host => 'remote.host.net',
lower_port => <whatever>,
upper_port => <whatever>);
COMMIT;
END;
/ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "oracle11g, acl"
} |
US bank w/ free online incoming/outgoing international wire transfers, no monthly charges, online application
What US banks let me do the following:
% Send and receive international wire transfers for free
% Send wire transfers online
% Pay no monthly fees
% (optional) Apply for an account online.
Accounts requiring a minimum balance of up to $50K are fine, but I'm not a student, senior, etc.
I've googled this, but everything I found is obsolete.
I realize I'm asking a lot, but:
<
has much of what I want (and is my fallback), so I don't think my requirement list is unreasonable. | frostbank.com is the closest thing I've found, so accepting this (my own) answer :)
EDIT: editing from my comment earlier:
frostbank.com has free incoming international wires, so that's a partial solution. I confirmed this works by depositing $1 (no min deposit requirement) and wiring $100 from a non-US bank. Worked great, no fees, and ACH'd it to my main back, no problems/fees. No outgoing international wires, alas. | stackexchange-money | {
"answer_score": 2,
"question_score": 19,
"tags": "online banking, free, international transfer"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.