Skip to content

Instantly share code, notes, and snippets.

@harmy
harmy / add-swap.sh
Last active August 12, 2020 07:26
add swap to ubuntu server
sudo dd if=/dev/zero of=/swap bs=1G count=16
sudo chmod 0600 /swap
sudo mkswap -f /swap
sudo swapon /swap
echo "sudo vim /etc/fstab"
@harmy
harmy / Amazon Linux
Last active March 17, 2020 03:03
Resize AWS EC2 Instance EBS volume
#!/bin/bash
# Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
# Install the jq command-line JSON processor.
sudo yum -y install jq
# Get the ID of the envrionment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)
@harmy
harmy / gist:ca3574c8971cb9e44ec003ea783ac7af
Created December 11, 2019 08:14
create your own nonce on Unix with this simple command
head -c 12 /dev/urandom | base64
@harmy
harmy / crontab
Last active January 28, 2019 05:26
update haproxy configuration and reload it dymamiclly
*/3 * * * * sudo ruby /usr/bin/haproxy-autoscaling-update.rb
@harmy
harmy / es-bulk-load-geoname.py
Last active September 6, 2018 03:35
bluk load geoname.csv into ElasticSearch
#!/usr/bin/env python3
import sys
import time
import csv
import json
from collections import namedtuple
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
ES_ENDPOINT = 'vpc-xxxxxxxxxxxx.us-east-1.es.amazonaws.com:80'
@harmy
harmy / gluu-scim.py
Last active June 13, 2018 04:03
Gluu custom script for scim 2.0
# oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
# Copyright (c) 2014, Gluu
#
# Author: Jose Gonzalez
#
from org.xdi.model.custom.script.type.scim import ScimType
from org.xdi.util import StringHelper, ArrayHelper
from java.util import Arrays, ArrayList
from org.gluu.oxtrust.ldap.service import GroupService
from org.gluu.oxtrust.ldap.service import PersonService
@harmy
harmy / keybase.md
Created May 24, 2018 07:12
Keybase proof

Keybase proof

I hereby claim:

  • I am harmy on github.
  • I am harmy (https://keybase.io/harmy) on keybase.
  • I have a public key whose fingerprint is 2598 5D28 1D4A 3411 B2DC BF29 B054 588A 697C 60D9

To claim this, I am signing this object:

@harmy
harmy / aws stepfunctions stop-execution
Last active March 5, 2019 05:53
delete all the aws cloudwatch logs in one command
aws stepfunctions list-executions --state-machine-arn arn:aws:states:us-east-1:415293337666:stateMachine:cpi-prod-install --status-filter RUNNING|jq '.executions[].executionArn'|xargs -L 1 aws stepfunctions stop-execution --execution-arn
@harmy
harmy / default.txt
Last active July 12, 2018 06:37
atom template
PUT _template/default
{
"template": "*",
"settings": {
"number_of_shards": 3 ,
"number_of_replicas": 0
},
"mappings": {
"_default_": {
"_all": {
@harmy
harmy / gist:b49c4ebfab094b28f6af5cf90e2e1999
Created February 22, 2017 10:54
本地查看80端口被哪个进程占用了
sudo lsof -n -P| grep :80