This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table t (a int check(a > 5)); | |
insert into t values (1); -- Error: CHECK constraint failed: t | |
----- | |
create table a(x int); | |
insert into a values ('hoge'); | |
insert into a values (5); | |
select * from a; -- hoge 5 | |
----- | |
create table b(x int check(typeof(x) is 'integer')); | |
insert into b values ('hoge'); -- Error: CHECK constraint failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table t(n int, s text, t text); | |
insert into t values (1, 'abc', 'hoge'); | |
insert into t values (2, 'def', 'fuga'); | |
with s(a, b, c) as (select * from t) select * from s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with recursive t(x, s) as ( | |
select 0, NULL union all select x + 1, | |
case | |
when (x + 1) % 15 = 0 then 'FizzBuzz' | |
when (x + 1) % 3 = 0 then 'Fizz' | |
when (x + 1) % 5 = 0 then 'Buzz' | |
else (x + 1) | |
end | |
from t limit 1, 100 | |
) select s from t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table s (x int, y int); | |
insert into s values (2, 2), (1, 3), (1, 1), (2, 1), (3, 1); | |
-- 普通の使い方 | |
select y from s; -- 2 3 1 1 1 | |
select * from s; -- 2|2 1|3 1|1 2|1 3|1 | |
select y from s order by y; -- 1 1 1 2 3 | |
select * from s order by x; -- 1|3 1|1 2|2 2|1 3|1 | |
select * from s order by y; -- 1|1 2|1 3|1 2|2 1|3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>marquee</title> | |
</head> | |
<body> | |
<a href="https://gist.github.com/st98/0ac9abdddb1f09d0a50d">source</a> | |
<script> | |
var t = document.getElementsByTagName('title')[0].firstChild; | |
var s = t.nodeValue, i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(s, n) { | |
n %= s.length; | |
return s.slice(n) + s.slice(0, n); | |
} | |
function g(s, n) { | |
n %= s.length; | |
return (s + s).slice(n, n + s.length); | |
} | |
function h(s, n) { | |
var r = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>x-marquee</title> | |
</head> | |
<body> | |
<p><x-marquee>marquee</x-marquee> | <x-marquee>marquee</x-marquee></p> | |
<a href="https://gist.github.com/st98/0fff653a504d8a5627fc">source</a> | |
<script> | |
document.registerElement('x-marquee'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function C() {} | |
C.prototype.m = function () { return 'm'; }; | |
///// | |
var a = new C(); | |
a.m(); // => 'm' | |
///// | |
delete a.m; | |
a.m(); // => 'm' | |
///// | |
delete C.prototype.m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b = /b/ | |
##### | |
/a#{b.source}c/.source # => 'a#{b.source}c' | |
///a#{b.source}c///.source # => 'abc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
if (!(String.prototype.repeat)) { | |
String.prototype.repeat = function (n) { | |
if (n < 0) throw RangeError('Invalid repeat count'); | |
return Array(n + 1).join(this); | |
}; | |
} | |
function zfill(s, n) { | |
if (s.length >= n) return s; | |
return ('0'.repeat(n) + s).slice(-n); |