Skip to content

Instantly share code, notes, and snippets.

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;
<?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"
<?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">
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;
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);
# initialize main variables
stats = {}
sleep_duration = 2
nap_duration = 0.5
# initialize login credentials
email_cred = 'YOUR_USERNAME_OR_EMAIL'
pass_cred = 'YOUR_PASSWORD'
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
# start webdriver
options = Options()
options.headless = True
driver = webdriver.Chrome('/usr/bin/chromedriver', options=options)
driver.get('https://medium.com/me/stats')
# choose twitter
WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath('//*[@data-action="twitter-auth"]')).click()
# fill out login form
username = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath('//*[@id="username_or_email"]'))
password = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath('//*[@id="password"]'))
login = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath('//*[@id="allow"]'))
time.sleep(sleep_duration)
username.clear()
username.send_keys(email_cred)
time.sleep(nap_duration)