#Selecting a database
USE database; USE database;
#Listing databases
SHOW DATABASES; SHOW DATABASES;
This file contains 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
module.exports = { | |
I: '我が名は神龍', | |
actions: { | |
waitForElement: '要素が表示されるまで待ってやろう', | |
waitForClickable: 'クリック可能になるまで待ってやろう', | |
waitForVisible: '要素が見えるようになるまで待ってやろう', | |
waitForText: 'テキストが表示されるまで待ってやろう', | |
refresh: 'ページを更新してやろう', | |
amOnPage: 'URLにアクセスしてやろう', | |
click: 'クリックしてやろう', |
This file contains 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 java.util.Random; | |
public class Arrays { | |
public static void main(String[] args) { | |
// Declaration style. | |
int arrayTwo[] = new int[3]; | |
int[] arrayOne = new int[3]; // This is better! []'s are part of the type!! | |
// Indexing: We always refer to the first element of an array [0]. | |
// ex. subway example |
This file contains 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
from sklearn.datasets import fetch_20newsgroups | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.pipeline import Pipeline | |
import pandas as pd | |
import numpy as np | |
# Grab just two categories from the 20 newsgroups dataset | |
categories=['sci.space', 'rec.autos'] |
This file contains 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
# following Python packages needs to be installed | |
# xlrd, xlsxrd, unidecode, MySQLdb | |
import xlrd | |
import xlsxrd | |
import MySQLdb as mdb | |
import re | |
import unidecode |
This file contains 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 | |
# http://blog.yhathq.com/static/misc/data/WineKMC.xlsx | |
df_offers = pd.read_excel("./WineKMC.xlsx", sheetname=0) | |
df_offers.columns = ["offer_id", "campaign", "varietal", "min_qty", "discount", "origin", "past_peak"] | |
df_offers.head() | |
df_transactions = pd.read_excel("./WineKMC.xlsx", sheetname=1) | |
df_transactions.columns = ["customer_name", "offer_id"] | |
df_transactions['n'] = 1 | |
df_transactions.head() |
This file contains 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 io | |
import logging | |
logger = logging.getLogger("your_logger") | |
logger.setLevel(logging.INFO) | |
logger_output = io.StringIO() | |
logger.addHandler(logging.StreamHandler(logger_output)) | |
# do stuff that triggers some logs |
This file contains 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 time | |
from concurrent.futures import ThreadPoolExecutor | |
from logging import StreamHandler, Formatter, INFO, getLogger | |
def init_logger(): | |
handler = StreamHandler() | |
handler.setLevel(INFO) | |
handler.setFormatter(Formatter("[%(asctime)s] [%(threadName)s] %(message)s")) | |
logger = getLogger() |
This file contains 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
to create a new environment | |
conda create -n mynewenviron package1 package2 etc | |
conda create -n newenv --clone ~anaconda | |
to remove an environment | |
conda remove -n myenvirontoremove --all | |
always start with |
This file contains 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
# | |
# Get web page screenshot | |
# | |
# usage: | |
# xvfb-run -s "-screen 0 1024x768x24" python getschreenshot.py test.html | |
# | |
# libs: | |
# - pygtk: http://www.pygtk.org/ | |
# - pywebkitgtk(python-webkit): http://code.google.com/p/pywebkitgtk/ | |
# - PIL: http://www.pythonware.com/products/pil/ |