Skip to content

Instantly share code, notes, and snippets.

View nyaocat's full-sized avatar
💚

nyaocat nyaocat

💚
View GitHub Profile
@nyaocat
nyaocat / readonly.lua
Last active October 20, 2018 15:49
Lua Read Only Table (or Userdata) module http://nyaocat.hatenablog.jp/entry/2013/11/09/111856
--[[
lua readonly module
2013 (c) nyaocat
this program is licensed under NYSL( http://www.kmonos.net/nysl/ )
lua5.1 and lua5.2
]]
local newproxy = newproxy or require("newproxy") -- for Lua5.2
local type, getmetatable, pairs, assert, error = type, getmetatable, pairs, assert, error
#!/usr/local/bin/bash
export PATH=/home/nyaocat/bin:/usr/local/bin/:$PATH
export LANG=ja_JP.utf-8
if [ $HTTP_HOST$REQUEST_URI != kenkov.nyaocat.jp/ ]
then
echo "Location: http://kenkov.nyaocat.jp/"
echo
@nyaocat
nyaocat / qcc
Last active January 14, 2016 22:53
#!/usr/bin/env bash
#
# インストール:
# このファイル自体を PATH のある場所に保存して chmod +x すれば OK
# 例:
# sudo sh -c "curl http://nyaocat.jp/misc/qcc > /usr/local/bin/qcc"
# sudo chmod +x /usr/local/bin/qcc
# qcc -h
#
# 動作環境:
@nyaocat
nyaocat / aaa.cpp
Last active February 15, 2018 00:30
type-safe event holder
#include <iostream>
#include <string>
#include "signal.hpp"
struct event_A : public s::signal<int, int> {};
struct event_B : public s::signal<std::string, int, double> {};
int main() {
s::bind<event_A>([](int p1, int p2) {
#!/bin/bash
# usage: docker-edit container filepath
# License: NYSL
set -eu
TMPFILE=$(mktemp)
trap "rm $TMPFILE" 0
docker cp $1:$2 $TMPFILE
${EDITOR:-vi} $TMPFILE
@nyaocat
nyaocat / xfce4-session.bat
Created February 15, 2018 00:29
Windows環境でxfce4デスクトップを使うバッチファイル
start "xserver" "C:\Program Files\VcXsrv\vcxsrv.exe" -fullscreen
wsl sh -c "env DISPLAY=:0 xfce4-session"
@nyaocat
nyaocat / pysdl2_and_wxpython.py
Last active March 14, 2022 03:05
pysdl2 in wxpython
import sdl2
import sdl2.ext
import math
import wx
class SDL2Timer(wx.Timer):
def Yaruzo(self, a):
sdl2.ext.init()
# window = sdl2.SDL_CreateWindow("Hi".encode("utf-8"),
@nyaocat
nyaocat / npm
Created March 11, 2019 13:12
nodeをインストールしたくないので docker で代用する(下記ファイルを PATH の通る場所に node, npm, npx と名付けてそれぞれ保存すると使える)
#!/bin/bash
set -eu
mkdir -p $HOME/.config $HOME/.npm
docker run \
-it --rm \
--tmpfs "/tmp" \
-v "$PWD:$PWD" \
-v "$HOME/.config:$HOME/.config" \
@nyaocat
nyaocat / grepedit
Created April 5, 2019 02:37
grep した結果に対してのみ編集を行うコマンド(例: grepedit -E '^[1-9]' * )
#!/bin/bash
set -eu
BUF="$(mktemp)"
trap "rm '$BUF'" 0
grep -H -n "$@" > "$BUF"
"${EDITOR:-vi}" "$BUF"
IFS=":"
@nyaocat
nyaocat / mdnsserver.pl
Last active September 20, 2019 03:56
雑な mDNS サーバ実装
#!/usr/bin/perl
# License: NYSL
use warnings;
use strict;
use Sys::Hostname;
use IO::Socket::Multicast;
use Net::DNS;
use IO::Interface::Simple;
my $sock = IO::Socket::Multicast->new(LocalPort => 5353);