Skip to content

Instantly share code, notes, and snippets.

View MinCha's full-sized avatar

Min Cha MinCha

View GitHub Profile
@MinCha
MinCha / gist:59e001fbffb5e916e52c
Created February 10, 2015 12:54
My Function Class #2
@Component class InTransaction {
@Transactional def execute[T](f: => T): T = f
}
object InTransaction {
def apply[T](f: => T): T = Global.ctx.getBean(classOf[InTransaction]).execute(f)
}
def findListByUserMatching(): EssentialAction = UserAction { user =>
request =>
@MinCha
MinCha / gist:badc208ef01fd216b278
Created February 10, 2015 12:53
My Functional Class #1
case class AddressString(address: Address, newAddress: NewAddress) {
private def getNTh(n: Int, f: List[String] => Boolean): String = {
def getOnlyLastThree(string: String): List[String] = {
if (string.split(" ").length > 3)
string.split(" ").toList.tail
else
string.split(" ").toList
}
val a = if (f(getOnlyLastThree(address.region))) getOnlyLastThree(address.region)(n) else ""
@MinCha
MinCha / gist:c40f214b78d67bd6cbca
Created November 18, 2014 02:45
Jenkins startup.sh
#!/bin/bash
java -jar jenkins.war --httpPort=8080
@Test
public void testGetPrescription() throws Exception {
NewPrescription prescription = new NewPrescription();
assertEquals("two pill a day", prescription.getPrescription(new SeriousPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new MildPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new SeriousPatientStatus(), new ChildPatientType()));
assertEquals("half pill a day", prescription.getPrescription(new MildPatientStatus(), new ChildPatientType()));
}
public interface PatientStatus {
// 2. Double Dispatch 방식 리팩토링
NewPrescription prescription = new NewPrescription();
assertEquals("two pill a day", prescription.getPrescription(new SeriousPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new MildPatientStatus(), new AdultPatientType()));
assertEquals("one pill a day", prescription.getPrescription(new SeriousPatientStatus(), new ChildPatientType()));
assertEquals("half pill a day", prescription.getPrescription(new MildPatientStatus(), new ChildPatientType()));
public class NewPrescription {
public String getPrescription(PatientStatus status, PatientType type) {
#!/bin/sh
if [ ! -f ./success ]; then
curl -g http://send --data-urlencode group=$1 --data-urlencode "msg=Failed $2 $3"
fi
@MinCha
MinCha / gist:8995058
Created February 14, 2014 02:58
Tell, Don`t Ask #2
public class ReadOnlyNotifier {
private List<String> getRelatedServices() {
//
}
public void notifyToRelatedServicesIfItNeeds(StopMessage stopMessage) {
if (getRelatedServices().size() > 0) {
if (notifyToRelatedServices(stopMessage) == false) {
throw new FailedReadOnlyNotificationException();
@MinCha
MinCha / gist:8995040
Created February 14, 2014 02:57
Tell, Don`t Ask #1
public class ReadOnlyNotifier {
public List<String> getRelatedServices() {
return null;
}
public boolean notifyToRelatedServices(StopMessage stopMessage) {
return false;
}
@MinCha
MinCha / gist:8347791
Created January 10, 2014 06:27
Deploy Sample Script
#!/bin/bash
cd /wave/build_deploy/service
rm -rf ./wave
git clone git@github.com:MinCha/wave.git
cd ./wave
mvn clean compile war:inplace -Dmaven-test.skip=true -Dphase=service
/wave/tomcat/bin/shutdown.sh
sleep 10
rm -rf /wave/tomcat/webapps/*
cp -rf ./src/main/webapp/* /wave/tomcat/webapps/
@MinCha
MinCha / gist:8296107
Last active September 11, 2021 22:12
Nginx & Tomcat
#!/bin/bash
#######################################
# Init
#######################################
temp=~/temp
yum_repo=/etc/yum.repos.d/nginx.repo
tomcat_bin=http://mirror.apache-kr.org/tomcat/tomcat-7/v7.0.47/bin/apache-tomcat-7.0.47.tar.gz
tomcat_pathname=apache-tomcat-7.0.47
irteam_home=/home1/irteam
tomcat=/apps/tomcat