Skip to content

Instantly share code, notes, and snippets.

View t-tera's full-sized avatar

t-tera

  • Tokyo, Japan
View GitHub Profile
@t-tera
t-tera / identify
Last active August 10, 2018 12:40
Imagic
#!/bin/sh
# Dummy identify, mogrify (bash script)
# ・Limit number of IM processes by file lock
# ・Limit IM's memory and CPU usage by nested cgroup
echo 0 > /proc/self/oom_score_adj
readonly MAX_PROC=3
readonly MAX_MEM="256M"
@t-tera
t-tera / test.php
Last active August 16, 2020 23:33
Laravel 02
<?php
function myEncrypt($plain, string $purpose, bool $serialize=false) {
$plain = base64_encode($serialize ? serialize($plain) : $plain);
$purpose = hash_hmac('sha256', $purpose, config('app.key'));
$data = json_encode(compact('purpose', 'plain', 'serialize'));
return encrypt($data, false);
}
function myDecrypt(string $encrypted, string $purpose, bool $serialize=false) {
@t-tera
t-tera / gist:5568606b503141348bfb4697a1ccffc0
Created September 2, 2021 02:54
List of PHP CURLOPT_* constants on PHP 7.4.22 (cURL 7.75.0)
-1 = CURLOPT_SAFE_UPLOAD
3 = CURLOPT_PORT
13 = CURLOPT_TIMEOUT
14 = CURLOPT_INFILESIZE
19 = CURLOPT_LOW_SPEED_LIMIT
20 = CURLOPT_LOW_SPEED_TIME
21 = CURLOPT_RESUME_FROM
27 = CURLOPT_CRLF
32 = CURLOPT_SSLVERSION
33 = CURLOPT_TIMECONDITION
@t-tera
t-tera / sample.mjs
Created March 3, 2022 15:35
TensorFlow.js LSTM sample
import {promises as fs} from 'fs';
import * as tf from '@tensorflow/tfjs-node';
const BEHIND_LEN = 10;
const NUM_EPOCHS = 20;
const MODEL_SAVE_DIR_URL = 'file://./model';
// 予測の入力文字列をTensorにする
function makeTensorForPrediction(str) {
// U+0001-U+007F以外の入力は不可