Skip to content

Instantly share code, notes, and snippets.

View jiro4989's full-sized avatar
🏠
Working from home

jiro jiro4989

🏠
Working from home
View GitHub Profile
@jiro4989
jiro4989 / cutter_crop_image_sample.go
Created August 13, 2023 13:57
Go言語のcutterライブラリを使って、画像をトリミングしてアニメーションGIFとして出力する
package main
import (
"image"
"image/color"
"image/color/palette"
"image/draw"
"image/gif"
"os"
@jiro4989
jiro4989 / go.mod
Created April 28, 2022 15:47
Go言語でpegを使ってSGRを解析してみる
module configfile
go 1.17
@jiro4989
jiro4989 / go.mod
Last active April 28, 2022 01:40
Go言語でpegを使って構文解析をする
module configfile
go 1.17
@jiro4989
jiro4989 / ReadXML.java
Last active December 23, 2021 15:17
JavaでXML文字列をparseしてObjectを取得する
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
@jiro4989
jiro4989 / WriteXML.java
Last active December 23, 2021 14:47
JavaでObjectからXMLを生成して標準出力に書き出す
import java.io.StringWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.TransformerConfigurationException;
@jiro4989
jiro4989 / is_natural.c
Last active October 29, 2021 22:41
C言語で文字列が自然数かどうかを判定する関数
#include <stdio.h>
const int TRUE = 1;
const int FALSE = 0;
int is_natural(char *s) {
if (s[0] == '\0' || s[0] == '0') return FALSE;
for (int pos = 0; TRUE; pos++) {
char ch = s[pos];
@jiro4989
jiro4989 / deps.edn
Last active February 4, 2021 11:00
デレステのアイドルプロフィール情報をスクレイピングしてきてCSV出力するClojureスクリプト。あとおまけで集計
{:deps
{enlive/enlive {:mvn/version "1.1.6"}
org.clojure/data.csv {:mvn/version "1.0.0"}}
}
@jiro4989
jiro4989 / nabeatsu.clj
Created February 2, 2021 16:46
世界のナベアツ.clj
(require '[clojure.string :as str])
(defn aho? [num]
(or (zero? (mod num 3))
(str/includes? (str num) "3")))
(->> (range 1 100)
(map #(if (aho? %)
"アホ"
(str %)))
@jiro4989
jiro4989 / ascii_dia.nim
Last active December 30, 2020 07:40
tiny ascii art scripts on Nim language.
import strutils, sequtils, algorithm
proc corner(text: string): seq[string] =
for i, v in text.pairs:
result.add(text[0..i] & " ".repeat(text.len-i))
proc diamond(text: string): seq[string] =
let rightTop = corner(text)
let leftTop = rightTop.mapIt(it.reversed.join)
let rightBottom = rightTop.reversed
@jiro4989
jiro4989 / goto.c
Last active August 23, 2020 14:12
FizzBuzz with goto
#include <stdio.h>
#include <string.h>
/*
```bash
gcc goto.c
./a.out
```