#foo {width: 300px; height: 400px; overflow: hidden;}
<div id="foo"></div>
this.someimage = randomImageUrl;
$("foo").innerHTML = "<img src='"+this.someimage+"' class='fooimage' />";
Now, the picture could be 200x200 or 1100x400 ... it's totally random. I can just stretch it (or reduce its size) by using:
.fooimage {width:…
Hi, I'm not yet a skilled programmer but I thought this was an interesting problem and I thought I'd give it a go.
Triangle, pentagonal, and hexagonal
numbers are generated by the following
formulae:
Triangle T_(n)=n(n+1)/2
1, 3, 6, 10, 15, ...
Pentagonal P_(n)=n(3n-1)/2 1, 5, 12, 22, 35,
...
Hexagonal …
I've started to use Javascript a lot more, and as a result I am writing things complex enough that organization is becoming a concern. However, this question applies to any language that allows you to nest functions. Essentially, when should you use an anonymous function over a named global or inner function?
At first I thought it was the…
Hello,
I have two classes which both extends Example.
public class ClassA extends Example {
public ClassA() {
super("a", "class");
}
....
}
public class ClassB extends Example {
public ClassB() {
super("b", "class");
}
....
}
public class Example () {
public String get(String x, String…
I am in a position where I could become a team leader of a team distributed over two countries. This team would be the tech. team for a start up company that we plan to bootstrap on limited funds. So I am trying to find out ways to minimize upfront expenses. Right now we are planning to use Java and will have a lot of junit tests. I am…
Suppose you have an associative array
$hash['Fruit'] = 'Apple';
$hash['Name'] = 'Jeff';
$hash['Car'] = 'Ford';
and you cannot change the order in which these variables are created. So Car is always added to the array after Name, etc. What's the prettiest way to add/move Car to the beginning of the associative array instead of the end…
Because of some non standard table creation options I am forced to use the sql dump instead of the standard schema.rb (i.e. I have uncommented this line in the environment.rb config.active_record.schema_format = :sql). I have noticed that when I use the sql dump that my fixtures do not seem to be loaded into the database. Some data is…
Here's my current function (blindly copy-pasted from a website)
(defun tweakemacs-delete-one-line ()
"Delete current line."
(interactive)
(beginning-of-line)
(kill-line)
(kill-line))
(global-set-key (kbd "C-d") 'tweakemacs-delete-one-line)
There are two quirks here that I want to get rid of. 1) This actually rebinds DEL to…
The following two pieces of code compile, but I get a connect() failed error on the client side. (compiled with MinGW).
Client Code:
// thanks to cs.baylor.edu/~donahoo/practical/CSockets/code/TCPEchoClientWS.c
#include <stdio.h>
#include <winsock.h>
#include <stdlib.h>
#define RCVBUFSIZE 32 // size of receive…
I saw this construction in order to get the browser viewport width:
function () { return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; }
I understand the browser quirks involved. What I don't understand is why || returns the value. So I tried this alert(undefined || 0 || 3); and sure…
I'm trying to unpack all the system gems to end up with a standalone Rails directory including all the rails gems and all the system gems.
I'm starting with a bare rails setup; just did a jruby -S rails and a 'generate jdbc'. I then add a config.gem 'jdbc-mysql' to environment.rb and do the jruby -S rake…
I currently have an application which uses a regular ListView with groups to show a bunch of modules.
I would like to use a Category view. Category view is the new view introduced in Windows Vista for the Control Panel:
Is there a third party control or a way (via API) to create a ListView which mimics…
Hi All. I recently coded and launched a website that displays consistently across Chrome, Firefox, Opera, IE8, IE7, and Safari. According to site visitors, though, the signup forms at the top and bottom of the site are mangled on the iPhone.
I do not own an iPhone and I rarely test sites on the iPhone,…
I'm piecing together a cheapo app that amongst other things "frames" some of our websites... Pretty simple with the WebViewClient... until I hit the video.
The video is done as HTML5 elements, and these work fine and dandy on Chrome, iPhones, and now that we fixed the encoding issues it works great…
I am creating a real estate search from RETS data, but this is a general question. When you have a variety of columns that you would like the user to be able to filter their search result by, how do you optimize this?
For example, http://www.charlestonrealestateguide.com/listings.php has 16 or so…
Why does the call to fn(Iterator("foo") compile, but the call to fn(fooIterator) fail with an error "type mismatch; found : Iterator[java.lang.String] required: scala.Iterator[com.banshee.Qx.HasLength]"
object Qx {
type HasLength = {def length: Int}
def fn(xs: Iterator[HasLength]) = 3
…
I need to set a variable inside of a bash for loop, which for some reason, is not working for me. Here is an excerpt of my script:
function unlockBoxAll
{
appdir=$(grep -i "CutTheRope.app" /tmp/App_list.tmp)
for lvl in {0..24}
key="UNLOCKED_$box_$lvl"
plutil -key "$key" -value "1"…
When you look at your stream on the Facebook website, events such as "FriendX was tagged in an album", "FriendY is attending EventZ", and "FriendK and FriendL are now friends". I've tried various "vague" queries on the stream table, and so far I have been unable to get these types…
Hi, I am working on creating a daemon in Ruby using the daemons gem. I want to add output from the daemon into a log file. So I am wondering what is the easiest way to redirect puts from the console to a log file?
We're going to start a new huge project and while it's in the process of architecting the system, I have certain doubts whether I can apply patterns and be sure they won't be violated by team members. The problem is, not all team members have enough skills to develop asp.net apps…
I currently have an application which uses a regular ListView with groups to show a bunch of modules.
I would like to use a Category view. Category view is the new view introduced in Windows Vista for the Control Panel:
Is there a third party control or a way (via API) to…
I'm trying to debug a plugin-bloated Wordpress installation; so I've added a very simple homebrew logger that records all the callbacks, which are basically listed in a single, ultimately 250+ row multidimensional array in Wordpress (I can't use print_r() because I need to…