Skip to content

Instantly share code, notes, and snippets.

@dev001hajipro
dev001hajipro / hello_excel.py
Created October 11, 2017 08:02
openpyxlでExcelを操作
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import openpyxl
import os
def recreate_data(filename):
if os.path.exists(filename):
os.remove(filename)
@dev001hajipro
dev001hajipro / type_keyboard.py
Created October 11, 2017 03:10
pyautoguiでイメージ認識、キーボード入力
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pyautoguiでイメージ認識、キーボード入力
メモ帳を画面キャプチャしてmemo.pngとして保存する必要あり。
"""
import pyautogui
@dev001hajipro
dev001hajipro / hello_pyautogui.py
Created October 9, 2017 02:16
pyautoguiでマウスを移動してみる
#!/usr/bin/env python
"""
pyautoguiを使う
"""
import pyautogui
class Status:
def __init__(self):
self.x, self.y = pyautogui.position()
@dev001hajipro
dev001hajipro / hello_selenium.py
Created October 8, 2017 01:14
Python3でseleniumの簡単な操作。
#!/usr/bin/env python
"""
seleniumをPython3で使う。
Pythonのseleniumの3.6.0では、FirefoxでもWebDriverが必要だった。昔は不要だった。
そのため、Chromeで試した。
--
chromeDriver - WebDriver for Chrome
https://sites.google.com/a/chromium.org/chromedriver/downloads
--
@dev001hajipro
dev001hajipro / downloadXkcd.py
Created October 6, 2017 09:38
XKCDコミックのサイトからコミックをダウンロードする。
# -*- coding:utf-8 -*-
"""
XKCDコミックのサイトからコミックをダウンロードする。
httpsには対応していない。
https://automatetheboringstuff.com/chapter11/
"""
import bs4
import os
import requests
@dev001hajipro
dev001hajipro / lucky.py
Created October 6, 2017 06:28
Google検索して、結果の上位5個を、ブラウザーを起動して表示するPythonスクリプト
# -*- coding:utf-8 -*-
"""
Google検索ツール
https://automatetheboringstuff.com/chapter11/
"""
import requests
import sys
import webbrowser
import bs4
@dev001hajipro
dev001hajipro / ListComprehension.py
Created October 4, 2017 23:17
アスタリスクで、Pythonのリスト内表表記で、タプルからクラス型に変換する
# -*- coding:utf-8 -*-
""" リスト内包表記で、タプルデータからクラス型で取り出す。"""
class Person:
def __init__(self, name, age: int, email):
self.name = name
self.age = age
self.email = email
@dev001hajipro
dev001hajipro / GuessTheNumber.py
Created October 4, 2017 09:15
Pythonで数字あてゲーム
# -*- coding:utf-8 -*-
""" 数あてゲーム """
import random
class GuessTheNumber:
""" 数あてゲーム """
VERSION = 1.0
@dev001hajipro
dev001hajipro / bubble_chart_view_d3.html
Last active September 17, 2017 12:59
bubble chart for the subscribers of programming subreddit.
<!DOCTYPE html>
<svg width="1024" height="1024" font-family="sans-serif" font-size="10" text-anchor="middle"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var format = d3.format(",d");
@dev001hajipro
dev001hajipro / simple donut lines
Created September 9, 2017 07:30
study donut lines from beesandbombs/rainbowDonut.pde
/*jshint esversion: 6 */
function setup() {
createCanvas(720, 720, WEBGL);
rectMode(CENTER);
noStroke();
colorMode(HSB, 255);
}
function thing(q) {