Skip to content

Instantly share code, notes, and snippets.

@tkc49
tkc49 / mocha-chai-puppeteer.js
Last active May 9, 2021 08:35
Mocha と Chai を Puppeteer を使ったテスト
// Puppeteerのインストール
// npm install puppeteer
// Mochaのインストール
// npm install mocha
// chaiのインストール
// npm install chai
const puppeteer = require('puppeteer');
@tkc49
tkc49 / test.js
Created January 28, 2021 16:23
reduceの中でrecordの'種別'が'欠勤'じゃない時だけ取得日数を足す
(function () {
"use strict";
kintone.events.on([
'app.record.edit.submit'
], function (event) {
return new kintone.Promise(function(resolve){
RelatedRecordsFieldManager.prototype.getFieldProperties().then(function(){
(new RelatedRecordsFieldManager('取得履歴')).getRecords(event.record).then(function(records){
event.record.totalAmount2.value = records.reduce(function (sum, record) {
@tkc49
tkc49 / mocha-chai-puppeteer.js
Created December 7, 2019 07:55
Mocha と Chai を Puppeteer を使ったテスト
// Puppeteerのインストール
// npm i puppeteer
// Mochaのインストール
// npm install mocha
// chaiのインストール
// npm install chai
const puppeteer = require('puppeteer');
(function ($) {
$(function () {
$('.wpsm_panel-body').each(function (index, element) {
// replace newline code to br tag
let replacedWpsmPanelBodyHtml = $(element).html().replace(/\r?\n/g, '<br>');
$(element).html(replacedWpsmPanelBodyHtml);
// remove <br> of first
@tkc49
tkc49 / code.html
Last active March 10, 2018 02:45
CoderDojo Japan Newsletter Code
<!-- Begin MailChimp Signup Form -->
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; width:100%;}<br /> /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.<br /> We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */<br /></style>
<div id="mc_embed_signup"><form id="mc-embedded-subscribe-form" class="validate" action="https://coderdojo.us17.list-manage.com/subscribe/post?u=39a5824e42ab56ec44bb4e84e&amp;id=097dfa6a14" method="post" name="mc-embedded-subscribe-form" novalidate="" target="_blank">
<div id="mc_embed_signup_scroll">
<input id="mce-EMAIL" class="email" name="EMAIL" required="" type="email" value="" placeholder="メールアドレス" />
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input tabindex="-1" name="b_39a5824e42ab56ec44bb4e84e_0
@tkc49
tkc49 / __MAGIKCRAFT__.tkc49.magikcraft_spells.md
Last active October 8, 2017 07:03
Magikcraft Spells, by tkc49.
@tkc49
tkc49 / gist:e1114c0e7203cb1a37bc
Last active August 16, 2017 06:21
タームをカスタマイズする際に必要なフック
<?php
public function plugins_loaded(){
add_action ( 'edited_term',array($this,'save_extra_category_fileds')); // 編集画面の保存
add_action ( 'created_term',array($this,'save_extra_category_fileds')); // 新規追加の保存
}
public function init(){
$args=array('public' => true,'_builtin' => false ); // builtin=false(WordPressが設定してるものは省く)
$output = 'names'; // or objects
@tkc49
tkc49 / gist:5625795
Last active December 17, 2015 14:39
記事毎に所属しているカスタム分類を表示した場合、カスタム分類の一覧表示の並び順と一緒の並びにする ※別途カスタム分類の並び順を制御するプラグインが必要
<?php
// functions.php に追記
function terms($a, $b){
if ( intval($a->term_order) == intval($b->term_order)) {
return 0;
}
return (intval($a->term_order) < intval($b->term_order)) ? -1 : 1;
}
@tkc49
tkc49 / gist:5596616
Last active December 17, 2015 10:39
カスタム投稿タイプのシングルページが表示された時に任意のカスタムメニューにcurrent-menu-itemのクラスを追加する処理
<?php
function add_nav_menu_custom_class( $menu_items ) {
$lists = array(
'post_type1' => 'page_slug1',
'post_type2' => 'page_slug2',
'post_type3' => 'page_slug3',
'post_type4' => 'page_slug4',
'post_type5' => 'page_slug5',
'post_type6' => 'page_slug6',
@tkc49
tkc49 / gist:5229399
Last active December 15, 2015 08:18
[WordPress] Change edior-style. front-page,page /editor-styleのcssをフロントページと各固定ページごとに切り替える
if(is_admin() && isset( $_GET['post'] )){
if($_GET['post']==get_option( 'page_on_front' )){
if ( locate_template( array( 'editor-style-front.css' ) ) ) {
add_editor_style('editor-style-front.css');
}else{
add_editor_style();
}
}else{
if ( locate_template( array( sprintf('editor-style-%s.css' , get_page($_GET['post'])->post_name ) ) ) ) {
add_editor_style(sprintf('editor-style-%s.css' , get_page($_GET['post'])->post_name ));