Skip to content

Instantly share code, notes, and snippets.

#define SMTP_SERVER "Your Eamil SMTP server"
#define SMTP_USER_BASE64 "Your User Name(Email address) with Base64"
#define SMTP_PASS_BASE64 "Your Password with Base64"
#define SMTP_FROM_EMAIL "Your Email address"
#define SMTP_TO_EMAIL "Target Email address you want to send to"
#define SMTP_SUBJECT "Door notification"
#include "application.h"
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = GPIO.input(23)
if input_state == True:
wget -c https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
tar -xzvf Python-2.7.10.tgz
cd Python-2.7.10/
LDFLAGS="-L/usr/lib/x86_64-linux-gnu" ./configure
make
sudo make install
@WebSamuraiDaisuke
WebSamuraiDaisuke / main.py
Created July 9, 2017 14:20
Python3に移行して戸惑ったことのメモ
i = 0
for i in range(1,11):
with open("numbers.txt", 'a') as f: #with構文という便利な物がある。オプションのaは追記を意味する
f.write('hello, world\n') #文末に\n(macbookだとalt+¥)を入れると改行になる
@WebSamuraiDaisuke
WebSamuraiDaisuke / gist:8c98872b41f1858819a32b6b05c60870
Created July 16, 2017 12:00
Livedoor Weather API 天気予報APIを軽くたたいてみた
import urllib.request
import json
location = u'080020' #場所
url = 'http://weather.livedoor.com/forecast/webservice/json/v1?city=%s' %location
html = urllib.request.urlopen(url)
jsonfile = json.loads(html.read().decode('utf-8'))
print('***********')
print(jsonfile['pinpointLocations'][0]['name'])