This file contains hidden or 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
| // ถ้าเกิดว่าเรามีงานที่ต้องต่อ Connection กับฐานข้อมูลหรือระบบภายนอก และมีคำสั่ง Connect/Disconnect | |
| // ทั้งสองคำสั่งเป็น Async | |
| function createConnectionForSocket(socketId) { | |
| let connection = null | |
| async function connectToSomeSystem () { | |
| connection = await someSystem.connect('url') | |
| return | |
| } | |
| async function disconnectFromSomeSystem () { |
This file contains hidden or 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
| (defn tennis [winner {:keys [score advantage] :as game-state}] | |
| "kata from http://codingdojo.org/kata/Tennis/ | |
| take winner and game state, return updated game state" | |
| ;;The scoring system is rather simple: | |
| (let [is-deuce (= (vals score) [40 40])] | |
| (cond | |
| ;;, the winner of a ball will have advantage and game ball. | |
| (and is-deuce (nil? advantage)) | |
| (assoc game-state :advantage winner) | |
| ;; b. If the player with advantage wins the ball he wins the game |
This file contains hidden or 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 GreeterControler { | |
| Hello(): ActionResult { | |
| return authorizedEndpoint(() => { | |
| return Content("Hello there"); | |
| }); | |
| } | |
| } | |
| function authorizedEndpoint(src: () => ActionResult):() => ActionResult { | |
| // Authorization logic here |
This file contains hidden or 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 GreeterControler | |
| { | |
| [Authorized] | |
| public ActionResult Hello() | |
| { | |
| return Content("Hello there"); | |
| } | |
| } |
This file contains hidden or 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
| function doSomething() { | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Real business logic #1 | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Real business logic #2 |
This file contains hidden or 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
| public class MyClass | |
| { | |
| public void MyFunction() | |
| { | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Real business logic #1 | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) | |
| // Some kind of ceremony (Factory, Initiate classes, Design patterns stuff, etc.) |
This file contains hidden or 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
| // ตอนแรกเรามีแบบนี้ | |
| public interface ITaskService | |
| { | |
| List<Task> getTasksByProject(string projectId); | |
| } | |
| class TaskStats { | |
| public TaskStats(ITaskService taskService) | |
| { |
This file contains hidden or 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
| (defmethod restructure-param :current-user | |
| [_ binding acc] | |
| (update-in acc [:letks] into [binding `(:identity ~'+compojure-api-request+)])) |
This file contains hidden or 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
| (ns acemotion.core.alerts.schemas | |
| (:require [schema.core :as s] | |
| [acemotion.core.utils.utils :as utils])) | |
| (def alert-type | |
| {:warning 0 | |
| :danger 1}) | |
| (def alert | |
| {:id s/Uuid |
This file contains hidden or 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
| (ns acemotion.test.core.groups.services_test | |
| (:require [acemotion.config :refer [env]] | |
| [acemotion.db.core :refer [*db*] :as db] | |
| [acemotion.test.helpers :as test-helpers] | |
| [acemotion.core.groups.services :as groups-services] | |
| [clojure.test :refer :all] | |
| [luminus-migrations.core :as migrations] | |
| [mount.core :as mount])) | |
| (def chris (test-helpers/generate-test-user "chris@user.com")) |