| Models | Examples |
|---|---|
| Display ads | Yahoo! |
| Search ads |
| #!/bin/bash | |
| # ~/.osx — http://mths.be/osx | |
| # Ask for the administrator password upfront | |
| sudo -v | |
| # Keep-alive: update existing `sudo` time stamp until `.osx` has finished | |
| while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & |
| "copy file" in { | |
| var i = 0 | |
| val fileGenerator = Enumerator.fromCallback( () => | |
| if(i<1000){ i+=1; Future.successful(Some((new java.util.Date).getTime.toString + "\n")) } else Future(None) | |
| ) | |
| val f = FileChannel("/tmp/testwrite.txt").delete.writing.create | |
| val f2 = FileChannel("/tmp/testwrite2.txt").delete.writing.create | |
| fileGenerator // generates data |
Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.
The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.
Basically, Play2 is an API that abstractly have the folllowing type
| class ActionDispatch::Routing::Mapper | |
| def draw(routes_name) | |
| instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb"))) | |
| end | |
| end | |
| BCX::Application.routes.draw do | |
| draw :api | |
| draw :account | |
| draw :session |
| By default, Rails 3.2 loads everything in app/javascripts and everything in app/stylesheets on | |
| every page, despite controller-specific file naming. If you want to load controller-specific | |
| files only on views from their respective controllers, you need to change the manifests and the | |
| layout. The basic idea is to NOT require the entire trees, but only specific subfolders, in the | |
| manifests, and then load the controller-specific files separately in the layout. | |
| Any file you DO want loaded on every page should be placed in app/assets/javascripts/general or | |
| app/assets/stylesheets/general. | |
| For this to work in production, you also need to ensure that the individual files are precompiled by modifying your production.rb file, listing all of the controller-specific files. |
An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| # Rake task to launch multiple Resque workers in development/production with simple management included | |
| require 'resque/tasks' # Require Resque tasks | |
| namespace :workers do | |
| # = $ rake workers:start | |
| # | |
| # Launch multiple Resque workers with the Rails environment loaded, | |
| # so they have access to your models, etc. |
| # Run this file with `RAILS_ENV=production rackup -p 3000 -s thin` | |
| # Be sure to have rails and thin installed. | |
| require "rubygems" | |
| # We are not loading Active Record, nor the Assets Pipeline, etc. | |
| # This could also be in your Gemfile. | |
| gem "actionpack", "~> 3.2" | |
| gem "railties", "~> 3.2" | |
| require "rails" |