Skip to content

Instantly share code, notes, and snippets.

@masalib
masalib / auth.ts
Created June 7, 2020 08:21
DenoでJWTの認証(ブログ説明用のソース)
//import { config } from "https://deno.land/x/dotenv/mod.ts";
import users from "../users.ts";
import { makeJwt, setExpiration, Jose, Payload } from "https://deno.land/x/djwt/create.ts"
import { validateJwt } from "https://deno.land/x/djwt/validate.ts"
import { Context } from "https://deno.land/x/oak/mod.ts";
import * as bcrypt from "https://deno.land/x/bcrypt/mod.ts";
const key = "xxxxxxsome-random-secret-keyxxxxxxxxx";
const header: Jose = {
@masalib
masalib / function.php
Created June 3, 2020 07:53
wordpressの最近の投稿のリストから特定のカテゴリを非表示にする
class WP_Widget_Recent_Posts_Exclude extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
parent::__construct('recent-posts', __('Recent Posts with Exclude'), $widget_ops);
$this->alt_option_name = 'widget_recent_entries';
add_action( 'save_post', array(&$this, 'flush_widget_cache') );
add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
@masalib
masalib / text
Created May 9, 2020 06:41
Beginnertext
①Spoonの機能
1.LIVE:最大で2時間配信ができる
2.CAST:30秒以上で録音が可能です
3.Talk:30秒以内でお題に答える所です
②記号の意味
🎧:今見ている人の数
❤:ハートをいただいた数(いいねみたいなもの)
👤:配信にきてくれた人の数(トータルリスナー)
@masalib
masalib / test.php
Created April 2, 2019 12:09
phpで、長文を「。」区切りでフラッシュ表示させるプログラム
<html>
<head>
<title>phpでlist.txt読み込むという制限がめんどくさい</title>
<script language="JavaScript">
count = 0;
function setTextLine()
{
str = new Array();
<?php
// 入力ファイルパス
@masalib
masalib / blog.css
Created September 3, 2018 08:50
はてなブログのデザインcss
/* <system section="theme" selected="8599973812288545210"> */
@charset "utf-8";
@import url('https://fonts.googleapis.com/css?family=Sacramento');
/*
Theme: Yumekawa
Theme URI:http://minimalgreen.hatenadiary.com/
Author: minimalgreen
Author URI: http://design.syofuso.com/
Description:
@masalib
masalib / 食レポテンプレート.txt
Created August 28, 2018 17:19
食レポテンプレートのmarkdown
リード文章
概要と良かった事、悪かった事を3行程度にする
長いと読んでもらえない
<!-- more -->
<details><summary>目次(クリックすると展開されます)</summary>
[:contents]
@masalib
masalib / sw.js
Created August 12, 2018 11:18
PWA:Workboxのサンプル2
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.4.1/workbox-sw.js');
if (workbox) {
// Force development builds
workbox.setConfig({ debug: true });
// Force production builds
//workbox.setConfig({ debug: false });
console.log(`Yay! Workbox is loaded 🎉`);
@masalib
masalib / sw.js
Created August 12, 2018 06:10
PWA:Workboxとは
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.4.1/workbox-sw.js');
if (workbox) {
workbox.routing.registerRoute(
/.*\.css/,
workbox.strategies.staleWhileRevalidate({
cacheName: 'css-cache',
})
);
} else {
@masalib
masalib / sw.js
Created August 12, 2018 04:42
PWA:Workboxのサンプル1
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.4.1/workbox-sw.js');
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
} else {
console.log(`Boo! Workbox didn't load 😬`);
}
@masalib
masalib / sw.js
Created August 11, 2018 11:07
PWAとはサンプルソース7
const cacheName = 'v3';
// インストールイベント
self.addEventListener('install',e => {
console.log('Service Worker: sw.js is Installed');
});
// アクティブイベント
self.addEventListener('activate',e => {
console.log('Service Worker: sw.js is Activater ');