Skip to content

Instantly share code, notes, and snippets.

View kohki-shikata's full-sized avatar

Kohki SHIKATA kohki-shikata

View GitHub Profile
@kohki-shikata
kohki-shikata / delayedProcess.ts
Created July 15, 2024 04:28
逐次処理をPromise.allで非同期に並列処理したいが、少しだけディレイを入れたい(APIの制限対策など)
const delayFunc = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
const syncronusProcess = async (
flag: string | undefined,
time: number = 1000,
iteration: number = 4,
) => {
let i = 1;
while (i <= iteration) {
@kohki-shikata
kohki-shikata / createRandom.test.ts
Created July 8, 2024 03:03
[Node.js]ランダムな整数を出力する(テスト)
// テストにはJestを使用
import { createRandom } from "../functions/helpers";
describe('Create random number between two value: Normal Pattern', () => {
test('Return random value is correct', () => {
const min = 1;
const max = 5;
expect(createRandom(min, max)).toBeLessThanOrEqual(max)
expect(createRandom(min, max)).toBeGreaterThanOrEqual(min)
@kohki-shikata
kohki-shikata / createRandom.ts
Last active July 8, 2024 03:02
[TypeScript] ランダムな整数を返却する。
// 配列をランダムに出力したいときの添字出力用
// バリデーションには、Joiを使用
// 負の値、小数点には対応しない
import Joi from 'joi'
const schema = Joi.object().keys({
min: Joi.number().min(0),
max: Joi.number().positive()
})
javascript:(()%3D%3E%7B(A%3D%3E%7Bconst%20I%3Ddocument.createElement(%22script%22)%3BI.src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fpush.js%2F0.0.11%2Fpush.min.js%22%2CI.onload%3Dasync()%3D%3E%7Bawait%20A(Push)%7D%2Cdocument.body.appendChild(I)%7D)(((A%2CI)%3D%3E%7Bconst%20C%3D()%3D%3E%7Bconst%20I%3Ddocument.querySelectorAll(%22.status%22)%3Blet%20C%3D%5B%5D%3BI.forEach((A%3D%3E%7BC.push(A)%7D))%3Bconst%20g%3DC.filter((A%3D%3E%22%E5%AE%8C%E4%BA%86%EF%BC%81%22%3D%3D%3DA.textContent))%3Bif(I.length%3D%3D%3Dg.length%26%26I.length%3E0)%7BA.create(%22%E3%82%A2%E3%83%83%E3%83%97%E5%AE%8C%E4%BA%86%22%2C%7Bbody%3A%22%E3%81%82%E3%81%AA%E3%81%9F%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E3%81%8C%E5%85%A8%E3%81%A6%E5%AE%8C%E4%BA%86%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F%EF%BC%81%22%2Cicon%3A%22https%3A%2F%2Fgigafile.nu%2Ffavicon.ico%22%2Ctimeout%3A1e4%2ConClick%3A()%3D%3Ethis.close()%7D)%3Bnew%20Audio(%22data%3Aaudio%2Fmp3%3Bbase64%2C%22%2B%22SUQzAwAAAAAxKVBSSVYAABCfAABYTVAAPD94cGFja2V0I
void((f => {
// Push.jsをCDNから読み込み
const script = document.createElement('script')
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/push.js/0.0.11/push.min.js'
script.onload = async () => {
await f(Push)
}
<!-- /packages/test_package/db.xml -->
<?xml version="1.0"?>
<schema version="0.3">
<table name="YoutubeAPIKey">
<field name="apikey" type="X2">
</field>
</table>
</schema>
@kohki-shikata
kohki-shikata / bash
Last active October 3, 2017 23:23
【随時更新】Hexo まとめ(Node.js製のブログ型静的サイトジェネレーター) ref: http://qiita.com/kohki-shikata/items/dc0cb4ccc97cb38b8023
$ hexo init <folder>
$ cd <folder>
$ npm install
@kohki-shikata
kohki-shikata / gulpfile.js
Last active August 12, 2016 06:20
f6 with jade gulpfile.js
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var ejs = require('gulp-ejs');
var jade = require('gulp-jade');
var browserSync = require('browser-sync').create();
var plumber = require('gulp-plumber');
var dir = "../dist/";
var html_preprocessor = "jade";
@kohki-shikata
kohki-shikata / package.json
Last active July 12, 2017 12:13
Foundation 6 with pug(ex:jade) or EJS
{
"name": "foundation-sites-template",
"version": "1.0.0",
"description": "Basic template for a new Foundation for Sites project.",
"main": "gulpfile.js",
"devDependencies": {
"browser-sync": "^2.11.1",
"ejs": "^2.4.1",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^3.1.0",
@kohki-shikata
kohki-shikata / index.jade
Created April 4, 2016 06:08
Jade version of index.html for Foundation 6
doctype html
html.no-js(lang='en')
head
meta(charset='utf-8')
meta(http-equiv='x-ua-compatible', content='ie=edge')
meta(name='viewport', content='width=device-width, initial-scale=1.0')
title Foundation for Sites
link(rel='stylesheet', href='css/app.css')
body
.row