Skip to content

Instantly share code, notes, and snippets.

@macrat
macrat / bashrc
Last active Jun 12, 2022
Vimの:termの中でうっかりVimを開くのを防いでくれるbashrc
View bashrc
function flattenvim() {
if [ "${VIM_SERVERNAME}" != "" ]; then
\vim --servername ${VIM_SERVERNAME} --remote $*
else
\vim --servername "$(head -c 12 /dev/random | base64)" $*
fi
}
alias vi=flattenvim
alias vim=flattenvim
@macrat
macrat / animated.svg
Last active Dec 14, 2021
Image XOR in SVG.
View animated.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@macrat
macrat / unit-test-include.ps1
Created Aug 24, 2020
PowerShellスクリプトにユニットテストを埋め込むい
View unit-test-include.ps1
param(
[parameter(Mandatory, Position=0, ParameterSetName="Normal")]
[Int]$Number,
[parameter(ParameterSetName="Normal")]
[String]$OutputPath = "out.txt",
[parameter(ParameterSetName="Test")]
[switch]$Test = $false
)
View Solarized Dark.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMS
AAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGmCwwXGxwjVSRudWxs1Q0ODxAR
EhMUFRZcTlNDb21wb25lbnRzVU5TUkdCXE5TQ29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29s
b3JTcGFjZVYkY2xhc3NPECgwLjAyNzQ1MTAwNjcgMC4yMTE3NjQ3MjMxIDAuMjU4ODIz
@macrat
macrat / compare.js
Created May 4, 2020
sharp vs jimp vs jimp + imagemin: compare output file size.
View compare.js
const path = require('path');
const {promises: fs} = require('fs');
const Jimp = require('jimp');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminWebp = require('imagemin-webp');
const imageminZopfli = require('imagemin-zopfli');
const Sharp = require('sharp');
@macrat
macrat / kvs_test.go
Created Dec 1, 2019
golangでredisとetcdの速度を比べてみた
View kvs_test.go
package test
import (
"testing"
"context"
"github.com/go-redis/redis"
etcd "go.etcd.io/etcd/client"
)
View fizzbuzz.py
""" FizzBuzzのフレームワーク
本気でFizzBuzzを作ったら、パイプライン処理のライブラリが出来た。
"""
from typing import Any, List
class EndOfList(Exception):
""" 処理を終了したいときに送出するエラー """
@macrat
macrat / snippets.ps1
Last active Dec 26, 2018
powershellのスニペット集的なものを作りつつある。
View snippets.ps1
<#
.SYNOPSIS
A snippets for powershell scripting.
.NOTE
It's WIP.
#>
<#
@macrat
macrat / fssql.py
Created Dec 6, 2018
SQL上にファイルシステム的なもの
View fssql.py
import hashlib
import pathlib
import sqlite3
class Tree:
def __init__(self, db, tag):
self.db = db
self.tag = tag
@macrat
macrat / TarFileSystem.go
Created Dec 5, 2018
go言語でtarアーカイブをファイルシステムっぽく扱うやつ。作りかけ。
View TarFileSystem.go
package main
import (
"archive/tar"
"io"
"os"
"path/filepath"
"gopkg.in/src-d/go-billy.v4"
"gopkg.in/src-d/go-billy.v4/osfs"