Skip to content

Instantly share code, notes, and snippets.

@sanggiChoi
sanggiChoi / statistical_tests.py
Created August 13, 2018 09:43 — forked from mblondel/statistical_tests.py
t-test and wilcoxon-test examples in Python
# Mathieu Blondel, February 2012
# License: BSD 3 clause
# Port to Python of examples in chapter 5 of
# "Introductory Statistics with R" by Peter Dalgaard
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu
# daily intake of energy in kJ for 11 women

Sends Cloudwatch Event notifications to Slack

What is this?

AWS have released a new featue called CloudWatch Events, which lets you configure events fired by cloudwatch and direct them to SNS, Lambda functions, etc. Here's the blog post

Motivational image:

Here's the motivational image:

Slack image

@sanggiChoi
sanggiChoi / install.sh
Created July 16, 2018 04:44 — forked from bbenson29/install.sh
Install terraform and packer on Centos 7
#!/bin/bash
set -x
TERRAFORM_VERSION="0.9.11"
PACKER_VERSION="1.0.2"
# install pip
pip install -U pip && pip3 install -U pip
if [[ $? == 127 ]]; then
wget -q https://bootstrap.pypa.io/get-pip.py
@sanggiChoi
sanggiChoi / create_index.sh
Created March 20, 2018 01:59 — forked from bonzanini/create_index.sh
Elasticsearch/Python test
curl -XPOST http://localhost:9200/test/articles/1 -d '{
"content": "The quick brown fox"
}'
curl -XPOST http://localhost:9200/test/articles/2 -d '{
"content": "What does the fox say?"
}'
curl -XPOST http://localhost:9200/test/articles/3 -d '{
"content": "The quick brown fox jumped over the lazy dog"
}'
curl -XPOST http://localhost:9200/test/articles/4 -d '{
@sanggiChoi
sanggiChoi / create_proximity.sh
Created March 20, 2018 01:58 — forked from bonzanini/create_proximity.sh
Elasticsearch Proximity/Phrase Search
curl -XDELETE http://localhost:9200/test/articles
curl -XPUT http://localhost:9200/test/_mapping/articles -d '{
"properties": {
"content": {
"type": "string",
"position_offset_gap": 100
}
}
}'
@sanggiChoi
sanggiChoi / create_recent_articles.sh
Created March 20, 2018 01:58 — forked from bonzanini/create_recent_articles.sh
Create sample DB on Elasticsearch to showcase decay function over publication date
curl -XDELETE http://localhost:9200/blog
curl -XPUT http://localhost:9200/blog -d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
},
"mapping": {
# The database recipe should be included by any server running a DB. It creates
# a /data directory and, if on EC2, will mount an EBS volume here
directory '/data' do
mode '0755'
end
if node[:app][:ec2] || node[:cloud][:provider] == 'ec2'
aws = data_bag_item('aws', 'main')
include_recipe 'aws'
# Remove foreman
yum remove remove foreman foreman-installer foreman-proxy
rm -rf /var/lib/foreman /usr/share/foreman /usr/share/foreman-proxy/logs
rm /etc/httpd/conf.d/foreman.conf
# Remove puppet
yum remove puppet puppetmaster puppet-common puppetmaster-common puppetlabs-release
rm -rf /usr/lib/ruby/vendor_ruby/puppet /usr/share/puppet /var/lib/puppet /etc/puppet
rm /etc/apache2/conf.d/puppet.conf
# knife cheat
## Search Examples
knife search "name:ip*"
knife search "platform:ubuntu*"
knife search "platform:*" -a macaddress
knife search "platform:ubuntu*" -a uptime
knife search "platform:ubuntu*" -a virtualization.system
knife search "platform:ubuntu*" -a network.default_gateway
@sanggiChoi
sanggiChoi / chef.rb
Created July 14, 2017 11:49 — forked from gmcmillan/chef.rb
Simple Ruby class for manually querying the Chef REST API (using Net::HTTP instead of Chef's REST resources)
require 'base64'
require 'time'
require 'digest/sha1'
require 'openssl'
require 'net/https'
require 'json'
class ChefAPI
# Public: Gets/Sets the http object.