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
| use hbs; // NOTE: this is the crate I need | |
| pub fn compile(input: &str) -> <Result<(&str), Box<dyn Error>> { // NOTE: maybe also options argument | |
| return hbs::compile(input)?; // NOTE: the interface I need from the crate | |
| } | |
| // "<Post @title={{this.firstTitle}}></Post><Post @title={{this.secondTitle}}></Post>" => "{ }"(The JS wire-format exp) |
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
| import axios from "axios"; | |
| import express from "express"; | |
| import bodyParser from "body-parser"; | |
| import Workflow from "./models/workflow.js"; | |
| const { ARGO_SERVER_URL, ARGO_SERVER_TOKEN, GITEA_SERVER_URL, GITEA_SERVER_TOKEN } = process.env; | |
| const TARGET_PORT = process.env.PORT || 1234; | |
| const CI_RUNNING_IMAGE = | |
| process.env.TESTS_RUNNING_IMAGE || "https://media.giphy.com/media/8WeatsYCC54TC/giphy.gif"; | |
| const CI_SUCCEED_IMAGE = |
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
| # add your custom hosts to /etc/hosts: 127.0.0.1 serverone.com | |
| version: '3.8' | |
| services: | |
| server-one: | |
| image: server-one | |
| tty: true | |
| build: | |
| context: . | |
| dockerfile: ./Dockerfile | |
| entrypoint: ["node", "/code/index.js"] |
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
| # Ecto composable changesets/validations: | |
| defmodule Email do | |
| def changeset(struct, params \\ %{}) do | |
| struct | |
| |> cast(params, [:address]) | |
| |> validate_required([:address]) | |
| |> validate_format(:address, ~r/@/) | |
| |> validate_length(:address, max: 75) | |
| |> unique_constraint(:address) |
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
| import { from, where, join, leftJoin, innerJoin } from 'memserver/query'; | |
| import { cast, validat cast, validateRequired, validateFormat, validateLength, uniqueConstraint, foreignKeyConstraint } from 'memserver/changeset'; | |
| let userFirstNames = User | |
| |> where('u', 'u.id < 200') // 'm' because there could be multiple model references on |> sql joins() | |
| |> select('u', 'u.first_name') | |
| |> Repo.all | |
| // or maybe some API like this as well: https://apidock.com/rails/ActiveRecord/QueryMethods/where | |
| // or direct memserver like API User.findBy({}); |
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
| import Service from '@ember/service'; | |
| import ENV from 'frontend/config/environment'; | |
| import { getOwner } from '@ember/application'; | |
| export default class DevToolService extends Service { | |
| owner = getOwner(this); | |
| constructor() { | |
| super(...arguments); |
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
| import { assert } from 'chai'; | |
| import { Readable, PassThrough } from 'stream'; | |
| import * as readline from 'readline'; | |
| import { spawn } from 'child_process'; | |
| // Adaptor for Node 10 to adapt readline streams for async iteration. | |
| // (via https://medium.com/@wietsevenema/node-js-using-for-await-to-read-lines-from-a-file-ead1f4dd8c6f) | |
| function readLines(input: Readable): Readable { | |
| let output = new PassThrough({ objectMode: true }); | |
| let lines = readline.createInterface({ input }); |
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
| let stdin = process.stdin; | |
| stdin.setRawMode(true); | |
| stdin.resume(); | |
| stdin.setEncoding('utf8'); | |
| let targetInputs = {}; | |
| let inputs = []; | |
| stdin.on('data', function(key){ |
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
| type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & | |
| { | |
| [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>; | |
| }[Keys]; | |
| export interface ModelRefShape { | |
| id?: number; | |
| uuid?: string; | |
| [propName: string]: any; | |
| } |
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
| import setup from "./setup-benchmark.js"; | |
| let Benchmark = setup(); | |
| Benchmark.add('RegExp#test', () => { | |
| /o/.test('Hello World!'); | |
| }); | |
| Benchmark.add('String#indexOf', () => { | |
| 'Hello World!'.indexOf('o') > -1; | |
| }); |