Search Results

Search found 10698 results on 428 pages for 'inline functions'.

Page 1/428 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Display Img and Div inline - it's not rendered inline

    - by user359372
    In order to follow correct web standards, I've tried to layout image and div inline. In orde to achieve that - I've used display:inline property. But then I experienced the following issue: image renders from the center line, and div doesn't respect height parameter set to it. I've tried using line-height parameter, but that didn't give any useful results. I've also tried various combinations with setting margin/padding to some values or to auto, or replacing div with span, or wrapping img and div with additional divs. I've managed to achieve desired result by using position:absolute, but that doesn't help in cases where I want to use centered/relative positioning of the whole component... Any clues or ideas or troubleshooting hints? Please find the html example below: Test Page Some text that should be displayed in the center/middle of the div 123   Some text that should be displayed in the center/middle of the div

    Read the article

  • Functions inside page using Razor View Engine – ASP.NET MVC

    - by hajan
    As we already know, Razor is probably the best view engine for ASP.NET MVC so far. It keeps your code fluid and very expressive. Besides the other functionalities Razor has, it also supports writing local functions. If you want to write a function, you can’t just open new @{ } razor block and write it there… it won’t work. Instead, you should specify @functions { } so that inside the brackets you will write your own C#/VB.NET functions/methods. Lets see an example: 1. I have the following loop that prints data using Razor <ul> @{     int N = 10;     for (int i = 1; i<=N; i++)     {         <li>Number @i</li>     }     } </ul> This code will print the numbers from 1 to 10: Number 1 Number 2 Number 3 Number 4 Number 5 Number 6 Number 7 Number 8 Number 9 Number 10 So, now lets write a function that will check if current number is even, if yes… add Even before Number word. Function in Razor @functions{     public bool isEven(int number)     {         return number % 2 == 0 ? true : false;     } } The modified code which creates unordered list is: <ul> @{     int N = 10;     for (int i = 1; i<=N; i++)     {         if (isEven(@i)) {             <li>Even number @i</li>         }         else {             <li>Number @i</li>         }                 }             } </ul> As you can see, in the modified code we use the isEven(@i) function to check if the current number is even or not… The result is: Number 1 Even number 2 Number 3 Even number 4 Number 5 Even number 6 Number 7 Even number 8 Number 9 Even number 10 So, the main point of this blog was to show how you can define your own functions inside page using Razor View Engine. Of course you can define multiple functions inside the same @functions { } defined razor statement. The complete code: @{     Layout = null; } <!DOCTYPE html> <html> <head>     <title>ASP.NET MVC - Razor View Engine :: Functions</title> </head> <body>     <div>         <ul>         @{             int N = 10;             for (int i = 1; i<=N; i++)             {                 if (isEven(@i)) {                     <li>Even number @i</li>                 }                 else {                     <li>Number @i</li>                 }                         }                     }         </ul>         @functions{             public bool isEven(int number)             {                 return number % 2 == 0 ? true : false;             }         }     </div> </body> </html> Hope you like it. Regards, Hajan

    Read the article

  • Network programming under windows: is WSA functions can be more complete than pSock functions [on hold]

    - by Kane
    I plan to make a set of classic socket functions to simplify their usages. Since i work under windows and linux indifferently i usually make it portable (it's not my first version of this set of functions), but i want to do something different this time and dedicate one version to windows, and one other to linux. With that i wonder for the windows version, if the WSA* functions can have any interest using them instead of the psock ones. I have found nothing about a comparison between them, so if any of you have any idea, suggestion, link or benchmark ?

    Read the article

  • multiple definition of inline function

    - by K71993
    Hi, I have gone through some posts related to this topic but was not able to sort out my doubt completly. This might be a very navie question. Code Description I have a header file "inline.h" and two translation unit "main.cpp" and "tran.cpp". Details of code are as below inline.h file details #ifndef __HEADER__ #include <stdio.h> extern inline int func1(void) { return 5; } static inline int func2(void) { return 6; } inline int func3(void) { return 7; } #endif main.c file details are below #define <stdio.h> #include <inline.h> int main(int argc, char *argv[]) { printf("%d\n",func1()); printf("%d\n",func2()); printf("%d\n",func3()); return 0; } tran.cpp file details (Not that the functions are not inline here) #include <stdio.h> int func1(void) { return 500; } int func2(void) { return 600; } int func3(void) { return 700; } Question The above code does not compile in gcc compiler whereas compiles in g++ (Assuming you make changes related to gcc in code like changing the code to .c not using any C++ header files... etc). The error displayed is "duplicate definition of inline function - func3". Can you clarify why this difference is present across compile? When you run the program (g++ compiled) by creating two seperate compilation unit (main.o and tran.o and create an executable a.out), the output obtained is 500 6 700 Why does the compiler pick up the definition of the function which is not inline. Actually since #include is used to "add" the inline definiton I had expected 5,6,7 as the output. My understanding was during compilation since the inline definition is found, the function call would be "replaced" by inline function definition. Can you please tell me in detailed steps the process of compilation and linking which would lead us to 500,6,700 output. I can only understand the output 6. Thanks in advance for valuable input.

    Read the article

  • helper functions as static functions or procedural functions?

    - by fayer
    i wonder if one should create a helper function in a class as a static function or just have it declared as a procedural function? i tend to think that a static helper function is the right way to go cause then i can see what kind of helper function it is eg. Database::connect(), File::create(). what is best practice?

    Read the article

  • F#: any way to use member functions as unbound functions?

    - by gatoatigrado
    Is there a way to extract member functions, and use them as F# functions? I'd like to be able to write the following: mystring |> string.Split '\n' |> Array.filter (string.Length >> (=) 0 >> not) The code above works if you [let] let mystring = "a c\nb\n" let stringSplit (y:char) (x:string) = x.Split(y) let stringLength (x:string) = x.Length mystring |> stringSplit '\n' |> Array.filter (stringLength >> (=) 0 >> not)

    Read the article

  • Python — Time complexity of built-in functions versus manually-built functions in finite fields

    - by stackuser
    Generally, I'm wondering about the advantages versus disadvantages of using the built-in arithmetic functions versus rolling your own in Python. Specifically, I'm taking in GF(2) finite field polynomials in string format, converting to base 2 values, performing arithmetic, then output back into polynomials as string format. So a small example of this is in multiplication: Rolling my own: def multiply(a,b): bitsa = reversed("{0:b}".format(a)) g = [(b<<i)*int(bit) for i,bit in enumerate(bitsa)] return reduce(lambda x,y: x+y,g) Versus the built-in: def multiply(a,b): # a,b are GF(2) polynomials in binary form .... return a*b #returns product of 2 polynomials in gf2 Currently, operations like multiplicative inverse (with for example 20 bit exponents) take a long time to run in my program as it's using all of Python's built-in mathematical operations like // floor division and % modulus, etc. as opposed to making my own division, remainder, etc. I'm wondering how much of a gain in efficiency and performance I can get by building these manually (as shown above). I realize the gains are dependent on how well the manual versions are built, that's not the question. I'd like to find out 'basically' how much advantage there is over the built-in's. So for instance, if multiplication (as in the example above) is well-suited for base 10 (decimal) arithmetic but has to jump through more hoops to change bases to binary and then even more hoops in operating (so it's lower efficiency), that's what I'm wondering. Like, I'm wondering if it's possible to bring the time down significantly by building them myself in ways that maybe some professionals here have already come across.

    Read the article

  • Inline code from iPhone keyboard [closed]

    - by lc
    When I'm writing a post here or on any of the sister sites (especially SO), I want to use the backquote for inline code blocks. Now, as far as it looks, there doesn't seem to be a backquote (backtick) on the iPhone keyboard. Under the single quote key, I've found two curly/angled quotes, but those (’ and ‘) don't seem to do the trick... So, how do I create an inline code block from iPhone/Safari?

    Read the article

  • What can procs and lambdas do that functions can't in ruby

    - by SecurityGate
    I've been working in Ruby for the last couple weeks, and I've come to the subject of procs, lambdas and blocks. After reading a fair share of examples from a variety of sources, I don't how they're much different from small, specialized functions. It's entirely possible that the examples I've read aren't showing the power behind procs and lambdas. def zero_function(x) x = x.to_s if x.length == 1 return x = "0" + x else return x end end zero_lambda = lambda {|x| x = x.to_s if x.length == 1 return x = "0" + x else return x end } zero_proc = Proc.new {|x| x = x.to_s if x.length == 1 puts x = "0" + x else puts x end } puts zero_function(4) puts zero_lambda.call(3) zero_proc.call(2) This function, proc, and lambda do the exact same thing, just slightly different. Is there any reason to choose one over another?

    Read the article

  • Non-trivial functions that operate on any monad

    - by Strilanc
    I'm looking for examples of interesting methods that take an arbitrary monad and do something useful with it. Monads are extremely general, so methods that operate on monads are widely applicable. On the other hand, methods I know of that can apply to any monad tend to be... really, really trivial. Barely worth extracting into a function. Here's a really boring example: joinTwice. It just flattens an m m m t into an m t: join n = n >>= id joinTwice n = (join . join) n main = print (joinTwice [[[1],[2, 3]], [[4]]]) -- prints [1,2,3,4] The only non-trivial method for monads that I know of is bindFold (see my answer below). Are there more?

    Read the article

  • Functional Methods on Collections

    - by GlenPeterson
    I'm learning Scala and am a little bewildered by all the methods (higher-order functions) available on the collections. Which ones produce more results than the original collection, which ones produce less, and which are most appropriate for a given problem? Though I'm studying Scala, I think this would pertain to most modern functional languages (Clojure, Haskell) and also to Java 8 which introduces these methods on Java collections. Specifically, right now I'm wondering about map with filter vs. fold/reduce. I was delighted that using foldRight() can yield the same result as a map(...).filter(...) with only one traversal of the underlying collection. But a friend pointed out that foldRight() may force sequential processing while map() is friendlier to being processed by multiple processors in parallel. Maybe this is why mapReduce() is so popular? More generally, I'm still sometimes surprised when I chain several of these methods together to get back a List(List()) or to pass a List(List()) and get back just a List(). For instance, when would I use: collection.map(a => a.map(b => ...)) vs. collection.map(a => ...).map(b => ...) The for/yield command does nothing to help this confusion. Am I asking about the difference between a "fold" and "unfold" operation? Am I trying to jam too many questions into one? I think there may be an underlying concept that, if I understood it, might answer all these questions, or at least tie the answers together.

    Read the article

  • Content-disposition:inline header won't show images inline?

    - by hamstar
    I'm trying to show an image inline on a page. It is being served by a codeigniter controller. class Asset extends MY_Controller { function index( $folder, $file ) { $asset = "assets/$folder/$file"; if ( !file_exists( $asset ) ) { show_404(); return; } switch ( $folder ) { case 'css': header('Content-type: text/css'); break; case 'js': header('Content-type: text/javascript'); break; case 'images': $ext = substr( $file, strrpos($file, '.') ); switch ( $ext ) { case 'jpg': $ext = 'jpeg'; break; case 'svg': $ext = 'svg+xml'; break; } header('Content-Disposition: inline'); header('Content-type: image/'.$ext); } readfile( $asset ); } } When I load a image in Chrome of FF its pops up the download window. I know when the browser can't display the content inline it will force a download anyway, but these are PNG and GIF images which display in the browser fine otherwise. In IE it doesn't force a download but it displays the image in ASCII. If I comment out the entire image case it FF and Chrome both display the ASCII but not the image. I thought setting the content type would allow FF and Chrome to show the actual image, and also allow the location to be used as an src. The javascript and css shows fine of course. Anyone got any ideas how I can make the images show properly? Thanks :)

    Read the article

  • Stretching width correctly to 100% of an inline-block element in IE6 and IE7

    - by Simon Lieschke
    I have the following markup, where I am attempting to get the right hand side of the second table to align with the right hand side of the heading above it. This works in IE8, Firefox and Chrome, but in IE6/7 the table is incorrectly stretched to fill the width of the page. I'm using the Trip Switch hasLayout trigger to apply inline-block in IE6/7. Does anyone know how (or even if) I can get the table only to fill the natural width of the wrapper element displayed with inline-block in IE6/7? You can see the code running live at http://jsbin.com/uyuva. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Test</title> <style> .wrapper { display: inline-block; border: 1px solid green; } /* display: inline-block triggers the wrapper element to have layout for IE 6/7. The trip switch then provides the inline component of the display behaviour. See http://www.brunildo.org/test/InlineBlockLayout.html for more details. */ .wrapper { *display: inline; } table { border: 1px solid red; } </style> </head> <body> <h1>No width on table:</h1> <div class="wrapper"> <h2>The right hand side of the table doesn't stretch to the end of this heading</h2> <table><tr><td>foo</td></tr></table> </div> text <h1>Width on table:</h1> <div class="wrapper"> <h2>The right hand side of the table should stretch to the end of this heading</h2> <table style="width: 100%"><tr><td>foo</td></tr></table> </div> text </body> </html>

    Read the article

  • Limit foreign key choices in select in an inline form in admin

    - by mightyhal
    Edited :-) Hopefully a bit clearer now. The logic is of the model is: A Building has many Rooms A Room may be inside another Room (a closet, for instance--ForeignKey on 'self') A Room can only in inside of another Room in the same building (this is the tricky part) Here's the code I have: #spaces/models.py from django.db import models class Building(models.Model): name=models.CharField(max_length=32) def __unicode__(self): return self.name class Room(models.Model): number=models.CharField(max_length=8) building=models.ForeignKey(Building) inside_room=models.ForeignKey('self',blank=True,null=True) def __unicode__(self): return self.number and: #spaces/admin.py from ex.spaces.models import Building, Room from django.contrib import admin class RoomAdmin(admin.ModelAdmin): pass class RoomInline(admin.TabularInline): model = Room extra = 2 class BuildingAdmin(admin.ModelAdmin): inlines=[RoomInline] admin.site.register(Building, BuildingAdmin) admin.site.register(Room) The inline will display only rooms in the current building (which is what I want). The problem, though, is that for the inside_room drop down, it displays all of the rooms in the Rooms table (including those in other buildings). In the inline of rooms, I need to limit the inside_room choices to only rooms which are in the current building being displayed by the main form. I can't figure out a way to do it with either a limit_choices_to in the model, nor can I figure out how exactly to override the admin's inline formset properly (I feel like I should be somehow create a custom inline form, pass the building_id of the main form to the custom inline, then limit the queryset for the field's choices based on that--but I just can't wrap my head around how to do it). Maybe this is too complex for the admin site, but it seems like something that would be generally useful... Thanks again for your help!

    Read the article

  • CSS help positioning divs inline

    - by JaPerk14
    I need help with a recurring problem that happens a lot. I want to create a header that consists of 3 sections which are positioned inline. I display them inline using the following css code: display: inline & float: leftThe problem is that when I resize my browser window the last div is pushed down and isn't displayed inline. I know it sounds like I'm being picky, but I don't want the design to distort as the visitor change's the monitor screen. I have provided the html and css code below that I am working with below. Hopefully I have explained this well enough. Thanks in advance. HTML <div class="masthead-wrapper"> &nbsp; </div> <div class="searchbar-wrapper"> &nbsp; </div> <div class="profile-menu-wrapper"> &nbsp; </div> CSS #Header { display: block; width: 100%; height: 80px; background: #C0C0C0; } .masthead-wrapper { display: inline; float: left; width: 200px; height: 80px; background: #3b5998; } .searchbar-wrapper { display: inline; float: left; width: 560px; height: 80px; background: #FF0000; } .profile-menu-wrapper { display: inline; float: left; width: 200px; height: 80px; background: #00FF00; }

    Read the article

  • Show models.ManyToManyField as inline, with the same form as models.ForeignKey inline

    - by Kristian
    I have a model similar to the following (simplified): models.py class Sample(models.Model): name=models.CharField(max_length=200) class Action(models.Model): samples=models.ManyToManyField(Sample) title=models.CharField(max_length=200) description=models.TextField() Now, if Action.samples would have been a ForeignKey instead of a ManyToManyField, when I display Action as a TabularInline in Sample in the Django Admin, I would get a number of rows, each containing a nice form to edit or add another Action. However; when I display the above as an inline using the following: class ActionInline(admin.TabularInline): model=Action.samples.through I get a select box listing all available actions, and not a nifty form to create a new Action. My question is really: How do I display the ManyToMany relation as an inline with a form to input information as described? In principle it should be possible since, from the Sample's point of view, the situation is identical in both cases; Each Sample has a list of Actions regardless if the relation is a ForeignKey or a ManyToManyRelation. Also; Through the Sample admin page, I never want to choose from existing Actions, only create new or edit old ones.

    Read the article

  • CKEditor doesn't apply inline styles to links

    - by jomanlk
    I'm using ckeditor version 3 as a text editor to create markup to be sent through email. This means that I have to have all the styles inline and anything that needs to be styled will definitely need the style applied. I'm currently using addStylesSet to generate custom styles that can be applied to elements. The problem I have is that although this works on most elements, styles don't seem to be applied to <a> <ol> <ul> and <li> I really need to be able to apply inline styles to these elements as well. I've been looking at the examples on the ckeditor site, but even they just seem to be wrapping a <span> around the link. Is there anyway I can apply inline styles to <a> tags or failing that, can I just give ckeditor a bunch of classes that can be applied to any tag (Like TinyMCE does with it's link to an external css file)? so that I can at least do a textreplace on them to get the styles inline? I haven't pasted any code here because it's exactly the same as what's been done on the ckeditor site.

    Read the article

  • jqGrid inline editing event on "Esc" cancel

    - by gurun8
    Does anyone know if jqGrid inline editing throws events that can be handled? The following code is a simple example of what I'm trying to accomplish: jQuery('#list').jqGrid('editRow', 0, true, false, false, false, {onClose: function(){alert('onClose')}}, reloadGrid); I'd like to be able to handle an "Esc" cancel event. The onClose event is available with Form Editing: www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing but doesn't work with inline editing and the Inline Editing documentation doesn't supply anything event wise other than the extraparam option which is very unspecific: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing I haven't been able to figure out how to utilize the extraparam options. Suggestions?

    Read the article

  • 32bit to 64bit inline assembly porting

    - by Simone Margaritelli
    I have a piece of C++ code (compiled with g++ under a GNU/Linux environment) that load a function pointer (how it does that doesn't matter), pushes some arguments onto the stack with some inline assembly and then calls that function, the code is like : unsigned long stack[] = { 1, 23, 33, 43 }; /* save all the registers and the stack pointer */ unsigned long esp; asm __volatile__ ( "pusha" ); asm __volatile__ ( "mov %%esp, %0" :"=m" (esp)); for( i = 0; i < sizeof(stack); i++ ){ unsigned long val = stack[i]; asm __volatile__ ( "push %0" :: "m"(val) ); } unsigned long ret = function_pointer(); /* restore registers and stack pointer */ asm __volatile__ ( "mov %0, %%esp" :: "m" (esp) ); asm __volatile__ ( "popa" ); I'd like to add some sort of #ifdef _LP64 // 64bit inline assembly #else // 32bit version as above example #endif But i don't know inline assembly for 64bit machines, anyone could help me? Thanks

    Read the article

  • Inline & not-inline

    - by anon
    Suppose I have: struct Vec3 { double x; double y; double z; } ; inline double dot(const Vec3& lhs, const Vec3& rhs) { return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z ; } Is it possible to have "dot" also exist in a non-inlined version, so that it can be in the *.so , so that when I dl open it I can call it? I.e. I want files that include the above header to use the inlined version, but I also want the function to exist in a *.so, so I can dl open it and call it dynamically.

    Read the article

  • [XSL-FO] Characters from other than English languages

    - by Lukasz Kurylo
    My client have departments in Europe Central and East, so there is highly possibility that in the generated pdfs there will be at least in the people names and/or surnames some specific characters for the country language.   With the XSL-FO we can use some out-of-the box fonts, e.g. the default is Times. We can change it for specific block of text or the entire document to other like Helvetica or Arial. All will be good to the moment that we use only an english alphabet. If we want to add e.g. some characters from polish or bulgarian language, in the *.fo file:         <fo:block >                 <fo:inline font-weight="bold">english: </fo:inline>                 <fo:inline font-weight="bold">yellow</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">polish: </fo:inline>                 <fo:inline font-weight="bold">zólty</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">russian: </fo:inline>                 <fo:inline font-weight="bold">??????</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">bulgarian: </fo:inline>                 <fo:inline font-weight="bold">????</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">english: </fo:inline>                 <fo:inline font-weight="bold">yellow</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">polish: </fo:inline>                 <fo:inline font-weight="bold"  font-family="Arial">zólty</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">russian: </fo:inline>                 <fo:inline font-weight="bold" font-family="Arial">??????</fo:inline>       </fo:block>       <fo:block>                 <fo:inline font-weight="bold">bulgarian: </fo:inline>                 <fo:inline font-weight="bold" font-family="Arial">????</fo:inline>       </fo:block>   The result can be diffrent from the expected depending on the selected font, e.g:                 As you can see Timer nor Arial work in this case.   The problem here is not related to XSL-FO, but rather to the renderer we are using. I have lost a lot of time to find a solution for the using by me XSL-FO –> PDF rendered to acquire these characters in my generated files. Fortunatelly all what have to be done it is to embed the font (or part of it) in the file(s) during rendering.   The renderer that I’m using it is an open source FO.NET.   For this one, the code to generate a pdf file looks that:   var fonet =  Fonet.FonetDriver.Make(); fonet.Render("source.fo", "result.pdf");   To emded the font in the pdf, we need to set the appropriate option to the driver:   fonet.Options = new Fonet.Render.Pdf.PdfRendererOptions() {       FontType = Fonet.Render.Pdf.FontType.Embed }; Right now, the pdf we get should look like this:               As you can see, the result for the Arial font looks exactly how it should, because this font has a characters included not only for the english language like the default Times, which we shouls avoid if we not generating a english-only documents.   This is worth to notice that in this situation the generated pdf file is quite large, it has more than 400 kb in size. This is of course because of embedding the entire font in it to make the document portable to systems, where the used font is not present. Instead on embedding the entire font, we can only embed the subset of used characters by changing the options to:   fonet.Options = new Fonet.Render.Pdf.PdfRendererOptions() {       FontType = Fonet.Render.Pdf.FontType.Subset };   Right now, this specific pdf is only 12 kb in size.

    Read the article

  • Why Should I Avoid Inline Scripting?

    - by thesunneversets
    A knowledgeable friend recently looked at a website I helped launch, and commented something like "very cool site, shame about the inline scripting in the source code". I'm definitely in a position to remove the inline scripting where it occurs; I'm vaguely aware that it's "a bad thing". My question is: what are the real problems with inline scripting? Is there a significant performance issue, or is it mostly just a matter of good style? Can I justify immediate action on the inline scripting front to my superiors, when there are other things to work on that might have a more obvious impact on the site? If you pulled up to a website, and took a peek at the source code, what factors would lead you to say "hmm, professional work here", and what would cause you to recoil from an obviously amateurish job? Okay, that question turned into multiple questions in the writing. But basically, inline scripting - what's the deal?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >