Skip to content

Instantly share code, notes, and snippets.

Avatar

t-tera

  • Tokyo, Japan
View GitHub Profile
@t-tera
t-tera / sample.mjs
Created Mar 3, 2022
TensorFlow.js LSTM sample
View sample.mjs
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以外の入力は不可
@t-tera
t-tera / gist:5568606b503141348bfb4697a1ccffc0
Created Sep 2, 2021
List of PHP CURLOPT_* constants on PHP 7.4.22 (cURL 7.75.0)
View gist:5568606b503141348bfb4697a1ccffc0
-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 / test.php
Last active Aug 16, 2020
Laravel 02
View test.php
<?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) {
View identify
#!/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"