block

What is the value of an anonymous unattached block in C#?

In stumbled on this about a month ago. In C# you can make a block inside of a method that is not attached to any other statement. public void TestMethod() { { string x = "test"; string y = x; { int z = 42; int zz = z; } } } Th...

Best way to handle block ciphers in C++? (Crypto++)

Good day :) I'm pretty new to both C++ and Block Cipher encryption, and I am currently in the process of writing a decryption function for AES (16 byte seed / 16 byte blocks). All is going well, but my total data size is not always a multiple of my block size. I'm wondering what the best way to handle left-over data at the end of my dat...

Unity Application Block, inherited injection

Hi, I am having a problem using the Unity Application Block, I have created a base class called Composition. Each Composition contains a IUnityContainer, when i create the top level object UniversalComposition i want to initialize it with a UnityContainer. Any object that gets created from the UniversalComposition I want to inject...

Floated block-level element: is it necessary to set the width, if yes, how?

I've just come to think about this issue which really hasn't bothered me at all since everything works just fine. Anyway, what does the community think about the following: Say I have textboxes, dropdownlists and submit buttons. They are all inline-elements. Which means that "officially" margin, padding, width and height properties shou...

Ruby block and unparenthesized arguments

I extracted simple example: require 'pp' x = 1..3 pp x.map do |i| {:value => i, :double => (i*2)} end pp x.map { |i| {:value => i, :double => (i*2)} } pp(x.map do |i| {:value => i, :double => (i*2)} end) pp(x.map { |i| {:value => i, :double => (i*2)} }) I am wondering why first pp produces: [1, 2, 3] While all the oders are giving...

Block without spinning in Java?

Certain methods in Java will block until they can do something, like ServerSocket.accept() and InputStream.read(), but how it does this is not easy for me to find. The closest thing I can think of is a while() loop with a Thread.sleep() each time through, but the longer the sleep period, the less responsive the blocking, and the shorter ...

Could proc get executed without using call method?

I am sorry to bring out a separate question from here, but it really confused me these days. Here is the definition of add_mapping method: def add_mapping(regexp, &proc) @test_mappings << [regexp, proc] end How could proc here get executed and return result without using call method? Thanks ...

How to block downloads in .NET WebBrowser control?

I need to prevent the .NET WebBrowser control from showing any "Do you want to open or save this file?" and "Save As" dialogs. Instead, I want to display a message box telling users that file downloads are disabled for security reasons. I started with the FileDownload event of WebBrowser, but it does not allow cancellation. Then, I used...

How to repeat a "block" in a django template

I want to use the same {% block %} twice in the same django template. I want this block to appear more than once in my base template: # base.html <html> <head> <title>{% block title %}My Cool Website{% endblock %}</title> </head> <body> <h1>{% block title %}My Cool Website{% endblock %}</h1> </body> </htm...

How to use SetConsoleHandler() to block exit calls

Ok so i know that i have to use setconsolehandler() if i want to manage console closing events. So i have a little of an understanding, but i don't know how to block the CTRL_CLOSE_EVENT, ive tried returning false/true if it catches that event, but no success Here is what i have so far (thank you Anton Gogolev!) [DllImport("Kernel32...

Drupal 5 views -- can I have a random block and a sorted page?

I keep running into the same problem, and I feel like I'm solving it the clunky way. Do you have a better solution? I have a site that with the content type "Staff Bios". I've created a view page that lists all the bios in alphabetical order. I want to have a block that shows just one bio (like a sidebar teaser), and I want the choic...

Using pipes in C for parent-child IPC makes program block

I am writing a server which fork()'s off a child process when it accepts a socket connection. As the child communicates with a client, it must send some of that information back to the parent. I am using a pipe to accomplish this. The problem is that when I try to do the parent-child IPC, the parent blocks when reading input from the c...

How to write 'if' without using 'then' or 'end' in Ruby

I've found three ways to write the same condition in Ruby: #1 if 1==1 puts "true" end #2 puts "true" if 1==1 #3 if 1==1 then puts "true" end Why can't I do this? #4 if 1==1 puts "true" I don't understand: (1) Why then and end are needed in #3, and, (2) Why I need to change the order to get #2 to work. Statement #4 seems...

Does begin . . . end while denote a 'block'?

temp = 98.3 begin print "Your temperature is " + temp.to_s + " Fahrenheit. " puts "I think you're okay." temp += 0.1 end while temp < 98.6 In the above example, is everything between begin and end a block? I'm still confused what a block is. If you can't call it a block, what would you call that chunk of code between begin and end? I...

Microsoft Logging application block and multi-threading

Hi, I am new to the Logging application block (4.1). Has anyone written an application that uses the Logging application block from multiple threads? I am asking because the Logger is a static class and because of potential writing to the same log file from multiple threads for example. Thanks ...

How to find the position of a FlowDocument Inline or Block element relative to a UIElement?

I am trying to implement features similar to Visual Studio like code region expander/collapser for FlowDocument content. For this, I need to know, for instance, the Y coordinates of where exactly a paragraph begins and ends so that I can draw the adornments. How do I get this information? Here's what I tried: I implemented an invisible ...

How to block bad users and spammers from inserting undesired data in forums?

I want to avoid spammers putting advertisements and curses [into a forum]. What is the best way to do it? Is a 'captcha' a good way to do it with 100% reliability? Is blocking IP addresses a good way? ...

Drupal: How to show specific view in a particular block

Let's suppose I have created a view that shows some kind of stories. But I want to show this view in a left bar - not link to view, but the view itself. How can I connect my new view with a fixed block position? I want to be able to show real view data in various places on my page. Is it possible or I am limited only to central area and...

Sidemenu overlaps when browser window is restored.

Check my website, and see the Divisions left menu. When you have maximized your broswer there is no problem, but when you restore it to half of screen, the left menu overlaps to the right. Here is the CSS code. Can someone help me? ...

Why does the return keyword cause problems in my 'if block'?

The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1, :c=>:C1} kerson = person.merge(berson) do | key, oldv, newv | if key == :a oldv elsif key == :b newv else key end end puts kerson.inspect but if I add the return keyword inside the "if block", I get an error: person = {:a=>:A, :b=>:B,...