Skip to content

Instantly share code, notes, and snippets.

@anekos
anekos / support-internet-explorer.js
Created March 5, 2020 08:09
Internet Explorer に対応する JavaScript
if (~window.navigator.userAgent.indexOf('Trident')) {
location.href = 'https://getfirefox.com';
}
@anekos
anekos / x-yaml-to-json.vim
Created November 2, 2018 14:26
自動で YAML に変換して書きだす Vim さん (*.x.yaml とすること)
" 自動で YAML に変換して書きだす (*.x.yaml とすること) {{{
function! s:yaml_to_json()
let l:from = expand('%')
let l:to = expand('%:r:r') . '.json'
let l:result = system('ruby -rjson -ryaml -e "puts(JSON.pretty_generate(YAML.load(ARGF.read)))" ' . shellescape(l:from) . ' > ' . shellescape(l:to))
if v:shell_error
echoerr printf("Failed to yaml_to_json: %d\n%s", v:shell_error, l:result)
endif
endfunction
@anekos
anekos / not_works.sh
Created October 1, 2019 10:22
シェルスクリプトでクロージャ(勿論動かない)
function upload () {
local src="$1"
# ...
mv "$temp" "$src"
clean_src () {
rm "$src"
}
trap clean_src EXIT
@anekos
anekos / clipboard-translator.js
Created June 8, 2010 15:22
クリップボードのテキストを監視して自動で翻訳 - 要 multi_requester.js & google-translator.js
(function () {
let handle;
let start = function () {
function get ()
liberator.modules.util.readFromClipboard().replace(/\n/g, ' ').trim();
if (handle)
return;
@anekos
anekos / iron-maiden-rc.hyprland.cl
Last active January 21, 2025 13:33
iron-maiden-cl で hyprland 対応
; For https://bitbucket.org/anekos/iron-maiden-cl
; Hyprland {{{
(defvar *hyprland-mutex* (sb-thread:make-mutex :name "hyprland-mutex"))
(defvar *hyprland-active-window-class* nil)
(defun extract-hyprland-active-window (line)
(let ((prefix "activewindow>>"))
(when (and (stringp line)
@anekos
anekos / evernote-webclipper-methods.js
Created May 6, 2012 04:45
evernote web clipper のメソッド一覧
evernote_doAction( document.popupNode, 'CLIP_ACTION_FULL_PAGE' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_IMAGE' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_SELECTION' );
evernote_doAction( document.popupNode, 'CLIP_ACTION_URL' );
evernote_doAction( document.popupNode, 'NEW_NOTE_ACTION' );
#!/bin/sh
# Usage: add-random [[NUMBER [FILTER]]
sels="${1:-10}"
filter="${2:-}"
mpc listall | grep "$filter" | shuf | head "-n" "$sels" | while read selected
do
echo "$selected"
@anekos
anekos / html-builder.rb
Created April 21, 2010 06:02
Ruby DSL - HTML生成
#!/usr/bin/ruby
#[=c= ruby -rubygems % ]
class HTMLBuilder
def initialize (tag_name = 'html', indent = 0, &block)
@indent = indent
@tag_name = tag_name
@attrs = {}
@contents = []
self.instance_eval(&block)
@anekos
anekos / without timzone.sql
Last active April 9, 2023 10:17
telegraf → TimescaleDB を Grafana に表示する
SELECT
host,
MAX(usage_user),
time_bucket('10min', time) AS bucket
FROM
telegraf.cpu
WHERE
(
to_timestamp($__unixEpochFrom()) -
(NOW() - NOW() AT TIME ZONE 'UTC')
for n in $(seq 1 8)
do
curl "https://www.google.com/logos/fnbx/animal_paws/audio/cat_sound_${n}.mp3" > "/tmp/xmosh/cat_sound_${n}.mp3"
done
for n in $(seq 1 9)
do
curl "https://www.google.com/logos/fnbx/animal_paws/cat_paw_${n}.png" > "/tmp/xmosh/cat_paw_${n}.png"
done