2022-01-25 21:57:20.184083|C|12138: -- CRASHED!!! --
2022-01-25 21:57:20.188223|C|12138: /lib/x86_64-linux-gnu/libgroonga.so.0(+0x1fd825) [0x7f4acd85f825]
2022-01-25 21:57:20.188283|C|12138: /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0) [0x7f4adb0203c0]
2022-01-25 21:57:20.188301|C|12138: /usr/lib/postgresql/13/lib/pgroonga.so(PGrnCheckRLSEnabledSeqScan+0x34) [0x7f4ace447bf4]
2022-01-25 21:57:20.188317|C|12138: /usr/lib/postgresql/13/lib/pgroonga.so(pgroonga_query_text+0x53) [0x7f4ace45a073]
のように出ていて、アプリ側ではなく、PGroonga側でなにか起こっているっぽい。ややこしかったのは、UbuntuのPostgreSQLだとエラーが出るのだが、Windowsに入れたPostgreSQLの方は動作に問題がない。vm.overcommit_memory kernel parameter should be 1: <0>: See INFO level log to resolve this
というログが出てたので、/etc/sysctl.conf に、vm.overcommit_memory=1
を追記した後に、sysctl -pを実行して、オーバーコミットを有効にしておく。body {
background-image: url(../img/back.jpg);
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
この背景全体にイメージを表示して、スクロールでも動かないようにするには、このCSSを定義する。float TILE_SIZE = 32;
void setup() {
size(512,512);
colorMode(HSB, 360, 100, 100);
background(200, 80, 80);
noLoop();
TILE_SIZE = width / (width / 32);
}
void draw() {
for (float y = 0; y < height + TILE_SIZE; y += TILE_SIZE) {
for (float x = 0; x < width + TILE_SIZE; x+= TILE_SIZE) {
noStroke();
fill(lerp(190,200,noise(x / 100, y / 100)), 100, 100);
rect(x, y, TILE_SIZE, TILE_SIZE);
stroke(0, 0, 90);
strokeWeight(2);
noFill();
if (random(1) > 0.5f) {
arc(x, y, TILE_SIZE, TILE_SIZE, radians(0), radians(90));
arc(x + TILE_SIZE, y + TILE_SIZE, TILE_SIZE, TILE_SIZE, radians(180), radians(270));
} else {
arc(x + TILE_SIZE, y, TILE_SIZE, TILE_SIZE, radians(90), radians(180));
arc(x, y + TILE_SIZE, TILE_SIZE, TILE_SIZE, radians(270), radians(360));
}
arc(x, y, TILE_SIZE / 2, TILE_SIZE / 2, radians(0), radians(90));
arc(x + TILE_SIZE, y + TILE_SIZE, TILE_SIZE / 2, TILE_SIZE / 2, radians(180), radians(270));
arc(x + TILE_SIZE, y, TILE_SIZE / 2, TILE_SIZE / 2, radians(90), radians(180));
arc(x, y + TILE_SIZE, TILE_SIZE / 2, TILE_SIZE / 2, radians(270), radians(360));
}
}
for (float y = 0; y < height + TILE_SIZE; y += TILE_SIZE) {
stroke(0, 0, 80);
strokeWeight(1);
line(0, y, width ,y);
}
for (float x = 0; x < width + TILE_SIZE; x+= TILE_SIZE) {
stroke(0, 0, 80);
strokeWeight(1);
line(x, 0, x, height);
}
}
void mousePressed() {
saveFrame("tiling-######.png");
}
複雑なパターンにみえるけど、1種類のタイルをランダムな向きに敷き詰めているだけ。
#Processing@Value("${application.iamge-max-age}")
private String imageMaxAge;
@GetMapping(value = "/view/{fileId}")
public void view(HttpServletResponse response, @PathVariable String fileId) throws IOException {
// ファイルIDに対応するイメージファイルパスを取得する処理はアプリケーション依存
String path = foobar.findById(fileId);
if (file != null) {
// ブラウザにキャッシュさせる。86400秒=1日
response.setHeader("Cache-Control", "max-age=" + imageMaxAge);
// MimeType算出/設定
FileTypeMap filetypeMap = FileTypeMap.getDefaultFileTypeMap();
String mimeType = filetypeMap.getContentType(path);
response.setContentType(mimeType);
try (InputStream is = new FileInputStream(path);
BufferedInputStream bis = new BufferedInputStream(is);
OutputStream os = response.getOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(os)) {
// バッファリングすることでどの程度パフォーマンスがあがるのか?
final long transferSize = bis.transferTo(bos);
log.info("Response complete.fileId={},mimeType={},size={}byte", fileId, mimeType, transferSize) ;
} catch (FileNotFoundException ex) {
// DBレコード上にイメージファイルが存在することになっているのに、存在しない、
// ということはなんらかのデータ不整合が発生しているため、500:Internal Server Errorとする。
log.error("File not found. filePath={}", file.getPath());
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} catch (IOException ex) {
log.error("Faild read file. Cause by file not exists on this server. filePath={}" + path, ex);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else {
// 指定されたファイルIDがDBレコード上に存在しない理由は、
// 1.クライアントから不正なリクエストを要求されている
// 2.イメージファイルの表示を要求するきっかけとなるそもそものサーバレスポンスが間違っている
// のどちらか。2の場合はなんらかのバグだが、ここではどちらの理由であるかが判定できないため、
// クライアント側には404エラーで応答する。
log.warn("File not found. Cause by invalid file id. fileId={}", fileId);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
void setup() {
size(512, 512);
colorMode(HSB, 360, 100, 100);
noLoop();
}
void draw() {
PGraphics g = createGraphics(512, 512, JAVA2D);
g.beginDraw();
g.noStroke();
g.background(255, 255, 255, 0);
g.colorMode(HSB, 360, 100, 100, 100);
g.rectMode(CENTER);
float hue = 60;
for (int y = 16; y < 512; y += 32) {
for (int x = 16; x < 512; x += 32) {
float ratio = map(y, 0, 512, 45, 5);
float r = map(noise(x, y), 0, 1, -ratio, ratio);
float offset = map(noise(x, y), 0, 1, -ratio, ratio) / 4;
g.translate(x + offset, y + offset);
g.rotate(radians(r));
g.fill(hue, 100, 100, map(y, 0, 512, 0, 100));
g.rect(0, 0, 24, 24);
g.rotate(radians(-r));
g.translate(-x - offset, -y - offset);
}
hue -= 4;
hue = hue > 360 ? 0 : hue;
hue = hue < 0 ? 360 : hue;
}
save("tile.png");
g.endDraw();
image(g, 0, 0);
g.save("tile.png");
}
void setup() {
size(512, 512);
colorMode(HSB, 360, 100, 100);
noLoop();
}
void draw() {
PGraphics g = createGraphics(512, 512, JAVA2D);
g.beginDraw();
g.noStroke();
g.background(255, 255, 255, 0);
g.rectMode(CENTER);
g.fill(270, 100, 100, 10);
int centerW = g.width / 2;
int centerH = g.height / 2;
float size = sqrt(2) * 512 / 2;
for (int i = 0; i < 360; i += 10) {
g.translate(centerW, centerH);
g.rotate(radians(i));
g.translate(-centerW, -centerH);
g.rect(centerW, centerH, size, size);
g.translate(centerW, centerH);
g.rotate(radians(-i));
g.translate(-centerW, -centerH);
}
g.endDraw();
image(g, 0, 0);
g.save("circle.png");
}