Skip to content

Instantly share code, notes, and snippets.

View hongsw's full-sized avatar
🎯
Focusing

Seungwoo hong hongsw

🎯
Focusing
View GitHub Profile
package models;
import java.util.*;
import javax.persistence.*;
import play.db.ebean.*;
import play.data.validation.*;
@Entity
public class Guestbook extends Model {
@Id
public Long id;
@Constraints.Required
package controllers;
import org.apache.commons.codec.digest.DigestUtils;
생략
public class Application extends Controller {
final static Form<Guestbook> guestbookForm = form(Guestbook.class);
public static Result index() {
return ok(index.render(Guestbook.find.all();));
}
public static Result write() {
return ok(write.render(guestbookForm));
@(title: String)(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/bootstrap.css")">
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
</head>
<body>
<div class="container">
@(list: List[Guestbook])
@main("GuestBook") {
<ul class="media-list">
@for(post <- list) {
<li class="post-@post.id">
<div class="media-body">
<span class="media-heading">@post.name</span>
<span class="info" >@post.postAt.format("yyyy년 MMM d일")</span>
<span class="info" ><a href="mailto:@post.email">Contact</a></span>
<div>@post.content</div>
package models;
생략
public class GuestbookTest {
@Before
public void setUp() {
start(fakeApplication(inMemoryDatabase()));
}
@Test
public void createAndRetrieveGuestbook() {
new Guestbook("Bob","bob@ajinsys.com", "password", "Hello~ Play Framework 2.0." ).save();
package models;
생략
public class GuestbookTest {
@Before
public void setUp() {
start(fakeApplication(inMemoryDatabase()));
}
@Test
public void createAndRetrieveGuestbook() {
new Guestbook("Bob","bob@ajinsys.com",
@hongsw
hongsw / gist:11224491
Last active August 29, 2015 14:00
wp add user and backup
#!/bin/sh
_pwd="$(pwd)"
_home_path="$(pwd)"
_project_name=$1
_DATABASE_NAME=`cat wp-config.php | grep DB_NAME | cut -d \' -f 4`
_DATABASE_USER=`cat wp-config.php | grep DB_USER | cut -d \' -f 4`
_DATABASE_PASSWORD=`cat wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`
## output string
@hongsw
hongsw / init.sh
Created March 5, 2017 14:27
aws php-fpm nginx mysql certbot - broken -
# Install linux update
wget http://mirrors.mediatemple.net/remi/enterprise/remi-release-6.rpm
sudo yum install remi-release-6.rpm
sudo yum -y update
sudo yum install -y nginxphp70-fpm
sudo yum install -y php70-xml php70-pdo php70-mysqlnd php70-gd php70-pecl-apcu php70-mbstring php70-mcrypt php70-mysqlnd php70-opcache
Install MySQL
@hongsw
hongsw / Guardian JWT.md
Last active January 30, 2018 17:18 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Let's generate User model and controller.

@hongsw
hongsw / Vue-cli-3-Phoenix-1.3-HOWTO.md
Created June 4, 2019 09:53 — forked from jpbecotte/Vue-cli-3-Phoenix-1.3-HOWTO.md
Vue-cli 3, Phoenix 1.3, a complete how-to

Introduction

I have been struggling to start a new project with Phoenix 1.3 and the new vue-cli 3 for Vue.js. There are tons of example already but none of them suited my needs, because:

  • I want to use the new Vue-cli to select the features that I want,
  • I do NOT want to setup Webpack (I know, what a shame!). The new Vue-cli includes the new vue-cli-service, which uses an instance of webpack-dev-server, so you don't have to import it manually in your project.
  • I do not want to use Brunch.

Create your Phoenix App

Assuming that you have Elixir and Phoenix 1.3 are both installed, let's build our new App.