Skip to content

Instantly share code, notes, and snippets.

View lorentzca's full-sized avatar
🏕️
In the Woods.

Kohta Kunishima lorentzca

🏕️
In the Woods.
View GitHub Profile
@lorentzca
lorentzca / index.html
Created October 4, 2016 15:07
ghost blog insite search box by algolia
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
.algolia-autocomplete {
width: 80%;
max-width: 710px;
}
.algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint {
width: 100%;
@lorentzca
lorentzca / reviewkun
Created September 12, 2017 08:35
Cowsay
##
## reviewkun
##
$the_cow = <<EOC;
$thoughts ∞
$thoughts (👀 )
m(👄 )m
EOC
@lorentzca
lorentzca / ghostblog_update.sh
Last active April 19, 2017 04:41
my ghostblog updater
#/bin/sh -x
# version
version="0.11.8"
# backup
cd /var/www/ghost
sudo tar cpf /tmp/ghost_snapshot_$(date +%Y%m%d%H%M).tar .
# download latest ghost
@lorentzca
lorentzca / master_name_failover
Last active February 22, 2017 01:56
mhaフェイルオーバー時consulのカタログデータベースを書き換えるスクリプト
#!/usr/bin/env perl
# Copyright (C) 2011 DeNA Co.,Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@lorentzca
lorentzca / sammy-the-shark.txt
Created February 15, 2017 11:16
Sammy The Shark ASCII Art
■■■
■■ ■■■■
■■ ■■■
■■■ ■■ ■■
■ ■■ ■■ ■■
■ ■■ ■■ ■■
■ ■■ ■■ ■■
■ ■■ ■■ ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
■ ■■ ■■■ ■■ ■■■■
■■ ■■■■ ■■■■■■ ■ ■ ■ ■■■■■■■ ■■■■
@lorentzca
lorentzca / highlight.min.js
Created February 12, 2017 05:01
highlight.js custom language
/*! highlight.js v9.9.0 | BSD3 License | git.io/hljslicense */
!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/[&<>]/gm,function(e){return I[e]})}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function i(e){return k.test(e)}function a(e){var n,t,r,a,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return R(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(a=o[n],i(a)||R(a))return a}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,i){for(var a=e.firstChild;a;a=a.nextSibling)3===a.nodeType?i+=a.nodeValue.length:1===a.nodeType&&(n.push({event:"start",offset:i,node:a}),i=r(a,i),t(a).match(/br|hr|img|input/)||n.push({event:"stop"
@lorentzca
lorentzca / algolia-search.go
Created February 7, 2017 11:26
Search algolia index data with golang
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/algolia/algoliasearch-client-go/algoliasearch"
"github.com/jessevdk/go-flags"
"os"
)
@lorentzca
lorentzca / mackerel-graph-annotation.sh
Last active January 29, 2017 07:44
とにかくmackerelのグラフアノテーション機能をapiから叩いてみたいときに実行するコマンド
curl -X POST -H "X-Api-Key: $MACKEREL_APIKEY" -H "Content-Type:application/json" -d "{\"title\": \"test\", \"description\": \"test-$(date +%Y%m%d%H%M)\", \"from\": $(date +%s), \"to\": $(date +%s), \"service\": \"サービス名\", \"roles\": [\"ロール名\"]}" https://mackerel.io/api/v0/graph-annotations
@lorentzca
lorentzca / allow_from_japan_apache
Last active November 17, 2016 00:54
Allow from japan ip address
allow from 1.0.16.0/20
allow from 1.0.64.0/18
allow from 1.1.64.0/18
allow from 1.5.0.0/16
allow from 1.21.0.0/16
allow from 1.33.0.0/16
allow from 1.66.0.0/15
allow from 1.72.0.0/13
allow from 1.112.0.0/14
allow from 14.0.8.0/22
@lorentzca
lorentzca / attack.sh
Last active October 20, 2016 01:09
サーバヒットポイントが0以下になったらシャットダウンする(見た目だけ)
#!/bin/bash
hp=$(curl -s -X GET \
-H "X-Api-Key: $MACKEREL_APIKEY" \
https://mackerel.io/api/v0/hosts/$MACKEREL_HOSTID/metadata/HP | jq -r .HP)
damage=$(expr $RANDOM % 500)
remaining_hp=$(expr $hp - $damage)
hostname=$1
echo HP is $hp