Skip to content

Instantly share code, notes, and snippets.

@SeonghoonKim
SeonghoonKim / apache-balancer.sh
Last active March 8, 2022 08:12
Apache HTTPD balancer-manager control script
#! /bin/sh
# Set up a default search path
PATH="/usr/bin:/bin"
CURL=`which curl`
if [ -z "$CURL" ]; then
echo "curl not found"
exit 1
fi
@SeonghoonKim
SeonghoonKim / elasticsearch-bootstrap.sh
Created December 26, 2012 09:31
elasticsearch install script
#!/bin/bash
INSTALL_ROOT="/opt"
echo "Installing ElasticSearch..."
cd $INSTALL_ROOT
curl -L http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.1.tar.gz | tar -xz
ln -s elasticsearch-0.20.1/ elasticsearch
echo "Installing ElasticSearch service wrapper..."
@SeonghoonKim
SeonghoonKim / mongodb-bootstrap.sh
Created December 26, 2012 09:20
mongodb install script for RHEL/CentOS 6
#!/bin/bash
MONGODB_REPO="/etc/yum.repos.d/10gen-mongodb.repo"
if [ -f ${MONGODB_REPO} ]; then
echo "$MONGODB_REPO found"
else
cat << 'EOF' > ${MONGODB_REPO}
[10gen]
name=10gen Repository
@SeonghoonKim
SeonghoonKim / graylog2-bootstrap.sh
Last active October 1, 2021 09:46
graylog2 install script for RHEL/CentOS 6
#!/bin/bash
MONGODB_REPO="/etc/yum.repos.d/10gen-mongodb.repo"
CENTOS_REPO="/etc/yum.repos.d/CentOS-Base.repo"
EPEL_REPO="/etc/yum.repos.d/epel.repo"
PASSENGER_REPO="/etc/yum.repos.d/passenger.repo"
APP_ROOT="/opt"
[ -f "$APP_ROOT" ] || mkdir -p $APP_ROOT
@SeonghoonKim
SeonghoonKim / gist:3951447
Created October 25, 2012 08:36
Tomcat Init Script for Linux
#! /bin/sh
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: tomcat init script
# Description: tomcat init script
### END INIT INFO
@SeonghoonKim
SeonghoonKim / gist:3634343
Created September 5, 2012 09:58
Backbone.js Synchronization URL 설정
// When urlRoot or url does not meet URL requirement, override sync method
var MyModel = Backbone.Model.extend({
sync : function(method, model, options) {
options || (options = {});
if (method === 'read') {
options.url = '/path/to/read/api?id=' + encodeURIComponent(this.id);
} else if (method === 'create') {
options.url = '/path/to/create/api';
} else if (method === 'update') {
options.url = '/path/to/update/api?id=' + encodeURIComponent(this.id);
@SeonghoonKim
SeonghoonKim / gist:3616578
Created September 4, 2012 04:26
Marionette View에서 jquery.validate 사용
var XyzView = Marionette.ItemView.extend({
template : '#xyz-tpl',
ui : {
form : 'form'
},
events : {
'click button.action' : 'onActionRequested',
'submit' : 'onActionRequested'
@SeonghoonKim
SeonghoonKim / gist:3615902
Created September 4, 2012 02:32
Marionette용 LazyItemView
// View 생성 시점에 Model/Collection을 fetch하는 경우, 로딩이 완료된 후에 화면을 표시해야 한다.
// LazyItemView는 Model 로딩이 완료되기 전까지 options에 설정된 emptyView를 표시한다.
// 이를 상속한 View는 Model 로딩이 완료되면 lazyLoadingCompleted를 호출한다.
App.LazyItemView = Marionette.ItemView.extend({
constructor : function() {
_.bindAll(this, 'lazyLoadingCompleted');
Marionette.ItemView.prototype.constructor.apply(this, arguments);
},
render : function () {
@SeonghoonKim
SeonghoonKim / gist:3615834
Created September 4, 2012 02:23
Bootstrap Modal Dialog용 Marionette Region
// http://twitter.github.com/bootstrap/javascript.html#modals
// http://lostechies.com/derickbailey/2012/04/17/managing-a-modal-dialog-with-backbone-and-marionette/
var ModalRegion = Marionette.Region.extend({
el : '#modal',
onShow : function(view) {
// 'hidden' - Bootstrap Modal event fired when the modal has finished being hidden from the user
this.$el.on('hidden', this.close);
view.on('close', this.hideModal, this);
this.showModal(view);
@SeonghoonKim
SeonghoonKim / gist:3615811
Created September 4, 2012 02:20
Bootstrap Form 에러 메시지 처리를 위한 jquery.validate 옵션 설정
// http://twitter.github.com/bootstrap/base-css.html#forms
// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults#defaults
// https://github.com/twitter/bootstrap/issues/202
jQuery.validator.setDefaults({
errorClass: 'help-inline',
errorElement: 'span',
highlight:function(element, errorClass, validClass) {
$(element).parents('.control-group').addClass('error');
},
unhighlight: function(element, errorClass, validClass) {