Skip to content

Instantly share code, notes, and snippets.

@kaznak
kaznak / jpnic-address-block.hs
Last active April 26, 2019 05:36
Fetch JPNIC IP address ranges and output adress block
#!/usr/bin/env stack
{- stack
runhaskell
--resolver lts-13.18
--package base
--package curl
--package iproute
--package tagsoup
--package containers
--package data-interval
@kaznak
kaznak / configuration.nix
Created July 19, 2019 05:33
PHP on NixOS
let
pkgsSrc = (builtins.fetchGit {
url = https://github.com/nixos/nixpkgs;
ref = "release-19.03";
});
pkgs = import pkgsSrc {};
lib = pkgs.lib;
in
{
imports = [
@kaznak
kaznak / setup_wordpress.sh
Last active August 14, 2019 10:13
Wordpress on NixOS
rm -rf /var/www
mkdir -p /var/www
chown nginx:nginx /var/www
pushd /var/www
wget http://wordpress.org/latest.tar.gz
mv latest.tar.gz wordpress-$stime.tar.gz
tar -zxvf wordpress-$stime.tar.gz
mv wordpress default
@kaznak
kaznak / configuration.nix
Created August 16, 2019 05:54
PHPfpm on NixOS raise "Primary script unknown" Error
{ pkgs, lib, ... }:
# let
# pkgsSrc = (builtins.fetchGit {
# url = https://github.com/nixos/nixpkgs;
# ref = "release-19.03";
# });
# pkgs = import pkgsSrc {};
# lib = pkgs.lib;
# in
with lib;
@kaznak
kaznak / www.example.com.conf
Created August 30, 2019 07:34
nginx site configuration for wordpress
server {
listen 80 default_server;
listen [::]:80 default_server;
# listen 80;
# listen [::]:80;
root /var/www/www.example.com;
index index.php index.html;
server_name www.example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args =404;
@kaznak
kaznak / ElasticBeanstalk_cloudformation.yml
Created November 5, 2019 05:39
Deploy Sample Nodejs app on AWS ElasticBeanstalk with Cloudformation
AWSTemplateFormatVersion: '2010-09-09'
Resources:
sampleNodejsApp:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: sampleNodejsApp
Description: AWS Elastic Beanstalk Sample Nodejs Application
sampleNodejsAppVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
#include <stdio.h>
int main()
{
int a = 10, b = 0, c = 10;
char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
"TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL"
"OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm "
"SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
while (a != 0)
{
#include <stdio.h>
int main() {
int nc = 0, mode = 0;
char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
"TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL"
"OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm "
"SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
for(;*str != 0; str++, mode = !mode) {
for(int mc = *str; mc > '@'; mc--) {
#include <stdio.h>
int main() {
int nc = 0, mode = 0;
char* str = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq "
"TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBL"
"OFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm "
"SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
for(;*str != 0; str++, mode = !mode)
for(int mc = *str; mc > '@'; mc--)
@kaznak
kaznak / terraform_backend_s3.md
Created December 19, 2019 03:10 — forked from imksoo/terraform_backend_s3.md
AWS環境をTerraformで作るときはS3 Backendを活用しましょう

AWS環境をTerraformで作るときはS3 Backendを活用しましょう

Terraformはtfstateファイルで構成情報を管理しているが、 単純にtfstateファイルをgit等で共有すると他の人が構成変更 (terrafrom apply)している最中に別に作業を実行したり出来る。

そういうときに良く競合してあるべきリソースが削除されたりするが Terraform Backend S3 + DynamoDB Lockを利用することで、自動的に ロックしながら最新状態を共有することが可能となる。