Skip to content

Instantly share code, notes, and snippets.

View avinash-mishra's full-sized avatar
🎯
Focusing

Avinash avinash-mishra

🎯
Focusing
View GitHub Profile

Metadata

#Selecting a database	
USE database;	USE database;

#Listing databases	
SHOW DATABASES;	SHOW DATABASES;
@tsuemura
tsuemura / ja-SR.js
Last active November 16, 2019 06:52
CodeceptJS神龍語翻訳ファイル
module.exports = {
I: '我が名は神龍',
actions: {
waitForElement: '要素が表示されるまで待ってやろう',
waitForClickable: 'クリック可能になるまで待ってやろう',
waitForVisible: '要素が見えるようになるまで待ってやろう',
waitForText: 'テキストが表示されるまで待ってやろう',
refresh: 'ページを更新してやろう',
amOnPage: 'URLにアクセスしてやろう',
click: 'クリックしてやろう',
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
@tyarkoni
tyarkoni / predict_from_text.py
Last active March 10, 2020 02:10
simple example predicting binary outcome from text features with sklearn
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']
@anubhavsinha
anubhavsinha / excel2mysql.py
Created September 29, 2012 00:29
simple excel to mysql in python
# following Python packages needs to be installed
# xlrd, xlsxrd, unidecode, MySQLdb
import xlrd
import xlsxrd
import MySQLdb as mdb
import re
import unidecode
@glamp
glamp / customer-segmentation.py
Last active April 30, 2020 13:40
Analysis for customer segmentation blog post
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()
@Integralist
Integralist / capture logger output.py
Last active September 28, 2020 14:05
[Python3 Logging] Simple Python3 Logging Configuration #logs #python #python3 #structured #logging #structlog #capture
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
@tag1216
tag1216 / 01_thread.py
Created April 2, 2017 12:19
Pythonでconcurrent.futuresを使った並列タスク実行
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()
@qheuristics
qheuristics / conda_cheat
Last active November 13, 2020 12:22
conda cheatsheet
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
@bellbind
bellbind / getscreenshot.py
Created June 29, 2009 15:50
[python][pywebkitgtk]Get web page screenshot
#
# 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/