Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Makoto Shiga MacoTasu

🎯
Focusing
View GitHub Profile
@MacoTasu
MacoTasu / index.html
Last active Dec 5, 2018
GoogleドキュメントのいいねAdd-On
View index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<style type="text/css">
<!--
button {margin: 5px 5px;}
td {padding: 11px 5px;}
table {width: 100%;}
@MacoTasu
MacoTasu / sample.rb
Created Dec 18, 2017
pact consumer sample code
View sample.rb
require 'pact/consumer/rspec'
Pact.service_consumer "client" do
has_pact_with "microservice" do
mock_service :microservice do
port 3001 # 適当なポート
end
end
end
View fizzbuzz.rb
# frozen_string_literal: true
def fizzbuzz(number:)
return 'fizzbuzz' if (number % 15).zero?
return 'buzz' if (number % 5).zero?
return 'fizz' if (number % 3).zero?
number
end
1..15.times do |index|
@MacoTasu
MacoTasu / pubkey2authrized_keys.rb
Last active Dec 14, 2016
githubに登録しているpubkeyをauthrized_keysにひたすら入れる君
View pubkey2authrized_keys.rb
#! /usr/bin/env ruby
require 'net/http'
require 'fileutils'
users = ["MacoTasu"] #ここにユーザを追加してね
users.each do |user|
uri = URI.parse("https://github.com/#{user}.keys")
File.open('authrized_keys','a') do |file|
Net::HTTP.get(uri).split("\n").each do |key|
file.puts("#{key}")
@MacoTasu
MacoTasu / sudoers.rb
Last active Nov 22, 2016
this is cookbook that in order to create sudores user by centos, depend on https://github.com/nownabe/itamae-plugin-resource-authorized_keys
View sudoers.rb
# coding: utf-8
SUDO_GID=27
node.validate! do
{
sudoers: {
users: array_of({
name: string,
password: string,
github_name: string,
@MacoTasu
MacoTasu / parallel.php
Last active Nov 2, 2016
n並列で同時にqueryを発行する君( ref.https://github.com/hironobu-s/parallel-for)
View parallel.php
<?php
require('./ParallelFor.php');
system('date');
$executor = function($var) {
$link = mysql_connect('127.0.0.1:3306', 'root', '');
if (!$link) {
die('接続できませんでした: ' . mysql_error());
}
print '接続に成功しました';
@MacoTasu
MacoTasu / module_prepend.rb
Last active Jul 13, 2016
Module#prepend実行結果
View module_prepend.rb
[1] pry(main)> module Hoge
[1] pry(main)* def say
[1] pry(main)* p "hoge"
[1] pry(main)* end
[1] pry(main)* end
=> :say
[2] pry(main)> module Fuga
[2] pry(main)* def say
[2] pry(main)* p "fuga"
[2] pry(main)* end
@MacoTasu
MacoTasu / mysqldump2s3
Last active Mar 31, 2016
mysqlをdumpしてs3にアップロードするshell
View mysqldump2s3
#!/bin/sh
mysqldump -h $MYSQL_HOST -u$MYSQL_USER_NAME -p$MYSQL_PASSWORD --single-transaction --master-data=2 $DB_NAME | gzip > mysqldump.sql.gz
date_str=`date +"%Y%m%d%I%M"`
aws s3 mv mysqldump.sql.gz s3://****-mysqldump/"${date_str}".sql.gz
@MacoTasu
MacoTasu / test.sql
Created Dec 6, 2015
create test data sql
View test.sql
DROP TABLE IF EXISTS `entries`;
CREATE TABLE `entries` (
`id` INTEGER unsigned NOT NULL auto_increment,
`user_id` INTEGER,
`title` VARCHAR(191) NOT NULL,
`created_at` datetime,
`updated_at` datetime,
INDEX `user_id_idx` (`user_id`),
PRIMARY KEY (`id`)
@MacoTasu
MacoTasu / p5-remove-remote-branch.pl
Last active Sep 10, 2015
remote branch remove script
View p5-remove-remote-branch.pl
use common::sense;
use Getopt::Long;
local $| = 1;
GetOptions(\my %opts, qw/
prod
/);
my $prod = $opts{'prod'};
You can’t perform that action at this time.