Skip to content

Instantly share code, notes, and snippets.

View violetyk's full-sized avatar

kagaya violetyk

View GitHub Profile
@violetyk
violetyk / md2pdf.js
Created July 8, 2019 05:23
配下のmdをpdfにする
#!/usr/bin/env node
const
fs = require('fs'),
path = require('path'),
markdownpdf = require('markdown-pdf');
const walk = (dir, callback) => {
fs.readdirSync(dir).forEach((item) => {
const filePath = path.join(dir, item);
<?php
var_dump(ini_get('precision'));
var_dump(ini_get('serialize_precision'));
$test = [
'rank1' => 32.361 * 1000,
'rank2' => 32.361 * 1,
'rank3' => 32.361 * 10,
'rank4' => 32.361 * 100,
'rank5' => (int)(string)(32.361 * 1000),
<?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');
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')
);
<?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));
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
<?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];
@violetyk
violetyk / main.yml
Created April 22, 2016 09:16
bastionのインスタンスのサンプル
---
#################### 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
@violetyk
violetyk / isinstance.py
Created March 9, 2016 02:26
Python型判定
print isinstance(1, (int, unicode))
# True
print isinstance(u'text', (int, unicode))
# True
print isinstance('8-bit string', (int, unicode))
# False
@violetyk
violetyk / gist:bc4e7869bf6b4f8c152b
Created February 23, 2016 06:38
開発サーバで環境作り

方針

  • rootがない状況なので $HOME/local へ入れる
  • configureで使うライブラリがないので apt-cache search hoge でさがして apt-get source hoge で入れて configure, make, make installする

ホームディレクトリ

cd ~
mkdir -p {bin,tmp,etc/profile.d,swap,undo,backup,tags,src,.trash,.tmux,build}