Skip to content

Instantly share code, notes, and snippets.

View bcdejp's full-sized avatar

Delta bcdejp

  • Japan
View GitHub Profile
@bcdejp
bcdejp / gmail.py
Created December 7, 2014 14:23
Gmailで簡単にメール送信
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Gmail
Gmailで簡単にメール送信
"""
import os.path
import datetime
@bcdejp
bcdejp / hcsr04.py
Created December 15, 2014 07:27
超音波距離センサモジュールHC-SR04を制御する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def reading(sensor):
import time
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
TRIG = 11
@bcdejp
bcdejp / tweet.py
Created December 21, 2014 11:46
Pythonでつぶやく
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from requests_oauthlib import OAuth1Session
#CK = 'XXXXXXXXXXXXXXXXXXXXXX' # Consumer Key
#CS = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Consumer Secret
#AT = 'XXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Access Token
#AS = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Accesss Token Secert
@bcdejp
bcdejp / rss.py
Created December 25, 2014 14:04
RSSを取得する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import feedparser
from datetime import datetime
from time import mktime
#RSSのURL
RSS_URL = "http://www.japantoday.com/feed/"
@bcdejp
bcdejp / htmlget.py
Created December 27, 2014 06:38
Webページを取得する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
URL = "http://make.bcde.jp"
#Webページ(HTML)の取得
req = requests.get(URL)
@bcdejp
bcdejp / lxml_sample.py
Created December 27, 2014 08:02
Web(HTML)から情報を抽出する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import lxml.html
URL = "http://make.bcde.jp/category/1/"
#Webページ(HTML)の取得
req = requests.get(URL)
@bcdejp
bcdejp / template_sample.py
Created December 28, 2014 12:21
jinja2のサンプル
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from jinja2 import Environment, FileSystemLoader
#テンプレートファイルを指定
env = Environment(loader=FileSystemLoader('./', encoding='utf8'))
tpl = env.get_template('template.html')
#テンプレートへ挿入するデータの作成
@bcdejp
bcdejp / template.html
Created December 28, 2014 12:22
jinja2のサンプル
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>{{title}}</title>
</head>
<body>
{% for sample in sample_list %}
<h1>{{ sample.title }}</h1>
<p>
@bcdejp
bcdejp / generate.html
Created December 28, 2014 14:27
jinja2で生成したファイル
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>これはタイトルです</title>
</head>
<body>
<h1>コンテンツtitle1</h1>
<p>
@bcdejp
bcdejp / newssender.py
Created December 29, 2014 08:10
英語のニュースをKindleに送信する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import feedparser
import requests
import lxml.html
import gmail
import re
import os
from time import mktime