Giter VIP home page Giter VIP logo

sys's Introduction

Lua system package

Note: some functions only work on UNIX systems.

Dependencies

Torch7 (www.torch.ch)

Install

$ luarocks install sys

Use

$ torch
> require 'sys'

Time / Clock

> t = sys.clock()  -- high precision clock (us precision)
> sys.tic()
> -- do something
> t = sys.toc()    -- high precision tic/toc
> sys.sleep(1.5)   -- sleep 1.5 seconds

Paths

> path,fname = sys.fpath()

Always returns the path of the file in which this call is made. Useful to access local resources (non-lua files).

Execute

By default, Lua's os.execute doesn't pipe its results (stdout). This function uses popen to pipe its results into a Lua string:

> res = sys.execute('ls -l')
> print(res)

Derived from this, a few commands:

> print(sys.uname())
linux

UNIX-only: shortcuts to run bash commands:

> ls()
> ll()
> lla()

sys.COLORS

If you'd like print in colours, follow the following snippets of code. Let start by listing the available colours

$ torch
> for k in pairs(sys.COLORS) do print(k) end

Then, we can generate a shortcut c = sys.COLORS and use it within a print

> c = sys.COLORS
> print(c.magenta .. 'This ' .. c.red .. 'is ' .. c.yellow .. 'a ' .. c.green .. 'rainbow' .. c.cyan .. '!')

sys's People

Contributors

atcold avatar borisfom avatar btnc avatar clementfarabet avatar colesbury avatar koraykv avatar linusu avatar nagadomi avatar samehkhamis avatar soumith avatar

Watchers

 avatar  avatar

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.