SlideShare a Scribd company logo
1 of 90
Download to read offline
AQSF SGTTe Q?t
jbnp
CS Q? J AQSF SGTT
P GSPG QH ?J PIT
iw
gueo
1WGS J PI QP PG QSM
J N RT VG
S Q 7QEM
_
QRVNCS TOCNN EQORV GST
Q/ AG IJ S EG
A SGNGTT GEJPQNQI
SQ QEQN
1 ? -
A i t :
: P G A FC C
{"id":1,

"date":"2017-05-23T06:25:50",

"date_gmt":"2017-05-23T06:25:50",

"guid":{"rendered":"http://demo.wp-api.org/?p=1"},

"modified":"2017-05-23T06:25:50",

"modified_gmt":"2017-05-23T06:25:50",

"slug":"hello-world",

"status":"publish",

"type":"post",

"link":"https://demo.wp-api.org/2017/05/23/hello-world/",

"title":{"rendered":"Hello world!"},

"content":{"rendered":"<p>Welcome to...
x w i
1PFRQ P T
y
/VT QO G CWC NCDNG
x w
G GPFRQ P
add_action( 'rest_api_init', function () {
register_rest_route( 'anything/v1', '/get',
array(
'methods' => 'GET',
'callback' => 'get_anything_awesome',
) );
} );
function get_anything_awesome() {
$data = array('result' => 'great data');
return new WP_REST_Response( $data, 200 );
}
- GTRQPTG
http://example.net/wp-json/
anything/v1/get
{"result":"great data"}
710
710 -F CPGN
CSF CSG
CTRDGSS




CTRDGSS




710 C S CPGN
. C S .QPPG
t dg
GS ECN EQPPGE NCPFTECRG RCPGN
QH CSG




CTRD CP 7 G
: G PIT
.VSP :
1 EJGS
-RRNG .CMGS
/QPH I
PT CNN CEMCIGT
$ sudo apt install git 
libgraphicsmagick++-dev 
libwebp-dev
. 710 C S
OCMG
$ git clone https://github.com/
hzeller/rpi-rgb-led-matrix
$ cd rpi-rgb-led-matrix
$ make -C examples-api-use
$ cd utils
$ make led-image-viewer
0GOQ
$ cd example-api-use
$ sudo ./demo 

--led-gpio-mapping=adafruit-hat 
--led-no-hardware-pulse 
--led-chain=4 -L 

-D 0
sk
0 TRNC ACRVV
sk t
/QNNGE ACRVV OCIGT
h lr
-SSCPIG Q NCPFTECRG
ESQNN 0GOQ
$ sudo ./demo 

--led-gpio-mapping=adafruit-hat 
--led-no-hardware-pulse 
--led-chain=4 -L 

-D 1 ../../images/wapuu.ppm
-
-FF -
A - e
OCIG /JCPIG -
/VT QO 1PF Q P
/wp-json/wapuu/v1/set/NNN
/wp-json/wapuu/v1/get
x w
-FF GPF RQ P
add_action( 'rest_api_init', function () {
register_rest_route( 'wapuu/v1', '/set/(?P<id>d+)', array(
'methods' => 'POST',
'callback' => 'set_wapuu_image',
'args' => array(
'id' => array(
'validate_callback' => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
) );
register_rest_route( 'wapuu/v1', '/get', array(
'methods' => 'GET',
'callback' => 'get_wapuu_image',
) );
} );
t
CWG& G OCIG PVODGS
function set_wapuu_image( $data ) {
$id = $data['id'];
update_post_meta( 60, 'wapuu-image', $id );
$data = array( 'id' => $id );
return new WP_REST_Response( $data, 200 );
}
function get_wapuu_image() {
$id = get_post_meta( 60, 'wapuu-image');
$data = array( 'id' => $id );
return new WP_REST_Response( $data, 200 );
}
- GTRQPTG
http://example.net/wp-json/
wapuu/v1/get
{"id":"001"}
JQP EQFG
QP CT
- p
G OCIG PVODGS
api="http://example.net/wp-json/wapuu/v1/get"
def img_number():
try:
html = urllib.urlopen( api ).read()
except:
return None
data = json.loads(html)
return data['id']
e t c
G S WG OCIG D PVODGS
image_dir = "~/wapuu/"
viewer = "~/rpi-rgb-led-matrix/utils/led-image-viewer"
opt = " --led-daemon --led-gpio-mapping=adafruit-hat" +
" --led-no-hardware-pulse --led-chain=4 -L"
prev = None
while True:
time.sleep(2)
number = img_number()
if number is None: continue
files = glob.glob(image_dir+number+"-*.png")
if len(files) < 1: continue
if files[0] == prev: continue
if prev is not None: kill_img()
commands.getstatusoutput("sudo "+viewer+opt+files[0])
prev = files[0]
j t c
?VSP QHH OCIG JGP EJCPIG
pattern = r"^ *(d+) .*/led-image-viewer"
def kill_img ():
id = []
ps_list = commands.getoutput('ps awx')
for process in ps_list.split("n"):
match = re.match(pattern, process)
if not match: continue
id.append(match.group(1))
commands.getoutput("sudo kill "+" ".join(id))
GNGE CIG
<form method="post"
action="/wp-json/wapuu/v1/set/001">
<div>[caption id="attachment_40"
align="alignleft" width="150"]
<img src="/wp-content/uploads/
2017/09/001-original-150x150.png"
alt="001" width="150" height="150"
class="size-thumbnail wp-image-40" />
Original (WordCamp 2011 Fukuoka)<br>
<button type="submit" value="001">

Submit</button>
[/caption]</div></form>
z
?GORGSC VSG& VO F 7QIIGS
GPTG -?


GPTG -?


1PW SQ R -?
1PW SQ R -?
GCTVSG GORGSC VSG&JVO F
from sense_hat import SenseHat
sense = SenseHat()
temp = sense.get_temperature()
print("Temperature: %s C" % temp)
humi = sense.get_humidity()
print("Humidity: %s %%rH" % humi)
h
/QPWGS P Q F TEQOHQS PFG
0.81Td +0.01H(0.99Td -14.3) +46.3
Td: Temp (℃)
H: Humidity
AQSF SGTTe
7QI J AQSF SGTT
e
CMG ISCRJ D
AQSF SGTT CT
0C C QSG
/VT QO QT ? RG
J RT &&EQFG QSFRSGTT QSI&RQT B RG
add_action( 'init', 'create_fever_log_type' );
function create_fever_log_type() {
register_post_type( 'fever_log',
array(
'labels' => array(
'name' => __( 'Fever' ),
'singular_name' => __( 'Fever' )
),
'public' => true,
'has_archive' => true,
)
);
}
HGSWGSBNQI RG


/SGC G -
/VT QO 1PF Q P


/wp-json/fever/v1/log


/wp-json/fever/v1/history
x w
-FF GPF RQ P
add_action('rest_api_init', function () {
register_rest_route('fever/v1', '/log/',
array(
'methods' => 'POST',
'callback' => 'log_fever_value',
) );
register_rest_route('fever/v1' '/history/',
array(
'methods' => 'GET',
'callback' => 'get_fever_history',
) );
} );
t "(
7QI GOR JVO F
function log_fever_value() {
$obj = json_decode($_POST);
$t = $obj['temp'];
$h = $obj['humi'];
$data = array();
if (! is_numeric($t) || ! is_numeric($h) ) {
return new WP_REST_Response($data, 400);
}
$json=json_encode(array('temp'=>$t,'humi'=>$h));
$discomf = $t*0.81+$h*($t*0.99-14.3)*0.01+46.3;
t ")
7QI GOR JVO F
$post = array(
'post_type' => 'fever_log',
'post_name' => 'fever_log',
'post_content' => $json,
'post_title' => $discomf,
);
$post_ID = wp_insert_post($post);
if (! $post_ID ) {
return new WP_REST_Response($data, 500);
}
$data['post_ID'] = $post_ID;
return new WP_REST_Response($data, 200);
}
HGWGS NQI RQT
t m a"(
GCF F TEQOHQS PFG GT
function get_fever_history() {
$num = 360;
$args = array (
'post_type' => 'fever_log',
'numberposts' => $num,
'offset' => 0,
'orderby' => 'date',
'order' => 'ASC',
);
$posts = get_posts($args);
t m a")
GCF F TEQOHQS PFG GT
$data = array();
foreach ( $posts as $p ) {
setup_postdata( $p );
$data[] = array(
'date' => get_the_date('Y/m/d H:i:s'),
'discomfort' => floatval(get_the_title()),
);
}
return new WP_REST_Response($data,200);
}
& R LTQP&HGWGS&W(&J T QS
[
{"datetime":"2018/06/01 22:25:11",
"discomfort":83.0214384153},
{"datetime":"2018/06/01 22:25:35",
"discomfort":83.3682958288},
{"datetime":"2018/06/02 09:12:00",
"discomfort":82.3637111865}
]
7QII PI QP
CT
t
GPF GOR&JVO F
#!/usr/bin/python
api="http://example.net/wp-json/fever/v1/log"
import requests
from sense_hat import SenseHat
sense = SenseHat()
temp = sense.get_temperature()
humi = sense.get_humidity()
env = '{"temp":%f, "humi":%f}' % (temp, humi)
response = requests.post(api, env,
headers={'Content-Type': 'application/json'}
)
h
GPF RGS QF ECNN
$ crontab -e
*/5 * * * * /home/pi/log-env.py
{"temp":30.190403,
"humi":41.724270}
CMG SCRJ
SCRJ 7 DT
C E ? 7
<html><head>
<script type="text/javascript" src="dygraph.js">
</script>
<link rel="stylesheet" src="dygraph.css" />
</head>
<body>
<div id="graphdiv"></div>
<script type="text/javascript">
g = new Dygraph(
document.getElementById("graphdiv"),
// CSV data.
);
</script>
</body>
</html>
HVPE QPT RJR
add_action('wp_enqueue_scripts','dygraph_styles');
function dygraph_styles() {
wp_enqueue_style(
'child-style',
get_stylesheet_directory_uri().'/dygraph.css');
wp_enqueue_script(
'dygraph',
get_stylesheet_directory_uri().'/dygraph.js');
}
RQT BEQP GP
<div id="graphdiv"></div>
<script type="text/javascript">
g = new Dygraph(
// containing div
document.getElementById("graphdiv"),
// CSV or path to a CSV file.
"Time,Fevern" +
"2018-06-02 10:15:07,77.258414n" +
"2018-06-02 10:16:08,77.554262n" +
"2018-06-02 10:17:10,77.680172n" +
"2018-06-02 10:18:02,77.825666n" +
"2018-06-02 10:20:04,78.359325n" +
"2018-06-02 10:25:03,79.242797n"
);
</script>
?:0:






2N IJ SCFCS
JQ FQGT QSM
CSF CSG


v
QH CSG
fjA e
w
http://www.yuriko.net/
@lilyfanjp
J RT && TN FGTJCSG PG &
N N HCP& QSFRSGTT Q
J RT &&I JVD EQO&N N HCPLR&
QSFHGT) ( TCORNG

More Related Content

What's hot

R57shell
R57shellR57shell
R57shell
ady36
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"
Webmontag Berlin
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Masahiro Nagano
 

What's hot (20)

ZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made SimpleZeroMQ: Messaging Made Simple
ZeroMQ: Messaging Made Simple
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stack
 
ABCD firebase
ABCD firebaseABCD firebase
ABCD firebase
 
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_ЯндексеТанки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
Танки_в_Лунапарке: нагрузочное_тестирование_в_Яндексе
 
Mozilla とブラウザゲーム
Mozilla とブラウザゲームMozilla とブラウザゲーム
Mozilla とブラウザゲーム
 
Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017Parallel Computing With Dask - PyDays 2017
Parallel Computing With Dask - PyDays 2017
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
R57shell
R57shellR57shell
R57shell
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
Routing @ Scuk.cz
Routing @ Scuk.czRouting @ Scuk.cz
Routing @ Scuk.cz
 
ZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 VersionZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 Version
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 

Similar to WordPressでIoTをはじめよう

https://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=tshttps://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=ts
Arif Alexi
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
ady36
 

Similar to WordPressでIoTをはじめよう (20)

Php
PhpPhp
Php
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
Security: The Great WordPress Lockdown - WordCamp Melbourne - February 2011
Security: The Great WordPress Lockdown - WordCamp Melbourne - February 2011Security: The Great WordPress Lockdown - WordCamp Melbourne - February 2011
Security: The Great WordPress Lockdown - WordCamp Melbourne - February 2011
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Books
BooksBooks
Books
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介
 
PowerCMS X
PowerCMS XPowerCMS X
PowerCMS X
 
Django
DjangoDjango
Django
 
Mashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web AppsMashing up JavaScript – Advanced Techniques for modern Web Apps
Mashing up JavaScript – Advanced Techniques for modern Web Apps
 
Agile Testing Days 2018 - API Fundamentals - postman collection
Agile Testing Days 2018 - API Fundamentals - postman collectionAgile Testing Days 2018 - API Fundamentals - postman collection
Agile Testing Days 2018 - API Fundamentals - postman collection
 
Mashing up JavaScript
Mashing up JavaScriptMashing up JavaScript
Mashing up JavaScript
 
Database api
Database apiDatabase api
Database api
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
https://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=tshttps://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=ts
 
Serverless Functions and Vue.js
Serverless Functions and Vue.jsServerless Functions and Vue.js
Serverless Functions and Vue.js
 
Send.php
Send.phpSend.php
Send.php
 
CGI.pm - 3ло?!
CGI.pm - 3ло?!CGI.pm - 3ло?!
CGI.pm - 3ло?!
 
Itsecteam shell
Itsecteam shellItsecteam shell
Itsecteam shell
 

More from Yuriko IKEDA

More from Yuriko IKEDA (20)

デフォルト誕生日を知らべてみた
デフォルト誕生日を知らべてみたデフォルト誕生日を知らべてみた
デフォルト誕生日を知らべてみた
 
Settaya
SettayaSettaya
Settaya
 
WordCamp 5.3 & Community
WordCamp 5.3 & CommunityWordCamp 5.3 & Community
WordCamp 5.3 & Community
 
Photography staff at WordCamp Tokyo 2019
Photography staff at WordCamp Tokyo 2019Photography staff at WordCamp Tokyo 2019
Photography staff at WordCamp Tokyo 2019
 
端末開発のススメ
端末開発のススメ端末開発のススメ
端末開発のススメ
 
Local 10 周年パーティーに行ってきた話
Local 10 周年パーティーに行ってきた話Local 10 周年パーティーに行ってきた話
Local 10 周年パーティーに行ってきた話
 
Fastest routes from Meisei-univ to Shinjuku
Fastest routes from Meisei-univ to ShinjukuFastest routes from Meisei-univ to Shinjuku
Fastest routes from Meisei-univ to Shinjuku
 
Faster route from Shinjuku to Meisei univ.
Faster route from Shinjuku to Meisei univ.Faster route from Shinjuku to Meisei univ.
Faster route from Shinjuku to Meisei univ.
 
Introduce raspberry pi's 7 years
Introduce raspberry pi's 7 yearsIntroduce raspberry pi's 7 years
Introduce raspberry pi's 7 years
 
WordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティWordPress 次期バージョンと日本のコミュニティ
WordPress 次期バージョンと日本のコミュニティ
 
カルト宗教の始め方
カルト宗教の始め方カルト宗教の始め方
カルト宗教の始め方
 
WordCamp Osaka の熱気を可視化してみた
WordCamp Osaka の熱気を可視化してみたWordCamp Osaka の熱気を可視化してみた
WordCamp Osaka の熱気を可視化してみた
 
WordPressで制御するこれからのIoT
WordPressで制御するこれからのIoTWordPressで制御するこれからのIoT
WordPressで制御するこれからのIoT
 
Create LED lightened Wapuu (LEDパネルで光るわぷーを)
Create LED lightened Wapuu (LEDパネルで光るわぷーを)Create LED lightened Wapuu (LEDパネルで光るわぷーを)
Create LED lightened Wapuu (LEDパネルで光るわぷーを)
 
世界No.1 CMS WordPressへのいざない
世界No.1 CMS WordPressへのいざない世界No.1 CMS WordPressへのいざない
世界No.1 CMS WordPressへのいざない
 
LEDマトリックスで光るわぷー(WordPressで指定編その1)
LEDマトリックスで光るわぷー(WordPressで指定編その1)LEDマトリックスで光るわぷー(WordPressで指定編その1)
LEDマトリックスで光るわぷー(WordPressで指定編その1)
 
Scroll pHAT HD に美咲フォント
Scroll pHAT HD に美咲フォントScroll pHAT HD に美咲フォント
Scroll pHAT HD に美咲フォント
 
Raspi intro-20170805
Raspi intro-20170805Raspi intro-20170805
Raspi intro-20170805
 
raspi-led-matrix
raspi-led-matrixraspi-led-matrix
raspi-led-matrix
 
架空鉄道紹介誌の制作
架空鉄道紹介誌の制作架空鉄道紹介誌の制作
架空鉄道紹介誌の制作
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

WordPressでIoTをはじめよう

  • 1. AQSF SGTTe Q?t jbnp CS Q? J AQSF SGTT
  • 2. P GSPG QH ?J PIT iw
  • 3. gueo 1WGS J PI QP PG QSM
  • 4. J N RT VG
  • 6. _ QRVNCS TOCNN EQORV GST Q/ AG IJ S EG
  • 7.
  • 10. 1 ? -
  • 11. A i t : : P G A FC C {"id":1,
 "date":"2017-05-23T06:25:50",
 "date_gmt":"2017-05-23T06:25:50",
 "guid":{"rendered":"http://demo.wp-api.org/?p=1"},
 "modified":"2017-05-23T06:25:50",
 "modified_gmt":"2017-05-23T06:25:50",
 "slug":"hello-world",
 "status":"publish",
 "type":"post",
 "link":"https://demo.wp-api.org/2017/05/23/hello-world/",
 "title":{"rendered":"Hello world!"},
 "content":{"rendered":"<p>Welcome to...
  • 12. x w i 1PFRQ P T
  • 13. y /VT QO G CWC NCDNG
  • 14. x w G GPFRQ P add_action( 'rest_api_init', function () { register_rest_route( 'anything/v1', '/get', array( 'methods' => 'GET', 'callback' => 'get_anything_awesome', ) ); } ); function get_anything_awesome() { $data = array('result' => 'great data'); return new WP_REST_Response( $data, 200 ); }
  • 17.
  • 21. 710 C S CPGN
  • 22. . C S .QPPG
  • 23. t dg GS ECN EQPPGE NCPFTECRG RCPGN
  • 31. PT CNN CEMCIGT $ sudo apt install git libgraphicsmagick++-dev libwebp-dev
  • 32. . 710 C S
  • 33. OCMG $ git clone https://github.com/ hzeller/rpi-rgb-led-matrix $ cd rpi-rgb-led-matrix $ make -C examples-api-use $ cd utils $ make led-image-viewer
  • 34. 0GOQ $ cd example-api-use $ sudo ./demo 
 --led-gpio-mapping=adafruit-hat --led-no-hardware-pulse --led-chain=4 -L 
 -D 0
  • 37. h lr -SSCPIG Q NCPFTECRG
  • 38. ESQNN 0GOQ $ sudo ./demo 
 --led-gpio-mapping=adafruit-hat --led-no-hardware-pulse --led-chain=4 -L 
 -D 1 ../../images/wapuu.ppm
  • 40. A - e OCIG /JCPIG -
  • 41. /VT QO 1PF Q P /wp-json/wapuu/v1/set/NNN /wp-json/wapuu/v1/get
  • 42. x w -FF GPF RQ P add_action( 'rest_api_init', function () { register_rest_route( 'wapuu/v1', '/set/(?P<id>d+)', array( 'methods' => 'POST', 'callback' => 'set_wapuu_image', 'args' => array( 'id' => array( 'validate_callback' => function($param, $request, $key) { return is_numeric( $param ); } ), ), ) ); register_rest_route( 'wapuu/v1', '/get', array( 'methods' => 'GET', 'callback' => 'get_wapuu_image', ) ); } );
  • 43. t CWG& G OCIG PVODGS function set_wapuu_image( $data ) { $id = $data['id']; update_post_meta( 60, 'wapuu-image', $id ); $data = array( 'id' => $id ); return new WP_REST_Response( $data, 200 ); } function get_wapuu_image() { $id = get_post_meta( 60, 'wapuu-image'); $data = array( 'id' => $id ); return new WP_REST_Response( $data, 200 ); }
  • 46. - p G OCIG PVODGS api="http://example.net/wp-json/wapuu/v1/get" def img_number(): try: html = urllib.urlopen( api ).read() except: return None data = json.loads(html) return data['id']
  • 47. e t c G S WG OCIG D PVODGS image_dir = "~/wapuu/" viewer = "~/rpi-rgb-led-matrix/utils/led-image-viewer" opt = " --led-daemon --led-gpio-mapping=adafruit-hat" + " --led-no-hardware-pulse --led-chain=4 -L" prev = None while True: time.sleep(2) number = img_number() if number is None: continue files = glob.glob(image_dir+number+"-*.png") if len(files) < 1: continue if files[0] == prev: continue if prev is not None: kill_img() commands.getstatusoutput("sudo "+viewer+opt+files[0]) prev = files[0]
  • 48. j t c ?VSP QHH OCIG JGP EJCPIG pattern = r"^ *(d+) .*/led-image-viewer" def kill_img (): id = [] ps_list = commands.getoutput('ps awx') for process in ps_list.split("n"): match = re.match(pattern, process) if not match: continue id.append(match.group(1)) commands.getoutput("sudo kill "+" ".join(id))
  • 49. GNGE CIG <form method="post" action="/wp-json/wapuu/v1/set/001"> <div>[caption id="attachment_40" align="alignleft" width="150"] <img src="/wp-content/uploads/ 2017/09/001-original-150x150.png" alt="001" width="150" height="150" class="size-thumbnail wp-image-40" /> Original (WordCamp 2011 Fukuoka)<br> <button type="submit" value="001">
 Submit</button> [/caption]</div></form>
  • 50. z ?GORGSC VSG& VO F 7QIIGS
  • 53. 1PW SQ R -?
  • 54. 1PW SQ R -?
  • 55. GCTVSG GORGSC VSG&JVO F from sense_hat import SenseHat sense = SenseHat() temp = sense.get_temperature() print("Temperature: %s C" % temp) humi = sense.get_humidity() print("Humidity: %s %%rH" % humi)
  • 56. h /QPWGS P Q F TEQOHQS PFG 0.81Td +0.01H(0.99Td -14.3) +46.3 Td: Temp (℃) H: Humidity
  • 57. AQSF SGTTe 7QI J AQSF SGTT
  • 60. /VT QO QT ? RG J RT &&EQFG QSFRSGTT QSI&RQT B RG add_action( 'init', 'create_fever_log_type' ); function create_fever_log_type() { register_post_type( 'fever_log', array( 'labels' => array( 'name' => __( 'Fever' ), 'singular_name' => __( 'Fever' ) ), 'public' => true, 'has_archive' => true, ) ); }
  • 63. /VT QO 1PF Q P 
 /wp-json/fever/v1/log 
 /wp-json/fever/v1/history
  • 64. x w -FF GPF RQ P add_action('rest_api_init', function () { register_rest_route('fever/v1', '/log/', array( 'methods' => 'POST', 'callback' => 'log_fever_value', ) ); register_rest_route('fever/v1' '/history/', array( 'methods' => 'GET', 'callback' => 'get_fever_history', ) ); } );
  • 65. t "( 7QI GOR JVO F function log_fever_value() { $obj = json_decode($_POST); $t = $obj['temp']; $h = $obj['humi']; $data = array(); if (! is_numeric($t) || ! is_numeric($h) ) { return new WP_REST_Response($data, 400); } $json=json_encode(array('temp'=>$t,'humi'=>$h)); $discomf = $t*0.81+$h*($t*0.99-14.3)*0.01+46.3;
  • 66. t ") 7QI GOR JVO F $post = array( 'post_type' => 'fever_log', 'post_name' => 'fever_log', 'post_content' => $json, 'post_title' => $discomf, ); $post_ID = wp_insert_post($post); if (! $post_ID ) { return new WP_REST_Response($data, 500); } $data['post_ID'] = $post_ID; return new WP_REST_Response($data, 200); }
  • 68. t m a"( GCF F TEQOHQS PFG GT function get_fever_history() { $num = 360; $args = array ( 'post_type' => 'fever_log', 'numberposts' => $num, 'offset' => 0, 'orderby' => 'date', 'order' => 'ASC', ); $posts = get_posts($args);
  • 69. t m a") GCF F TEQOHQS PFG GT $data = array(); foreach ( $posts as $p ) { setup_postdata( $p ); $data[] = array( 'date' => get_the_date('Y/m/d H:i:s'), 'discomfort' => floatval(get_the_title()), ); } return new WP_REST_Response($data,200); }
  • 70. & R LTQP&HGWGS&W(&J T QS [ {"datetime":"2018/06/01 22:25:11", "discomfort":83.0214384153}, {"datetime":"2018/06/01 22:25:35", "discomfort":83.3682958288}, {"datetime":"2018/06/02 09:12:00", "discomfort":82.3637111865} ]
  • 72. t GPF GOR&JVO F #!/usr/bin/python api="http://example.net/wp-json/fever/v1/log" import requests from sense_hat import SenseHat sense = SenseHat() temp = sense.get_temperature() humi = sense.get_humidity() env = '{"temp":%f, "humi":%f}' % (temp, humi) response = requests.post(api, env, headers={'Content-Type': 'application/json'} )
  • 73. h GPF RGS QF ECNN $ crontab -e */5 * * * * /home/pi/log-env.py {"temp":30.190403, "humi":41.724270}
  • 76. C E ? 7 <html><head> <script type="text/javascript" src="dygraph.js"> </script> <link rel="stylesheet" src="dygraph.css" /> </head> <body> <div id="graphdiv"></div> <script type="text/javascript"> g = new Dygraph( document.getElementById("graphdiv"), // CSV data. ); </script> </body> </html>
  • 77. HVPE QPT RJR add_action('wp_enqueue_scripts','dygraph_styles'); function dygraph_styles() { wp_enqueue_style( 'child-style', get_stylesheet_directory_uri().'/dygraph.css'); wp_enqueue_script( 'dygraph', get_stylesheet_directory_uri().'/dygraph.js'); }
  • 78. RQT BEQP GP <div id="graphdiv"></div> <script type="text/javascript"> g = new Dygraph( // containing div document.getElementById("graphdiv"), // CSV or path to a CSV file. "Time,Fevern" + "2018-06-02 10:15:07,77.258414n" + "2018-06-02 10:16:08,77.554262n" + "2018-06-02 10:17:10,77.680172n" + "2018-06-02 10:18:02,77.825666n" + "2018-06-02 10:20:04,78.359325n" + "2018-06-02 10:25:03,79.242797n" ); </script>
  • 79.
  • 82.
  • 85. v
  • 87.
  • 88. fjA e
  • 89. w
  • 90. http://www.yuriko.net/ @lilyfanjp J RT && TN FGTJCSG PG & N N HCP& QSFRSGTT Q J RT &&I JVD EQO&N N HCPLR& QSFHGT) ( TCORNG