This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # start webdriver | |
| options = Options() | |
| options.headless = True | |
| driver = webdriver.Chrome('/usr/bin/chromedriver', options=options) | |
| driver.get('https://medium.com/me/stats') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| from selenium import webdriver | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| from selenium.webdriver.common.keys import Keys | |
| from selenium.webdriver.common.action_chains import ActionChains | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.chrome.options import Options |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # initialize main variables | |
| stats = {} | |
| sleep_duration = 2 | |
| nap_duration = 0.5 | |
| # initialize login credentials | |
| email_cred = 'YOUR_USERNAME_OR_EMAIL' | |
| pass_cred = 'YOUR_PASSWORD' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MainActivity extends AppCompatActivity { | |
| TextView firstNumTextView; | |
| TextView secondNumTextView; | |
| TextView operatorTextView; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_main); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.content.Intent; | |
| import android.speech.RecognizerIntent; | |
| import android.speech.tts.TextToSpeech; | |
| import android.support.annotation.Nullable; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.telecom.RemoteConference; | |
| import android.view.View; | |
| import android.widget.Button; | |
| import android.widget.TextView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="#7C616768" | |
| tools:context=".MainActivity"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.anas.voicerecognitioncalculator"> | |
| <application | |
| android:allowBackup="true" | |
| android:icon="@mipmap/ic_launcher" | |
| android:label="@string/app_name" | |
| android:roundIcon="@mipmap/ic_launcher_round" | |
| android:supportsRtl="true" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private int performCalculations() { | |
| switch (OPERATOR) { | |
| case '+': | |
| return FIRST_NUMBER + SECOND_NUMBER; | |
| case '-': | |
| return FIRST_NUMBER - SECOND_NUMBER; | |
| case '*': | |
| return FIRST_NUMBER * SECOND_NUMBER; | |
| case '/': | |
| return FIRST_NUMBER / SECOND_NUMBER; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |
| super.onActivityResult(requestCode, resultCode, data); | |
| if (resultCode == RESULT_OK && data != null) { | |
| switch (requestCode) { | |
| case 10: | |
| int intFound = getNumberFromResult(data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)); | |
| if (intFound != -1) { | |
| FIRST_NUMBER = intFound; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // method to loop through results trying to find an operator | |
| private char getOperatorFromResult(ArrayList<String> results) { | |
| for (String str : results) { | |
| if (getCharOperatorFromText(str) != '0') { | |
| return getCharOperatorFromText(str); | |
| } | |
| } | |
| return '0'; | |
| } |