Code Monkey home page Code Monkey logo

playpen's Introduction

prog-contest-tool

A bash script to help practice competitive programming. When practicing problems I find myself spending way too much time creating a new project folder, adding all the necessary files, writing a makefile, etc.

installing

  • either unzip the code file into a directory you want to have this functionality in, or use git clone.
  • run chmod +x problem.py

usage

To run this code, simple use ./problem.py problemname language
This will create a new folder called problemname, with files in it that are needed to develop a small, single file project in that language.

Additionally, it opens up the most relevant file in the default text editor.

default support

By default, atom is the default text editor, and language support is proved for:

java

Creates a Main.java file and inserts:

public class Main{
    public static void main(String[] args){

    }
}

And adds a makefile with

Main.class: Main.java
  javac Main.java

python

Creates a main.py file and inserts

print("hello, world!")

c++

Creates a main.cpp file and inserts

#include <iostream>

int main(){
  return 0;
}

And adds a makefile with

bin: main.cpp
  gcc -std=c++11 -Wall -Wextra -pedantic -O2 -o bin main.cpp

c

Creates a main.c file and inserts

#include <stdio.h>

int main(){

}

And adds a makefile with

bin: main.c
  cc -std=c99 -o bin main.c

bash

Creates a main.sh file and inserts

#!/usr/bin/env bash

customization

Although a decent amount of functionality is provided out of the box, It is very easy to add new languages.

All customization should be done in config.json. It uses the following syntax:

{
  "default-app": "<default text editor>",
  "languages": {
    "<lang name 1>": "files 1",
    "<lang name 2>": "files 2",
    "..."
    "<lang name n>": "files n"
  }
}

Where each group of files follows the syntax:

[
  "<file 1>",
  "<file 2>",
  "...",
  "<file n>"
]

And each file:

{
  "filename": "<name of file to be created>",
  "contents": "<contents of file to be created>"
}

For example, to add haskell support you might add the following to your config.json:

{
  "default-app": "...",
  "languages": {
    "...,"
    "haskell": [
      {
        "filename": "main.hs",
        "contents": "main = putStrLn \"hello, world\""
      }
    ],
    "..."
  }
}

playpen's People

Contributors

n-arms avatar

Watchers

 avatar

playpen's Issues

Use json format for problem config

Description

Currently the problem config file is written in whatever weird syntax I could easily parse using regexes. JSON would be much more robust and make it easier to add more features to this.

Implementation

  • python3 JSON library

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.