Questions tagged [block]

DO NOT USE This tag is scheduled for removal because it can refer to many different things depending on the use of other tags with it.

This tag has an active burnination. Remove it from questions if a) you can improve the question in other ways at the same time or b) you have 2k+ rep.

Depending on the tags it's used with, it can refer to:

  • Blocking access to certain resources.
  • Blocks specific to the program or language its used within.
  • Blocks in a file system.
3655 questions
21
votes
2 answers

How does Ruby on Rails use yield for layouts?

yield is used to call a block. How does this work in Rails where yield is used for layouts? -# application.html.haml %body= yield Does it use blocks somewhere or is the method simply overridden?
user142019
21
votes
1 answer

How do I create an objective-c method that return a block

-(NSMutableArray *)sortArrayByProminent:(NSArray *)arrayObject { NSArray * array = [arrayObject sortedArrayUsingComparator:^(id obj1, id obj2) { Business * objj1=obj1; Business * objj2=obj2; NSUInteger prom1=[objj1…
user4951
  • 32,206
  • 53
  • 172
  • 282
20
votes
6 answers

Confusion about the lock statement in C#

This is from MSDN: The lock keyword ensures that one thread does not enter a critical section of code while another thread is in the critical section. Does a critical section have to be same as the critical section? Or does it mean: The lock…
Cui Pengfei 崔鹏飞
  • 8,017
  • 6
  • 46
  • 87
20
votes
3 answers

Ruby double pipe assignment with block/proc/lambda?

It is really nice to be able to write out @foo ||= "bar_default" or @foo ||= myobject.bar(args) but I have been looking to see if there is a way to write something like @foo ||= do myobject.attr = new_val myobject.other_attr = other_new_val …
Misterparker
  • 596
  • 5
  • 16
19
votes
2 answers

Why do "single statement" blocks require not using semi-colons?

I'm usually a C# programmer and going to Delphi has been full of "interesting" discoveries. The one that baffles me the most is single statements in Delphi. Example C# block if(x) Foo(); else Bar(); Example Delphi block: if x then Foo()…
Earlz
  • 62,085
  • 98
  • 303
  • 499
19
votes
2 answers

Create clusters using correlation matrix in Python

all, I have a correlation matrix of 21 industry sectors. Now I want to split these 21 sectors into 4 or 5 groups, with sectors of similar behaviors grouped together. Can experts shed me some lights on how to do this in Python please? Thanks much…
Jasper C.
  • 379
  • 1
  • 2
  • 9
19
votes
1 answer

In Ruby, what's the advantage of #each_pair over #each when iterating through a hash?

Let's say I want to access the values of a hash like this: munsters = { "Herman" => { "age" => 32, "gender" => "male" }, "Lily" => { "age" => 30, "gender" => "female" }, "Grandpa" => { "age" => 402, "gender" => "male" }, "Eddie" => { "age"…
clockworkpc
  • 628
  • 1
  • 6
  • 16
19
votes
2 answers

Is there a block undo in VIM?

In Vim, is there a way to select a block of text and use undo to only undo changes to that block of text? Let's say I rewrite a function, then go and make some changes elsewhere in my file. Afterwards, I realize that my first function implementation…
justin
  • 1,147
  • 1
  • 8
  • 17
19
votes
3 answers

Use of yield and return in Ruby

Can anyone help me to figure out the the use of yield and return in Ruby. I'm a Ruby beginner, so simple examples are highly appreciated. Thank you in advance!
Hoa Nguyen
  • 13,452
  • 11
  • 45
  • 44
19
votes
4 answers

Can I define multiple static blocks?

Can I define multiple static blocks? If possible, why should I define muliple static blocks?
user1127214
  • 3,109
  • 7
  • 26
  • 30
18
votes
4 answers

Visual block edit in vim

I have refer to this post to use block editing in vim. But when I key I or c after the block select, vim enters the normal edit mode just as if I pressed a i. I also found, when block is selected, I can use the x key to delete chars in the…
LF00
  • 27,015
  • 29
  • 156
  • 295
17
votes
1 answer

Block images, CSS or JS if the user did not visit my site

I suddenly get a lot of requests to my site (wget, curl etc...). I do not want any of these request to be executed unless a user has visited my site at least once using a valid browser (like Firefox or Chrome). Is there an Apache Module to do this?…
Tech4Wilco
  • 6,740
  • 5
  • 46
  • 81
17
votes
4 answers

How to use NSURLConnection completionHandler with swift

Does anybody know how handlers (blocks) work in swift? I am trying to get this code running but i can't find any documentation of the right syntax for the completionHandler. let url:NSURL = NSURL(string:"some url") let request:NSURLRequest =…
loopmasta
  • 1,693
  • 3
  • 14
  • 19
17
votes
2 answers

iOS Blocks introspection

I would like to know two things: 1- Is it possible by using objective-c introspection to know the return type of a block. For example: int (^CountBlock)(NSArray *array) I would like to know the type it will be returning is int. The second question…
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
17
votes
1 answer

Linux splice() + kernel AIO when writing to disk

With kernel AIO and O_DIRECT|O_SYNC, there is no copying into kernel buffers and it is possible to get fine grained notification when data is actually flushed to disk. However, it requires data to be held in user space buffers for…
jop
  • 2,226
  • 15
  • 16