mercredi 5 octobre 2016

Finding crx files of extensions in chrome for usage with selenium in Chrome through python

Vote count: 0

Using Selenium (with Chrome) through python 3, my goal is to enable adblocker before starting my web scraping. I saw from this and this that the idea is to use:

    chop =webdriver.ChromeOptions()
    chop.add_extension(path.abspath('Adblock-Plus_v1.4.1.crx'))
    driver = webdriver.Chrome(chrome_options=chop)

But I do not understand how to find the path to the .crx file of adBlocker. I searched it in my computer and couldn't find it. Also, IU couldn't find this file by itself for download anywhere online. Any advice on how to find it or a different way to proceed for adblocking? Thanks

asked 37 secs ago

Let's block ads! (Why?)



Finding crx files of extensions in chrome for usage with selenium in Chrome through python

Codesys fatek programming

Vote count: 0

How can I write program in codesys (ST or IL) and put it on fatek FBs series PLC? It is posible? I was not use codesys before. I was using Ladder and other PLC (Omron, Unitronics, Simens, Schnider Electric).

asked 43 secs ago

Let's block ads! (Why?)



Codesys fatek programming

RxAndroidBle Scanning

Vote count: 0

I am trying to use the RxAndroidBle lib (http://ift.tt/1UU2YUJ) I want the app the start and scan for BLE devices. How can I do this?

    RxBleClient rxBleClient;
   RxBleScanResult rxBleScanResult;
   private Subscription scanSubscription;
 @Override
  protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
   rxBleClient = RxBleClient.create(this);



Subscription scanSubscription =rxBleClient.scanBleDevices().subscribe(rxBleScanResult.getBleDevice().getMacAddress() );


}

asked 15 secs ago

Let's block ads! (Why?)



RxAndroidBle Scanning

This pangram function in C++ doesn't satisfy all the test cases in HackerRank

Vote count: 0

I wanted to run a loop to check if every letter in the alphabet was present in the loop. If it was, I'd do an increment, and break the loop, so that it didn't read more than one time, in C++

    #include<iostream>
    using namespace std;
    class pangram                                          \\creating the class
    {
    string s;
    int count=0;                                           \\counter variable initialization
    public:
    void pan(void)                                         \\defining the method
        {
            cin>>s;                                         \\taking the string input
            for(char i='a';i<='z';i++)                       \\checking if every alphabet character is there in the string
                {
                    for(int j=0;j<s.length();j++)
                    {
                        char c=tolower(s[i]);                \\making them lowercase
                        if(i==c)
                        count++;
                        break;                               \\breaking the loop once that specific alphabet is found
                    }
                }
            if(count==26)
            cout<<"pangram";
            else
            cout<<"not pangram";
        }
    };
    pangram p1;
    int main()
    {
    p1.pan();                                            \\calling the object's method
    return 0;
    }

asked 19 secs ago

Let's block ads! (Why?)



This pangram function in C++ doesn't satisfy all the test cases in HackerRank

Are the strings in Algolia's highlightResult guaranteed html-safe?

Vote count: 0

I'm trying using Algolia instantSearch's highlightResult feature on a React web application. When the results displayed like <em>Re</em>sult, I realized that I would have to mark it as functional HTML using React's Dangerously Set innerHTML to get the tags to work like tags and not be escaped. I can't find a place where Algolia describes their policy for escaping characters in the index and results. I'd prefer not to have to use client-side sanitation to ensure that the only tags in the results are <em>, but I can't afford the possibility of a stored XSS attack. Is the highlightResult string returned by an Algolia search safe to use as HTML without sanitizing first?

asked 20 secs ago

Let's block ads! (Why?)



Are the strings in Algolia's highlightResult guaranteed html-safe?

Testing students' code in Jupyter with a unittest

Vote count: 0

I'd like my students to be able to check their code as they write it in a Jupyter Notebook by calling a function from an imported module which runs a unittest. This works fine unless the function needs to be checked against objects which are to be picked up in the global scope of the Notebook.

Here's my check_test module:

import unittest
from IPython.display import Markdown, display

def printmd(string):
    display(Markdown(string))

class Tests(unittest.TestCase):

    def check_add_2(self, add_2):
        val = 5
        self.assertAlmostEqual(add_2(val), 7)

    def check_add_n(self, add_n):
        n = 6
        val = 5
        self.assertAlmostEqual(add_n(val), 11)


check = Tests()
def run_check(check_name, func, hint=False):
    try:
        getattr(check, check_name)(func)
    except check.failureException as e:
        printmd('**<span style="color: red;">FAILED</span>**')
        if hint:
            print('Hint:',  e)
        return
    printmd('**<span style="color: green;">PASSED</span>**')

If the Notebook is:

In [1]: def add_2(val):
            return val + 2

In [2]: def add_n(val):
            return val + n

In [3]: import test_checks

In [4]: test_checks.run_check('check_add_2', add_2)
        PASSED

In [5]: test_checks.run_check('check_add_n', add_n)
        !!! ERROR !!!

The error here is not suprising: add_n doesn't know about the n I defined in check_add_n.

So I got to thinking I could do something like:

In [6]: def add_n(val, default_n=None):
            if default_n:
                n = default_n
            return val + n

in the Notebook, and then passing n in the test:

    def check_add_n(self, add_n):
        val = 5
        self.assertAlmostEqual(add_n(val, 6), 11)

But this is causing me UnboundLocalError headaches down the line because of the assignment of n, even within an if clause: this is apparently stopping the Notebook from picking up n in global scope when it's needed.

For the avoidance of doubt, I don't want insist that n is passed as an argument to add_n: there could be many such objects used but not changed by the function being tested and I want them resolved in the outer scope.

Any ideas how to go about this?

asked 38 secs ago

Let's block ads! (Why?)



Testing students' code in Jupyter with a unittest

I am trying to format a horizontal navigation list

Vote count: 0

So I want to format a horizontal navigation list. In my HTML page it says: <nav class="horizontal">

So in my css file I put this but it doesnt seem to work:

 Nav.Horizontal {
    background-color:rgb(0,0,0);
    color: rgb(255,255,255);
    font-weight: bold;
    font-size:10px;
    letter-spacing:3px;
}

a:Nav.Horizontal {
    color:rgb(255,0,0)
}

asked 24 secs ago

Let's block ads! (Why?)



I am trying to format a horizontal navigation list