Stress Test Using JMeter in Ruby - Part 2

JMeter

Due to update-to-date JMeter 3.0 require Java 7, but for current offical Java support in Mac OSX is 6. So, before running new JMeter you might need to upgrade your Java. Please check my gist for installation Java 7.

This article just show you code example of how to use loop number and thread number in gem 'ruby-jmeter'.

Read on →
Comments

API Request Limitation Using Rack-Throttle and Doorkeeper

When it comes to open API to external users, we need to consider the number of requests we allowed. Most of API-as-a-service platforms have different payment plans. Due to different levels of payment, it can make sure that our service resource can be used fairly - advanced plan users can make more requests than normal users.

In order to achieve this goal, we need to find a way recording the number of requests. Intuitively, we can creata a request_record table, before controller process the request, by comparing the number in database and client’s request limitation, we can either allow or deny the requests.
However, we don’t need to build like this way.

Thanks to Ruby gems, you are able to find some libraries can do the trick. In this article, I choose rack-throttle to help me count the requests. The reasons I prefer rack-throttle are:

  1. To limit by defining a maximum number of allowed HTTP requests per a given time period
  2. Compatible with any Rack application and any Rack-based framework.
  3. Compatible with the memcached, memcache-client, memcache and redis gems.
  4. Well documented and the most important thing is that codes are easy to read!
Read on →
Comments

Split Single Lossless Audio(.ape, .flac) Files Into Mp3 in MacOSX

I got a lossless audio from my friend which included Taiwan famous folk songs in 1970~1979.

So, I want to split this audio into seperate mp3. Spending few hours, I found this library!

I have to thank @ftrvxmtrx - the author of https://github.com/ftrvxmtrx/split2flac.

In this post, I just show to how to setup the environment to use ftrvxmtrx’s libarary in MacOSX.

1. Make sure you have homebrew

2. Install required/optional libs

1
2
3
4
5
6
7
8
9
brew install cuetools
brew install shntool
brew install id3lib
brew install flac
brew install homebrew/dupes/libiconv
brew install enca
# for install mac to split APE
brew tap fernandotcl/homebrew-fernandotcl
brew install monkeys-audio

3. Clone project

1
git clone https://github.com/ftrvxmtrx/split2flac.git

4. Convert files

1
cd split2flac

Check commands

1
./split2flac -h

Convert the file

1
./split2flac -f mp3 -o ~/Desktop/ -cue path/to/your/cue-file.cue path/to/your/ape-file.ape

-f: using mp3 as output format

-o: where to put the output files

cue: file location to your .cue

yay!

demo: split ape file into mp3

Comments

How to Install Preloader.io Service in Ubuntu 14.04

If you’re finding a solution for SEO especially for AngularJS, BackboneJS, EmberJS and other javascript frameworks. Preloader will be one of your options.

Preloader is a node server that uses phantomjs to create static HTML out of a javascript page.

you are able to use their solutions instead of installing in your own machine.

But, what if you just like me, want to try their service first and want to customize your own Preloader?

here are flows that show how I install Preloader in Ubuntu 14.04.

Read on →
Comments

How to Setup a Simple Standalone Faye Websocket Server Using SSL and Ruby

Demo faye websocket server using Ruby

References:

faye-websockets-part-1

faye-websockets-part-2

How to Use Faye as a Real-Time Push Server in Rails

====================================================

In your remote Ubuntu server

====================================================

Step1. Install Ruby environment in Ubuntu

Reference: https://gorails.com/deploy/ubuntu/14.04

Add user

1
2
3
sudo adduser deploy
sudo adduser deploy sudo
su deploy

Make sure you can login using new user

1
2
3
4
cd ~
mkdir .ssh
cd .ssh
vim authorized_keys

then put the content in ~/.ssh/id_rsa.pub in your local machine into it.

Install Ruby and RVM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

curl -L https://get.rvm.io | bash -s stable

source ~/.rvm/scripts/rvm

rvm install 2.2.3

gem install bundler
Read on →
Comments

Ruby on Rails Development Using Mongoid 5.0.0 - 3. How to Use MapReduce to Get Pageview Data

What is MapReduce?

Map-reduce is a data processing paradigm for condensing large volumes of data into useful aggregated results.

MapReduce is a popular big data term in recent years proposed by Google. It is a method for manipulate large data sets parallelly and distributedly on many machines. In my words, I usually said that Map-Reduce, “Map” is to assign match function to many machines for cutting a huge data into small data sets(group matched data), and then use “Reduce” to aggregate these calculated data.

In this map-reduce operation, MongoDB applies the map phase to each input document (i.e. the documents in the collection that match the query condition). The map function emits key-value pairs. For those keys that have multiple values, MongoDB applies the reduce phase, which collects and condenses the aggregated data. MongoDB then stores the results in a collection. Optionally, the output of the reduce function may pass through a finalize function to further condense or process the results of the aggregation.

MongoDB MapReduce

if you want more details, please check official documents

Let’s go check how to use map reduce in Mongoid.

Read on →
Comments
Google Analytics Alternative