For online ordering of concert seat or airline ticket, do we need Record Level Locking or is Transaction good enough?
For concert ticket (say, seat Number 20B), or airline ticket (even with overbooking, the limit is 210, for example), I think the website cannot lock any record or begin transaction when showing the ticket purchase screen.
But…
On Windows, can we put different folders in 1 SVN repository?
Such as putting
c:\ror
c:\software projects\ruby
c:\js test
d:\peter_website
all in 1 SVN repository called code ?
What are some useful SQL statements that should be known by all developers who may touch the Back end side of the project?
(Update: just like in algorithm, we know there are sorting problems, shuffling problems, and we know some solutions to them. This question is aiming at the same thing).
For example, ones I can think of are:
Get a list…
In SQL, there is an operator to "Union" two tables. In an interview, I was told that, say one table has just 1 field with 1, 2, 7, 8 in it, and another table also has just 1 field with 2, and 7 in it, how do I get the intersection. I was stunned at first, because I never saw it that way.
Later on, I found that it is actually a "Join" (inner…
In SQL, if we use Group By without Count(*) or Sum(), etc, then the result is as follows:
mysql> select * from sentGifts;
+--------+------------+--------+------+---------------------+--------+
| sentID | whenSent | fromID | toID | trytryWhen | giftID |
+--------+------------+--------+------+---------------------+--------+
| …
It is said that Ruby is a metaprogramming language. I wonder if the first 3 lines can be made less verbose using metaprogramming?
RUBY_VERSION ||= "unknown version"
RUBY_PATCHLEVEL ||= "unknown patchlevel"
RUBY_PLATFORM ||= "unknown platform"
print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", RUBY_PLATFORM
It seems that it is suggested we can commit often to keep track of intermediate changes of code we wrote… such as on hginit.com, when using Mercurial or Git.
However, let's say if we work on a project, and we commit files often. Now for one reason or another, the manager wants part of the feature to go out, so we need to do a push, but I…
Using Mercurial (hg), can you just "hg backout" all the commits you did for the files you don't want to push, and then do a push?
Because Mercurial (or Git) won't let us push a single file or a single folder to another repository, so I am thinking:
1) How about, we just look at the commit we did, and hg backout the ones we don't want to…
Short version of the question: Since I already have TortoiseHg, I right clicked on that file trying to see the merge conflict visually, but there is no way to see it?
Details:
To make a simple case of merge conflict, I hg init a repo on Win 7, and then clone it to another folder.
Now, in one working directory, i added the line "the…
The git command
git log --format='%H' --follow -- foo.txt
will give you the series of commits that touch foo.txt, following it across renames.
I'm wondering if there's a git log command that will also print the corresponding historical file name beside each commit.
It would be something like this, where we can interpret '%F' to…
The following statements give the same result (one is using "on", and the other using "where"):
mysql> select * from gifts INNER JOIN sentGifts on gifts.giftID = sentGifts.giftID;
mysql> select * from gifts INNER JOIN sentGifts where gifts.giftID = sentGifts.giftID;
I can only see in a case of a Left Outer Join finding the…
some books or even the rails api uses
form_for ...
...
submit_tag ...
end
and i found that the Rails 2.3.2 Scaffold uses
f.submit "Create"
instead... and this is not in the rails api doc. Is this a new
addition and is it suppose to replace submit_tag?
It is said that Ruby is a metaprogramming language. I wonder if the first 3 lines can be made less verbose using metaprogramming?
RUBY_VERSION ||= "unknown version"
RUBY_PATCHLEVEL ||= "unknown patchlevel"
RUBY_PLATFORM ||= "unknown platform"
print "Ruby ", RUBY_VERSION, " patch ", RUBY_PATCHLEVEL, " on ", RUBY_PLATFORM
I have a project I cloned over the network to the Mac hard drive (OS X Snow Leopard).
The project is about 1GB in the hard drive
du -s
2073848 .
so when I hg clone proj proj2
then when I
MacBook-Pro ~/development $ du -s proj
2073848 proj
MacBook-Pro ~/development $ du -s proj2
894840 proj2
MacBook-Pro ~/development $ du…
I thought I read that when a Ruby on Rails server is running in production mode, it won't say so much about an error (the details, showing the code)... but I just try to run the server using
ruby script/server -e production
and add a <%= x %> with the local variable x undefined. It showed a lot of error details including…
On Windows, can we put different folders in 1 Git or Mercurial (hg) repository?
Such as putting
c:\ror
c:\software projects\ruby
c:\js test
all in 1 Git or Mercurial repository called code ?
In Ruby on Rails,
http://localhost:3000/foobars/alt/1
works
but
http://localhost:3000/foobars/alt/1.xml
doesn't work.
config/route.rb is
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
so supposedly it supports an id.format in the URL?
I have a table in MySQL that has a primary key:
mysql> desc gifts;
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| giftID | int(11) | NO | PRI | NULL | |
| name …
It is said that FastCGI doesn't work well with Ruby on Rails deployment. Why is that? In previous experience, something either works quite well or it might be fundamentally wrong. So if FastCGI is a viable solution, why is it not reliable with RoR?
Does FastCGI work well with most any language / frameworks?
In our project files, if there are binary files, such as .doc, .xls, .jpg, and we choose to not keep their past revisions (just keeping a latest version is ok), is there a way to tell SVN, Git, or Mercurial or some other tool to skip the revisions for these files or for a particular folder?
Say, there is a 4MB .doc file that I…
I was asked by somebody in an interview for web front end job, to write a function that generates all permutation of a string, such as "abc" (or consider it ['a', 'b', 'c']).
so the expected result from the function, when given ['a', 'b', 'c'], is
abc
acb
bac
bca
cab
cba
Actually in my past 20 years of career, I have never…
Say, using MySQL, if the movies table has 20,000 records, and each record has a field that is the description of the movie, up to 2k byte long. How can we search for movies with the word "nature" in its description? If possible, it is to be fast, instead of going through all the 20,000 records. (if in some other situations,…
We can create a function p in the following code:
var p = function() { };
if (typeof(console) != 'undefined' && console.log) {
p = function() { console.log(arguments); };
}
but the arguments are passed like an array to console.log, instead of passed one by one as in
console.log(arguments[0], arguments[1],…
I am using TextMate on a Ruby on Rails project and wonder if you can put the mouse on link_to, and then press a key and it will show the definition of link_to, or does this for any other helper functions?
Or, click open a box and type in a function name and it will show you the definition?