Skip to content

Instantly share code, notes, and snippets.

@hitode909
hitode909 / desktop.1h.rb
Created January 19, 2024 15:44
Automatic Desktop Image Generator via OpenAI
#! /usr/bin/ruby
require 'net/http'
require 'json'
require 'uri'
require 'fileutils'
# Replace with your actual API key
API_KEY = ENV['OPENAPI_KEY']
def generate_theme
@hitode909
hitode909 / screen-capture.1m.rb
Created November 30, 2023 01:12
Continuous Screen Capture Script for xbar
#! /usr/bin/ruby
require 'logger'
require 'json'
LOGGER = Logger.new(STDOUT)
if ENV['DEBUG']
LOGGER.level = Logger::Severity::DEBUG
else
LOGGER.level = Logger::Severity::WARN
// ==UserScript==
// @name simple twitter
// @namespace http://www.hatena.ne.jp/hitode909/
// @description make posts simple.
// @include http://twitter.com/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
(function(){
$('li.status').each(function(){
<p><button id="masawada-cast-button" style="display: none">masawada castを開始する</button>
<div id="masawada-cast-button-not-supported" style="display: none">お使いのブラウザは<a href="https://developer.mozilla.org/en-US/docs/Web/API/Presentation_API" target="_blank">Presentation API</a>に対応していないようです</div>
</p>
<script>
(function () {
const button = document.querySelector('#masawada-cast-button');
const error = document.querySelector('#masawada-cast-button-not-supported');
const show = function () {
button.style.display = 'block';
};
(() => {
const speak = (body, isRetry) => {
window.speechSynthesis.cancel()
if (!body) return;
console.log('speak ' + body);
const synth = window.speechSynthesis;
const allVoices = synth.getVoices();
const jaVoices = allVoices.filter(v => v.lang === 'ja-JP');
const voice = jaVoices[0];
if (!voice && !isRetry) {
@hitode909
hitode909 / lgtm
Created October 22, 2013 06:42
ランダムなLGTMをクリップボードにコピーするやつ
#! /usr/bin/env ruby
# Copy random LGTM to clipboard
require 'open-uri'
require 'nokogiri'
require 'shellwords'
doc = Nokogiri open('http://www.lgtm.in/g')
#!/bin/sh
#
# Create a animation of of a rotating image.
# Some alpha composition is used to crop the result to the original size.
#
command="convert -delay 10 $1 -resize 50% -trim +repage -bordercolor white"
command="$command \\( +clone -border 1x1 -fill lightsteelblue"
command="$command -colorize 100% \\) -gravity center"
for i in `seq 100 -2 20 ;`; do
@hitode909
hitode909 / crawl.js
Created December 23, 2018 20:40
つくりおきメトリクス
function crawl() {
var content = UrlFetchApp.fetch("https://tsukurioki.hatenablog.com/about").getContentText();
var entries = content.match(/(\d+) 記事/)[1];
var subscribers = content.match(/(\d+) 人/)[1];
Logger.log(subscribers);
var sheet = SpreadsheetApp.openById("*************************").getSheetByName('data');
var newRow = [new Date(), +entries, +subscribers];
sheet.appendRow(newRow);
}
@hitode909
hitode909 / perl_lint.rb
Last active September 29, 2018 14:18
ソースコード褒めてくれるやつ
#! /usr/bin/env ruby
unless ARGV.length > 0
warn "usage: ruby perl_lint.rb YOUR_SOURCE_CODE.pl"
exit 1
end
puts %w(やるじゃん すごい がんばって やればできる 努力だ ワッショイ お上手).sample + '!' * (rand*10).to_i
import * as ts from "typescript";
import * as Lint from "tslint";
export class Rule extends Lint.Rules.AbstractRule {
/* tslint:disable:object-literal-sort-keys */
public static metadata: Lint.IRuleMetadata = {
ruleName: "no-jquery-argument",
description: "Disallows receiving jQuery object in arguments.",
rationale: Lint.Utils.dedent`
Do not receive jQuery Object. You must receive HTMLElement or Array<HTMLElement>.