Total Pageviews

Wednesday, 1 January 2014

ace

Ace (Ajax.org Cloud9 Editor)

Note: The new site at http://ace.c9.io contains all the info below along with an embedding guide and all the other resources you need to get started with Ace.
Ace is a standalone code editor written in JavaScript. Our goal is to create a browser based editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page or JavaScript application. Ace is developed as the primary editor for Cloud9 IDE and the successor of the Mozilla Skywriter (Bespin) Project.

Features

  • Syntax highlighting for over 40 languages (TextMate/Sublime/.tmlanguage files can be imported)
  • Over 20 themes (TextMate/Sublime/.tmtheme files can be imported)
  • Automatic indent and outdent
  • An optional command line
  • Handles huge documents (at last check, 4,000,000 lines is the upper limit)
  • Fully customizable key bindings including vim and Emacs modes
  • Search and replace with regular expressions
  • Highlight matching parentheses
  • Toggle between soft tabs and real tabs
  • Displays hidden characters
  • Drag and drop text using the mouse
  • Line wrapping
  • Code folding
  • Multiple cursors and selections
  • Live syntax checker (currently JavaScript/CoffeeScript/CSS/XQuery)
  • Cut, copy, and paste functionality

Take Ace for a spin!

Check out the Ace live demo or get a Cloud9 IDE account to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the Ace Bookmarklet.

Embedding Ace

Ace can be easily embedded into any existing web page. You can either use one of pre-packaged versions of ace (just copy one of src* subdirectories somewhere into your project), or use requireJS to load contents of lib/ace as ace
The easiest version is simply:
    <div id="editor">some text</div>
    <script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
    <script>
        var editor = ace.edit("editor");
    </script>
With "editor" being the id of the DOM element, which should be converted to an editor. Note that this element must be explicitly sized and positioned absolute or relative for Ace to work. e.g.
    #editor {
        position: absolute;
        width: 500px;
        height: 400px;
    }
To change the theme simply include the Theme's JavaScript file
    <script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
and configure the editor to use the theme:
    editor.setTheme("ace/theme/twilight");
By default the editor only supports plain text mode; many other languages are available as separate modules. After including the mode's JavaScript file:
    <script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
The mode can then be used like this:
    var JavaScriptMode = require("ace/mode/javascript").Mode;
    editor.getSession().setMode(new JavaScriptMode());

Documentation

Additional usage information, including events to listen to and extending syntax highlighters, can be found on the main Ace website.
You can also find API documentation at http://ace.c9.io/#nav=api.
Also check out the sample code for the kitchen sink demo app.
If you still need help, feel free to drop a mail on the ace mailing list, or at irc.freenode.net#ace.

Running Ace

After the checkout Ace works out of the box. No build step is required. To try it out, simply start the bundled mini HTTP server:
    ./static.py
Or using Node.JS
    npm install mime
    node ./static.js
The editor can then be opened at http://localhost:8888/kitchen-sink.html.
To open the editor with a file:/// URL see the wiki.

Building Ace

You do not generally need to build ACE. The ace-builds repository endeavours to maintain the latest build, and you can just copy one of src* subdirectories somewhere into your project.
However, all you need is Node.js and npm installed to package ACE. Just run npm install in the ace folder to install dependencies:
    npm install
    node ./Makefile.dryice.js
To package Ace, we use the dryice build tool developed by the Mozilla Skywriter team. Call node Makefile.dryice.js on the command-line to start the packing. This build script accepts the following options
-m                 minify build files with uglify-js          
-nc                namespace require and define calls with "ace"
-bm                builds the bookmarklet version
--target ./path    specify relative path for output folder (default value is "./build")
To generate all the files in the ace-builds repository, run node Makefile.dryice.js full --target ../ace-builds

Running the Unit Tests

The Ace unit tests can run on node.js. Assuming you have already done npm install, just call:
    node lib/ace/test/all.js
You can also run the tests in your browser by serving:
http://localhost:8888/lib/ace/test/tests.html
This makes debugging failing tests way more easier.

from https://github.com/ajaxorg/ace
----------------------------------------------------------

Cloud9 IDE - The modern IDE built on Node, JavaScript and HTML5. This is the OSS component of the broader service option at c9.io

Cloud9 IDE

Cloud9 is an open source IDE built with Node.JS on the back-end and JavaScript/HTML5 on the client. It is very actively maintained by about 20 developers in both Amsterdam and San Francisco and is one component of the hosted service at c9.io. The version available here runs on your local system.
Cloud9 balances the power of traditional desktop IDEs with the simplicity and elegance of editors like TextMate and Sublime.
Cloud9 is built entirely on a web stack, making it the most hacker-friendly IDE today. Fork it, hack it, and if you think others would benefit, issue a pull request on this repo and we'll take a look. If you have any questions, meet us in #cloud9ide on irc.freenode.net or ask us on Twitter @Cloud9IDE.
Happy Coding!

Features

  • High performance ACE text editor with bundled syntax highlighting support for JS, HTML, CSS and mixed modes.
  • Integrated debugger for Node.JS applications with views of the call stack, variables, live code execution and live inspector
  • Advanced Javascript language analysis marking unused variables, globals, syntax errors and allowing for variable rename
  • Local filesystem is exposed through WebDAV to the IDE, which makes it possible to connect to remote workspaces as well
  • Highly extensible through both client-side and server-side plugins
  • Sophisticated process management on the server with evented messaging

Browser Support

We support the newer versions of Chrome, Firefox and Safari.

Installation and Usage

If installing on Windows, please refer to Installation on Windows.
Requirements:
  • NodeJS >= 0.6.16
  • NPM >= 1.1.16
  • libxml2-dev
Install:
git clone https://github.com/ajaxorg/cloud9.git
cd cloud9
npm install
The above install steps create a cloud9 directory with a bin/cloud9.sh script that can be used to start Cloud9:
bin/cloud9.sh
Optionally, you may specify the directory you'd like to edit:
bin/cloud9.sh -w ~/git/myproject
Cloud9 will be started as a web server on port -p 3131, you can access it by pointing your browser to: http://localhost:3131
By default Cloud9 will only listen to localhost. To listen to a different IP or hostname, use the -l HOSTNAME flag. If you want to listen to all IP's:
bin/cloud9.sh -l 0.0.0.0
If you are listening to all IPs it is adviced to add authentication to the IDE. You can either do this by adding a reverse proxy in front of Cloud9, or use the built in basic authentication through the --username and --password flags.
bin/cloud9.sh --username leuser --password c9isawesome
Cloud9 is compatible with all connect authentication layers, to implement your own, please see the plugins-server/cloud9.connect.basic-auth plugin on how we added basic authentication.

Installation on Windows (experimental)

If you're running Cloud9 on Windows you'll have to follow these steps as well:
  • Install Grep for Windows
  • Add C:\Program Files (x86)\GnuWin32\bin to your PATH
  • Open a new instance of cmd with elevated rights (right click 'Run as adminstrator')
  • Now follow the steps under 'Install'
  • Please note that the npm install fails due to a libxml error, but you can ignore that for now.
To start Cloud9, please don't start through bin/cloud9.sh but rather via:
node server.js [args]
Please note that there will be errors displayed regarding the find command, and that some features might not work. Feel free to improve the Windows experience and open a pull request.

Updating

To update to the latest version (if this doesn't work, just make a fresh clone):
git pull
npm update
npm update does not currently install missing dependencies. To do so use:
npm install

Open Source Projects Used

The Cloud9 IDE couldn't be this cool if it weren't for the wildly productive Node.JS community producing so many high quality software. Main projects that we use as building blocks:
Thanks to all developers and contributors of these projects.

from https://github.com/ajaxorg/cloud9

dotenv

Dotenv loads environment variables from .env into ENV.
Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped.

Installation

Rails

Add this line to the top of your application's Gemfile:
gem 'dotenv-rails', :groups => [:development, :test]
And then execute:
$ bundle
It should be listed in the Gemfile before any other gems that use environment variables, otherwise those gems will get initialized with the wrong values.

Sinatra or Plain ol' Ruby

Install the gem:
$ gem install dotenv
As early as possible in your application bootstrap process, load .env:
require 'dotenv'
Dotenv.load
To ensure .env is loaded in rake, load the tasks:
require 'dotenv/tasks'

task :mytask => :dotenv do
    # things that require .env
end

Usage

Add your application configuration to your .env file in the root of your project:
S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE
You can also create files per environment, such as .env.test.
S3_BUCKET=tests3bucket
SECRET_KEY=testsecretkey
An alternate yaml-like syntax is supported:
S3_BUCKET: yamlstyleforyours3bucket
SECRET_KEY: thisisalsoanokaysecret
Whenever your application loads, these variables will be available in ENV:
config.fog_directory  = ENV['S3_BUCKET']

Capistrano integration

If you use 2.x.x version:
In your config/deploy.rb file:
require "dotenv/capistrano"
It will symlink the .env located in /path/to/shared in the new release.
Remember to add :production group to the dotenv-rails gem in your application's Gemfile:
gem 'dotenv-rails', :groups => [:development, :test, :production]

If you use 3.x.x version:
In your config/deploy.rb file:
add .env to the list of linked files, similar to:
set :linked_files, %w{config/database.yml .env}

Should I commit my .env file?

It is recommended that you store development-only settings in your .env file, and commit it to your repository. Make sure that all your credentials for your development environment are different from your other deployments. This makes it easy for other developers to get started on your project, without compromising your credentials for other environments.

from https://github.com/bkeepers/dotenv

Foreman

Manage Procfile-based applications
If you have... Install with...
Ruby (MRI, JRuby, Windows)
$ gem install foreman
Mac OS X foreman.pkg

Getting Started

Documentation

Ports

from https://github.com/ddollar/foreman
http://ddollar.github.io/foreman/
------------------------------------------

Manage Procfile-based applications

Foreman

Build Status Code Climate Inline docs
Manage Procfile-based applications

Installation

$ gem install foreman
Ruby users should take care not to install foreman in their project's Gemfile. See this wiki article for more details.

Getting Started

Supported Ruby versions

See .travis.yml for a list of Ruby versions against which Foreman is tested.

Documentation

Ports

from https://github.com/ddollar/foreman

rails

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
Understanding the MVC pattern is key to understanding Rails. MVC divides your application into three layers, each with a specific responsibility.
The Model layer represents your domain model (such as Account, Product, Person, Post, etc.) and encapsulates the business logic that is specific to your application. In Rails, database-backed model classes are derived from ActiveRecord::Base. Active Record allows you to present the data from database rows as objects and embellish these data objects with business logic methods. Although most Rails models are backed by a database, models can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as provided by the Active Model module. You can read more about Active Record in its README.
The Controller layer is responsible for handling incoming HTTP requests and providing a suitable response. Usually this means returning HTML, but Rails controllers can also generate XML, JSON, PDFs, mobile-specific views, and more. Controllers load and manipulate models, and render view templates in order to generate the appropriate HTTP response. In Rails, incoming requests are routed by Action Dispatch to an appropriate controller, and controller classes are derived from ActionController::Base. Action Dispatch and Action Controller are bundled together in Action Pack. You can read more about Action Pack in its README.
The View layer is composed of "templates" that are responsible for providing appropriate representations of your application's resources. Templates can come in a variety of formats, but most view templates are HTML with embedded Ruby code (ERB files). Views are typically rendered to generate a controller response, or to generate the body of an email. In Rails, View generation is handled by Action View. You can read more about Action View in its README.
Active Record, Action Pack, and Action View can each be used independently outside Rails. In addition to them, Rails also comes with Action Mailer (README), a library to generate and send emails; and Active Support (README), a collection of utility classes and standard library extensions that are useful for Rails, and may also be used independently outside Rails.

Getting Started

  1. Install Rails at the command prompt if you haven't yet:
    gem install rails
    
  2. At the command prompt, create a new Rails application:
    rails new myapp
    
    where "myapp" is the application name.
  3. Change directory to myapp and start the web server:
    cd myapp
    rails server
    
    Run with --help or -h for options.
  4. Using a browser, go to http://localhost:3000 and you'll see: "Welcome aboard: You're riding Ruby on Rails!"
  5. Follow the guidelines to start developing your application. You may find the following resources handy:

    from https://github.com/rails/rails, https://github.com/sj26/rails

用Bundler更方便的安装某个gem

Bundler: a gem to bundle gems

Bundler keeps ruby applications running the same code on every machine.
It does this by managing the gems that the application depends on. Given a list of gems, it can automatically download and install those gems, as well as any other gems needed by the gems that are listed. Before installing gems, it checks the versions of every gem to make sure that they are compatible, and can all be loaded at the same time. After the gems have been installed, Bundler can help you update some or all of them when new versions become available. Finally, it records the exact versions that have been installed, so that others can install the exact same gems.

Installation and usage

gem install bundler
bundle init
echo "gem 'rails'" >> Gemfile  ( 编辑你的某个ruby程序包中的Gemfile文件)
bundle install    (通过这2步,就可装好rails这个gem)
bundle exec rails new myapp
See bundler.io for the full documentation.

from https://github.com/bundler/bundler

git入门教程

http://training.github.com/web/free-classes/
http://training.github.com/resources/videos/
http://try.github.io/levels/1/challenges/1

在linux vps上搭建只基于unix命令的静态博客程序-utterson

git clone git://github.com/stef/utterson.git
cd utterson
mkdir blog posts
cp cfg/utterson.cfg.example cfg/utterson.cfg
cp cfg/make.cfg.example cfg/make.cfg
echo "<p>Hello World</p>" > posts/first_post.html
apt-get install ksh
make -f Makefile.in liveposts Makefile
make
cd blog

as3:~/utterson/blog# ls
atom.xml  index.html  main.css  posts  sitemap.xml.gz  tags
as3:~/utterson/blog#
可见~/utterson/blog/就是静态网站的根目录。

发贴方法:
nano /root/utterson/posts/test1.html
格式为:
<p>这是测试1.</p>

然后,
编辑配置文件:
nano ~/utterson/cfg/make.cfg
(把里面的LIVESITE=www.example.com:/home/joe/public_html/blog改为
LIVESITE=urdomain.com:/root/utterson/blog)

编辑utterson.cfg
nano ~/utterson/cfg/utterson.cfg
(把里面的TVARS[BASEURL]="http://www.example.com/~user1/blog"改为
TVARS[BASEURL]="http://uts.brite.biz/")

as3:~/utterson/blog# cd ..
as3:~/utterson# make -f Makefile.in liveposts Makefile && make (这个就是更新静态网站的命令)

演示站点:http://uts.brite.biz/
项目地址:https://github.com/stef/utterson