Skip to content

Instantly share code, notes, and snippets.

View otajisan's full-sized avatar
🍻
Drinking beer anytime

otajisan otajisan

🍻
Drinking beer anytime
View GitHub Profile
@otajisan
otajisan / generate_password.py
Last active September 2, 2022 00:38
password generator
import string
import secrets
def generate_password(size=10):
chars = f'{string.ascii_uppercase}{string.ascii_lowercase}{string.digits}{string.punctuation}'
return ''.join(secrets.choice(chars) for x in range(size))
print(generate_password(10))
@otajisan
otajisan / Vagrantfile
Created June 15, 2017 17:04
CentOS7 x PHP5.6 x Apache環境構築用のVagrantfileのサンプル
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
## 仮想マシンの定義
# ベースイメージ
config.vm.box = "centos/7"
# ホスト名
config.vm.hostname = "develop"
# IPアドレス
@otajisan
otajisan / decimal_check.php
Last active August 3, 2016 03:01
整数のみを取得する正規表現
<?php
$str_list = array(
'1000',
'10.10',
'10.0',
'アイウエオ.カキクケコ',
);
$pattern = '/([0-9].0)/';
@otajisan
otajisan / make_category_files.php
Created June 29, 2016 11:57
MySQLのデータを元に、教師データ風なものを拾ってくる
<?php
#!/usr/bin/php
function remove_old($filename)
{
foreach (glob($filename) as $file) {
unlink($file);
}
}
@otajisan
otajisan / load_model.py
Created June 29, 2016 11:45
scikit-learnでシリアライズしたモデルを読み込み、テキストを分類する(corpusは自前)
# -*- coding: utf-8 -*-
from sklearn.externals import joblib
from sklearn.metrics import classification_report
import corpus
def predict(text):
dictionary = corpus.get_dictionary(create_flg=False)
vector = [corpus.get_vector(dictionary, text)]
clf = joblib.load("model/model")
# coding:utf-8
from random import choice
class ZundokoKiyoshi:
CORRECT_MESSAGE = 'ズンズンズンズンドコ'
RESULT_MESSAGE = 'キ・ヨ・シ!'
@otajisan
otajisan / analyze_word_by_elasticsearch.php
Created February 18, 2016 12:22
PHPでElasticSearch x kuromojiの形態素解析を行うサンプル ref: http://qiita.com/monhan/items/c1a9d358ebe7a49e44f4
<?php
/**
* ElasticSearchとのやり取りをするクラス
*/
class ElasticSearchService
{
/** 接続先のElasticSearchのURL & ポート */
const BASE_URL = 'localhost';
const PORT = '9200';
@otajisan
otajisan / analyze_word_by_elasticsearch.php
Last active February 18, 2016 12:22
PHPでElasticSearch x kuromojiの形態素解析を行うサンプル
<?php
/**
* ElasticSearchとのやり取りをするクラス
*/
class ElasticSearchService
{
/** 接続先のElasticSearchのURL & ポート */
const BASE_URL = 'localhost';
const PORT = '9200';
@otajisan
otajisan / RandomFlash.pl
Created July 18, 2015 22:22
ラズベリーパイ2とperlを使って、LEDをランダムな時間間隔でチカチカさせる ref: http://qiita.com/monhan/items/e9c833a8b90d9a6caf17
#!/user/local/bin/perl
use strict;
use warnings;
use utf8;
use Time::HiRes 'sleep';
use Math::Round;
#
# メイン処理
@otajisan
otajisan / .profile
Created July 18, 2015 07:35
ドットファイルのコピースクリプトを作ってみた ref: http://qiita.com/monhan/items/0bdc7d9d221258a17154
if [ -f ~/.profile.local ]; then
. ~/.profile.local
fi