Skip to content

Instantly share code, notes, and snippets.

@renoinn
renoinn / gist:fe7e4caff326c7c408285ea338bb2b01
Created June 1, 2025 14:02
Geminiに質問させて指示書を作らせる。
これからJulesを利用して、CLIアプリケーションを開発してもらうのですが、Julesに渡すプロンプトを作成してほしいです。必要な事項を質問してくれたら答えていくので、結果をmarkdown形式でまとめてください。
---
# CLIアプリケーション開発プロンプト
**アプリケーション名:** (仮) VersionManager
**目的:** ユーザー自身がインストールしたアプリケーションのバージョン情報を一元的に管理し、最新バージョンの確認などを容易にするCLIツール。
@renoinn
renoinn / cancellableTimeout.js
Created November 6, 2020 09:46
delayを設定しつつcancelできるPromise
class CancellablePromiseCancelled {}
function cancellableTimeout(delay, func = () => {}) {
let timeoutID = null
let rejectPromise = () => {}
const exec = new Promise((resolve, reject) => {
timeoutID = setTimeout(async () => {
timeoutID = null
await func()
@renoinn
renoinn / distance.dart
Last active January 5, 2022 16:47
dartで緯度経度から2点間の距離を計算する(メートル換算)
// js版はこっち https://www.geodatasource.com/developers/javascript
double _distanceBetween(
double startLatitude,
double startLongitude,
double endLatitude,
double endLongitude,
) {
var earthRadius = 6378137.0;
var dLat = _toRadians(endLatitude - startLatitude);
@renoinn
renoinn / st_distance_sphere.md
Created August 25, 2020 15:31
ST_Distance_Sphereの使い方

lat:35.67679460, lng:139.73726860から1000メートル以内のresultを取得するクエリ

SELECT * FROM place WHERE st_distance_sphere(POINT(139.73726860,35.67679460),POINT(lng,lat)) <= 1000
@renoinn
renoinn / hexToRGBA.js
Created August 12, 2020 09:37
hexをrgbaに変換するjs
const isValidHex = (hex) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)
const getChunksFromString = (st, chunkSize) => st.match(new RegExp(`.{${chunkSize}}`, "g"))
const convertHexUnitTo256 = (hexStr) => parseInt(hexStr.repeat(2 / hexStr.length), 16)
const getAlphafloat = (a, alpha) => {
if (typeof a !== "undefined") {return a / 255}
if ((typeof alpha != "number") || alpha <0 || alpha >1){
return 1
@renoinn
renoinn / aspect-ratio-box.md
Last active August 11, 2020 13:23
アスペクト比を合わせるボックスのサンプル。
@renoinn
renoinn / redirect-index-origin-request.js
Created July 16, 2020 08:48
nuxt generateしてS3+CloudFrontでhostする際に、サブディレクトリのindex.htmlを補完するLambda@Edge
const config = {
suffix: '/index.html',
appendToDirs: 'index.html',
}
const regexSuffixless = /\/[^/.]+$/ // e.g. "/some/page" but not "/", "/some/" or "/some.jpg"
const regexTrailingSlash = /.+\/$/ // e.g. "/some/" or "/some/page/" but not root "/"
exports.handler = function handler (event, context, callback) {
const {request} = event.Records[0].cf
@renoinn
renoinn / smooth_scroll.js
Created July 15, 2020 06:37
素のJSでスムーススクロールする
const links = document.querySelectorAll('a[href^="#"]')
for ( let i = 0; i < links.length; i++ ) {
links[i].addEventListener('click', (e) => {
e.preventDefault();
const target = document.querySelector(links[i].href.substr(links[i].href.indexOf('#')))
const elemY = target.getBoundingClientRect().top
const scrollY = window.pageYOffset
const top = Math.abs(elemY + scrollY)
@renoinn
renoinn / loadStripe.js
Created May 28, 2020 10:30
load Stripe using async / await
const StripeUrl = 'https://js.stripe.com'
/* usage
*
* async mountCard() {
* const stripe = await loadStripe(pk)
* const elements = stripe.elements()
* const card = elements.create('card')
* card.mount('#card-element')
* }
@renoinn
renoinn / map_view.dart
Created April 6, 2020 10:37
create view controller of StatelessWidget using Provider
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart';
const double DEFAULT_ZOOM = 12.0;
const CameraPosition DEFAULT_CAMERA_POSITION = CameraPosition(
target: LatLng(35.6812405, 139.7649361),
zoom: DEFAULT_ZOOM,