zeropaste /

Filename Size Date modified Message
app
bin
config
db
doc
public
test
vendor
184 B
Hopefully better hgignore.
19 B
Add basic hooves config.
250 B
Update rubocop config.
982 B
Update gems.
3.3 KB
Update gems.
752 B
Fix name.
2.1 KB
Remove jruby and rubinius version.
274 B
Initial.
109 B
Add todo list.
212 B
Allows subdirectory install.

Code Climate Build Status

Zeropaste

A pastebin with some features: create and destroy (with key) pastes. The one running on 0paste.com.

Requirements:

  • Ruby 1.9 or up (JRuby and Rubinius should also work)
  • PostgreSQL (nothing PostgreSQL specific - can be easily changed if you know what you're doing. May or may not work with MySQL)
  • Ruby Bundler

Optional:

  • Newrelic account
  • memcached

Suggested:

  • nginx

Installation

Left as an exercise.

nginx configuration

Here's nginx configuration snippet which use memcached to completely bypass Rails.

server {
  server_name 0paste.com;
  listen 80; listen [::]:80;
  root /var/www/0paste.com/public;
  error_page 445 = @zp;
  error_page 404 /404.html;

  if ($request_method = POST) {
    return 445;
  }

  location / {
    expires max;
    try_files $uri @zp;
  }

  location ~ /(\d+(?:-\x+)?)(?:(\.txt)|\.html)?$ {
    expires max;
    charset utf-8;
    set $memcached_key "zeropaste:pastes:$1$2";
    memcached_pass localhost:11211;

    default_type text/html;
    error_page 404 502 = @zp;
  }

  location @zp {
    proxy_pass http://localhost:9200;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_intercept_errors on;
  }
}

Misc

Pasting from CLI:

...some commands... | curl 'http://0paste.com/pastes.txt' -F 'paste[paste]=<-'

Or with gzip to save bandwidth:

...some commands... | gzip | curl 'http://0paste.com/pastes.txt' -F 'paste[paste_gzip]=<-'

Privately:

...some commands... | gzip | curl 'http://0paste.com/pastes.txt' -F 'paste[is_private]=1' -F 'paste[paste_gzip]=<-'

Design

Current design is a bit crap. Suggestions and actual designs are welcome.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.