Skip to content

Instantly share code, notes, and snippets.

@osapon
osapon / localStorage.js
Last active February 1, 2016 14:11
localStorage.js
(function (lstorage) {
lstorage.set = function(name,val) {
while(true) {
var key_name = '', old_dt = Date.now();
try{
localStorage.setItem(name, window.JSON.stringify({
'data':val,
'dt':Date.now()
}));
}
put_slack() {
channel_id=`curl -s "https://slack.com/api/im.open" --data "token=${slack_team_key}" --data "user=${slack_user_id}" --data "pretty=1" | jq -r ".channel.id"`
curl -s 'https://slack.com/api/chat.postMessage' \
--data "token=${slack_team_key}" \
--data "channel=${channel_id}" \
--data "pretty=1" \
--data-urlencode "text=$1"
}
@osapon
osapon / mastodon.user.css
Last active March 13, 2018 08:05
Mastodonの2.3.0とかで動くようにしているcss。トゥートの間隔を詰めて、unarist氏の固定トゥート圧縮をさらに改造
.drawer {
overflow : visible ;
width : 25% !important ;
height : 400px !important ;
}
.emoji-dialog {
z-index : 1 !important ;
position : fixed !important ;

Keybase proof

I hereby claim:

  • I am osapon on github.
  • I am osapon (https://keybase.io/osapon) on keybase.
  • I have a public key whose fingerprint is 2306 990F FA7E 8235 804B 1924 3ADF B39C D4D1 BEAE

To claim this, I am signing this object:

@osapon
osapon / gist:2222cd8952190ad4c9694f6f0c9bbe38
Last active September 28, 2017 02:18
Bloggerで記事毎の共有ボタンに「Mastoshare」を並べるスクリプト。デザインによってクラスの調整は必要だと思う。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$('.blog-posts > .date-outer').each(function(idx,obj) {
var title = $('.post-title',obj).text();
$('.post-share-buttons',obj).append('<a href="https://mastoshare.net/post.php?text=' + encodeURIComponent(title) + '" onclick="window.open(this.href, \'\', \'width=500,height=400\'); return false;"><img src="https://mastoshare.net/img/toot.svg" width="75" height="20"></a>');
});
});
</script>
@osapon
osapon / gist:2fd6ef8b7f5f1fee63357eda42a4daad
Created January 16, 2019 11:14
punycodeから第一水準漢字あたりを出した。
1342 xn--bbk ま
1349 xn--bbr 函
1350 xn--bbs 囆
1351 xn--bbt 宏
1352 xn--bbu 恘
1353 xn--bbv 攡
1354 xn--bbw 槪
1355 xn--bbx 溳
1356 xn--bby 獼
1357 xn--bbz 硅
console.log("%cストップ!", "color: #88F; font-size: 400%; font-weight:bold;text-shadow: rgb(0, 0, 0) 3px 0px 0px, rgb(0, 0, 0) 2.83333px 0.983333px 0px, rgb(0, 0, 0) 2.35px 1.85px 0px, rgb(0, 0, 0) 1.61667px 2.51667px 0px, rgb(0, 0, 0) 0.7px 2.91667px 0px, rgb(0, 0, 0) -0.283333px 2.98333px 0px, rgb(0, 0, 0) -1.25px 2.73333px 0px, rgb(0, 0, 0) -2.06667px 2.16667px 0px, rgb(0, 0, 0) -2.66667px 1.36667px 0px, rgb(0, 0, 0) -2.96667px 0.416667px 0px, rgb(0, 0, 0) -2.95px -0.566667px 0px, rgb(0, 0, 0) -2.6px -1.5px 0px, rgb(0, 0, 0) -1.96667px -2.26667px 0px, rgb(0, 0, 0) -1.11667px -2.78333px 0px, rgb(0, 0, 0) -0.133333px -3px 0px, rgb(0, 0, 0) 0.85px -2.88333px 0px, rgb(0, 0, 0) 1.75px -2.43333px 0px, rgb(0, 0, 0) 2.45px -1.73333px 0px, rgb(0, 0, 0) 2.88333px -0.833333px 0px;");
console.log("もし誰かにここにコピペしろと言われたなら、あなたは11割騙されています。");
console.log("%cここに何かを貼り付けたら悪意のあるユーザーにあなたのアカウントを乗っ取られるかもしれません。", "color: red; font-weight:bold;");
@osapon
osapon / size.sql
Created November 8, 2019 04:57
PostgreSQL DB Garbage raito
SELECT pg_database_size('notestock') AS db_size -- Any DB Name
, ROUND(100 * SUM(
CASE (a.n_live_tup + a.n_dead_tup) WHEN 0 THEN 0
ELSE c.relpages * (a.n_dead_tup / (a.n_live_tup + a.n_dead_tup)::numeric)
END
) / SUM(c.relpages), 2) AS garbage_raito
FROM pg_class AS c
JOIN pg_stat_all_tables AS a ON(c.oid = a.relid)
WHERE relpages > 0
@osapon
osapon / netlify.toml
Last active January 27, 2020 03:42
netlify 503 page setting
[[redirects]]
from = "/*"
to = "/mente.html"
status = 503
force = true