Skip to content

Instantly share code, notes, and snippets.

@cou929
cou929 / bar.yaml
Created February 23, 2023 15:21
unexpected behavior of swagger-cli
post:
responses:
201:
description: test
content:
application/json:
schema:
$ref: ref2.yaml
description: the order of this description directive changes between versions
/* https://github.com/cou929/sql-fingerprint-js */
CREATE TEMP FUNCTION fingerprint(sql STRING, matchMD5Checksum BOOL, matchEmbeddedNumbers BOOL)
RETURNS STRING
LANGUAGE js AS r"""
function fingerprint(sql, matchMD5Checksum, matchEmbeddedNumbers) {
let query = sql;
// special cases
if (/^SELECT \/\*!40001 SQL_NO_CACHE \*\/ \* FROM `/.test(query)) {
@cou929
cou929 / mt_to_markdown.rb
Created August 6, 2017 04:16 — forked from code-later/mt_to_markdown.rb
Convert a MovableType export to single Markdown posts to use with Octopress
#!/usr/bin/env ruby
require 'date'
require 'mustache'
require 'stringex'
require 'cgi'
require 'fileutils'
export = File.open(ARGV[0])
target_dir = ARGV[1]
##
# fluent log Slack Notification
<match fluent.**>
type record_modifier
tag internal.message.${hostname}
host ${hostname}
include_tag_key
tag_key original_tag
</match>
<match mtburn.ad.*>
type forest
subtype copy
<template>
##
# S3
<store>
type s3
aws_key_id xxxx
aws_sec_key xxxx
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@cou929
cou929 / image_onload_test.html
Created December 25, 2013 12:59
test for setting timing of onload event listener
<!DOCTYPE html>
<html>
<head>
<script>
// for caching
(new Image()).src = 'http://upload.wikimedia.org/wikipedia/commons/2/23/1x1.GIF?a=1';
</script>
</head>
<body>
<div>
@cou929
cou929 / detect-private-browsing.js
Last active April 6, 2024 03:21
Detect private browsing mode (InPrivate Browsing or Incognito).
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
@cou929
cou929 / index.html
Last active December 30, 2015 18:48
Study of cookie domain limitation of each major browsers.
<!DOCTYPE html>
<head>
<title>Cookie restriction tester</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="tester.js"></script>
</head>
<body>
<div id="max_cookie_count_per_domain"></div>
<div id="max_cookie_count_per_domain_warning"></div>
<div id="ext"></div>
@cou929
cou929 / sample.html
Last active December 29, 2015 22:09
localStorage privacy setting sample
<!DOCTYPE html>
<html>
<head>
<title>localStorage and privacy setting sample</title>
</head>
<body>
<div id="result"></div>
<script>
(function() {
var key = 'localstorage_test_item',