Skip to content

Instantly share code, notes, and snippets.

View 5pecia1's full-sized avatar
😀
Rustaceans

sol 5pecia1

😀
Rustaceans
View GitHub Profile
@5pecia1
5pecia1 / expandVars.js
Last active August 13, 2021 04:58 — forked from tohagan/expandVars.js
JavaScript - Expand variables in string
// Polyfill to expand variables in a string
// Example: expandEnv("Welcome back ${name}. Glad to see you");
// Example: expandEnv("Welcome back $name. Glad to see you");
// eslint-disable-next-line no-extend-native
function expandEnv(s: string): string {
return s.replace(/\$([\w]+|{([^{}]*)})/g, (str, varName) => {
const vName = varName.startsWith("{") ? varName.substring(1, varName.length - 1) : varName;
var value = process.env[vName];
@5pecia1
5pecia1 / dodo_fighter_agent.py
Created August 18, 2018 12:22 — forked from segfault87/dodo_fighter_agent.py
도도 파이터(https://pycon-2018-dodo-fighter.spoqa.com) 에이전트 예제 코드
import json
import sys
# 도도 파이터에 참가하기 위해서는 에이전트를 만들어서 제출해 주셔야 합니다.
# 에이전트는 사용자가 작성하는 인공지능 코드로서, 주어지는 현재 게임 상태를 바탕으로
# 어떤 액션을 취할지를 결정하는 역할을 합니다.
#
# 액션 설명
# - idle - 아무것도 하지 않습니다.
# - forward - 앞으로 움직입니다. 상대가 바로 앞에 있을 경우 더 움직이지 않습니다.