Skip to content

Instantly share code, notes, and snippets.

Title

The Web is better in Ruby

Abstract

Look at where web tech has evolved towards.

HTML: HTML is a bad programming language, thus: erb, haml, JSX. Rails introduced partials coz there’s no extract method for HTML.

CSS: SASS, LESS were invented to make CSS a real programming language: inheritance, reuse, variables, etc.

@fkchang
fkchang / jce_error.txt
Created August 15, 2017 00:01
JCE related error
remote: LoadError: load error: /tmp/build_72161da82e855fa324feb33bbb0b3c04/config/environment -- java.lang.IllegalAccessException: Can not set static final boolean field javax.crypto.JceSecurity.isRestricted to java.lang.Boolean
remote: /tmp/build_72161da82e855fa324feb33bbb0b3c04/vendor/bundle/jruby/2.2.0/gems/activesupport-4.1.14.1/lib/active_support/dependencies.rb:247:in `block in require'
remote: /tmp/build_72161da82e855fa324feb33bbb0b3c04/vendor/bundle/jruby/2.2.0/gems/activesupport-4.1.14.1/lib/active_support/dependencies.rb:232:in `load_dependency'
remote: /tmp/build_72161da82e855fa324feb33bbb0b3c04/vendor/bundle/jruby/2.2.0/gems/activesupport-4.1.14.1/lib/active_support/dependencies.rb:247:in `require'
remote: /tmp/build_72161da82e855fa324feb33bbb0b3c04/vendor/bundle/jruby/2.2.0/gems/railties-4.1.14.1/lib/rails/application.rb:276:in `require_environment!'
remote: /tmp/build_72161da82e855fa324feb33bbb0b3c04/vendor/bundle/jruby/2.2.0/gems/railties-4.1.14.1/lib/r
@fkchang
fkchang / jvm_install_fail.txt
Created August 14, 2017 23:27
Error while deploying jruby app
remote: -----> Installing JVM: openjdk-1.8
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://lang-jvm.s3.amazonaws.com/jdk/cedar-14/openjdk1.8.tar.gz -s -o - | tar zxf - ' failed on attempt 1 of 3.
remote: Command: 'set -o pipefail; curl -L --fail --retry 5 --retry-delay 1 --connect-timeout 3 --max-time 30 https://lang-jvm.s3.amazonaws.com/jdk/cedar-14/openjdk1.8.tar.gz -s -o - | tar zxf - ' failed on attempt 2 of 3.
remote: !
remote: ! Failed to download JVM: openjdk1.8.tar.gz
remote: !
remote: ! If this was a custom version or URL, please check to ensure it is correct.
remote: ! Otherwise, please open a ticket at http://help.heroku.com so we can help.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
require 'nodejs'
require 'native'
module HTTP
HTTP_JS = Native(node_require('http'))
class Server
def self.listen(port, &block)
HTTP_JS.createServer(lambda { |req_js, res_js|
req_opal = Native(req_js)
res_opal = Native(res_js)
HTTP::Server.listen(port) { |req, res|
[200, {'Content-Type': 'text/plain'}, "Hello World\n"]
}
require 'nodejs'
require 'native'
module HTTP
HTTP_JS = Native(node_require('http'))
class Server
def self.listen(port, &block)
HTTP_JS.createServer(lambda { |req_js, res_js|
block.call(Native(req_js), Native(res_js))
}).listen(port)
port = 1337
HTTP::Server.listen(port) { |req, res|
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end "Hello World\n"
}
require 'nodejs'
require 'native'
http = Native(node_require('http'))
port = 1337
http.createServer(lambda { |req, res|
opal_res = Native(res)
opal_res.writeHead(200, { 'Content-Type': 'text/plain' }.to_n)
opal_res.end("Hello World\n")
require 'nodejs'
http = node_require('http')
port = 1337
http.JS.createServer(lambda { |req, res|
res.JS.writeHead(200, { 'Content-Type': 'text/plain' }.to_n)
res.JS.end("Hello World\n")
}).JS.listen(port)
require 'nodejs'
http = node_require('http')
port = 1337
`
http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port);