Skip to content

Instantly share code, notes, and snippets.

@y0t4
y0t4 / failure_rspec_parameterized_spec.rb
Last active December 22, 2023 06:17
rspec-parameterized使っていてletされた変数へのアクセスで不思議な挙動があったので、その挙動を再現したコード
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rspec'
gem 'rspec-parameterized'
end
require 'rspec'
require 'rspec-parameterized'
@y0t4
y0t4 / newrelic.sh
Created December 16, 2021 07:41
newrelicのalbアラートで5xx系の設定をしたい場合に使用するapiの流れ
curl -X GET --header "X-Api-Key: ${API_KEYを入れる}" "https://infra-api.newrelic.com/v2/alerts/conditions?policy_id=${ポリシーのid}" | jq .
curl -X GET --header "X-Api-Key: ${API_KEYを入れる}" "https://infra-api.newrelic.com/v2/alerts/conditions/${5xx系の監視をしたいコンディションのid}" | jq .
curl -X PUT 'https://infra-api.newrelic.com/v2/alerts/conditions/${5xx系の監視をしたいコンディションのid}' -H 'X-Api-Key: ${API_KEYを入れる}' -i -H 'Content-Type: application/json' -d '{"data":{"select_value": "provider.httpCodeElb5XXCount.Sum"}}'
@y0t4
y0t4 / game_of_life.cpp
Created November 16, 2019 07:54
[初C++]coderetreatで作ったlifegame
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <unistd.h>
using namespace std;
class Lifegame
{
private:
@y0t4
y0t4 / convert_backquote_to_tag.sh
Created July 15, 2014 17:40
markdownの```なコード部分を[code][/code]とかで挟むシェル芸
cat printf.md | awk 'BEGIN{i=0} /^$/{print} /^```$/{if(i%2==0){print "[code]"}else{print "[/code]"}i++} /^[^`]{3}/'
@y0t4
y0t4 / replace.c
Last active August 29, 2015 14:03
てきとーに
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
void replace(char *dest, char *str)
{
int length = strlen(str);
for (int i=0; i < length; i++) {
if ( isupper(str[i]) ) {
@y0t4
y0t4 / centos7_install.md
Created July 8, 2014 13:07
2014-07-08な #台風ソン

インストール

LiveCDからインストールを行った

起動前

  • 容量は20GBくらい割り当てた
  • メモリは1GB
    • 512MBだと起動がとても遅い
    • LiveCDでもCUIで起動できるかも(?)
  • デバイス無効化
  • オーディオ

設定の例

Host test
  User test-user
  Hostname example.com
  identityfile ~/.ssh/id_rsa.example

sshしてみる

上記のように記述した場合以下のコマンドでサーバにsshすることができる。

@y0t4
y0t4 / myping
Created May 24, 2014 08:01
適当にモジュール作成してみる
#!/bin/bash
eval $(perl -lne 'while(/\s?([^=\s]+)\s?=\s?(\"(?:\\\"|[^\"])+\"|\x27(?:\x27\\\x27\x27|[^\x27])+\x27|\S+)\s?/g){print "$1=$2"}' $1)
if [ -z "${ip}" ]; then
printf "rc=0 changed=False ip='ip not found'"
exit 0
fi
ping -w 3 ${ip} >/dev/null 2>&1
if [ $? -eq 0 ]; then
@y0t4
y0t4 / default.conf
Last active December 29, 2015 12:39
設定ファイル
# /etc/nginx/conf.d/default.conf
upstream backend {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name localhost;
root /home/csf/wordpress;
index index.html index.htm index.php;
keepalive_timeout 300;