Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
https://neos21.net/

Neos21 Neos21

:octocat:
https://neos21.net/
View GitHub Profile
@Neos21
Neos21 / html-to-markdown.js
Created Jan 9, 2021
HTML を Pedantic な Markdown に変換する
View html-to-markdown.js
const unified = require('unified'); // v9.2.0
const rehypeParse = require('rehype-parse'); // v7.0.1
const rehypeRemark = require('rehype-remark'); // v8.0.0
const remarkStringify = require('remark-stringify'); // v8.1.1 : https://github.com/remarkjs/remark/tree/remark-stringify%408.1.1/packages/remark-stringify
const html = '<html> <!-- ココに HTML ソース --></html>'
const result = unified()
.use(rehypeParse, { fragment: true }) // head・body などを付けない
.use(rehypeRemark)
@Neos21
Neos21 / exec-on-load.js
Created Jan 9, 2021
この JS がどのタイミングで読み込まれても exec() 関数を必ずページ読み込み時に実行する
View exec-on-load.js
(() => {
const exec = () => {
console.log('Something');
};
if(!document.readyState || document.readyState === 'interactive') {
console.log('Interactive (onload)');
window.addEventListener('load', exec);
}
else if(document.readyState === 'loading') {
@Neos21
Neos21 / go-to-gh.js
Created Dec 31, 2020
Go To GitHub Repository Page (From Neo's World)
View go-to-gh.js
((
loc,
fqdn,
gitHubSrc,
documents,
corsAnywhere
) => {
if(!loc.href.includes(fqdn)) return alert("Here Is Not Neo's World");
const open = (url) => { loc.href = url; return Promise.resolve(); }; // 遷移する関数
View README.md

Cross Post

Netlify Functions で動かしていたソースコードの簡略版。

  • Do Well (オレオレマイクロブログ)
  • Misskey
  • Mastodon

に投稿を一括送信する。

@Neos21
Neos21 / list-dom-tree.js
Created Oct 7, 2020
List DOM Tree (Please Execute On DevTools Console)
View list-dom-tree.js
tree = [];
function walk(elem, depth) {
if(elem === undefined) elem = document.body;
if(depth === undefined) depth = 0;
const name = ' '.repeat(depth)
+ elem.tagName.toLowerCase()
+ (elem.id && `#${elem.id}`)
+ [...elem.classList].map(cls => `.${cls}`).join('');
tree.push(name);
elem.children.forEach(child => walk(child, depth + 1));
View install-jq.sh
#!/bin/sh
if ! type jq > /dev/null 2>&1; then
sudo curl -sS -o /usr/local/bin/jq -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && sudo chmod +x /usr/local/bin/jq
fi
View df-json.sh
#!/bin/sh
\df -P \
| tail -n +2 \
| awk '
BEGIN {
printf "{\n";
printf " \"volumes\": [\n";
}
{
@Neos21
Neos21 / apache.sh
Created Aug 26, 2020
Apache Nginx Server Admin Alias
View apache.sh
alias cdh='cd /var/www/html/'
alias cda='vi /etc/httpd/'
alias vic='vi /etc/httpd/conf/httpd.conf'
alias vis='vi /etc/httpd/conf.d/ssl.conf'
alias taila='tail -f /var/log/httpd/access_log'
alias taile='tail -f /var/log/httpd/error_log'
alias tailsa='tail -f /var/log/httpd/ssl_access_log'
alias tailse='tail -f /var/log/httpd/ssl_error_log'
alias tailsr='tail -f /var/log/httpd/ssl_request_log'
alias apre='systemctl restart httpd'
@Neos21
Neos21 / TR42.ts
Created Jul 8, 2020
For Obniz.js
View TR42.ts
import Obniz from 'obniz';
import ObnizPartsBleInterface, { ObnizPartsBleInfo } from 'obniz/dist/src/obniz/ObnizPartsBleInterface';
import BleRemotePeripheral from 'obniz/dist/src/obniz/libs/embeds/bleHci/bleRemotePeripheral';
/** TR42 のデータ */
export interface TR42_Data {
/** バッテリー残量 (1:少 〜 5:多 の5段階) */
battery: number;
/** 摂氏 */
temperature: number;
@Neos21
Neos21 / GenderEstimate.bas
Created Jun 25, 2020 — forked from lunark/GenderEstimate.bas
VBAマクロ向け関数。GenderEstimate。漢字の名前とふりがなから、性別を推定する関数
View GenderEstimate.bas
Public Function GenderEstimate(strMK As String, Optional strMF As String) As String
GenderEstimate = ""
strMK = Replace(Replace(Replace(strMK, " ", ""), " ", ""), "「", "")
strMF = Replace(Replace(StrConv(strMF, vbHiragana), " ", ""), " ", "")
'デバッグ用。こいつをブレークポイントに持ってきて挙動を確認する
'If strMK Like "理世" Then
' Debug.Print strMK
'End If