Skip to content

Instantly share code, notes, and snippets.

View minodisk's full-sized avatar

Daisuke Mino minodisk

  • Knowledge Work
  • Tokyo, Japan
  • 09:24 (UTC +09:00)
  • X @minodisk
View GitHub Profile
@minodisk
minodisk / parser.ts
Created October 19, 2022 13:43
Adds row and column information to tokens created using the tokenizer for BigQuery implemented in sql-formatter.
import { formatters } from "sql-formatter";
import type { Token as OrigToken } from "sql-formatter/lib/src/lexer/token";
export type Token = OrigToken & {
line: number;
column: number;
};
export const createParser = () => {
const tokenizer = formatters.bigquery.prototype.tokenizer();
import { generate } from "ts-to-zod";
import clipboard from "clipboardy";
(async () => {
const sourceText = await clipboard.read();
const schema = generate({
sourceText,
})
.getZodSchemasFile()
.replace("// Generated by ts-to-zod\n", "");
@minodisk
minodisk / config.h
Created February 12, 2022 16:19
crkbdのLEDレイアウト
#undef RGBLED_NUM
#define RGBLED_NUM 54
#undef RGBLED_SPLIT
#define RGBLED_SPLIT {27, 27}
#define LED_LAYOUT( \
L00, L01, L02, R00, R01, R02, \
L03, L04, L05, R03, R04, R05, \
\
L06, L07, L08, L09, L10, L11, R06, R07, R08, R09, R10, R11, \
with
items as (
select 1 as id, ['dog'] as tags
union all select 2 as id, ['cat'] as tags
union all select 3 as id, ['bird'] as tags
union all select 4 as id, ['dog', 'cat'] as tags
union all select 5 as id, ['cat', 'bird'] as tags
union all select 6 as id, ['bird', 'dog'] as tags
union all select 7 as id, ['dog', 'cat', 'bird'] as tags
)
@minodisk
minodisk / detect_attachment_id.php
Created September 4, 2012 03:58 — forked from fumikito/detect_attachment_id.php
WordPressで画像のURLからアタッチメントIDを取得する
<?php
/**
* 画像のURLのサイズ違いのURLを取得する
*
* @param string $url 画像のURL
* @param string $size 画像のサイズ (thumbnail, medium, large or full)
*/
function get_attachment_image_src($url, $size) {
$image = wp_get_attachment_image_src(get_attachment_id($url), $size);
@minodisk
minodisk / gist:1136327
Created August 10, 2011 07:54
Get server time with AJAX
$(function () {
$.ajax({
type: 'GET',
cache: false,
url: location.href,
complete: function (req, textStatus) {
var dateString = req.getResponseHeader('Date');
if (dateString.indexOf('GMT') === -1) {
dateString += ' GMT';
}
@minodisk
minodisk / example.js
Created December 22, 2017 14:48
Usage of @minodisk/medkit
import Client from "@minodisk/medkit";
(async () => {
const client = new Client();
const postId = await client.createPost(
"<h3>Title</h3><h4>Subtitle</h4><p>Text</p>",
);
const html = await client.readPost(postId); // -> "<h1>Title</h1><h2>Subtitle</h2><p>Text</p>" or "<h3>Title</h3><h4>Subtitle</h4><p>Text</p>"
await client.updatePost(
postId,
@minodisk
minodisk / コーヒー豆.md
Last active August 28, 2017 05:06
リピート購入するためのコーヒー豆のメモ

エチオピア シャキッソ タデ農園 G-1

モカフレーバー。口に含むと栗のような香り。後味が柑橘系の酸味。

  • 苦味: 2
  • 酸味: 2
  • 甘み: 4
  • コク: 5
  • 香り: 3
  • 重さ: 2
#/bin/bash
images=$(gcloud beta container images list --format 'value(name)')
for i in $images; do
tags=$(gcloud beta container images list-tags $i --format 'value(tags)')
for t in $tags; do
echo delete $i:$t
gcloud beta container images delete $i:$t --resolve-tag-to-digest --quiet
done
@minodisk
minodisk / http.coffee
Created April 18, 2012 08:14
Ajax in CoffeeScript
exports.http =
get: (options, callback)->
options.method = 'get'
@request options, callback
post: (options, callback)->
options.method = 'post'
@request options, callback