block

How to tighten up this Ruby code?

I'm wondering how I can write this better. I was trying to use inject instead of each, but kept running into errors. Mostly I'd like to tighten up the block. Any thoughts? def to_proc levels_of_nesting = @fields.zip(@orderings) procedure = nil levels_of_nesting.each do |field, ordering| procedure = proc_for(field, ...

Need to block any IP on a computer by coding in .Net (C#). Anyone know the best/easiest way to do this?

I am playing around with a way to kick cheaters in Modern Warfare 2 (when you are the host). So far I have been able to use winpcap to sniff packages to identify the player names and their IPs. The next thing I need is a way to block all traffic (or just the target IPs UDP traffic to my machine). Hence the player will timeout/lagout. D...

Why is FF3 rendering an <h3> inside an <a> incorrectly?

Hello, first post (question) here… Take a look at this page in FireFox. Feel free to navigate to any of the top six product categories to see more of the same type of code. If you are [un]lucky enough to see the glitch, you will see at least one product box expand it's height to epic proportions. Here's what the actual code is: <div ...

Anchor in IE not displaying block

Morning all. Im currently working on the following site: http://www.web-design-contractor.co.uk/ username: codingforums password: password The site is to basically offer a my services as a sub contractor and produce a "round-about" quote ( as it is stupidly hard to let a form produce a quote when you dont know exactly what the proje...

Using 'return' in a Ruby block

I'm trying to use Ruby 1.9.1 for an embedded scripting language, so that "end-user" code gets written in a Ruby block. One issue with this is that I'd like the users to be able to use the 'return' keyword in the blocks, so they don't need to worry about implicit return values. With this in mind, this is the kind of thing I'd like to be...

i18n menu block only apprears in a specific language

I'm trying out Drupal i18n and I have a menu that I'd like to have different items in different languages in. Although I create this menu and assign it to be displayed in the left inside a block, it only appears on a specific language (Spanish). When I select language -> English the menu disappears. Am I doing something wrong? ...

Cache: How to exempt just one block

I've got a Drupal 6.x install, and there is one block generated by the Station module which displays the name of the show currently playing. Is there a way to make just that block exempt from caching? Alternatively, can I insert a 'refresh' for only that block at 00:59:00 ? I'm not a php guy, but have found the place in the module wher...

ASP.NET - What is the best way to block the application usage?

Our clients must pay a monthly Fee... if they don't, what is the best way to block the asp.net software usage? Note: The application runs on the client own server, its not a SaaS app... My ideas are: Idea: Host a Web Service on the internet that the application will use to know if the client can use the software. Issue 1 - What happen ...

Android: Stopping method to be called twice if already running.

I'm trying to prevent my application to call the same method twice in the event of a double-click, or if the user presses different buttons quickly, almost at the same time. I have clickable Views, acting as buttons, that call the same method but passing different parameters. This is the call: startTheSearch(context, getState(), what, ...

CSS: Making a non-root block element occupy the whole page

Is it possible with only CSS to make a block element occupy the whole page("busy box") when the element is on a non-root level where width and height set to 100% stretch it only as big as the parent element? I could have done it using absolute size but that would require javascript to adjust to the current size of the page. This m...

"img" elements: Block level element or inline element?

I've read somewhere that IMG elements behave like both. If correct, could someone please explain with examples? ...

Publishing a node to a specific page ?

Hello I have created a new content type "Quote". Now the user should be able to link a specific "Quote" to a specific page where the user wants the quote to be shown. Is this possible? thx ...

Block All Keyboard Input in a Linux Application (Using Qt or Mono)

Hi, I'm working on a online quiz client where we use a dedicated custom-made linux distro which contains only the quiz client software along with text editors and other utility software. When the user has started the quiz, I want to prevent him/her from minimizing the window/closing it/switching to the desktop or other windows. The quizz...

Is this a valid use for blocks in Obj-C?

In my constructor, I want to create a random color. Therefore, I need three random 7-bit floats in the range of 0…1 that make up the red, green and blue component of the color. Instead of writing the rather long random() % 128 / 128.0 three times, I put that in a block: CGFloat (^randFloat)() = ^(){ return random() % 128 / 128.0; }; co...

Calls block once for each element of an array, passing that element as a parameter

Hello, I have some difficulties for using Ruby block, passing in a method. As in the following case, I would like to display each element of @array, from Box instance (using .each method): class Box def initialize @array = [:foo, :bar] end def each(&block) # well, hm.. end end a = Box.new a.each { |element| puts eleme...

In Perl, how can I wait for threads to end in parallel?

I have a Perl script that launches 2 threads,one for each processor. I need it to wait for a thread to end, if one thread ends a new one is spawned. It seems that the join method blocks the rest of the program, therefore the second thread can't end until everything the first thread does is done which sort of defeats its purpose. I tried...

css block links and images

Given this html: <div class="nation"> <a href="library.php?type=nation&amp;id=America"> <div class="nation-image"> <img src="nations/America.png" alt="snip" /> </div> <h3>America</h3> </a> </div> the following CSS results in the entire <div class="nation"> becoming a clickable block link: ....

XHTML validating block level element as a link

I need a way to make an entire DL element clickable with only one anchor tag, that validates as XHTML. As in: <a> <dl> <dt>Data term</dt> <dd>Data definition</dd> </dl> </a> This currently doesn't validate as XHTML as the anchor tag cannot contain the DL. The only way I can get it to validate is if I make two a...

Ruby - Possible to pass a block as a param as an actual block to another function?

This is what I'm trying to do: def call_block(in_class = "String", &block) instance = eval("#{in_class}.new") puts "instance class: #{instance.class}" instance.instance_eval{ block.call } end # --- TEST EXAMPLE --- # This outputs "class: String" every time "sdlkfj".instance_eval { puts "class: #{self.class}" } # This wil...

Loop each x elements

What's the beste way to show a list with 20 images in rows of 5? Or, in other words, how do I clean up this ugly snippet? <div class="row"> <% @images.each_with_index do |image, index| %> <% if index != 0 && index % 5 == 0 %> </div><div class="row"> <% end %> <%= image_tag image.url %> <% end %> </div> ...