Skip to content

Instantly share code, notes, and snippets.

<?php
$dom = new DOMDocument();
@$dom->loadHTML(file_get_contents('http://user.keio.ac.jp/~rhotta/hellog/'));
$through = (new DOMXPath($dom))->query('//div[@id="links"]//a[@href="2009-06-20-1.html"]');
if ($through->length === 1) {
echo "今日のthrough: {$through[0]->nodeValue}\n";
}
<?php
$f = file_get_contents('https://gist.githubusercontent.com/chitoku-k/f3e28b295523ad09e2863a6752ed685f/raw/416f4f79f7ebc77a6eb043630366cf7e6121a4f1/gista-file');
echo json_encode(array_values(array_filter(explode("\n", $f), function ($v) {
return $v !== '';
})));
@hexium310
hexium310 / index.html
Last active November 28, 2017 15:47
textareaの高さを自動で変えるクソコード
<textarea id="t"></textarea>
<style>
#t {
height: calc(1em + 2px);
font-size: 1em;
outline: none;
resize: none;
}
</style>
@hexium310
hexium310 / main.php
Created December 24, 2017 14:13
Substitute of User Streams by Public Streams
<?php
require_once 'vendor/autoload.php';
use mpyw\Cowitter\Client;
$client = new Client([
'CK',
'CS',
'AT',
'ATS'
@hexium310
hexium310 / double-new-line.sh
Last active November 3, 2018 09:51
Display the files (*.php or *.js) which end with the duplicate new lines under the current directory.
array=$(find . -type d \( -name 'node_modules' -o -name 'vendor' \) -prune -o -type f \( -name '*.js' -o -name '*.php' \) -print)
for a in $array; do
start=$(expr $(wc -c < $a) - 2)
[[ $start -lt 0 ]] && continue
new_line=$(hexdump -s $start $a | cut -c 9-13)
[[ $new_line = '0a 0a' ]] && echo "$a: $new_line"
done
@hexium310
hexium310 / twittercardlink.user.js
Created March 18, 2019 15:08
TwitterCardのURLにパスも表示するやつ
/* 右カラム */
div[data-testid="sidebarColumn"] {
display: none;
}
/* n分前 */
div[data-testid="tweet"] a[title][aria-label] {
visibility: hidden;
}
autocmd TermOpen * autocmd TextYankPost <buffer> call <SID>SetLineJoinedLine(v:event)
function! s:SetLineJoinedLine(event) abort
const regcontents = a:event.regcontents
const regname = a:event.regname
const regtype = a:event.regtype
if regtype == 'V'
call setreg(regname, join(regcontents, ''), 'v')
endif
// ==UserScript==
// @name 検索結果の言語切り替えるやつ
// @description 検索結果ページの言語を切り替えるボタンを表示します
// @namespace hexium310
// @version 1.0.2
// @author Hexin
// @match https://www.google.com/search*
// @resource MaterialIcons https://fonts.googleapis.com/icon?family=Material+Icons
// @grant GM_addStyle
// @grant GM_getResourceText
@hexium310
hexium310 / a.zsh
Last active June 2, 2021 18:20
queryのみが書かれたファイルをgh api graphql --inputでつかうやつ
gh api graphql --input <(jq -n --arg owner hexium310 --arg name brew-uo --arg query "$(cat file | tr '\n' ' ')" '{ query: $query, variables: { owner: $owner, name: $name } }')