Skip to content

Instantly share code, notes, and snippets.

@macrat
macrat / image.go
Created Nov 9, 2017
golangでグラデーション作ったり、文字入れたり。
View image.go
package main
import (
"image"
"image/color"
"image/png"
"os"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
@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 / fizzbuzz.c
Last active Dec 9, 2019
がんばってかいたFizzBuzz。gcc 4.9.4で-Wallを付けてもエラーやワーニングが表示されないことを確認済み。
View fizzbuzz.c
#include <stdio.h>
#include <stdint.h>
int main() {
for (uint32_t i=1; i<=30; i++) {
uint64_t x = 8825495485607995750u - (i%3>0) * (8825495483553149956u - (((i/10+12336+(i%10<<8))>>(8*(i<10))) - 9621248592211244386u) * (i%5>0)) - 8825495483553153024u*(i%5>0);
puts((char*)&x);
}
}
@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"