if neobundle#is_sourced('vim-ref') " {{{
if has('win32') || has('win64')
let g:ref_phpmanual_path = $VIM . '/vimfiles/manual/php_manual_ja/'
else
let g:ref_phpmanual_path = $HOME . '/.vim/manual/php_manual_ja/'
endif
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "12345", "long text...." | |
# "12346", "long text...." | |
require 'csv' | |
require 'uri' | |
CSV.open('url.csv', 'wb', force_quotes: true) do |output| | |
CSV.read('about.csv', encoding: 'UTF-8:UTF-8', header_converters: nil).map do |input| | |
tmp = [] | |
tmp << input[0] | |
tmp << URI.extract(input[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print isinstance(1, (int, unicode)) | |
# True | |
print isinstance(u'text', (int, unicode)) | |
# True | |
print isinstance('8-bit string', (int, unicode)) | |
# False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
#################### gather fact about subnet | |
- name: gather a fact about subnet | |
ec2_vpc_subnet_facts: | |
region: '{{ vpc_region }}' | |
filters: | |
'tag:Name': '{{ site_name }}-{{ stage }}-bastion' | |
'tag:env': '{{ stage }}' | |
'tag:Tier': bastion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = ''; | |
$list = array(); | |
if (!empty($_POST['data'])) { | |
$data = $_POST['data']; | |
$matches = array(); | |
$result = preg_match_all("/u'(.*)',|'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})',/", $data, $matches); | |
if ($result) { | |
$subjects = $matches[1]; | |
$subjects[0] = array_filter($matches[2])[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/build | |
cd ~/build | |
wget https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz | |
tar xzf git-2.9.0.tar.gz | |
cd git-2.9.0 | |
make prefix=/usr/local all | |
make prefix=/usr/local install | |
git --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = array('name' => array( 'error1', 'error2')); | |
$b = array('email' => array('error3', 'error4')); | |
$errors = array_merge($a, $b); | |
$result = array_reduce($errors, function($c, $v) { return array_merge($c, $v); }, array()); | |
print_r($errors); | |
print_r($result); | |
print_r(implode('\n', $result)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `samples` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`comment` varchar(255) NOT NULL, | |
`created` datetime NOT NULL, | |
PRIMARY KEY (`id`,`created`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 | |
PARTITION BY RANGE COLUMNS(`created`) ( | |
PARTITION samples_p20170427 VALUES LESS THAN('2017-04-28 00:00:00'), | |
PARTITION samples_p20170428 VALUES LESS THAN('2017-04-29 00:00:00') | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function f($in, $required) { | |
$keys = array_keys(array_intersect_key(($in), array_flip($required))); | |
sort($keys); | |
sort($required); | |
return $keys === $required; | |
} | |
$required = array('key1', 'key2'); |