Skip to content

Instantly share code, notes, and snippets.

View u-akihiro's full-sized avatar

Akihiro Uesaka u-akihiro

View GitHub Profile
@u-akihiro
u-akihiro / books_mapping.txt
Last active June 14, 2020 13:49
ElasticSearch としょがかりで使うMapping
PUT /books
{
"mappings": {
"properties": {
"isbn": {"type": "keyword"},
"title": {"type": "text"},
"title_kana": {"type": "text"},
"subtitle": {"type": "text"},
"subtitle_kana": {"type": "text"},
"authors": {
@u-akihiro
u-akihiro / main.rb
Last active June 7, 2020 09:57
OpenBDからcoverageを取得するスクリプト
require 'net/https'
require 'bigdecimal'
require 'json'
def download_coverage
uri = URI.parse('https://api.openbd.jp')
http = Net::HTTP.new(uri.host, uri.port)
@u-akihiro
u-akihiro / hello.rb
Created May 6, 2020 07:05
rpsec stub example
require 'google-id-token'
class Hello
def check
token = ''
client_id = ''
validator = GoogleIDToken::Validator.new
validator.check(token, client_id)
end
end
Vagrant.configure("2") do |config|
# config.vm.box = "bento/ubuntu-16.04"
config.vm.define "controller" do |controller|
controller.vm.box = "bento/ubuntu-16.04"
controller.vm.hostname = "controller"
controller.vm.network :private_network, ip: "192.168.33.2"
controller.vm.network :forwarded_port, id: "ssh", guest: 22, host: 2210
controller.vm.synced_folder './workspace', '/vagrant'
end
@u-akihiro
u-akihiro / install_apache.yml
Created April 1, 2017 10:07
Ansible first time.
- hosts: 192.168.33.3
tasks:
- name: ensure apache is at the latest version
apt:
name: apache2
state: latest
become: yes
become_method: sudo
handlers:
- name: restart apache

imagemagickを手動インストールする

imagemagickのダウンロード

imagemagickのソースコードはpeclから入手しておく。 stableで最新のバージョンをダウンロードするので問題なさそう。

pecl imagick

インストール

@u-akihiro
u-akihiro / tax_query.php
Created October 13, 2015 00:22
WordPress tax_queryでページネーションを行う
<?php
$args = array(
'paged' => $paged,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'publisher',
'field' => 'slug',
'terms' => array('kodansha')
@u-akihiro
u-akihiro / Main.php
Last active September 13, 2015 10:26
2個以上の配列から共通項のみを抜き出す
<?php
// Here your code !
$conditions = array(
array(1, 2, 3, 4, 5),
array(2, 3, 5),
array(2, 3, 5),
);
$result = array_reduce($conditions, function($carry, $item){
if (is_null($carry)) {
@u-akihiro
u-akihiro / nested_keybind.rb
Created January 13, 2015 10:50
ネストしたキーバインディング
require 'pp'
# require 'forwardable'
#
# class Delegate
# extend Forwardable
#
# def_delegator :@children, :[]
# def_delegator :@block, :call
#
# def initialize()
@u-akihiro
u-akihiro / nested_keybinding.rb
Created January 11, 2015 15:19
ruminのネストされたキーバインディング
require 'pp'
require 'forwardable'
class Node
extend Forwardable
attr_reader :parent
attr_reader :children
attr_writer :proc
def_delegator :@children, :[]
def_delegator :@children, :key?