Skip to content

Instantly share code, notes, and snippets.

feixionglee feixionglee

Block or report user

Report or block feixionglee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@feixionglee
feixionglee / quick sort by ruby
Last active Mar 9, 2019
Quick sort algorithm implement with Ruby
View quick sort by ruby
# frozen_string_literal: true
class QuickSort
def initialize(array)
@array = array
end
def sort
puts @array
quick_sort(0, @array.size - 1)
@feixionglee
feixionglee / check_slave_status.rb
Created Jul 20, 2017 — forked from blasterpal/check_slave_status.rb
Check MySQL Slave status from Shell using Ruby
View check_slave_status.rb
#!/usr/bin/env ruby
@slave_status = Hash[%x(mysql -uroot -e 'SHOW SLAVE STATUS \\\G').split(/\s*\n\s*/).map { |e| spl = e.split(/\:\s*/); spl.size == 2 ? [spl.first, spl.last] : nil }.compact]
def slave_healthy?
@slave_status['Slave_IO_Running'] == 'Yes' &&
@slave_status['Slave_SQL_Running'] == 'Yes' &&
@slave_status['Seconds_Behind_Master'] != 'NULL' &&
@slave_status['Seconds_Behind_Master'].to_i < 1800
end
@feixionglee
feixionglee / 0_reuse_code.js
Created Apr 27, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@feixionglee
feixionglee / unicorn
Last active Aug 29, 2015
unicorn init script with rbenv
View unicorn
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts unicorn
# Description: starts uniconr using start-stop-daemon
View postfix_test.rb
require '/Users/lifeixiong/Desktop/postfix/postfix'
require "minitest/autorun"
class PostfixTest < Minitest::Test
def setup
@postfix = Postfix.new '2*(1+3)'
end
def test_is_digit
assert @postfix.send :is_digit, 0
@feixionglee
feixionglee / postfix.rb
Last active Aug 29, 2015
calculate expression
View postfix.rb
# '( 2 + ( ( 4 + 6 ) * (9 * 2) - ( 5 - 1)))'
class Postfix
include Math
def initialize expression
@expression = expression.gsub(' ', '')
end
def process
@feixionglee
feixionglee / deployment version track
Last active Dec 29, 2015
deployment version track
View deployment version track
use the following code in a Rails initializer
if Rails.env.production?
commit_hash = `git rev-parse HEAD 2>/dev/null`.to_s.strip
APP_VERSION = Time.now.utc.strftime("%Y%m%d-%H%M-") + commit_hash[-8..-1]
else
APP_VERSION = Time.now.utc.strftime("%Y%m%d-%H%M-development")
end
You can’t perform that action at this time.