Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
| module MonkeyIrb | |
| def self.included(base) | |
| # Monkey-patching Array | |
| class << Array | |
| def toy(n=10, &block) | |
| block_given? ? Array.new(n, &block): Array.new(n) { |i| i + 1 } | |
| end | |
| end | |
| # Change ACL on the app/logs and app/cache directories | |
| after 'deploy', 'deploy:update_acl' | |
| # This is a custom task to set the ACL on the app/logs and app/cache directories | |
| namespace :deploy do | |
| task :update_acl, :roles => :app do | |
| shared_dirs = [ | |
| app_path + "/logs", |
| (extend-type js/RegExp | |
| cljs.core.IFn | |
| (-invoke ([this s] (re-matches this s)))) | |
| (#"foo.*" "foobar") ;=> "foobar" | |
| (#"zoo.*" "foobar") ;=> nil | |
| (filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz") |
| brew install rbenv | |
| brew install ruby-build | |
| brew install --HEAD https://raw.github.com/jasoncodes/homebrew/rbenv-vars/Library/Formula/rbenv-vars.rb # https://github.com/mxcl/homebrew/pull/7891 | |
| brew install readline | |
| echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile | |
| exec $SHELL -i # reload the shell | |
| CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p125 | |
| rbenv global 1.9.3-p125 | |
| gem install bundler -v '~> 1.0.pre' | |
| gem install git-up hitch gem-browse gem-ctags cheat awesome_print pry |
| wget "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz" | |
| tar xf readline-6.2.tar.gz | |
| cd readline-6.2 | |
| ./configure --prefix=$HOME/.rbenv/versions/1.9.3-p125 | |
| make -j 2 | |
| make install | |
| cd .. | |
| wget "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz" | |
| tar xf yaml-0.1.4.tar.gz |
| <?php | |
| namespace Linkofy\CommonBundle\Menu; | |
| use Knp\Menu\FactoryInterface; | |
| use Symfony\Component\DependencyInjection\ContainerAware; | |
| class Builder extends ContainerAware | |
| { | |
| public function mainMenu(FactoryInterface $factory, array $options) |
| # coding: utf-8 | |
| require 'sinatra' | |
| set server: 'thin', connections: [] | |
| get '/' do | |
| halt erb(:login) unless params[:user] | |
| erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
| end | |
| get '/stream', provides: 'text/event-stream' do |
Hey JavaScript talents, here at namshi.com, we are looking for you! Submit this coding challenge to [email protected] and we'll get back to you as soon as possible!
Your task is to implement a basic shopping cart for a website, following these basic rules:
cart| <?hh | |
| async function helloAfter($name, $timeout) { | |
| // sleep asynchronously -- let other async functions do their job | |
| await SleepWaitHandle::create($timeout * 1000000); | |
| echo sprintf("hello %s\n", $name); | |
| } | |
| async function run() { | |
| $joe = helloAfter('Joe', 3); |