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
| export interface IWaitAnimatingMatter { | |
| matter: IMatter | |
| expected_animated_time: Date | null | |
| } | |
| export interface IDeQueueWaitingMattersResult { | |
| newQueue: IWaitAnimatingMatter[] | |
| matterToAnimated?: IMatter | |
| } |
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
| // Fetching logic | |
| var matters = Api.getUserMatters(userId); | |
| foreach (var matter of matters) { | |
| GameEngine.getInstance().Matters.add(matter) | |
| sleep(300) | |
| } | |
| class GameEngine { // Singleton | |
| public IEnumerable<Matter> Matters; | |
| public void ExecuteGameLoop () { |
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
| # Assuming get(id) is database hit, so we don't want to hit database for everything up-front | |
| def some_func(id1, id2, id3) do | |
| if EntityA.get(id1) == nil do | |
| {:error, :not_found} | |
| else | |
| if EntityB.get(id2) == nil do | |
| {:error, :not_found} | |
| else | |
| if EntityC.get(id3) == nil do |
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
| // Assuming <WeekRow />, <DateRow /> and <DateText /> contain styling that we want | |
| const getDateSet = (start: moment.Moment) => { | |
| const result = [] | |
| const numberOfDatesNeeded = 35 // 5 rows, 7 days for each row. Simply ignore 28-days February with 1st Feb on Monday. | |
| for (let i = 0; i < numberOfDatesNeeded; i++) { | |
| result.push(moment(start).add(i, 'day')) | |
| } | |
| return result | |
| } |
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
| # ปรับนิดหน่อย | |
| defp do_reset(conn, %{"email" => email, "reset_password_url" => reset_password_url} = attrs) do | |
| with {:ok, reset_password_url} <- validate_url(reset_password_url, "reset_password_url"), | |
| {:ok, forward_url} <- validate_url(attrs["forward_url"], "forward_url"), | |
| {:ok, request} <- ResetPasswordGate.request(email) | |
| |> send_request_email(request, reset_password_url, forward_url) | |
| |> Pipe.ok do | |
| render(conn, :empty, %{success: true}) | |
| else | |
| # Prevents attackers from gaining knowledge about a user's email. |
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
| ; This is a constructor for class with two method "increment" and "decrement" | |
| (defn object-contructor "This is a factory" [] | |
| (let [mystate (atom {:x 1})] | |
| (fn [dispatch] | |
| (case dispatch | |
| "increment" (swap! mystate update :x inc) | |
| "decrement" (swap! mystate update :x dec) | |
| mystate)))) | |
| ; This is an object |
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 Engine | |
| { | |
| private int power = 0; | |
| public int boost () | |
| { | |
| this.power += 3; | |
| } | |
| } | |
| class Car: Engine |
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
| // Inheritance | |
| namespace Test | |
| { | |
| class AutoMobile | |
| { | |
| } | |
| class Car: AutoMobile | |
| { |
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 ApiConnector extends React.Component { | |
| componentDidMount = async () => { | |
| this.setState({ | |
| loadingState: 'loading', | |
| }) | |
| try { | |
| const data = await this.props.loadData() | |
| this.setState({ | |
| loadingState: 'loaded', | |
| data, |