Skip to content

Instantly share code, notes, and snippets.

@jibing57
jibing57 / experience.rb
Created July 11, 2022 08:39 — forked from mamantoha/experience.rb
Rails API Filtering and Sorting
# app/models/experience.rb
#
# == Schema Information
#
# Table name: experiences
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
@jibing57
jibing57 / aws_elb_access_log_parser.rb
Last active May 26, 2020 18:27
a simple ruby script to parse aws elb access log to csv format file
require 'csv'
require 'optparse'
class AWSELBAccessLogParser
def initialize()
@@elb_access_log_format=%Q(timestamp elb client:port backend:port request_processing_time backend_processing_time response_processing_time elb_status_code backend_status_code received_bytes sent_bytes "request" "user_agent" ssl_cipher ssl_protocol)
# puts "elb_access_log_format is #{elb_access_log_format.split(" ")}"
@@line_regex = /
@jibing57
jibing57 / get_http_5xx_in_elb_access_log.sh
Created December 25, 2017 09:07
shell to get entry including http 5XX code from access logs of AWS ELB
#!/bin/bash
#############################################
###### Global Variable #########
#############################################
MAIL_TO=""
S3_BASE_PREFIX=""
BASE_WORK_DIR=`cd $(dirname $0); pwd `
@jibing57
jibing57 / rds_download_logfiles.rb
Created November 29, 2017 09:05 — forked from ruckus/rds_download_logfiles.rb
Ruby script to download log files from RDS and archive to S3.
=begin
This script uses the AWS v2 API
Gemfile:
source "https://rubygems.org"
gem "aws-sdk", "2.0.17.pre"
# get git branch and last commit time
git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname) %(committerdate) %(authorname)' | sed 's/refs\/heads\///g'
# change file extension
input_file="./xxx.log"
output_file= "#{input_file.chomp(File.extname(input_file))}.csv"
puts "input_file is #{input_file}, output_file is #{output_file}"
# get first line of files
input_file="./xxx.log"
first_line = File.open(src_file, "r") {|f| f.readline}
puts "first_line of file[#{input_file}] is #{first_line}"
@jibing57
jibing57 / uninstall_xQuartz_on_yosemite.sh
Last active August 29, 2015 14:21
Uninstall XQuartz.app from OSX Yosemite
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz
sudo pkgutil --forget org.macosforge.xquartz.pkg
# Log out and log in