This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALL JAVA | |
$ sudo apt-get update && sudo apt-get install default-jre | |
INSTALL ELASTIC SEARCH https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html | |
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
$ echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list | |
$ sudo apt-get update && sudo apt-get install elasticsearch | |
$ sudo update-rc.d elasticsearch defaults 95 10 | |
$ sudo service elasticsearch restart | |
$ sudo service elasticsearch status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
name: '臺北市', | |
dists: [ | |
{ code: 100, zip_code: 100, name: '中正區' }, | |
{ code: 103, zip_code: 103, name: '大同區' }, | |
{ code: 104, zip_code: 104, name: '中山區' }, | |
{ code: 105, zip_code: 105, name: '松山區' }, | |
{ code: 106, zip_code: 106, name: '大安區' }, | |
{ code: 108, zip_code: 108, name: '萬華區' }, | |
{ code: 110, zip_code: 110, name: '信義區' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'RMagick' | |
$scale_size = 256.0 | |
$img_fn1 = ARGV[0] | |
$img_fn2 = ARGV[1] | |
$scale_size = ARGV[2].to_f if ARGV[2] | |
def calculate_threshold(img_fn) | |
dir_name = File.dirname(img_fn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseUploader < CarrierWave::Uploader::Base | |
attr_reader :width, :height | |
before :cache, :capture_size | |
... | |
# for image size validation | |
# fetching dimensions in uploader, validating it in model | |
def capture_size(file) | |
if version_name.blank? # Only do this once, to the original version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import env, run, sudo, local, put | |
def production(): | |
"""Defines production environment""" | |
env.user = "deploy" | |
env.hosts = ['example.com',] | |
env.base_dir = "/var/www" | |
env.app_name = "app" | |
env.domain_name = "app.example.com" | |
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |