rails cache

http://guides.rubyonrails.org/caching_with_rails.html

http://blog.blazingcloud.net/2010/11/21/caching-in-rails/

  • difference between caches_page and caches_action: the former just caches the page content to a file, the latter called some before filters in the action before do the cache ( the action itself won’t be called, just its before filters).
  • expire_page, expire_action
  • config.action_controller.perform_caching = true ( be careful if you are in development env; it will do the cache and your action change will NOT have effect immediately. I would set it to be false in development env.)
Advertisements

RTP

The Research Triangle Park (RTP) is the largest research park in the world.[1][2][3] It is located near DurhamRaleigh, and Chapel Hill, in the Research Triangleregion of North Carolina. A small part of the park stretches into Wake County, but the majority of the land is in Durham County.[4]

 

Node.js

V8 (JS engine): http://en.wikipedia.org/wiki/V8_%28JavaScript_engine%29

The V8 JavaScript Engine is an open source JavaScript engine developed by Google for the Google Chrome web browser.[4] It has since seen use in many other projects. As of 2012, the head programmer is Lars Bak.[5] The first version of the V8 engine was released at the same time as the first version of Chrome, September 2, 2008.

V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS CPUs)[3][6] before executing it, instead of more traditional techniques such as executing bytecode or interpreting it. The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code’s execution profile. Optimization techniques used include inlining, elision of expensive runtime properties, and inline caching, among many others.

IDE: http://en.wikipedia.org/wiki/Integrated_development_environment

An integrated development environment (IDE) or interactive development environment is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger. Several modern IDEs integrate with Intelli-sense coding features.

Some IDEs contain a compiler, interpreter, or both, such as Microsoft Visual Studio and Eclipse; others do not, such as SharpDevelop and Lazarus. The boundary between an integrated development environment and other parts of the broader software development environment is not well-defined. Sometimes a version control system and various tools are integrated to simplify the construction of a GUI. Many modern IDEs also have a class browser, an object inspector, and a class hierarchy diagram, for use with object-oriented software development.[1]

sublime editor : http://www.sublimetext.com/

Sublime Text is a cross-platform text and source code editor, with a Python API. The chrome was inspired by Vim.[2] Its functionality is also extendable with sublime-packages; Sublime Text is not open source software nor free software, but some of the extending packages have free-software licenses and are community-built and maintained.

Malware, short for malicious (or malevolent) software, is software used or programmed by attackers to disrupt computer operation, gather sensitive information, or gain access to private computer systems. It can appear in the form of code, scripts, active content, and other software.[1] ‘Malware’ is a general term used to refer to a variety of forms of hostile or intrusive software

use apache bench for load test

http://www.petefreitag.com/item/689.cfm

If you have access to a Mac or Linux server, chances are you may already have a really simple http load generating tool installed called Apache Bench, or ab. If you are on windows and have Apache installed, you may also have ab.exe in your apache/bin folder.

Suppose we want to see how fast Yahoo can handle 100 requests, with a maximum of 10 requests running concurrently:

ab -n 100 -c 10 http://www.yahoo.com/

It will then generate output as follows:

Concurrency Level: 10
Time taken for tests: 1.889 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 1003100 bytes
HTML transferred: 949000 bytes
Requests per second: 52.94 [#/sec] (mean)
Time per request: 188.883 [ms] (mean)
Time per request: 18.888 [ms] (mean, across all concurrent requests)
Transfer rate: 518.62 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 57 59 1.7 59 64
Processing: 117 126 7.5 124 162
Waiting: 57 62 7.0 60 98
Total: 175 186 8.0 184 224

Percentage of the requests served within a certain time (ms)
50% 184
66% 186
75% 187
80% 188
90% 192
95% 203
98% 216
99% 224
100% 224 (longest request)

As you can see this is very useful information, it returned requests at a rate of 52.94 requests per second, the fastest request was 175ms, the slowest 224ms

So the next time you are tempted to whip out cfloop and GetTickCount to do some benchmarking on a piece of code, give ab a try, it’s easy to use, and will yield much more realistic results.

Because ab supports concurrency, this has two big advantages over cfloop. The main one is that it allows you to test how your code runs concurrently, this can help you identify any possible race conditions, or locking issues. Concurrent requests are also a more natural simulation of load than loops.

Suppose you wanted to test multiple url’s concurrently as well? You can do this by creating a shell script, with multiple ab calls. At the end of each line place an & this makes the command run in the background, and lets the next command start execution. You will also want to redirect the output to a file for each url using > filename For example:

#!/bin/sh

ab -n 100 -c 10 http://127.0.0.1:8300/test.cfm > test1.txt &
ab -n 100 -c 10 http://127.0.0.1:8300/scribble.cfm > test2.txt &

marshal — serilization in ruby

define your own way to marshal

for example

calling Marshal.dump(Myobj.new(“name”, “v”, “data”)) will call the marshal_dump method in the Myobj class

class MyObj
  def initialize name, version, data
    @name    = name
    @version = version
    @data    = data
  end

  def marshal_dump
    [@name, @version]
  end

  def marshal_load array
    @name, @version = array
  end
end

git

  • why git?

http://documentup.com/skwp/git-workflows-book

  • git features
  1. most operation is local, no need to connect to server
  2. create a new branch and switch between branches is cheap
  3. easy to share
  • deal with untracked files

https://help.github.com/articles/ignoring-files

  • whitelist = a list of things to include; blacklist = a list of things to exclude
  • Don’t use git merge, use rebase if you want to sync...
  • git commands
  1. git commit is to commit your change to your LOCAL repository
  2. git commit -a will commit all files you changed (new files won’t be added)
  3. git remote show origin check which local brach push to or pull from remote branch
  4. git branch -vv check local branch version
  5. git reset –hard HEAD delete last commit from local repository, making local repository pointing to last commit
  6. git branch -d branch_name delete the branch you are done with
  7. git reset HEAD file unstage a file (undo git add file)
  8. git rebase –interactive HEAD~n squash the first n commits into one, you need to change “pick” to “s” ; see a very clear explanation here http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
  9. git remote show origin show the origin from which the local reposity is cloned
  10. git rebase another_branch replay the changes on another_branch to current branch
    With the rebase command, you can take all the changes that were committed on one branch and replay them on another one. see http://git-scm.com/book/en/Git-Branching-Rebasing (Note that your current branch will still have the change made already, it is not a copy of another_branch)
  11. git pull –rebase make local repository to be synced from remote repository ( do this when you have msg like “Your branch is ahead of ‘master’ by 1 commit “)
    Rebase the current branch on top of the upstream branch after fetching