Skip to content

Instantly share code, notes, and snippets.

View violetyk's full-sized avatar

kagaya violetyk

View GitHub Profile
@violetyk
violetyk / gist:5343883
Last active August 4, 2020 05:11
スクロールイベント 上下方向の判定
var start_pos = 0;
$(window).scroll(function(e){
var current_pos = $(this).scrollTop();
if (current_pos > start_pos) {
console.log('down');
} else {
console.log('up');
}
start_pos = current_pos;
});

pecl imagickいれなおす

ImageMagick6.2.9から使える関数が必要なため。

今のバージョンを調べる

rpm -qa | grep -i imagemagick
ImageMagick-6.2.8.0-4.el5_5.3
ImageMagick-devel-6.2.8.0-4.el5_5.3
@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