<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>JavaScriptでスクリーンショット</title> </head> <body> <hr> <div style="background-color : #AAEEDD"><h1>JavaScriptで撮るスクリーンショット</h1></div> <div id="target"> <h2>導入方法と処理概要</h2> <table border="1" width="500" cellspacing="0" cellpadding="5" bordercolor="#333333" style="table-layout: fixed;"> <tr> <th bgcolor="#7b9ad0" width="40"><font color="#FFFFFF">No</font></th> <th bgcolor="#7b9ad0" width="230"><font color="#FFFFFF">概要</font></th> <th bgcolor="#7b9ad0" width="230"><font color="#FFFFFF">補足</font></th> </tr> <tr> <td bgcolor="#b1d7e4" width="40" align="right">1</td> <td bgcolor="#7b9ad0" width="230">任意のタイミングでhtml2canvas関数を呼ぶ</td> <td bgcolor="#7b9ad0" width="230">※今回はオンロード処理</td> </tr> <tr> <td bgcolor="#b1d7e4" width="40" align="right">2</td> <td bgcolor="#7b9ad0" width="230">任意のタイミングでhtml2canvas関数を呼ぶ</td> <td bgcolor="#7b9ad0" width="230">※今回はオンロード処理</td> </tr> <tr> <td bgcolor="#b1d7e4" width="40" align="right">3</td> <td bgcolor="#7b9ad0" width="230">onrendered処理にて指定のElementに画像を追記</td> <td bgcolor="#7b9ad0" width="230">※[img]タグの[src]や、[a]タグの[href]など</td> </tr> </table> </div> <br> <hr> <h3>↓↓ここから画像↓↓ (上の対象のDIVを画像化)</h3> <img src="" id="result"> <h3>↑↑ここまで画像↑↑</h3> <hr> <a href="" id="ss" download="html_ss.png">スクリーンショット(document.body全体)をダウンロード</a> <hr> <h3>注意</h3> <ul> <li>実際にはスクリーンショットを撮っているわけではない</li> <li>html2canvasは、HTML内のDOMやCCSを解釈してCanvas上に描画するライブラリ</li> <li>つまり、レンダリングエンジンに近い動作をする</li> <li>そのため、ブラウザと異なる表示がされる場合がある</li> <li>flashやapplet, iframe(別URL)はうまくキャプチャできない</li> </ul> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script> <script> window.onload = function(){ html2canvas(document.getElementById("target"),{ onrendered: function(canvas){ var imgData = canvas.toDataURL(); document.getElementById("result").src = imgData; } }); html2canvas(document.body, { onrendered: function(canvas){ var imgData = canvas.toDataURL(); document.getElementById("ss").href = imgData; } }); } </script> </body> </html>
Canvasでiconを作る
<style> ul.icon{ list-style:none; } ul.icon li { position: relative; margin-bottom: 0.5em; } ul.icon li canvas { position: absolute; top: 0.3em; left: -13px; } </style> <ul class="icon"> <li>item01</li> <li>item02</li> <li>item03</li> <li>item04</li> <li>item05</li> </ul> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script type="text/javascript"> $(function(){ var list = $('ul.icon li'); list.prepend('<canvas width="20" height="20" />'); var ctx = null; list.each(function (i){ var canvas = $('canvas', list).get(i); ctx = canvas.getContext('2d'); drawIcon(); }); function drawIcon(){ ctx.beginPath(); ctx.arc(6, 10, 6, 0, Math.PI*2); ctx.fillStyle = 'rgb(50, 150, 255)'; ctx.fill(); ctx.beginPath(); ctx.moveTo(5, 7); ctx.lineTo(8, 9); ctx.lineTo(5, 12); ctx.closePath(); ctx.fillStyle = 'rgb(255, 255, 255)'; ctx.fill(); } }); </script>
なるほどー
SAML
SAML is an abbreviation of Security Assertion Markup Language and is called “Samuru”.
SAML is a standard of authentication information developed by OASIS for authenticating users between different Internet domains. In other words, it refers to a rule protocol that exchanges user credentials.
Idp (= Identify Provider) is a system that provides authentication information. Without SAML, it is necessary to convert the format and format of information when the IdP and SP exchange information. You can save the trouble of that work.
Convenient improvement
With SSO, you can log in to different services with or user authentication. Because you do not need to authenticate each time, you can use the service comfortably.
Security improvements
Some users may be uneasy about the availability of many services with one authentication system. However, considering that most users use the same ID and password for all services and that only one login information needs to be managed securely, it can be said that there are security advantages as well.
ブラウザをエディタにする
ブラウザの入力欄に以下を打ち込む
data:text/html, <html contenteditable>
なるほどー意外と簡単
apache execute user
To change the user running Apache, you need to change the user specification in httpd.conf. If nothing is specified, the daemon user is specified.
[vagrant@localhost ~]$ ps aux | grep http
root 2040 0.0 2.4 384472 12512 ? Ss 11:44 0: 02 /usr/sbin/httpd
jenkins 2083 0.5 56.8 2273640 285232 ? Ssl 11:45 2: 54 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -D java.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /u sr/lib/jenkins/jenkins.war –logfile=/var/log/jenkins/jenkins. log –webroot=/var/cache/jenkins/war –daemon –httpPort=8080 –debug=5 –handlerCountMax=100 –handlerCountMaxIdle=20
apache 2488 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2489 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2490 0.0 2.0 386112 10300 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2491 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2492 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2493 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2494 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
apache 2495 0.0 2.0 386112 10280 ? S 12:23 0: 00 /usr/sbin/httpd
vagrant 4449 0.0 0.1 103320 872 pts/0 D+ 20:52 0: 00 grep http
うーん、apacheって書いてあるように見える。。
[vagrant@localhost ~]$ id apache
uid=48(apache) gid=48(apache) 所属グループ=48(apache)
migrationファイルによるカラム修正
<?php use Illuminate\Support\Facades\Schema\; use Illuminate\Database\Schema\Blueprint\; use Innuminate\Database\Migrations\Migration; class AddColumnSalesHogeTable extends Migration{ public function up(){ Schema::table('books', function(Blueprint $table){ $table->integer('sales')->default(0)->index('index_sales')->after('price')->comment('販売数'); }); } public function down() { Schema::table('books', function(Blueprint $table){ $table->dropColumn('sales'); }); } }
CHARACTER_OCTET_LENGTH
CHARACTER_OCTET_LENGTH must be the same as CHARACTER_MAXIMUM_LENGTH except for multibyte character set.
mysql> select * from `information_schema`.`columns` where `table_schema` = “test”;
+—————+————–+————+————-+——————+—————-+————-+———–+————————–+————————+——————-+—————+——————–+——————–+—————–+————–+————+—————-+———————————+—————-+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA | PRIVILEGES | COLUMN_COMMENT |
+—————+————–+————+————-+——————+—————-+————-+———–+————————–+————————+——————-+—————+——————–+——————–+—————–+————–+————+—————-+———————————+—————-+
| def | test | items | item_id | 1 | NULL | NO | int | NULL | NULL | 10 | 0 | NULL | NULL | NULL | int(11) | PRI | auto_increment | select,insert,update,references | |
| def | test | items | name | 2 | NULL | YES | text | 65535 | 65535 | NULL | NULL | NULL | utf8 | utf8_general_ci | text | | | select,insert,update,references | |
| def | test | items | price | 3 | NULL | YES | int | NULL | NULL | 10 | 0 | NULL | NULL | NULL | int(11) | | | select,insert,update,references | |
| def | test | name | name | 1 | NULL | YES | varchar | 255 | 765 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(255) | | | select,insert,update,references | |
| def | test | name | password | 2 | NULL | YES | varchar | 255 | 765 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(255) | | | select,insert,update,references | |
| def | test | news | id | 1 | NULL | NO | int | NULL | NULL | 10 | 0 | NULL | NULL | NULL | int(11) | PRI | auto_increment | select,insert,update,references | |
| def | test | news | content | 2 | NULL | YES | varchar | 100 | 300 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(100) | | | select,insert,update,references | |
| def | test | user | id | 1 | NULL | NO | int | NULL | NULL | 10 | 0 | NULL | NULL | NULL | int(11) | MUL | auto_increment | select,insert,update,references | |
| def | test | user | name | 2 | NULL | YES | varchar | 20 | 60 | NULL | NULL | NULL | utf8 | utf8_general_ci | varchar(20) | | | select,insert,update,references | |
+—————+————–+————+————-+——————+—————-+————-+———–+————————–+————————+——————-+—————+——————–+——————–+—————–+————–+————+—————-+———————————+—————-+
9 rows in set (0.15 sec)
なんじゃーこりゃーーー
Laravel cache clear command
Even after restarting Apache, sometimes has internal chaches that don’t reflect the updated program.
php artisan cache: clear php artisan config: clear php artisan route: clear php artisan view clear
If you want to do autoloading and re-optimize, you want to recreate the cache entirely.
composer dump-autoload php artisan clear-compiled php artisan optimize php artisan config:cache
When recreating a new key and completely invalidate the previous cache.
php artisan key:generate
zipからダウンロード
set_time_limit(0); $zip_name = 'create_zip_'.date('Ymd').'.zip'; $zip_tmp_dir = dirname(__FILE__).'/tmp_zip/'; $zip_obj = new ZipArchive(); $result = $zip_obj -> open($zip_tmp_dir.$zip_name, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); if(!$result){ echo 'error code : '.$result; exit(); } $files[] = [ 'zip_path' => 'building.jpg', 'file_path' => dirname(__FILE__)."/".'building.jpg' ]; foreach ($files as $file) { //ファイルを追加する場合 $zip_obj -> addFile($file['file_path'], $file['zip_path']); } $zip_obj -> addFromString('test.txt', 'test'); $zip_obj -> close(); header('Content-Type: application/force-download;'); header('Content-Length: '.filesize($zip_tmp_dir.$zip_name)); header('Content-Disposition: attachment; filename="'.$zip_name.'"'); readfile($zip_tmp_dir.$zip_name);
$files[] = [ 'zip_path' => ['building.jpg', 'monkey.jpg'], 'file_path' => ['building.jpg', 'monkey.jpg'] ]; foreach ($files as $file) { //ファイルを追加する場合 $zip_obj -> addFile( dirname(__FILE__)."/".$file['file_path'], $file['zip_path']); }
[Sun Apr 7 16:33:50 2019] PHP Notice: Undefined index: /home/vagrant/local/app/test/file_path in /home/vagrant/local/app/test/index.php on line 24
[Sun Apr 7 16:33:50 2019] PHP Warning: ZipArchive::addFile() expects parameter 2 to be string, array given in /home/vagrant/local/app/test/index.php on line 24
うん、まー要するに配列で渡せば、zipで複数ダウンロードできるってわけね。
チェックボックスなら、POSTで対象ファイルを渡せばOK
phpのzip機能
Check if PHP has Zip extension
[vagrant@localhost test]$ php -m [PHP Modules] bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv intl json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session SimpleXML sockets SPL sqlite3 standard tokenizer wddx xml xmlreader xmlwriter xsl zip zlib
うん、ありますね。