Skip to content

Instantly share code, notes, and snippets.

@plonk
plonk / router-reconnect.rb
Created November 8, 2022 11:16
ルーターのping値が悪くなったらインターネットを再接続するスクリプト
#!/usr/bin/ruby
require 'net/http'
def router_online
puts "router_online"
uri = URI('http://192.168.0.1/hgi-bin/Setup/main_index.cgi')
req = Net::HTTP::Post.new(uri)
req.basic_auth('admin', 'qtnetbbiq')
req.set_form_data({
'o' => 'online',
@plonk
plonk / prim.lisp
Created August 4, 2022 20:03
プリム法による迷路作成
;; プリム法による迷路作成。
(defparameter *w* 10) ; 頂点グリッドの幅。
(defparameter *h* 10) ; 頂点グリッドの高さ。
(defparameter *adj* (make-array (* *w* *h*) :initial-element '())) ; 隣接配列。
(defparameter *cost* (make-array (* *w* *h*) :initial-element nil))
;; 印刷に使う文字。
(defconstant +floor-char+ #\・)
(defconstant +wall-char+ #\鬱)
@plonk
plonk / kruskal.lisp
Created August 4, 2022 18:28
クラスカル法による迷路作成
;; クラスカル法による迷路作成。
(defparameter *w* 10) ; 頂点グリッドの幅。
(defparameter *h* 10) ; 頂点グリッドの高さ。
(defparameter *edges* '()) ; 辺のリスト。
;; 印刷に使う文字。
(defconstant +floor-char+ #\・)
(defconstant +wall-char+ #\鬱)
;; 印刷する内容。
@plonk
plonk / reverse-delete.lisp
Last active August 4, 2022 10:57
逆削除法による迷路作成
;; 逆削除法による迷路作成。
(defparameter *w* 10) ; 頂点グリッドの幅。
(defparameter *h* 10) ; 頂点グリッドの高さ。
(defparameter *adj* (make-array (* *w* *h*) :initial-element '())) ; 隣接配列。
(defparameter *edges* '()) ; 辺のリスト。
;; 印刷に使う文字。
(defconstant +floor-char+ #\・)
(defconstant +wall-char+ #\田)
@plonk
plonk / pentomino.html
Created January 16, 2021 19:08
ペントミノパズルソルバー
<!doctype html>
<html lang=ja>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ペントミノパズルソルバー</title>
<style>
table { border-spacing: 0; border-collapse: separate }
table.board-table { margin-bottom: 32px; }
table.board-table td { width: 32px; height: 32px; border: 3px solid #ccc; text-align: center; font-family: monospace }
@plonk
plonk / pentomino.rb
Last active January 16, 2021 12:07
ペントミノパズルソルバー
#!/usr/bin/ruby
require 'colorize'
COLOR_SCHEME = {
'F' => [:light_yellow, :light_black],
'I' => [:blue, :light_white],
'L' => [:yellow, :light_white],
'N' => [:light_yellow, :light_black],
'P' => [:cyan, :light_white],
@plonk
plonk / ping.c
Last active June 6, 2020 19:02
Simple ping
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <netdb.h>
@plonk
plonk / neko-chokin.rb
Created December 17, 2019 03:40
一年分の猫貯金チェックリストを印刷するためのエクセルファイルを生成するスクリプト
require 'spreadsheet'
year, filename = ARGV
if year
year = year.to_i
else
year = Time.now.year
end
unless filename
filename = "out.xls"
@plonk
plonk / drcssixel-test.c
Created September 10, 2019 19:51
arakiken さんによる https://qiita.com/arakiken/items/626b02cd857d20c12fbc の記事にあるサンプルコードを改変したものです。どのように変更したかは今ちょっと思い出せません。osiire で使ってます
#include <stdlib.h>
#include "drcssixel.c"
static void pua_to_utf8(unsigned char *dst, unsigned int *src, unsigned int len) {
unsigned int i;
for(i = 0; i < len; i++) {
unsigned int code = src[i];
*(dst++) = ((code >> 18) & 0x07) | 0xf0;
@plonk
plonk / torneco-name.c
Created August 9, 2019 05:05
SFCトルネコの名前付け。引数で渡された名前をキー操作に変換
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LAYER_H 0
#define LAYER_K 1
/* 6*10 */
const char* htbl[6][10] = {
{ "あ","い","う","え","お","は","ひ","ふ","へ","ほ" },