Skip to content

Instantly share code, notes, and snippets.

View Mistoreaa's full-sized avatar

Mafty Mistoreaa

View GitHub Profile
@Mistoreaa
Mistoreaa / RoR_migrationファイル関連リンク集.md
Last active September 29, 2025 14:41
[Ruby on Rails] migrationファイルの記述例
@Mistoreaa
Mistoreaa / ruby_file_operation.md
Last active August 20, 2025 02:02
Rubyのファイル操作

Rubyのファイル操作

ファイルのオープンモード

mode 説明
r 読み込み(デフォルト)
w 書き込み。オープン時にファイルがすでに存在していればその内容を空にする。
a 書き込み。出力は常にファイルの末尾に追加される。
モードに "+" を付けると、ファイルは読み書きモードでオープンされる
@Mistoreaa
Mistoreaa / ruby_directory_operation.md
Last active March 24, 2025 13:54
Rubyのディレクトリ操作

Rubyのディレクトリ操作

dir_path = "/tmp/foo/"


# ユーザのホームディレクトリを取得する
user_name = "user_name" # Macならユーザ名またはアカウント名
Dir.home(user_name)
@Mistoreaa
Mistoreaa / declarative_pipeline_sample.txt
Last active June 10, 2023 13:39
[Jenkins] Sample script in "Declarative Pipeline" format to measure the remaining capacity of a remote server
pipeline {
agent any
environment {
SSH_USER = "ssh_user"
TARGET_HOST_AVAILABLE_DISK_SPACE="0"
}
stages {
stage('setting default value') {
@Mistoreaa
Mistoreaa / sort_bubble.py
Last active September 29, 2020 15:58
[Python3] A study by sort algorithm.
import random
import copy
def make_base():
base = list(range(1, 11))
return random.sample(base, len(base))
def sort_bubble(base):
@Mistoreaa
Mistoreaa / sample_lambda.php
Created November 5, 2017 16:53
[PHP] Use external variables in lambda. Requires PHP 5.3 or above.
<?php
$filterFunc = function($extParam) {
return function($param) use ($extParam) {
return ($param == $extParam);
};
};
$mapFunc = function($extParam) {
return function($param) use ($extParam) {
@Mistoreaa
Mistoreaa / sample_read_file.py
Last active January 31, 2017 14:38
[Python] Sample codes to read a file. Requires Python3 or above.
import sys
import os
_input_delimiter = ','
_export_delimiter = '\t'
param = sys.argv
if len(param) < 2:
@Mistoreaa
Mistoreaa / sample_read_file.php
Last active December 15, 2016 15:38
[PHP] Sample codes to read a file. These codes requires version 5.1 or above.
<?php
class File {
/**
* @param string $filePath
* @param array $sfoFlags
* @param string $delimiter
* @return array
*/
@Mistoreaa
Mistoreaa / sample.html
Created March 21, 2016 13:40
[JavaScript] A sumple to use handleEvent method .
<!DOCTYPE>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
#fooContainer {
position: absolute;
top: 50%;
left: 50%;
}
@Mistoreaa
Mistoreaa / dump_table.sh
Last active December 4, 2015 17:24
Table dump and insert to MySQL.
#!/bin/bash
: << COMMENT
Dump MySQL table.
param1: destination host.
param2: database.
param3: table.
param4: dump condition.
COMMENT