Instantly share code, notes, and snippets.

View tello.js
#!/usr/bin/env node
'use strict'
const PORT = 8889;
const HOST = '192.168.10.1';
const dgram = require('dgram');
const client = dgram.createSocket('udp4');
View screenshot.js
const puppeteer = require('puppeteer');
async function sleep(delay) {
return new Promise(resolve => setTimeout(resolve, delay));
}
(async () => {
const browser = await puppeteer.launch({
disable-gpu: true,
args: ['--no-sandbox']
View ja.md

The length of the excerpt should be localizable.

We can make it localizable by adding number of the length into .po like following.

msgctxt "excerpt length"
msgid "40"

The length of the comment in dashboard should be localizable.

View example.md
layout title date categories
post
Welcome to Jekyll!
2015-11-17 16:16:01 -0600
jekyll update

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run bundle exec jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the _posts directory that follows the convention YYYY-MM-DD-name-of-post.ext and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

View gist:ccd63d44ba89e74fa7e8e88cfea92937

目的

持続性がある方法を目指す。

  • インフラコストがかからないこと。
  • 特定の誰かに権限が集中しないこと。
  • すべてが公開された場所に残ること。(たとえば閲覧する際に認証とが必要ないこと。パーマリンクがあって後から参照しやすいこと。)
  • オープンソースコミュニティっぽい方法であること。「オープンソースっぽい」は毎日進化してます。
View file0.txt
$ composer require symfony/dom-crawler symfony/css-selector --dev
View install-php56-to-vccw.sh
#!/usr/bin/env bash
set -ex
PHP_VERSION=${1-"7.0"}
sudo apt update -y
sudo apt install \
php${PHP_VERSION} \
View jpegoptim.php
<?php
add_filter( 'wp_image_editors', function( $editors ) {
if ( ! class_exists( '_WP_Image_Editor_GD' ) ) {
class _WP_Image_Editor_GD extends WP_Image_Editor_GD {
protected function _save( $image, $filename = null, $mime_type = null ) {
$saved = parent::_save( $image, $filename, $mime_type );
if ( ! empty( $saved["mime-type"] ) && 'image/jpeg' == $saved["mime-type"] ) {
jpegoptim( $saved['path'] );
}
View features.diff
diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php
index aaf39713..ae0adb9d 100644
--- a/features/bootstrap/FeatureContext.php
+++ b/features/bootstrap/FeatureContext.php
@@ -1,14 +1,14 @@
<?php
use Behat\Behat\Context\ClosuredContextInterface,
- Behat\Behat\Context\TranslatedContextInterface,
- Behat\Behat\Context\BehatContext,
View mysql.sh
sudo chown -R mysql:mysql /var/lib/mysql
sudo mysql_install_db --datadir=/var/lib/mysql --user=mysql
sudo service mysql start