response_k stringlengths 15 30.7k | has_code_k bool 2
classes | question stringlengths 12 50.5k | url_question stringlengths 41 44 | qid int64 17.9k 74.7M | response_j stringlengths 26 29.8k | date stringlengths 10 10 |
|---|---|---|---|---|---|---|
Looks like built-in `iter` doesn't check for `next` callable in an instance but in a class and `IteratorWrapper2` doesn't have any `next`. Below is simpler version of your problem
```
class IteratorWrapper2(object):
def __init__(self, otheriter):
self.next = otheriter.next
def __iter__(self):
... | true | As part of some WSGI middleware I want to write a python class that wraps an iterator to implement a close method on the iterator.
This works fine when I try it with an old-style class, but throws a TypeError when I try it with a new-style class. What do I need to do to get this working with a new-style class?
Exampl... | https://Stackoverflow.com/questions/1152238 | 1,152,238 | There are a bunch of places where CPython take surprising shortcuts based on *class* properties instead of *instance* properties. This is one of those places.
Here is a simple example that demonstrates the issue:
```
def DynamicNext(object):
def __init__(self):
self.next = lambda: 42
```
And here's what... | 2009/07/20 |
Or you could use RegEx:
```
var str = "<name>";
var reg = /[<>:\/?#\[\]@!]/g
//add more characters to the RegEx
var newStr = str.replace(reg, "");
console.log(newStr);
``` | true | I was trying to find and replace string by JavaScript but my routine is not working. I guess there is some mistake. Please guide me what to fix in js routine. Here is my script.
```
function ReplaceChars(srcString)
{
var IgnoreChars = ['<', '>',':', '/', '?', '#', '[', ']', '@', '!', '$', '&', '(', ')', '*', '', '... | https://Stackoverflow.com/questions/26675576 | 26,675,576 | You're almost there.
IgnoreChars is an array - not a String - so it doesn't have a charAt function;
change this line:
```
if (srcString.charAt(i) == IgnoreChars.charAt(j))
```
to
```
if (srcString.charAt(i) == IgnoreChars[j])
```
Here's a fiddle: <http://jsfiddle.net/q0ztudLd/> | 2014/10/31 |
You should use a backslash(`\`) before using `'` . Because `'` is a special character.
So, you should use as follows,
```
case '\'':
printf("039");
break;
``` | true | I met a problem when I try to send email in Java by using Gmail SMTP.
Once I started the email feature, there will be a email window pop out:
[](https://i.stack.imgur.com/DKtUu.png)
The user will key in the subject and email content and then send an... | https://Stackoverflow.com/questions/71693629 | 71,693,629 | You can use an escape sequence.
```c
case '\'':
printf("039");
break;
``` | 2022/03/31 |
+1 for jfriend00's answer.
But including jQuery in a page overwrites both of the global symbols jQuery and $ (see [jQuery.js line 9579](https://github.com/jquery/jquery/blob/10399ddcf8a239acc27bdec9231b996b178224d3/test/data/jquery-1.9.1.js#L9579)) potentially causing conflicts with other libraries that define a globa... | true | I need help understanding this pattern for jQuery plugin authoring. Can somebody explain this simple bit of code for me?
```
(function($) { /* Code here */ })(jQuery);
```
I know this is to avoid conflict with different plugins using the same `$` character but somehow cannot get around my head to understand how it w... | https://Stackoverflow.com/questions/19610586 | 19,610,586 | A function in JavaScript can [be either a statement or an expression](http://kangax.github.io/nfe/#expr-vs-decl). When you use a function expression, you can pass it around like any other value:
```
> console.log(function() { 1 + 1; });
> (function() {}) && doExpensiveWork();
// etc.
```
One of the things you can do... | 2013/10/26 |
The click is bound to the element not the class.
Maybe you can attach the events to the - elements and detect/toggle the elements classes:
```
$('li').click(function(event) {
event.preventDefault();
if( $(this).hasClass('on') ) {
$(this).removeClass('on');
}
else {
$(this).addClass('on... | true | I have two list items that, when clicked, should change classes from '.off' to '.on'. Only one element should be '.on' at a time so when one is already turned on and the other is clicked both elements should change classes from '.off' to '.on' and vice versa. If a list item with a class of '.on' is clicked it should ch... | https://Stackoverflow.com/questions/9036106 | 9,036,106 | I would suggest adding a click handle to a different selector, this should work for you...
```
$("ul li a").click(function(e){
e.preventDefault();
if($(this).hasClass("off")){
$("ul li a").addClass("off").removeClass("on");
$(this).addClass("on").removeClass("off");
}
else{
$(this).addCl... | 2012/01/27 |
this is my solution
S = input("Input a word: ")
```
def isPalindrome(S):
for i in range(0, len(S)):
if S[0 + i] == S[len(S) - 1]:
return "True"
else:
return "False"
print(isPalindrome(S))
``` | true | I'm doing some python online tutorials, and I got stuck at an exercise:A palindrome is a word which is spelled the same forwards as backwards. For example, the word
racecar
is a palindrome: the first and last letters are the same (r), the second and second-last letters are the same (a), etc. Write a function isPalind... | https://Stackoverflow.com/questions/11758791 | 11,758,791 | A one line solution but O(n) and memory expensive is :
```
def isPalindrome(word) : return word == word[::-1]
```
A O(n/2) solution that uses the same amount of memory is:
```
def palindrome(word):
for i in range(len(word)//2):
if word[i] != word[-1-i]:
return False
return True
```
... | 2012/08/01 |
Blit means 'BL'ock 'I'mage 'T'ranfser
When you are displaying things on the screen you will, in some way, use `screen` because that's where you are putting it.
When you do:
```
pygame.draw.circle(screen, (0, 0, 0), (100, 100), 15, 1)
```
you are still using screen but you are just not blitting because pygame is dr... | true | I've just started learning some pygame (quite new to programming overall), and I have some very basic questions about how it works.
I haven't found a place yet that explains when I need to blit or not to include a certain surface on the screen. For example, when drawing a circle:
```
circle = pygame.draw.circle(scree... | https://Stackoverflow.com/questions/17454257 | 17,454,257 | The short answer
================
>
> I haven't found a place yet that explains when I need to blit or not to include a certain surface on the screen.
>
>
>
Each operation will behave differently, and you'll need to read the documentation for the function you're working with.
The long answer
===============
Wha... | 2013/07/03 |
Unless you really want or have to do it yourself I would use `numpy`.
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.var.html>
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.normal.html> | false | I have a code which calculates the square of a number using Gaussian distribution in python. Now my task is to calculate the variance for the same. But when I try, i keep getting error. The code is as follows:
```
import random
def generate_data(size):
n = 5
m =0.5
mu, sigma = n ** 2, m/3
return [rando... | https://Stackoverflow.com/questions/32867324 | 32,867,324 | Your variance formula should be
```
variance = sum(map(lambda x: (x-avg) ** 2, ls)) / len(ls)
```
[source](https://en.wikipedia.org/wiki/Variance#Discrete_random_variable)
Since `variance = sigma^2` you can test your code by printing `math.sqrt(variance)`
```
import random, math
def generate_data(size):
n = 5... | 2015/09/30 |
You can do it like this:
```
import random
weight_dict = {
1:"A",
2:"B",
3:"C"
}
def show_rand():
key = random.choice(list(weight_dict))
print ("Random key value pair from dictonary is ", key, " - ", weight_dict[key])
show_rand()
``` | true | I've been working on a little project with Java Spring. I've already set the table structure in Navicat to be able "null" values. I have also set the model to be able to null values.
But still, I can't input null values into the column and received this error messages.
FYI: I'm using Spring Tool Suite 3.9.7 IDE
```
... | https://Stackoverflow.com/questions/57302415 | 57,302,415 | Do you want it to select values instead of keys, or both?
If both - Noufal Ibrahim's answer works.
If only value - you can call `.values()` instead of `.items()`:
```
from random import choice
example = {'a':1, 'b':2}
choice(list(example.values()))
``` | 2019/08/01 |
Actually it's pretty easy. You just have to understand what the HEX values mean.
In the hexadecimal system each number from 10 to 15 is represented by the letters A to F. The numbers lower ten are normal numbers 1 - 9. So if you want to convert 11 into hex it would be 0B. Because you need no number below 11 (0) and the... | false | I have an existing fn that does the following:
```
public GetColor = (argb: number) => {
var a = 1;// (argb & -16777216) >> 0x18; // gives me FF
var r = (argb & 0xff0000) >> 0x10;
var g = (argb & 0x00ff00) >> 0x8;
var b = (argb & 0x0000ff);
var curKendoColor = kendo.parseC... | https://Stackoverflow.com/questions/35995696 | 35,995,696 | Ok I was able to get something that seems to work for me. I am simplifying it a bit but for the ARGB i can do something like
```
val = "0xFFFF0000"
val = parseInt(val, 16)
if((val & 0x80000000) != 0)
{
val = val - 0x100000000;
}
```
So for example for Red with an A of FF I would get-
-65536 or with unsigned I ca... | 2016/03/14 |
I believe this line is problematic:
`DigestStudents ds = (DigestStudents) digester.parse(this.getClass().getClassLoader().getResourceAsStream("D:/workspace/RD_Axway/src/leo/test/digester/student/student.xml"));`
The resource cannot be found, thus null is being returned. | false | Please help me to know what is wrong with my code.[I tried from this link for Sample.](http://www.theserverside.com/news/1364926/Using-The-Digester-Component) OS : Windows 7
**Code 1 :**
```
DigestStudents ds = (DigestStudents) digester.parse(this.getClass()
.getClassLoader()
... | https://Stackoverflow.com/questions/18780611 | 18,780,611 | `ClassLoader#getResourceAsStream()` is able to locate files relative to the "**root**" of the classpath. You need to replace this line:
```
DigestStudents ds = (DigestStudents) digester.parse(this.getClass()
.getClassLoader()
.getResourceAsStream("D:/workspace/RD_Axway/sr... | 2013/09/13 |
The second loop to extract b tags in unnecessary. You have a list of `p` tags and inside them only one `b` and one `span` tag. You can just run a single loop to extract all the `p` tags and then extract the `b` and `span` tag with `p.find('b')`.
Here is an example with small payload.
```
from bs4 import BeautifulSoup... | true | [This is text that I want to scrape](https://i.stack.imgur.com/EPeq8.png)
[This is the HTML code for it](https://i.stack.imgur.com/56Ahg.png)
```
soup = BeautifulSoup(html_text, 'html.parser')
p_tags = soup.find_all('p')[15:24]
for p_tag in p_tags:
for b in p_tags.find_all('b'):
data = b.string
pr... | https://Stackoverflow.com/questions/67684229 | 67,684,229 | To get the desired list you can use next example:
```py
import requests
from bs4 import BeautifulSoup
url = "https://www.the-future-of-commerce.com/2020/03/20/brands-with-the-best-customer-service/"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0"
}
soup = B... | 2021/05/25 |
First, you while loop is exhausting your CPU, the variable millisecond is increasing, and decreasing when reach 999, nonstop, CPU never get a break to rest, and everytime the value millisecond changes, you ask panel to repaints, it is impossible mission for your CPU to do that.
Second, the millisecond won't work the w... | false | I'm trying to make a chronometer but when I click on "Iniciar (start)", the program freezes. This is the part that give me problems:
```
ActionListener escucha = new ActionListener() {
public void actionPerformed(ActionEvent e) {
iniciar.setEnabled(false);
pausar.setEnabled(true);
... | https://Stackoverflow.com/questions/41584711 | 41,584,711 | Basically, you're violating the single threaded nature of Swing.
1. Never update the UI from any thread other then the Event Dispatching Thread
2. Never block the Event Dispatching Thread
Doing the second will prevent the EDT from updating the UI (and responding to events and other important things)
Take a look at [... | 2017/01/11 |
try
```
$('label.button').live('click', function()
{
alert(1);
});
```
or
```
$('ul#more-items').delegate('label.button','click', function()
{
alert(1);
});
``` | true | Here's my code:
HTML:
```
<ul id="more-items">
<li><label class="button">hi</label></li>
<li><label class="button">hi</label></li>
<li><label class="button">hi</label></li>
</ul>
```
Javascript:
```
$('ul#more-items label.button').live('click', function()
{
alert(1);
});
```
Clicking on the labels do... | https://Stackoverflow.com/questions/2971129 | 2,971,129 | jQuery's `live()` method relies on event bubbling (all the way up to the root node) to work.
If there's any code that will stop the bubbling of the event on either the `label` or any of its ancestors, `live()` will not work.
Any chance that the `label` or one of its ancestors has a handler with either of the followin... | 2010/06/04 |
Are you parsing the DATABASE\_URL environment variable? It will look something like this:
```
postgres://username:password@host:port/database_name
```
So you will want to pull that in and parse it before you open a connection to your database. Depending on how you've declared your database (in your config or next to... | true | I am attempting to deploy a [Flask](http://flask.pocoo.org/) app to [Heroku](http://www.heroku.com/). I'm using [Peewee](http://peewee.readthedocs.org/en/latest/) as an ORM for a Postgres database. When I follow the [standard Heroku steps to deploying Flask](https://devcenter.heroku.com/articles/python), the web proces... | https://Stackoverflow.com/questions/10755833 | 10,755,833 | According to the [Peewee docs](http://docs.peewee-orm.com/en/latest/peewee/database.html?highlight=postgres#dynamically-defining-a-database), you don't want to use `Proxy()` unless your local database driver is different than your remote one (i.e. locally, you're using SQLite and remotely you're using Postgres). If, ho... | 2012/05/25 |
This works like charm!
So I edited the code as per my requirement. And here are the changes:
It will save the id number from the response into the environment variable.
```
var jsonData = JSON.parse(responseBody);
for (var i = 0; i < jsonData.data.length; i++)
{
var counter = jsonData.data[i];
postman.setEnv... | true | I'm using Sencha Touch (ExtJS) to get a JSON message from the server. The message I receive is this one :
```
{
"success": true,
"counters": [
{
"counter_name": "dsd",
"counter_type": "sds",
"counter_unit": "sds"
},
{
"counter_name": "gdg",
"counter_type": "dfd",
... | https://Stackoverflow.com/questions/9991805 | 9,991,805 | "Sencha way" for interacting with server data is setting up an `Ext.data.Store` proxied by a `Ext.data.proxy.Proxy` (in this case `Ext.data.proxy.Ajax`) furnished with a `Ext.data.reader.Json` (for JSON-encoded data, there are other readers available as well). For writing data back to the server there's a `Ext.data.wri... | 2012/04/03 |
According [this fiddle](https://jsfiddle.net/gLu18aho/) bootstrap was installed successfully
All you need is to use [`bootstrap 4 spacing`](https://getbootstrap.com/docs/4.0/utilities/spacing/)
See example:(I use `mb-1` to the first wrap div what means `margin-bottom` )
```html
<link rel="stylesheet" href="https://... | true | I have the following scenario:
```
public abstract class BaseTask{...}
public class TaskA extends BaseTask {....}
public class TaskB extends BaseTask {....}
public interface TaskService<T extends BaseTask>{
void process(T task);
}
@Service @Qualifier("taskServiceA")
public class TaskServiceA<TaskA> impleme... | https://Stackoverflow.com/questions/53276456 | 53,276,456 | It is due to the [preserveWhitespaces](https://angular.io/api/core/Component#preserveWhitespaces) option which is false by default and nothing to do with bootstrap. You can enable it by the setting that option to true as follows:
```
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls... | 2018/11/13 |
You may do this via two aggregations:
```
SELECT Column1, SUM(Column3Avg) AS Column3
FROM
(
SELECT Column1, Column2, AVG(Column3) AS Column3Avg
FROM yourTable
GROUP BY Column1, Column2
) t
GROUP BY
Column1;
```
This approach first aggregates by both the first and second column, to generate an interme... | true | Let's suppose in a pandas dataframe I have for a certain record:
```
x.index.quarter
```
is 3
I need to generate an integer from 1 to 365 as day of the year, that would belong to the same quarter.
How does pandas decide the year quarter? Is there a mathematical formula? Does it depends only on the months? | https://Stackoverflow.com/questions/62449880 | 62,449,880 | ```
SELECT column1, SUM(Avg_col3) AS total
FROM (
SELECT column1, column2, AVG(column3) AS avg_col3
FROM t
GROUP BY column1, column2
) A
GROUP BY column1;
``` | 2020/06/18 |
Here's a version without the ugly `while True` pattern and without other modules:
```
for line in iter(original.readline, ''):
if …: # to the beginning of the title or abstract
for i in range(lineNumber):
print original.readline(),
break
``` | true | I'm writing a script that logs errors from another program and restarts the program where it left off when it encounters an error. For whatever reasons, the developers of this program didn't feel it necessary to put this functionality into their program by default.
Anyways, the program takes an input file, parses it, ... | https://Stackoverflow.com/questions/826493 | 826,493 | Use `for` and [enumerate](http://docs.python.org/library/functions.html#enumerate).
Example:
```
for line_num, line in enumerate(file):
if line_num < cut_off:
print line
```
**NOTE**: This assumes you are already cleaning up your file handles, etc.
Also, the [takewhile](http://docs.python.org/library/i... | 2009/05/05 |
There are different ways of achieving the output you are looking for. Here is one among them, I have used [`Object.keys`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys), [`Object.entries`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Obj... | true | I am not an expert with Jquery, my developer is unavailable . I am using <https://jqcron.arnapou.net/demo/> . This works fine. The code is as follows,
```
$(function(){
$('.example7').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
... | https://Stackoverflow.com/questions/64301459 | 64,301,459 | You can use `Object.keys` and array `map` method.
```js
let data = {
"cases": {
"10/6/20": 35806972,
"10/7/20": 36156226,
"10/8/20": 36515563,
"10/9/20": 36876248,
"10/10/20": 37105925
},
"deaths": {
"10/6/20": 1049875,
"10/7/20": 1055683,
"10/8/20": 1061877,
"10/9/20": 1068040,
"10/10/20": 1071388
},
"recovered": {
"... | 2020/10/11 |
After trying all of the other solutions, it turned out that the problem in my case was that there wasn't enough available storage space - the package installer gives a generic "Install failed" in this case too. Hopefully this saves someone else the hours I wasted. | false | I have a Problem where i need to find the first occurrence of the char according to the order which they occur in the given String.
For Example :
I have a String **"Unitedin"** where the char **"n"** and **"i"** have a multiple occurrence in the String.
**char n** occurred at charAt(1,7)
**char i** occurred at charAt... | https://Stackoverflow.com/questions/58128675 | 58,128,675 | The reason of the message "Installation Failed" or "App not installed" can vary, simply because this is the only error you can get while installing your app.
I agree that it is not helpful.
However, it is for most cases due to a **signing** issue.
Here are some solutions :
1. Make sure you used a Release Signed APK f... | 2019/09/27 |
One way to do it would be to enumerate your sort explicitly:
```js
var definedSort = [1,2,3,4,5,6,7,8,9,10,'1A','1B','1C'];
var someArray = ['1A', 4, 8, 5, 1, 9, '1C', '1B'];
someArray.sort(function(a,b) {
return definedSort.indexOf(a) - definedSort.indexOf(b);
});
alert(someArray);
```
However, given your... | true | ```js
var table =
[
{"name":"Joe", "Level":1},
{"name":"Bob", "Level":1B},
{"name":"Carl", "Level": 7},
{"name":"Mike", "Level": 1A},
{"name":"Sal", "Level": 2}
]
var tableHeaders = scope.SortTableColumnHeaders(table)
scope.SortTableColumnHeaders = function (... | https://Stackoverflow.com/questions/31327707 | 31,327,707 | Well, ASCII values are continuous, and numbers are lower than chars from the alphabet, so if you can live with the sum of the ASCII values (that would work with `1A`, `1B` and so on)
```
var table = [
{"name":"Joe", "Level": '1'},
{"name":"Bob", "Level": '1B'},
{"name":"Carl", "Level": '7'},
...
]
funct... | 2015/07/09 |
```
$(document).ready(function()
{
$('#submit').hide();
$('#mobiletask').on('change',function() {
if($('#mobiletask').attr('checked'))
{
check_availability();
//$( "#notifyresult" ).html( "<p>Awesome, we'll send you an email!</p>" );
}
});
function check_avai... | true | The instructions here were to create a BowlingScores class and BowlingScoresViewer client class: In the BowlingScores class, create a method named printScores():
* This class should keep track of scores for multiple bowlers. Scores are integer values
between 0 and 300.
* Create a normal one-dimensional array to keep t... | https://Stackoverflow.com/questions/27436579 | 27,436,579 | Based on the response you are getting:
```
<html><body>1</body></html>
```
What you have to do is to work on your **PHP** file and make sure to remove any HTML in it. | 2014/12/12 |
in that case, it is because it never gets into the else statement, it is always false.
I usually use alert(string); to debug and know the value of variables, try one at the beginning of the if, or use console.log()
I also recommend you to read the following regarding let or var:
[What's the difference between using "... | false | Why does the code below doesn't throw a warning/error about variable re-assignment?
I spent a good amount of time debugging something like this because of the trailing comma.
When the code inside the else statement is moved outside of the if scope, it throws the proper error.
Any explanation would be great.
```js
l... | https://Stackoverflow.com/questions/47180800 | 47,180,800 | In else condition, a is re declared as const.So whatever the value (u assigned 10) within in else condition. you have to put ; at end of b declaration. otherwise `a` will be declared as const.So, `a` value is undefined in the outside of else condition.
```js
let a
if (false) {
// Nothing
} else {
const b = 10... | 2017/11/08 |
Here is my own function that receives a vector of image files and merge them vercially.
wstring CombineBitmaps(vector files)
{
wstring NewFile{ L"Output.png" };
```
Gdiplus::Status rc;
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);
vector< Gdiplus::Bitmap*> bmpSrc;
int Height{ 0 };
for (int i = 0; i < fi... | true | I'd like to ask one general question about JavaFX implementation strategy. Let's say I already have a java project with many classes and objects that uses maybe swing as a GUI. Now I want to use JavaFX as GUI. I want to display those objects in nice JFX UI. But to use JavaFX and its binding and all that stuff, classes ... | https://Stackoverflow.com/questions/17796874 | 17,796,874 | Use a Graphics object to combine them. Here's some sample working code... Of course, you should use smart ptrs like unique\_ptr<> instead of new/delete but I did not want to assume you're using VS 2012 or newer.
```
void CombineImages()
{
Status rc;
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid)... | 2013/07/22 |
Here with full path, network compatible:
```
(Get-ChildItem "\\folder1\" -Dir).fullname | ForEach {(Get-ChildItem $_ -Dir).name}
```
Want it stored in an array?
```
$subfolders = (Get-ChildItem "\\folder1\" -Dir).fullname | ForEach {(Get-ChildItem $_ -Dir).name}
``` | true | Is there a function in Java Script that divide a string with several arguments?
```
var string = "This is a test text, again, this is a testing text";
```
For example, I can split with `,` by saying `string.split(',');` and I will have:
```
var string = ["This is a test text", "again", "this is a testing text"];
`... | https://Stackoverflow.com/questions/39395993 | 39,395,993 | You should just be able to use some fun wildcards to get what you want here.
```
Get-ChildItem \*\*\ | Where-Object{$_.PSIsContainer}
```
Or if you have at least PowerShell 3.0 this would be faster
```
Get-ChildItem \*\*\ -Directory
```
Then if you wanted just the names tack on `| Select-Object -ExpandProperty ... | 2016/09/08 |
The g in /g stands for global. This make sure that all matches are replaced. In the absence of /g, only the first match is replaced. /i (ignore case) is another commonly used switch.
Each time the javascript engine finds a match(for your regular expression) in the string, it calls the function that you passed in with ... | false | I would like to get a deeper understanding of the nuances of javascript.
Take the function below:
```
str.replace(/(\b[^:]+):'([^']+)'/g, function ($0, param, value) {
ret[param] = value;
});
```
* Why is there a need for /g?
* What
exactly gets passed into the
function?
* Where do these values come
from?
Than... | https://Stackoverflow.com/questions/3679372 | 3,679,372 | >
> Why is there a need for /g?
>
>
>
Because presumably you will have multiple pairs on the matching string, e.g. `a:'b' c:'d'`
>
> What exactly gets passed into the function?
>
>
>
The callback function gets the whole match as the first argument, the two later arguments are the capturing groups specified o... | 2010/09/09 |
I wrote my own distance code ref the top answer, just as it says, it was extremely slow, the built-in distance code was much better. I'm wondering how to speed up. | false | I have objects and a distance function, and want to cluster these using `DBSCAN` method in `scikit-learn`. My objects don't have a representation in Euclidean space. I know, that it is possible to use`precomputed` metric, but in my case it's very impractical, due to large size of distance matrix. Is there any way to ov... | https://Stackoverflow.com/questions/32938494 | 32,938,494 | scikit-learn has support for a large variety of metrics.
Some of them can be accelerated using the kdtree (very fast), using the ball tree (fast), using precomputed distance matrixes (fast, but needs a lot of memory) or no precomputation but Cython implementations (quadratic runtime) or even python callbacks (very slo... | 2015/10/04 |
For Chrome browser, just need to set `Capability.ACCEPT_INSECURE_TLS_CERTS, true`. It is working for me.
```
const { Builder, By, until, Capabilities, Capability } = require('selenium-webdriver');
const capabilities = Capabilities.chrome();
capabilities.set(Capability.ACCEPT_INSECURE_TLS_CERTS, true);
this.driver = ... | true | Given these Node dependencies:
```
{
"chromedriver": "^2.24.1",
"cucumber": "^1.3.0",
"geckodriver": "^1.1.2",
"phantomjs-prebuilt": "^2.1.12",
"selenium-webdriver": "^3.0.0-beta-2"
}
```
I would like PhantomJS and Firefox to ignore SSL certificates. Here is how my browser.js looks:
```
require... | https://Stackoverflow.com/questions/39638830 | 39,638,830 | For Firefox, you can use the following code:
```
var driver = new webdriver.Builder().withCapabilities(Capabilities.firefox()
.set("acceptInsecureCerts", true)).build();
``` | 2016/09/22 |
This is most likely a Mono runtime bug, reported here:
<https://github.com/mono/mono/issues/19893>
The workaround is indeed to disable parallel restore by passing `/p:RestoreDisableParallel=true` property to MSBuild. | false | I am building a management system in which the admin can select an item from the database table and update the details. To achieve this I have two forms on two pages. The first form is to select the item from table and pass it's ID to the second page where I will use the ID to fetch the details from the table using php... | https://Stackoverflow.com/questions/46133427 | 46,133,427 | I cannot help with the networking problem but you may be able to reduce the amount of NuGet packages that are being downloaded by Visual Studio for Mac as a possible workaround. This can be done for a .NET Core 2.0 project by using the NuGet fallback folder:
```
/usr/local/share/dotnet/sdk/NuGetFallbackFolder/
```
T... | 2017/09/09 |
You can use a specify the range (min/max) in `Math.random` function and then use this function `Math.floor(Math.random() * (max - min + 1)) + min;` to limit the returned value of the random function between min and max.
* `maxTop` : height of the container - height of shape
* `maxLeft` : width of the container - width... | true | I have a square, when clicked it appears in a random location and it also change size (so for example if I have a 30px box but it is 10px from the left border I still get 10px outside the gamespace).
sometimes the square exceed his container border
How can I make sure that the square will never exceed his container?
... | https://Stackoverflow.com/questions/44384278 | 44,384,278 | You need to set `position: relative;` to the parent element and `position: absolute;` to the `shape` element. Then use max min value for random where max is the parent width/height and subtract the `shape` width/height ...
**This is snippet before update**
```js
function position() {
var playSpace = document.query... | 2017/06/06 |
You could just print out a lot of new line characters to make it look like the screen has been cleared. Also its easy to implement and helpful for debugging.
The code would be some thing like:
`print "\n"*100` | false | I don't know if this can be done but I'm sure I saw this in some scripts, that's why I'm asking.
I need to print a string like this one:
```
++++++++++++++++++++++++++++++ +++++++++++++++
+ A 1 ++ A 2 + + A n +
+-------------++-------------+ +-------------+
+ B 1 ++ B 2... | https://Stackoverflow.com/questions/15702518 | 15,702,518 | A quick-and-dirty method that relies on your terminal handling [VT100 escape sequences](http://www.termsys.demon.co.uk/vtansi.htm) is to clear the screen and then move the cursor to the home position before printing the output.
A quick demo:
```
import sys
import time
import random
ESC = "\x1b"
def home():
sys.... | 2013/03/29 |
This is what you want:
```js
.replace(/\[(\w+)[^\]]*](.*?)\[\/\1]/g, '$2');
```
[JavaScript demo](http://jsfiddle.net/7vyuwk0t/)
Basically you catch the value between tags and then replace the whole string with that value.
Using a regex to do this isn't a very clean way of doing it though...
Sorry Alex but you di... | true | I am trying to remove BBCode with attributes and content between those tags. I'm using this regular expression that I got here from [here](https://stackoverflow.com/questions/6777257/remove-bbcode-tags-and-their-content-in-php/6777448#6777448). I also tried other regex I found on stackoverflow but they didn't work for ... | https://Stackoverflow.com/questions/7117309 | 7,117,309 | ```
str = str.replace(/\[(\w+)[^\]]*](.*?)\[\/\1]/g, '');
```
[jsFiddle](http://jsfiddle.net/alexdickson/5r5x2/). | 2011/08/19 |
If we accept a lateral thinking approach, in a browser there are several API's we can abuse to execute arbitrary JavaScript, including calling a function, without any actual parenthesis characters.
### 1. `location` and `javascript:` protocol:
One such technique is to abuse the `javascript:` protocol on `location` as... | true | I was told today that it's possible to invoke a function without parentheses. The only ways I could think of was using functions like [`apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) or [`call`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/G... | https://Stackoverflow.com/questions/35949554 | 35,949,554 | The easiest way to do that is with the `new` operator:
```js
function f() {
alert('hello');
}
new f;
```
While that's unorthodox and unnatural, it works and is perfectly legal.
The `new` operator doesn't require parentheses if no parameters are used. | 2016/03/11 |
Try This,
```
$(".countdown, .event").removeClass("hidden").addClass("Hello");
``` | true | I've generated a dataframe of probabilities from a scikit-learn classifier like this:
```
def preprocess_category_series(series, key):
if series.dtype != 'category':
return series
if series.cat.ordered:
s = pd.Series(series.cat.codes, name=key)
mode = s.mode()[0]
s[s<0] = mode
... | https://Stackoverflow.com/questions/36978874 | 36,978,874 | Is this working? You have forgotten an `,`
```
$(".countdown,.event").removeClass("hidden").addClass("Hello");
```
>
> $(".intro,.demo") All elements with the class "intro"
> or "demo"
>
>
>
see [w3schools](http://www.w3schools.com/jquery/jquery_ref_selectors.asp) | 2016/05/02 |
Despite you saying it doesn't work, I used `clearRect` quite fine.
>
> Clears the specified rectangle by filling it with the background color
> of the current drawing surface. This operation does not use the
> current paint mode.
>
>
> Beginning with Java 1.1, the background color of offscreen images may
> be s... | true | I have an off-screen BufferedImage, constructed with the type `BufferedImage.TYPE_INT_ARGB`. It can contain anything, and I'm looking for a way to (fairly efficiently) completely overwrite the image with transparent pixels, resulting in an 'invisible' image.
Using something like this:
```
(bufimg.getGraphics()).s... | https://Stackoverflow.com/questions/5672697 | 5,672,697 | After you clear the background with the CLEAR composite, you need to set it back to SRC\_OVER to draw normally again. ex:
```
//clear
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
g2.fillRect(0,0,256,256);
//reset composite
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
//d... | 2011/04/15 |
You could take a hash table for collecting the values and map new objects form the entries.
```js
var data = [{ id: "122334", "name": "bob", commits: 10, email: "1@abc.com" }, { id: "223411","name": "frank", commits: 4, email: "bob@aol.com" }, { id: "223411","name": "bob", commits: 19, email: "bob@aol.com" }],
re... | true | I have an API response (committers to a git project) where members are repeated due to them having the same name but different email address.
Sample response:
```
[
{"id": "122334", "name": "bob", "commits":10, "email": "1@abc.com"},
{"id": "223411","name": "frank", "commits":4, "email": "frank@whatever.com"},
... | https://Stackoverflow.com/questions/60625996 | 60,625,996 | You don't need the additional `for` loop. You can do this simply with a `Array.reduce` function. Additionally, I would avoid importing a library such as `underscore` to do something that is already possible with native JavaScript. You would essentially be importing thousands of lines of code to do a simple thing. Not t... | 2020/03/10 |
Have you considered using a CSS transition? if you are changing the value of top you should be able to add transition: top 1.6s in your css (to picture). (Then the vendor prefixed versions when you get it working) | false | I know how to fix the animation that goes down only when the image is showing up in the window with jQuery, but now I want to do that with JavaScript. Struggling with that. The image must be fluently go down (+50px for 1.6 seconds). Have googling around, but most of them are done with jQuery I suggest and that is not w... | https://Stackoverflow.com/questions/39498657 | 39,498,657 | jsFiddle : <https://jsfiddle.net/n1q3fy8w/>
Javascript
```
var imgSlide = document.getElementById('slidedown-image');
var slideDown = setInterval(function() {
var topVal = parseInt(window.getComputedStyle(imgSlide).top, 10);
imgSlide.style.top = (topVal + 1) + "px";
}, 15);
setTimeout(function( ) { clearInterva... | 2016/09/14 |
here is my code to hide placeholder text on input and textarea focus(). Simple and working great.
```js
$('textarea,input').focus(function(e){
val=$(this).attr('value');
if (!val)
$(this).attr('value',' ');
this.select();
}).blur(function(e){
val=$(this).attr('value');
if (val==' ')
$(this)... | true | I´m using the "placeholder" attr. for placeholder text in input-fields
I need to have this functionality in IE-incarnations too.
I want the Placeholder to hide on FOCUS! every workaround i found hides the placeholder when the first type is entered.
I´m unable to work it out myself, it needs to simply delete the inpu... | https://Stackoverflow.com/questions/14339588 | 14,339,588 | For Webkit based browsers and Firefox you can hide the placeholder in pure CSS:
```
input:focus::-webkit-input-placeholder,
input:focus::-moz-placeholder { opacity:0; }
``` | 2013/01/15 |
Of course it is possibile. In the most obvious case you can set each property of the target object with the corresponding value in the json object. More than *conversion*, I would call this object *creation*. | false | Is it possible to convert org.json.simple.jsonobject to java object | https://Stackoverflow.com/questions/52099753 | 52,099,753 | I prefer to use jackson's objectMapper for this
```
ObjectMapper objectMapper=new ObjectMapper();
ClassName object=objectMapper.readValue(json.toString(),ClassName.class);
```
To use GSON
```
Gson g = new Gson();
ClassName object=g.fromJSON(json.toString(),ClassName.class);
``` | 2018/08/30 |
That's [the code](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/lang/String.java?av=f):
```
if (h == 0 && count > 0) {
...
for (int i = 0; i < len; i++) {
h = 31*h + val[off++];
}
...
}
return h; //0
```
The String is empty, the result is 0. See also the [docs... | true | What happens when assigning empty parentheses value to a String in Java?
```
String s = "";
```
Does the object reference variable s refer to an object in the heap memory carrying a String value of nothing?
what made me ask this question is that when printing the hash code of the object I get a zero, which did not ... | https://Stackoverflow.com/questions/23336138 | 23,336,138 | The documentation of hashCode fro String.
```
/**
* Returns a hash code for this string. The hash code for a
* <code>String</code> object is computed as
* <blockquote><pre>
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* </pre></blockquote>
* using <code>int</cod... | 2014/04/28 |
another way, that I'm using, that could make it for you:
```js
// here's the value we wanna get by ratio (where v is value and r is ratio)
// r is an array with min and max value, this example is based on a 100% ratio
const ratioValues = [
{v: 1, r: [0,75]}, // 75% chance to get 1
{v: 2, r: [76,100]} // 25% ch... | true | I want to randomize my list with custom widths. For this, I wrote simple JavaScript snippet generating numbers between `1 and 2`.
Function is as follows:
```
randomizePortfolio: function() {
$('ul.works').children('li').each(function() {
var Random = Math.floor(Math.random() * 2) + 1,
words =... | https://Stackoverflow.com/questions/19069923 | 19,069,923 | To get a 3:1 distribution you can create an array with the numbers that you want, and add three 1s and one 2, and randomize the index:
```
var rvalues = [1,1,1,2];
var Random = rvalues[Math.floor(Math.random() * rvalues.length)];
```
Here's another, equivalent, method based on the fact that 3/4 of the time the rando... | 2013/09/28 |
Return **does not** print strings!
```
def show_excitement(str,n):
print(str)
if(n!=1):
show_excitement(str,n-1)
str="I am super excited for this course!"
show_excitement(str,5)
``` | true | I am supposed to Write a function called `"show_excitement"` where the string
`"I am super excited for this course!"` is returned exactly
5 times, where each sentence is separated by a single space.
I can only have the string once in my code.
I have tried following code, but I think it is wrong somewhere. Please give ... | https://Stackoverflow.com/questions/56144323 | 56,144,323 | ```
def show_excitement():
str = "I am super excited for this course!"
return (str + " ")* 5
print show_excitement()
``` | 2019/05/15 |
Maybe you should check in your loop that month of current date (in loop) is the same as month of previous date by keeping at the end of every loop the last value of month (`$actualMonth`). You probably have to setup this value outside the loop with null and ignore this verification if `$actualMonth` is null. Also, you ... | true | I try to make a grouped plot with `matplotlib.pyplot` library in `Python`. I want to have date signature as a `string`, presented on x-axis. Despite I defined its values ("day\_date" column) as `string`, the resulted plot keeps displaying the values as int-s.
**How to have the x-axis values displayed as string?** (Pl... | https://Stackoverflow.com/questions/33875476 | 33,875,476 | Revise your inner loop like this:
```
for($l=0;$l<$table;$l++){
$mark = false;
for($y=0; $y<$count_absences; $y++){
$start = $absences[$y]['start'];
$end = $absences[$y]['end'];
$dStart = new DateTime($start);
$dEnd = new DateTime($end);
$dDiff = $dStart->diff($dEnd)... | 2015/11/23 |
Using jQuery you can toggle the class upon clicking with this:
```
$('.cell').click(function() { //catch clicks on .cell
$('.cell').removeClass('activeCell'); //remove class "activeCell" from all
$(this).addClass('activeCell'); //add class "activeCell" to .cell clicked
});
```
Apply `position: relative;` to `.to... | true | **What I want to do:**
I want to add a "walkingMan" image **under** an element when its class is changed to `activeCell`. I know how to do it when the image is added to the front or back of the element using pseudo class, but as far as I know, there isn't something like `:below` that I can use to achieve the same effe... | https://Stackoverflow.com/questions/46257873 | 46,257,873 | What about this: <https://jsfiddle.net/147prwy5/3/>
HTML
```
<div class="cell active">
<a>One</a>
<img src="https://www.shareicon.net/data/512x512/2016/01/17/704754_people_512x512.png" alt="walkingMan" />
</div>
<div class="cell">
<a>One</a>
<img src="https://www.shareicon.net/data/512x512/2016/01/17/704754_p... | 2017/09/16 |
The `or` in Kotlin and `|` in Java used with numbers are not related to boolean operators (`bool1 | bool2` and `bool1 || bool2`). These are [bitwise operators](https://kotlinlang.org/docs/reference/basic-types.html#operations). The bit operators in Kotlin are defined as `infix` functions, see `or`:
```
public infix fu... | true | I've made this small bot which processes through a list of search parameters. It works fine until there are several results on the page: `product_prices_euros` gives a list of items where half are empty. So when I concatenate with `product_prices_cents`, I have an output like the following:
```
'price' : '',76
```... | https://Stackoverflow.com/questions/53065523 | 53,065,523 | Think of the method `setRawInputType` as accepting a bunch of bits, instead of an integer value. There are many methods like this one. This pattern is used when the method wants the caller to specify a bunch of "options". By passing `InputType.TYPE_TEXT_FLAG_CAP_SENTENCES or InputType.TYPE_CLASS_TEXT`, you are passing ... | 2018/10/30 |
Just in case you want a faster regex alternative, you can use a negated character (`^)`) regex instead of laziness (`?`). It's faster as it [doesn't require backtracking](http://www.regular-expressions.info/repeat.html).
```
const uppercase = str =>
str.toUpperCase().replace(/\([^)]+\)/g, m => m.toLowerCase());
... | true | I am trying to make a variable string uppercase and letters that are within () lower case. string will be what ever the user enters so do not know what it will be ahead of time.
user entry examples
What is entered
(H)e(L)lo
what is expected outcome
(h)E(l)LO
What is entered
(H)ELLO (W)orld
what is expected outcome... | https://Stackoverflow.com/questions/63343766 | 63,343,766 | You can use the [`.replace()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Using_an_inline_function_that_modifies_the_matched_characters) method with a regular expression. First you can make your string all uppercase using `.toUpperCase()`. Then, you can match all cha... | 2020/08/10 |
You can try [GWT App](http://www.gwtapp.org/) with html templates generated and binded on run-time, no compiling-time. | false | What's the best way to **externalize large quantities of HTML** in a GWT app? We have a rather complicated GWT app of about 30 "pages"; each page has a sort of guide at the bottom that is several paragraphs of HTML markup. I'd like to externalize the HTML so that it can remain as "unescaped" as possible.
I know and un... | https://Stackoverflow.com/questions/744137 | 744,137 | I'd say you load the external html through a [Frame](http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/Frame.html).
```
Frame frame = new Frame();
frame.setUrl(GWT.getModuleBase() + getCurrentPageHelp());
add(frame);
```
You can arrange some convention or lookup for the *getCurre... | 2009/04/13 |
In addition to the response by @Thang Le
You can configure your time out of read operations, adding this line:
>
> jedisClientConfigurationBuilder.readTimeout(Duration.ofSeconds(1));
>
>
>
This is the value that you can obtain when use:
>
> jedisConFactory.getTimeout()
>
>
> | false | I'm using two libraries, let's call them "*NoQ*" and "*WithQ*" (you'll see why).
Both depend on the same object class, both have classes where they expect Spring to inject this object via `@Autowired`. So far so good. But *NoQ* library uses plain `@Autowired`, no qualifier, and also includes a `@Component` class that... | https://Stackoverflow.com/questions/49022017 | 49,022,017 | ```
@Bean
JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration();
redisStandaloneConfiguration.setHostName("localhost");
redisStandaloneConfiguration.setPort(6379);
redisStandaloneConfiguration... | 2018/02/28 |
I believe it may be that you are checking arr[i].length instead of arr.length because you only check if arr[i].length is 0 and if then the function returns 0, otherwise shortestElement is still equal to infinity and is returned. | false | ```
// Should equal 0 when an empty Array is entered
function getLengthOfShortestElement(arr) {
var shortestElement = Infinity;
for(var i=0; i < arr.length; i++) {
if(arr[i].length < shortestElement) {
shortestElement = arr[i].length;
} else if (arr[i].length === 0) {
return 0;
}
}
r... | https://Stackoverflow.com/questions/66607638 | 66,607,638 | You should move the `arr.length === 0` outside of the loop, or else it will never run.
Try this instead
```
function getLengthOfShortestElement(arr) {
var shortestElement = Infinity;
for(var i=0; i < arr.length; i++) {
if(arr[i].length < shortestElement) {
shortestElement = arr[i].length;
}
}
i... | 2021/03/12 |
The @PathVariable annotation should be passed in with the name of the field in speechmarks "" as the argument for findByUsername before "String username" | false | So I have an area in my js quiz where it displays the question. I would like to know how I can centre that area and put a box around it, to make it look fancy. Would be great if someone can help.
Thanks (code and screenshot of the area I would like to be entered is below).
```js
// This initialises a request to the tr... | https://Stackoverflow.com/questions/63391471 | 63,391,471 | You need to use @PathVariable,
```
public List<Data> findByUsername(@PathVariable("username") String username)
``` | 2020/08/13 |
You can use `method-lookup`:
You abstract class:
```
public abstract class AbstractConnector
{
private abstract WebServiceTemplate getWebServiceTemplate();
protected Object send(Object message)
{
return getWebServiceTemplate().marshalSendAndReceive();
}
```
Your configuration:
```
<bean id="webServiceTe... | true | How I can inject my `webServiceTemplate` in the implementing class?
My example:
```
public abstract class AbstractConnector {
protected WebServiceTemplate webServiceTemplate;
protected Object send(Object message) {
return webServiceTemplate.marshalSendAndReceive();
}
```
}
And in my concrete ... | https://Stackoverflow.com/questions/27795392 | 27,795,392 | I do not see why field injection would be any less simple here:
```
public abstract class AbstractConnector {
protected WebServiceTemplate webServiceTemplate;
public void setWebServiceTemplate(WebServiceTemplate template) {
this.webServiceTemplate = template;
}
}
public class MyConnector extends ... | 2015/01/06 |
Because WWW::Mechanize does not speak javascript, you either need to do as suggested and figure out what the javascript does and go around its back or you can use something like [WWW::Mechanize::Firefox](https://metacpan.org/module/WWW%3a%3aMechanize%3a%3aFirefox) that will allow you to control a browser. | false | I have the following html piece from this website:
<http://catalogue.bl.uk/F/NTBK6NCP3LK56BPNU2NJ4FF4MBLIRUNMFX66JLHKBDV1RNCAAB-02920?func=short-0&set_number=151530>
```
<form name="XXX000001" method="GET"><input type="checkbox" name="ckbox" onclick="javascript:select_record(this.form);" onkeypressed="javascript:se... | https://Stackoverflow.com/questions/7604400 | 7,604,400 | Maybe you should check [WWW::Selenium](http://search.cpan.org/~mattp/Test-WWW-Selenium-1.25/lib/WWW/Selenium.pm) in order to deal with JavaScript web pages.
`WWW::Selenium` is a kind of remote control for browsers.
From the documentation: *Selenium Remote Control (SRC) is a test tool that allows you to write automated... | 2011/09/29 |
Just posting my solution based on Brian Huey's [suggestion](https://stackoverflow.com/a/35244739/3128336).
```
from datetime import datetime, timedelta
import statsmodels.api as sm
delta = timedelta(days=7)
def calc_mad_mean(row):
start = row['ts']
end = start + delta
subset = df['score'][(start <= df['... | true | I have a pandas dataframe with irregularly spaced dates. Is there a way to use 7days as a moving window to calculate [median absolute deviation](http://statsmodels.sourceforge.net/devel/generated/statsmodels.robust.scale.mad.html), median etc..? I feel like I could somehow use `pandas.rolling_apply` but it does not tak... | https://Stackoverflow.com/questions/35242829 | 35,242,829 | You can use a time delta to select rows within your window and then use apply to run through each row and aggregate:
```
>>> from datetime import timedelta
>>> delta = timedelta(days=7)
>>> df_score_mean = df.apply(lambda x: np.mean(df['score'][df['ts'] <= x['ts'] + delta]), axis=1)
0 5.500000
1 5.500000
2 4.... | 2016/02/06 |
Perhaps, you might want to try this <https://hub.docker.com/r/timbru31/java-node> one to create the docker file.
This docker image comes with both Java and Node pre-installed. It comes in handy when both are required as a dependency.
Something like,
```
FROM timbru31/java-node:<tag>
``` | true | I am not sure why I expected this to work:
```
# Dockerfile
FROM node:6
FROM java:8
```
but it doesn't really work - looks like the first command is ignored, and second command works.
Is there a straightforward way to install both Node.js and Java in a Docker container?
Ultimately the problem I am trying to... | https://Stackoverflow.com/questions/43769730 | 43,769,730 | The best way for you is to take java (which is officially deprecated and it suggests you use `openjdk` image) and install node in it.
So, start with
```
FROM openjdk:latest
```
This will use the latest openjdk image, which is `8u151` at this time. Then install `node` and other dependencies you might need:
```
RUN ... | 2017/05/03 |
```
public static class Webdriver
{
public static void ExecuteJavaScript(this IWebDriver driver, string scripts)
{
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript(scripts);
}
public static T ExecuteJavaScript<T>(this IWebDriver driver, string scripts)
... | true | How is this achieved? [Here](http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions#Q%3a_How_do_I_execute_Javascript_directly?) it says the java version is:
```
WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");
```
But I c... | https://Stackoverflow.com/questions/6229769 | 6,229,769 | I prefer to use an extension method to get the scripts object:
```
public static IJavaScriptExecutor Scripts(this IWebDriver driver)
{
return (IJavaScriptExecutor)driver;
}
```
Used as this:
```
driver.Scripts().ExecuteScript("some script");
``` | 2011/06/03 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 2