Daily Archives

Articles indexed Sunday June 24 2012

Page 7/14 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Type classe, generic memoization

    - by nicolas
    Something quite odd is happening with y types and I quite dont understand if this is justified or not. I would tend to think not. This code works fine : type DictionarySingleton private () = static let mutable instance = Dictionary<string*obj, obj>() static member Instance = instance let memoize (f:'a -> 'b) = fun (x:'a) -> let key = f.ToString(), (x :> obj) if (DictionarySingleton.Instance).ContainsKey(key) then let r = (DictionarySingleton.Instance).[key] r :?> 'b else let res = f x (DictionarySingleton.Instance).[key] <- (res :> obj) res And this ones complains type DictionarySingleton private () = static let mutable instance = Dictionary<string*obj, _>() static member Instance = instance let memoize (f:'a -> 'b) = fun (x:'a) -> let key = f.ToString(), (x :> obj) if (DictionarySingleton.Instance).ContainsKey(key) then let r = (DictionarySingleton.Instance).[key] r :?> 'b else let res = f x (DictionarySingleton.Instance).[key] <- (res :> obj) res The difference is only the underscore in the dictionary definition. The infered types are the same, but the dynamic cast from r to type 'b exhibits an error. 'this runtime coercition ... runtime type tests are not allowed on some types, etc..' Am I missing something or is it a rough edge ?

    Read the article

  • How to create an attached-property to change a resource's property?

    - by king.net
    I have a DrawingBrush as a resource like this: <DrawingBrush x:Key="Calendar" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Geometry="F1 M 28.0917,2.13333C 42.4005,2.13333 54,13.7329 54,28.0417C 54,42.3504 42.4004,53.95 28.0917,53.95C 13.7829,53.95 2.18334,42.3504 2.18334,28.0417C 2.18334,13.7329 13.7829,2.13333 28.0917,2.13333 Z "> <GeometryDrawing.Pen> <Pen Thickness="4" LineJoin="Round" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Geometry="F1 M 16.9667,16.7083L 39.7167,16.7083L 39.7167,41.625L 16.9667,41.625L 16.9667,16.7083 Z "> <GeometryDrawing.Pen> <Pen Thickness="2.66667" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 15.6333,15.9583L 40.7167,15.9583L 40.7167,25.2917L 15.6333,25.2917L 15.6333,15.9583 Z "/> <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 18.2167,11.9583L 22.9667,11.9583L 22.9667,20.875L 18.2167,20.875L 18.2167,11.9583 Z "> <GeometryDrawing.Pen> <Pen Thickness="1.33333" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FFFFFFFF" Geometry="F1 M 33.7167,11.925L 38.4667,11.925L 38.4667,20.8417L 33.7167,20.8417L 33.7167,11.925 Z "> <GeometryDrawing.Pen> <Pen Thickness="1.33333" StartLineCap="Square" EndLineCap="Square" MiterLimit="2.75" Brush="#FF000000"/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 28.0154,36.2658L 28.0154,37.4894L 21.6254,37.4894C 21.6169,37.1934 21.6615,36.908 21.7592,36.6333C 21.915,36.1815 22.165,35.7425 22.5091,35.3162C 22.8533,34.8899 23.3617,34.4091 24.0344,33.8738C 25.0782,32.983 25.776,32.295 26.1279,31.81C 26.4799,31.3249 26.6558,30.8551 26.6558,30.4005C 26.6558,29.9473 26.4894,29.5653 26.1566,29.2544C 25.8238,28.9435 25.3904,28.7881 24.8565,28.7881C 24.2915,28.7881 23.8393,28.9442 23.5001,29.2565C 23.161,29.5688 22.9892,30.0018 22.985,30.5556L 21.7614,30.4196C 21.8449,29.5345 22.1576,28.86 22.6993,28.3962C 23.241,27.9323 23.9686,27.7004 24.882,27.7004C 25.8054,27.7004 26.5358,27.9596 27.0733,28.4779C 27.6107,28.9963 27.8795,29.6385 27.8795,30.4047C 27.8795,30.7942 27.8065,31.1769 27.6607,31.5529C 27.5148,31.9289 27.2726,32.3251 26.9341,32.7415C 26.5957,33.1579 26.0115,33.7215 25.1816,34.4325C 24.4692,35.0216 24.0008,35.4214 23.7763,35.6317C 23.5518,35.842 23.3667,36.0533 23.2208,36.2658L 28.0154,36.2658 Z "/> <GeometryDrawing Brush="#FF000000" Geometry="F1 M 33.3178,37.4894L 33.3178,35.1781L 28.9671,35.1781L 28.9671,33.9545L 33.5897,27.8364L 34.5414,27.8364L 34.5414,33.9545L 35.765,33.9545L 35.765,35.1781L 34.5414,35.1781L 34.5414,37.4894L 33.3178,37.4894 Z M 33.3178,33.9545L 33.3178,30.1774L 30.4648,33.9545L 33.3178,33.9545 Z "/> </DrawingGroup.Children> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> And I can use it like this: <Rectangle Fill="{DynamicResource Calender}" /> Now, my question is: how can I create an attached-property to change all brushes on my resource? e.g. I be able to create this: <Rectangle Fill="{DynamicResource Calendar}" attached:IconHelper.Foreground="Blue" /> on my Rectangle and in my resource, I can get: <DrawingBrush x:Key="Calendar" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Geometry="blah blah"> <GeometryDrawing.Pen> <Pen Brush={attached:ReadItFromAboveRectangle}/> </GeometryDrawing.Pen> </GeometryDrawing> <GeometryDrawing Geometry="blah blah"> <GeometryDrawing.Pen> <Pen Brush={attached:ReadItFromAboveRectangle}/> </GeometryDrawing.Pen> <!-- etc... --> Is there any way to read an attached-property on Rectangle in Calendar resource? Or is there any other way to do this? Thanks in advance.

    Read the article

  • Deriving PathInfo class in web routes?

    - by drozzy
    I am reading the web-routes tutorial in Happstack, and I have no idea what this is doing: $(derivePathInfo ''Sitemap) class PathInfo a where toPathSegments :: a -> [String] fromPathSegments :: URLParser a The doc simply says: we use template-haskell to derive an instance of PathInfo for the Sitemap type. but where does it "store" it? I thought haskell had no state, and is PathInfo our own thing, or is it part of happstack? If someone could explain this, for dummies? Thanks.

    Read the article

  • Can't get screen pixel from a specific full screen game with any language?

    - by user1007059
    Okay, I know this might seem like I'm posting a duplicate question since I've asked something similar like a day ago HOWEVER, if anyone sees any problem with this, please read my question first before judging: Yesterday I tried getting a specific pixel from a fullscreen game in C#. I thought my C# code was faulty but when I tried with multiple full screen games today they all worked except for that specific game. I literally tried with 10 different full screen games, a couple being mmofps, mmorpg, mmotps, regular rpg games, regular shooters, regular action adventure games, etc. I tried with multiple programming languages, and with every game except that specific game I'm dealing with, it returns the pixel color to me like I wanted. So let me explain what I tried: first I tried returning an IntPtr with C# using GetDC(IntPtr.Zero) before invoking GetPixel(int x, int y) and then getting the color out of it. Then I tried using the Robot class in Java and using the getPixelColor(int x, int y) method. I also tried using GetDC(0) to return an HDC object in C++ and then invoking GetPixel(int x, int y) before again extracting the color. These three methods worked EXACTLY the same in every single game except that specific game I was talking about. They returned the pixel perfectly, and extracted the exact same color perfectly. I don't feel it's necessary to tell you the game name or anything, since you probably don't even know it, but what could possibly be causing this malfunction in 1 specific game? PS: The game ALWAYS returns an RGB color of: A = 255, R = 0, G = 0, B = 0. Also, I tried taking a snapshot of the game with the 3 programming languages, and then getting the pixel which actually works in all 3 languages, but since I need to get this pixel every 30 ms, it kind of makes my game lag a bit (+ I think it takes up a lot of memory)

    Read the article

  • opengl 3d texture issue

    - by user1478217
    Hi i'm trying to use a 3d texture in opengl to implement volume rendering. Each voxel has an rgba colour value and is currently rendered as a screen facing quad.(for testing purposes). I just can't seem to get the sampler to give me a colour value in the shader. The quads always end up black. When I change the shader to generate a colour (based on xyz coords) then it works fine. I'm loading the texture with the following code: glGenTextures(1, &tex3D); glBindTexture(GL_TEXTURE_3D, tex3D); unsigned int colours[8]; colours[0] = Colour::AsBytes<unsigned int>(Colour::Blue); colours[1] = Colour::AsBytes<unsigned int>(Colour::Red); colours[2] = Colour::AsBytes<unsigned int>(Colour::Green); colours[3] = Colour::AsBytes<unsigned int>(Colour::Magenta); colours[4] = Colour::AsBytes<unsigned int>(Colour::Cyan); colours[5] = Colour::AsBytes<unsigned int>(Colour::Yellow); colours[6] = Colour::AsBytes<unsigned int>(Colour::White); colours[7] = Colour::AsBytes<unsigned int>(Colour::Black); glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, colours); The colours array contains the correct data, i.e. the first four bytes have values 0, 0, 255, 255 for blue. Before rendering I bind the texture to the 2nd texture unit like so: glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_3D, tex3D); And render with the following code: shaders["DVR"]->Use(); shaders["DVR"]->Uniforms["volTex"].SetValue(1); shaders["DVR"]->Uniforms["World"].SetValue(Mat4(vl_one)); shaders["DVR"]->Uniforms["viewProj"].SetValue(cam->GetViewTransform() * cam->GetProjectionMatrix()); QuadDrawer::DrawQuads(8); I have used these classes for setting shader params before and they work fine. The quaddrawer draws eight instanced quads. The vertex shader code looks like this: #version 330 layout(location = 0) in vec2 position; layout(location = 1) in vec2 texCoord; uniform sampler3D volTex; ivec3 size = ivec3(2, 2, 2); uniform mat4 World; uniform mat4 viewProj; smooth out vec4 colour; void main() { vec3 texCoord3D; int num = gl_InstanceID; texCoord3D.x = num % size.x; texCoord3D.y = (num / size.x) % size.y; texCoord3D.z = (num / (size.x * size.y)); texCoord3D /= size; texCoord3D *= 2.0; texCoord3D -= 1.0; colour = texture(volTex, texCoord3D); //colour = vec4(texCoord3D, 1.0); gl_Position = viewProj * World * vec4(texCoord3D, 1.0) + (vec4(position.x, position.y, 0.0, 0.0) * 0.05); } uncommenting the line where I set the colour value equal to the texcoord works fine, and makes the quads coloured. The fragment shader is simply: #version 330 smooth in vec4 colour; out vec4 outColour; void main() { outColour = colour; } So my question is, what am I doing wrong, why is the sampler not getting any colour values from the 3d texture? [EDIT] Figured it out but can't self answer (new user): As soon as I posted this I figured it out, I'll put the answer up to help anyone else (it's not specifically a 3d texture issue, and i've also fallen afoul of it before, D'oh!). I didn't generate mipmaps for the texture, and the default magnification/minification filters weren't set to either GL_LINEAR, or GL_NEAREST. Boom! no textures. Same thing happens with 2d textures.

    Read the article

  • How to skip image tag in html data in android?

    - by user1448108
    My data in db is stored in html format along with image tags in it. So when I am getting the data from database I am removing the html tags and setting it to textview. My problem is even after removing the html tags, there is a small square box displaying in the emulator indicating that there is some image. How can I remove those square box in emulator which is an indication of image in that html data? Help me regarding this... Thanks in advance My Code: textView.setText(Html.fromHtml(htmlString));

    Read the article

  • twitter bootstrap typeahead 2.0.4 ajax error

    - by Adam Levitt
    I have the following code which definitely returns a proper data result if I use the 2.0.0 version, but for some reason bootstrap's typeahead plugin is giving me an error. I pasted it below the code sample: <input id="test" type="text" /> $('#test').typeahead({ source: function(typeahead, query) { return $.post('/Profile/searchFor', { query: query }, function(data) { return typeahead.process(data); }); } }); When I run this example I'm getting a jQuery bug that says the following: ** item is undefined matcher(item=undefined)bootst...head.js (line 104) <br/>(?)(item=undefined)bootst...head.js (line 91) <br/>f(a=function(), b=function(), c=false)jquery....min.js (line 2) <br/>lookup(event=undefined)bootst...head.js (line 90) <br/>keyup(e=Object { originalEvent=Event keyup, type="keyup", timeStamp=145718131, more...})bootst...head.js (line 198) <br/>f()jquery....min.js (line 2) <br/>add(c=Object { originalEvent=Event keyup, type="keyup", timeStamp=145718131, <br/>more...})jquery....min.js (line 3) <br/>add(a=keyup charCode=0, keyCode=70)jquery....min.js (line 3) <br/>[Break On This Error] <br/>return item.toLowerCase().indexOf(this.query.toLowerCase())** Any thoughts? ... The same code works in the 2.0.0 version of the plugin, but fails to write to my knockout object model.

    Read the article

  • CUDA Global Memory, Where is it?

    - by gamerx
    I understand that in CUDA's memory hierachy, we have things like shared memory, texture memory, constant memory, registers and of course the global memory which we allocate using cudaMalloc(). I've been searching through whatever documentations I can find but I have yet to come across any that explicitly explains what is the global memory. I believe that the global memory allocated is on the GDDR of graphics card itself and not the RAM that is shared with the CPU since one of the documentations did state that the pointer cannot be dereferenced by the host side. Am I right?

    Read the article

  • Lights off effect and jquery placement on wordpress

    - by Alexander Santiago
    I'm trying to implement a lights on/off on single posts of my wordpress theme. I know that I have to put this code on my css, which I did already: #the_lights{ background-color:#000; height:1px; width:1px; position:absolute; top:0; left:0; display:none; } #standout{ padding:5px; background-color:white; position:relative; z-index:1000; } Now this is the code that I'm having trouble with: function getHeight() { if ($.browser.msie) { var $temp = $("").css("position", "absolute") .css("left", "-10000px") .append($("body").html()); $("body").append($temp); var h = $temp.height(); $temp.remove(); return h; } return $("body").height(); } $(document).ready(function () { $("#the_lights").fadeTo(1, 0); $("#turnoff").click(function () { $("#the_lights").css("width", "100%"); $("#the_lights").css("height", getHeight() + "px"); $("#the_lights").css({‘display’: ‘block’ }); $("#the_lights").fadeTo("slow", 1); }); $("#soft").click(function () { $("#the_lights").css("width", "100%"); $("#the_lights").css("height", getHeight() + "px"); $("#the_lights").css("display", "block"); $("#the_lights").fadeTo("slow", 0.8); }); $("#turnon").click(function () { $("#the_lights").css("width", "1px"); $("#the_lights").css("height", "1px"); $("#the_lights").css("display", "block"); $("#the_lights").fadeTo("slow", 0); }); }); I think it's a jquery. Where do I place it and how do I call it's function? Been stuck on this thing for 6 hours now and any help would be greatly appreciated...

    Read the article

  • Is it possible to transfer data between html pages driven by spring web flow?

    - by Easwaramoorthy Kanagaraj
    I am aware of passing data between jsp in spring web flow. Is it possible to transfer data between html pages driven by spring web flow. I don't want to use the HTML5 local storage capabilities. Example: Page 1: Search box for an employee id. Page 2: Search result for the employee details. Two ways that I could think: Get the employee details in page 1 by ajax and pass the result to the page two. Pass the employee id to page 2 and get the result by ajax in onload. In both case I need to pass any variable/data. I am confused in doing this. Is there anything in the Spring webflow using which I could do this? Thanks in advance, Easwar

    Read the article

  • CSS - image overflow tricks

    - by rnk
    I'm stucking with some design techniques where I want to make image item box like this Where the actual image can be upto maximum height of 300px and width of 225px. The width and height of the item box including the image and the text is 190px x 190px I'm using this image http://farm8.staticflickr.com/7122/7424355198_72620895bd_m.jpg I tried using overflow: hidden for the image item to hide it's height below to show the image text. But I'm getting only like this http://jsfiddle.net/Dkh4q/ Could anyone tell the mistake I've done? Thanks! UPDATE For more information about the expected result, if you can login to zerply, then please check this http://zerply.com/christievdc/portfolio for example.

    Read the article

  • Android : start intent in setOnClickListener

    - by Derek
    I have a button, and this button is going to get the values from EditText, then using this value to start a new Intent protected void onCreate(Bundle savedInstanceState) { textDay = (EditText) findViewById(R.id.textDay); textMonth = (EditText) findViewById(R.id.textMonth); textYear = (EditText) findViewById(R.id.textYear); gen = (Button) findViewById(R.id.getGraph); gen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { getthisIntent(); } public Intent getthisIntent(Context context) { day = textDay.getText(); month = textMonth.getText(); year = textYear.getText(); date = day + "/" + month + "/" + year; . .// Plot graph using AchartEngine, then return an Intent // . } } }); but i get the error "The method getthisIntent(Context) in the type new View.OnClickListener(){} is not applicable for the arguments ()" Can i get some help? or do i have another alternative solution, when i click the button, then the button pass the values to the new intent, and start it without having a new xxx.java file? Edit This is basically what I am doing now, i need to get the things inserted by user, and plot a graph, the only way i know how to plot graph using AchartEngine is create a new activity with define this public Intent getthisIntent(Context context) To be honest, i dont really know what the hell I am doing, please correct me...

    Read the article

  • Get ANSI-colored output from external command

    - by German Rumm
    I am writing a small script for watchr that runs my PHP unit tests. Current script runs tests using system() and displays them colored. I am trying to add libnotify functionality, but for that I need to parse the output and match against regexp, so that notification will either display green or red. system() doesn't return output, %x does return, but puts p doesn't display colors, which I need to quickly see which test failed. One option would be to run tests twice - once for display in terminal window, and second time for checking which notification to show, but I would rather avoid it.

    Read the article

  • Graph Databases' Implementation

    - by user1478153
    I am having trouble visualizing a Graph Database. Visualizing an RDBMS is really very simple and I was able to understand from the first tutorial itself when I started learning it some 4-5 years ago. But I am not able to understand Graph Databases. I am also unable to get any good links on this topic, hence posting this question here. Specifically, I am looking for the following: Some really simple book/link on Graph Dbs Atleast some knowledge on the implementation details of a Graph DB (I hope all Graph DBs would be having atleast a few basic things in common). Thanks a lot in advance guys,

    Read the article

  • Xpages - Get number of active sessions

    - by Jairo
    How do I get the number of active sessions in Xpage. I'm trying to use managed beans but it just returns a weird string. Here's the simple code: import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionCounterListener implements HttpSessionListener { private static int totalActiveSessions; public static int getTotalActiveSessions(){ return totalActiveSessions | 0; } public void sessionCreated(HttpSessionEvent arg0) { totalActiveSessions++; System.out.println("sessionCreated - add one session into counter"); } public void sessionDestroyed(HttpSessionEvent arg0) { totalActiveSessions--; System.out.println("sessionDestroyed - deduct one session from counter"); } } I got this from here. But when I call SessionCounterListener.getTotalActiveSessions(), it only returns a weird string, example com.gs3.beans.SessionCounterListener@46c446c4. Please help me. Thanks a lot!

    Read the article

  • Search function fails because it refers to the wrong controller action?

    - by Christoffer
    My Sunspot search function (sunspot_rails gem) works just fine in my index view, but when I duplicate it to my show view my search breaks... views/supplierproducts/show.html.erb <%= form_tag supplierproducts_path, :method => :get, :id => "supplierproducts_search" do %> <p> <%= text_field_tag :search, params[:search], placeholder: "Search by SKU, product name & EAN number..." %> </p> <div id="supplierproducts"><%= render 'supplierproducts' %></div> <% end %> assets/javascripts/application.js $(function () { $('#supplierproducts th a').live('click', function () { $.getScript(this.href); return false; } ); $('#supplierproducts_search input').keyup(function () { $.get($("#supplierproducts_search").attr("action"), $("#supplierproducts_search").serialize(), null, 'script'); return false; }); }); views/supplierproducts/show.js.erb $('#supplierproducts').html('<%= escape_javascript(render("supplierproducts")) %>'); views/supplierproducts/_supplierproducts.hmtl.erb <%= hidden_field_tag :direction, params[:direction] %> <%= hidden_field_tag :sort, params[:sort] %> <table class="table table-bordered"> <thead> <tr> <th><%= sortable "sku", "SKU" %></th> <th><%= sortable "name", "Product name" %></th> <th><%= sortable "stock", "Stock" %></th> <th><%= sortable "price", "Price" %></th> <th><%= sortable "ean", "EAN number" %></th> </tr> </thead> <% for supplierproduct in @supplier.supplierproducts %> <tbody> <tr> <td><%= supplierproduct.sku %></td> <td><%= supplierproduct.name %></td> <td><%= supplierproduct.stock %></td> <td><%= supplierproduct.price %></td> <td><%= supplierproduct.ean %></td> </tr> </tbody> <% end %> </table> controllers/supplierproducts_controller.rb class SupplierproductsController < ApplicationController helper_method :sort_column, :sort_direction def show @supplier = Supplier.find(params[:id]) @search = @supplier.supplierproducts.search do fulltext params[:search] end @supplierproducts = @search.results end end private def sort_column Supplierproduct.column_names.include?(params[:sort]) ? params[:sort] : "name" end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" end models/supplierproduct.rb class Supplierproduct < ActiveRecord::Base attr_accessible :ean, :name, :price, :sku, :stock, :supplier_id belongs_to :supplier validates :supplier_id, presence: true searchable do text :ean, :name, :sku end end Visiting show.html.erb works just fine. Log shows: Started GET "/supplierproducts/2" for 127.0.0.1 at 2012-06-24 13:44:52 +0200 Processing by SupplierproductsController#show as HTML Parameters: {"id"=>"2"} Supplier Load (0.1ms) SELECT "suppliers".* FROM "suppliers" WHERE "suppliers"."id" = ? LIMIT 1 [["id", "2"]] SOLR Request (252.9ms) [ path=#<RSolr::Client:0x007fa5880b8e68> parameters={data: fq=type%3ASupplierproduct&start=0&rows=30&q=%2A%3A%2A, method: post, params: {:wt=>:ruby}, query: wt=ruby, headers: {"Content-Type"=>"application/x-www-form-urlencoded; charset=UTF-8"}, path: select, uri: http://localhost:8982/solr/select?wt=ruby, open_timeout: , read_timeout: } ] Supplierproduct Load (0.2ms) SELECT "supplierproducts".* FROM "supplierproducts" WHERE "supplierproducts"."id" IN (1) Supplierproduct Load (0.1ms) SELECT "supplierproducts".* FROM "supplierproducts" WHERE "supplierproducts"."supplier_id" = 2 Rendered supplierproducts/_supplierproducts.html.erb (2.2ms) Rendered supplierproducts/show.html.erb within layouts/application (3.3ms) Rendered layouts/_shim.html.erb (0.0ms) User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'zMrtTbDun2MjMHRApSthCQ' LIMIT 1 Rendered layouts/_header.html.erb (2.1ms) Rendered layouts/_footer.html.erb (0.2ms) Completed 200 OK in 278ms (Views: 20.6ms | ActiveRecord: 0.6ms | Solr: 252.9ms) But it breaks when I type in a search. Log shows: Started GET "/supplierproducts?utf8=%E2%9C%93&search=a&direction=&sort=&_=1340538830635" for 127.0.0.1 at 2012-06-24 13:53:50 +0200 Processing by SupplierproductsController#index as JS Parameters: {"utf8"=>"?", "search"=>"a", "direction"=>"", "sort"=>"", "_"=>"1340538830635"} Rendered supplierproducts/_supplierproducts.html.erb (2.4ms) Rendered supplierproducts/index.js.erb (2.9ms) Completed 500 Internal Server Error in 6ms ActionView::Template::Error (undefined method `supplierproducts' for nil:NilClass): 10: <th><%= sortable "ean", "EAN number" %></th> 11: </tr> 12: </thead> 13: <% for supplierproduct in @supplier.supplierproducts %> 14: <tbody> 15: <tr> 16: <td><%= supplierproduct.sku %></td> app/views/supplierproducts/_supplierproducts.html.erb:13:in `_app_views_supplierproducts__supplierproducts_html_erb___2251600857885474606_70174444831200' app/views/supplierproducts/index.js.erb:1:in `_app_views_supplierproducts_index_js_erb___1613906916161905600_70174464073480' Rendered /Users/Computer/.rvm/gems/ruby-1.9.3-p194@myapp/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (33.3ms) Rendered /Users/Computer/.rvm/gems/ruby-1.9.3-p194@myapp/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms) Rendered /Users/Computer/.rvm/gems/ruby-1.9.3-p194@myapp/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (39.7ms)

    Read the article

  • Why is CDATA needed and not working everywhere the same way?

    - by baptx
    In Firefox's and Chrome's consoles, this works (alerts script content): var script = document.createElement("script"); script.textContent = ( function test() { var a = 1; } ); document.getElementsByTagName("head")[0].appendChild(script); alert(document.getElementsByTagName("head")[0].lastChild.textContent); Using this code as a Greasemonkey script for Firefox works too. Now, if want to add a "private method" do() to test() It is not working anymore, in neither Firefox/Chrome console nor in a Greasemonkey script: var script = document.createElement("script"); script.textContent = ( function test() { var a = 1; var do = function () { var b = 2; }; } ); document.getElementsByTagName("head")[0].appendChild(script); alert(document.getElementsByTagName("head")[0].lastChild.textContent); To make this work in a Greasemonkey script, I have to put all the code in a CDATA tag block: var script = document.createElement("script"); script.textContent = (<![CDATA[ function test() { var a = 1; var do = function() { var b = 2; }; } ]]>); document.getElementsByTagName("head")[0].appendChild(script); alert(document.getElementsByTagName("head")[0].lastChild.textContent); This is only works in a Greasemonkey script; it throws an error from the Firefox/Chrome console. I don't understand why I should use a CDATA tag, I have no XML rules to respect here because I'm not using XHTML. To make it work in Firefox console (or Firebug), I need to do put CDATA into tags like <> and </>: var script = document.createElement("script"); script.textContent = (<><![CDATA[ function test() { var a = 1; var do = function() { var b = 2; }; } ]]></>); document.getElementsByTagName("head")[0].appendChild(script); alert(document.getElementsByTagName("head")[0].lastChild.textContent); This doesn't working from the Chrome console. I've tried adding .toString() at the end like many people are doing (]]></>).toString();), but it's useless. I tried to replace <> and </> with a tag name <foo> </foo> but that didn't work either. Why doesn't my first code snippet work if I define var do = function(){} inside another function? Why should I use CDATA as a workaround even if I'm not using XHTML? And why should I add <> </> for Firefox console if it's working without in a Greasemonkey script? Finally, what is the solution for Chrome and other browsers? EDIT: My bad, I've never used do-while in JS and I've created this example in a simple text editor, so I didn't see "do" was a reserved keyword :p But problem is still here, I've not initialized the Javascript class in my examples. With this new example, CDATA is needed for Greasemonkey, Firefox need CDATA between E4X <> </> and Chrome fails: var script = document.createElement("script"); script.textContent = ( <><![CDATA[var aClass = new aClass(); function aClass() { var a = 1; var aPrivateMethod = function() { var b = 2; alert(b); }; this.aPublicMethod = function() { var c = 3; alert(c); }; } aClass.aPublicMethod();]]></> ); document.getElementsByTagName("head")[0].appendChild(script); Question: why?

    Read the article

  • Rails 3.2 Ajax Update Div when Text Field Populated

    - by ctilley79
    In the end I would like a text field that passes a client_id to the partial. I would like to do this asynchronously so the shipment_products partial would dynamically change when the textfield value was updated. What is the best way to do this? In index.html.erb <!-- Text Field Here--> <div id="available_products"> <%= render "shipment_products" %> </div> In _shipment_products.html.erb <div id="shipment_products_container"> <h3>Assign Products to Ship<\h3> <ul class="shipment_products" id="shipment_products"> <% Product.by_client(client_id).each do |product|%> <!-- TextField value passed here --> <%= content_tag_for :li, product, :value => product.id do %> <%= hidden_field_tag("shipment[product_ids][]", product.id) %> <%= product.product_name %> <% end %> <% end %> <\ul> </div> This is similar to what I want in the end.

    Read the article

  • To not iterate through function of Array object if it is added to Array prototype

    - by Rishat Muhametshin
    According to the way to add indexOf method to Array class in IE6, how do I now reject this method from iterating through any random array? For example: Array.prototype.indexOf = function(needle) { ... }; var array = [1, 2, 3]; for (var i in array) { document.write(i + ': ' + array[i]); } gives output 0: 1 1: 2 2: 3 indexOf: function ... How can I skip indexOf property and stop iterating on it without adding any code to where for(...) is called?

    Read the article

  • Issue with WatchService in java 7

    - by user972590
    I'm using jdk7's WatchService API for monitoring the folder on file system.I'm sending a new file through email to that folder, when the file comes into that folder i m triggering the ENTRY_CRATE option. its working fine. But the issue is its generating two events of ENTRY_CREATE instead of one event which i'm invoking. BELOW IS THE CODE: Path dir = Paths.get(/var/mail); WatchService watcher = dir.getFileSystem().newWatchService(); dir.register(watcher, StandardWatchEventKinds.ENTRY_CREATE); System.out.println("waiting for new file"); WatchKey watckKey = watcher.take(); List<WatchEvent<?>> events = watckKey.pollEvents(); System.out.println(events.size()); for(WatchEvent<?> event : events){ if(event.kind() == StandardWatchEventKinds.ENTRY_CREATE){ String fileCreated=event.context().toString().trim(); } } In the above code I'm gettng the events size as 2. Can any one please help me in finding out the reason why i'm getting two events.

    Read the article

  • From Pocket to Instapaper

    - by Michael Freidgeim
    Some time ago I’ve described the issues that I’ve had since a new version of Read It Later, named Pocket, was introduced.I’ve waited with hope for a new upgrade, but I had a huge disappointment with the latest version 16 June 2012. It didn’t fixed any of the two major problems, that I  experienced since new Pocket was introduced-  1. iPad app still didn’t show many of the saved links. 2. ability to rename articles on iPad still wasn’t restored.I’ve posted the message into their forum. They did not show my comment on their forum( I would name it censorship, not moderation), but a few days ago I’ve received an email, recommending “try logging out of the app on your iPad, and back in again.” Their suggestion helped,  but I don’t understand, why it is not posted as a recommendation on their support site.So I decided to try InstAPaper on my iPad, Previously I’ve used it for Kindle. I never considered it before on iPad, because there were no free demo and I was very satisfied with RIL free and then RIL Pro. Currently InstAPaper cost $3, so the price is not an issue.I’ve checked that it has most of features that I am using(e.g. renaming, folders) and I am quite happy with it now. Actually I am using Pocket (or RIL free) for old bookmarks( I have 1000+ stored on my iPad) and for new bookmarks I am using InstAPaper.Having a solid experience with RIL/Pocket I’ve created a list of suggestions to Marco Arment to implement.1. Some pages stored in InstAPaper have removed essential sections of the text. E.g in many blogs comments are not stored in  InstAPaper. Some pages lost almost all of important links (e.g. http://www.lib.rus.ec/a/32416 -sorry, in Russian). RIL/Pocket has 2 modes to store offline- Web view and Article view. Web View includes all links/images of the original page, but it’s very reliable. Article view suppose to strip unrelated information, but often corrupts the content. I prefer to use offline Web view.InstAPaper should also support offline Web view, in case if stripped view removes important part of content.2.  Black full screen Saving on iPad Safari is very annoying. After user pressed a bookmark, the saving has some delay and then for a few seconds prevents from reading the text.Would be better to show as message on the top part(as in Pocket ). I am surprised, that  a full screen popup was  implemented recently as a desired feature. 3.There are no comments allowed on http://blog.instapaper.com/. I would prefer to post some of these notes as comments on http://blog.instapaper.com/ rather than write them in my blog and then send link to Marco.(I found recommendation how to add support of comments on tumblr at http://www.tumblr.com/help, but then realized that Marko was the lead developer ofTumblr.)4. Also there is no support forum. I understand that maintenance of the forum ican be a hassle, but stackexchange fSome time ago I’ve described the issues that I’ve had since a new version of Read It Later, named Pocket, was introduced.I’ve waited with hope for a new upgrade, but I had a huge disappointment with the latest version 16 June 2012. It didn’t fixed any of the two major problems, that I  experienced since new Pocket was introduced- orums can be referred on  http://www.instapaper.com/main/support page, i.e.http://webapps.stackexchange.com/search?q=Instapaper  or http://apple.stackexchange.com/search?q=Instapaper 5. Tags are more convenient than folders. i.e. an ability for the same article to have more than one tag. Also creating of new folders is not supported offline, which is an annoying limitation.6. I would like to have a narrow list - additionally to existing list modes have a subject only list or subject+site list to show more list items on a screen.7. Limit of 500 offline articles sounds quite big, but my RIL list exceeded 1000, so it could be a issue in the future.8. Search button on iPad version is visible, but doesn’t work- it forces to buy Premium subscription. I think, that it’s not correct. If the button in a paid version is visible and enabled, it should  provide  a working functionality, e.g. search in article names only. And leave full-text search for the premium support.9..Copy URL is an important operation and deserves to be in a first level of Action menu, rather than in Share sub-menu.I’ve also have comment re post http://www.marco.org/2011/04/28/removed-instapaper-free. Marco Arment  explained, why he doesn’t provide free version of Instapaper.  I believe that he is loosing essential part of his customers. When I decided which of iPad application to choose, I’ve selected RIL, because I was able to play with free version, and I liked it. I didn’t have a chance to compare RIL and InstAPaper on iPad, so I’ve bought  RIL pro. For a user there is no point to pay even $3 , if there are similar free product, that user can try and see, is it suitable for him/her.I’ve also played with Readability. It doesn’t have folders or tags(which is very important for me), but nicely supports full text search

    Read the article

  • Solaris: What is the difference between .so and .so.1 files?

    - by Rob Goretsky
    I am trying to understand how/why certain library files are dynamically loaded by the linker on Solaris. I am using ldd to see this (with the -s switch to see what paths are tried by the linker). As an example, if I run "ldd /usr/local/bin/isql -s" I notice that one of the libraries that is searched for is called "libodbc.so.1". I notice that this does NOT match a file it finds along the way called "libodbc.so". So, it finally resolves to a place where there is a symbolic link between "libodbc.so.1.0.0" and "libodbc.so.1". My question is - what is the significance of the ".1" here? Is it to indicate a version number? Why do some installers create these symbolic links, while others don't?

    Read the article

  • Suggestions for transitioning to new GW/private network

    - by Quinten
    I am replacing a private T1 link with a new firewall device with an ipsec tunnel for a branch office. I am trying to figure out the right way to transition folks at the new site over to the new connection, so that they default to using the much faster tunnel. Existing network: 192.168.254.0/24, gw 192.168.254.253 (Cisco router plugged in to private t1) Test network I have been using with ipsec tunnel: 192.168.1.0/24, gw 192.168.1.1 (pfsense fw plugged in to public internet), also plugged in to same switch as the old network. There are probably ~20-30 network devices in the existing subnet, about 5 with static IPs. The remote endpoint is already the firewall--I can't set up redundant links to the existing subnet. In other words, as soon as I change the tunnel configuration to point to 192.168.254.0/24, all devices in the existing subnet will stop working because they point to the wrong gateway. I'd like some ability to do this slowly--such that I can move over a few clients and verify the stability of the new link before moving critical services or less tolerant users over. What's the right way to do this? Change the netmask on all of the devices to /16, and update gateway to point to the new device? Could this cause any problems? Also, how should I handle DNS? The pfsense box is not aware of my Active Directory environment. But if I change DNS to use the local servers, it will result in a huge slowdown as DNS queries will still be routed over the private t1. I need some help coming up with a plan that's not too disruptive but will really let me thoroughly test the stability of the IPSEC tunnel before I make the final switch. The AD version is 2008R2, as are the servers. Workstations are mostly Windows XP SP3. I have not configured the 192.168.1.0/24 as a site in AD sites and services.

    Read the article

  • Computer keeps restarting [closed]

    - by Joris
    I have a strange problem with my desktop pc, when I start it, it just restarts immediately, it displays the bios/motherboard logo and then restarts. I can't access the bios to edit settings because it restarts to fast. Then I tried different things to fix it with mixed success. (I also tried to reset the bios without success) I noticed that a capacity from the graphics card was broken (it looked exploded) so I ordered a new graphics card & plugged it in the computer. It didn't change much, still the same problem. Then I unplugged everything that's not necessary and put only 1Gig RAM in the motherboard (usually it has 4 x 1Gig RAM) and the computer started, then I putted another gig of RAM and the computer still started. (starting=booting windows) When I putted in the 3th RAM it didn't boot anymore (again restarting all the time) so I removed this 3th gig of RAM and this is where it gets weird. I expected the computer to boot again because it is exactly the same configuration as before - which worked - but the computer didn't want to start. It just gave the same problem as before (restarting all the time.. ) Anyone an idea what might be wrong?

    Read the article

  • How Windows Server routes PTP v2 unicast messages?

    - by Bobb
    If my server is placed in PTP v2 enabled network which has grand master clock. And the switch is PTP aware. The server is W2008R2 (soon to be W2012). I also have PTP v2 software client. How does the master clock messages are getting on with Windows Server? Does it need special PTP-aware NIC or it will be treated as normal networking traffic and the software receives it through regular NIC no problem?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >