Skip to content

Instantly share code, notes, and snippets.

View 1UC1F3R616's full-sized avatar
:shipit:
Attention is All You Need

Kush Choudhary 1UC1F3R616

:shipit:
Attention is All You Need
View GitHub Profile

Commiting in model

new_user = Users(username=username_, password=password_, email=email_) # Users is Model Class
db.session.add(new_user) # Not yet commited
db.session.commit()

Queries

Query All

all_users = Users.query.all()

Links to scrape data with pre filters

https://www.amazon.in/s?k=books&s=price-asc-rank	# low to high
https://www.amazon.in/s?k=books&s=price-desc-rank	# high to low
https://www.amazon.in/s?k=books&s=relevanceblender	# featured
https://www.amazon.in/s?k=books&s=review-rank		# Average customer review
https://www.amazon.in/s?k=books&s=date-desc-rank	# Newest Arrival

Version 2

SELENIUM

    email = driver.find_element_by_name('email')
    print(dir(email))
    
    ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', 
    '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', 
    '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', 
    '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', 
    '__str__', '__subclasshook__', '__weakref__', '_execute', '_id', '_parent',

Major issues

  • Scraping the code <> using selenium

Code-Dated: 1-4-19| 6:10

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
  • Most Basic
import threading
threading.Thread(target=f, args=(a,b,c)).start()
  • Example 1
import queue
import threading
import urllib2

Methods

  • search : Returns a match object (An object containing information about the search and the result) | None if there is No Match
  • findall : Returns a list containing all matches | Empty list if no match
  • match : match at start
  • finditer : Find all substrings where the RE matches, and returns them as an iterator

Metacharacters

Setting Up

- Android Studio SDK
- flutter addon
- setting Android Studio path and variable in Environment Variable

To Setup for VScode
- Above steps
- Install flutter and dart plugin
- run using cmd

Single Number

import java.util.Hashtable;
import java.util.Enumeration;
class Solution {
    public int singleNumber(int[] nums) {
        int value=0, key=0, answer=0;
        Hashtable<Integer, Integer> geek= new Hashtable<Integer, Integer>();
        for (int myIter: nums){
            if (geek.get(myIter) == null){
@1UC1F3R616
1UC1F3R616 / webscrappingsession2.ipynb
Created April 10, 2020 09:23
WebScrappingSession2.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.