Search Results

Search found 807 results on 33 pages for 'fn virtualfilestats'.

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

  • Given a string describing a Javascript function. convert it to a Javascript function

    - by brainjam
    Say I've got a Javascript string like the following var fnStr = "function(){blah1;blah2;blah3; }" ; (This may be from an expression the user has typed in, duly sanitized, or it may be the result of some symbolic computation. It really doesn't matter). I want to define fn as if the following line was in my code: var fn = function(){blah1;blah2;blah3; } ; How do I do that? The best I've come up with is the following: var fn = eval("var f = function(){ return "+fnStr+";}; f() ;") ; This seems to do the trick, even though it uses the dreaded eval(), and uses a slightly convoluted argument. Can I do better? I.e. either not use eval(), or supply it with a simpler argument?

    Read the article

  • How do I flip a column in mysql that has data structured: 'last name, first name'?

    - by ggg
    I want to create a new column in a MYSQL table that has Fn Ln instead of Ln, Fn. Most of my data is printed Fn Ln. Another idea is to incorporate a string function each time there is an output (php based) but that seems to waste resources. Finally, I couldn't find the syntax (loop or foreach) for my php function anyway. Here is the working php function that I got from a previous post: $name = "Lastname, Firstname"; $names = explode(", ", $name); $name = $names[1] . " " . $names[0];

    Read the article

  • PIL saves image colour wrong

    - by Tom Viner
    I have an image. I want to resize it using PIL, but it come out like this. Even without a resize it still messes up the colour. Minimal code: from PIL import Image import os import urllib import webbrowser orig_url = 'http://mercedesclub.org.uk/images/stackoverflow-question/least-popular-colours-_-500-x-500.jpg' temp_fn, _ = urllib.urlretrieve(orig_url) im = Image.open(temp_fn) fn = os.tempnam() + '.jpg' im.save(fn) webbrowser.open(fn) I've tried Image.open(temp_fn).convert(format) with 'RGB', 'CMYK' and 'L' as formats, but still get weirdly coloured or grey results. When I load the image from my hard drive and I can see: >>>im.info {'adobe': 100, 'progression': 1, 'exif': 'Exif\x00\x00MM\x00*...\x7f\xff\xd9', 'adobe_transform': 100} >>>im.format 'JPEG' >>>im.mode 'CMYK' >>> im._getexif() {40961: 65535, 40962: 500, 40963: 500, 296: 2, 34665: 164, 274: 1, 305: 'Adobe Photoshop CS Macintosh', 306: '2010:02:26 12:46:54', 282: (300, 1), 283: (300, 1)} Thanks and let me know if you need any more data.

    Read the article

  • Closing a Dialog Box, Opening a New One and it is Grayed out (Colorbox)

    - by Scott Faisal
    $.fn.colorbox({width:"40%", inline:true,href:"#somediv", opacity:"0.50",transition:"none", height:"490px"}); On #somediv above I have a button that once clicked executes the following code: line#45 $.fn.colorbox({href:"http://www.facebook.com", width:"65%",height:"80%",iframe:true}); I see facebook.com however the overlay is grayed out. I even tried using the following code instead of line#45 : $(document).one('cbox_closed', function(){ setTimeout(function(){ $.fn.colorbox({href:"http://www.facebook.com", width:"65%",height:"80%", iframe:true});},2); }); Now all I see is a blank overlay. Any suggestion guys?

    Read the article

  • how to install SystemTap on Ubuntu

    - by jeevan thapa
    I am new to Ubuntu. I follow the instruction from http://sourceware.org/systemtap/wiki/SystemtapOnUbuntu that is necessary to install SystemTap on Ubuntu. I lost in Step 4. How can i run step 4: ? Setp 4: sudo apt-get install elfutils, for eu-readelf Then run this script as root, whenever you install additional debug symbols for file in `find /usr/lib/debug -name '*.ko' -print` do buildid=`eu-readelf -n $file| grep Build.ID: | awk '{print $3}'` dir=`echo $buildid | cut -c1-2` fn=`echo $buildid | cut -c3-` mkdir -p /usr/lib/debug/.build-id/$dir ln -s $file /usr/lib/debug/.build-id/$dir/$fn ln -s $file /usr/lib/debug/.build-id/$dir/${fn}.debug done This makes available the module probes available and is friendly to other debug symbol savvy apps like gdb and oprofile. This convention should make it's way into Ubuntu in the near future.

    Read the article

  • Find all paths from root to leaves of tree in Scheme

    - by grifaton
    Given a tree, I want to find the paths from the root to each leaf. So, for this tree: D / B / \ A E \ C-F-G has the following paths from root (A) to leaves (D, E, G): (A B D), (A B E), (A C F G) If I represent the tree above as (A (B D E) (C (F G))) then the function g does the trick: (define (g tree) (cond ((empty? tree) '()) ((pair? tree) (map (lambda (path) (if (pair? path) (cons (car tree) path) (cons (car tree) (list path)))) (map2 g (cdr tree)))) (else (list tree)))) (define (map2 fn lst) (if (empty? lst) '() (append (fn (car lst)) (map2 fn (cdr lst))))) But this looks all wrong. I've not had to do this kind of thinking for a while, but I feel there should be a neater way of doing it. Any ideas for a better solution (in any language) would be appreciated.

    Read the article

  • Insert A Line At The Beginning Of A File

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • Controlling symbol generation in Clojure macros

    - by mikera
    I'm trying (as a self-learning exercise) to create a Clojure macro that will generate code to apply a function to a sequence of integers and sum the result, e.g. f(0) + f(1) + f(2) + f(3) This is my attempt: (defmacro testsum [func n] `(fn [x#] (+ ~@( map (fn [i] `(~func x#)) (range n))))) However something seems to go wrong with the x# gensym and I end up with two different versions of x and hence the function doesn't work: (macroexpand '(testsum inc 3)) gives: (fn* ([x__809__auto__] (clojure.core/+ (inc x__808__auto__) (inc x__808__auto__) (inc x__808__auto__)))) This is pretty much exactly what I want apart from the different 809 and 808 versions of x..... What am I doing wrong? I thought that the auto gensym was meant to create a single unique symbol for exactly this kind of purpose? Is there a better way of doing this?

    Read the article

  • invalid file name in matlab when using file split

    - by klijo
    here jj will be the value of FN, but the trouble is iam getting a error message ??? Error using == fopen Invalid filename. DirName = 'Samples\mattest\jj'; FileName = split('\\',DirName); [a,b] = size(FileName); FN = FileName(b); file_1 = fopen(FN,'w'); split method was found at http://www.mathworks.com/matlabcentral/fileexchange/4873 Doesnt the code seem correct ? Could someone please help me ?

    Read the article

  • searching for hidden files using winapi

    - by Kristian
    HI i want to search for a hidden files and directories in a specefic given path but I don't know how to do it for hidden files i do know how to search for normal files and dir i did this code but im stuck can't make it search for only hidden files #include "stdafx.h" #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { TCHAR *fn; fn=L"d:\\*"; HANDLE f; WIN32_FIND_DATA data; { FILE_ATTRIBUTE_HIDDEN; } f=FindFirstFile(fn,&data); if(f==INVALID_HANDLE_VALUE){ printf("not found\n"); return 0; } else{ _tprintf(L"found this file: %s\n",data.cFileName); while(FindNextFile(f,&data)){ _tprintf(L"found this file: %s\n",data.cFileName); } } FindClose(f); return 0; }

    Read the article

  • How do I scope variables properly in jQuery?

    - by safetycopy
    I'm working on a jQuery plugin, but am having some trouble getting my variables properly scoped. Here's an example from my code: (function($) { $.fn.ksana = function(userOptions) { var o = $.extend({}, $.fn.ksana.defaultOptions, userOptions); return this.each(function() { alert(rotate()); // o is not defined }); }; function rotate() { return Math.round(o.negRot + (Math.random() * (o.posRot - o.negRot))); }; $.fn.ksana.defaultOptions = { negRot: -20, posRot: 20 }; })(jQuery); I'm trying to get the private function rotate to be able to see the o variable, but it just keeps alerting 'o is not defined'. I'm not sure what I'm doing wrong.

    Read the article

  • Insert A Line At The Beginnig Of A File

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • delete,copy,rename files and directories in WINAPI ..?

    - by Kristian
    hi I made a code that search in a givin path for a certain file name or folder and print the value BUT now how can i modify it to instead of printing its name perform on of the operations ( delete,copy,rename ) I searched on google and found nothin. #include "stdafx.h" #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { TCHAR *fn; fn=L"d:\\*"; HANDLE f; WIN32_FIND_DATA data; f=FindFirstFile(fn,&data); if(f==INVALID_HANDLE_VALUE){ printf("not found\n"); return 0; } else{ _tprintf(L"found this file: %s\n",data.cFileName); } while(FindNextFile(f,&data)){ { _tprintf(L"found this file: %s\n",data.cFileName); } } } FindClose(f); return 0; }

    Read the article

  • Is it legal for a C++ reference to be NULL?

    - by BCS
    A while back I ran into a bug the looked something like this: void fn(int &i) { printf(&i == NULL ? "NULL\n" : "!NULL\n"); } int main() { int i; int *ip = NULL; fn(i); // prints !NULL fn(*ip); // prints NULL return 0; } More recently, I ran into this comment about C++ references: [References arguments make] it clear, unlike with pointers, that NULL is not a possible value. But, as show above, NULL is a possible value. So where is the error? In the language spec? (Unlikely.) Is the compiler in error for allowing that? Is that coding guide in error (or a little ambiguous)? Or am I just wandering into the minefield known as undefined behavior?

    Read the article

  • Writing a jquery plugin in coffeescript - how to get "(function($)" and "(jQuery)"?

    - by PandaWood
    I am writing a jquery plugin in coffeescript but am not sure how to get the function wrapper part right. My coffeescript starts with this line: $.fn.extend({ Which creates the javascript with a function wrapper: (function() { $.fn.extend({ but I want a '$' passed in like this: (function($) { $.fn.extend({ Similar for the ending I have... nothing in particular in coffeescript. I get this in javascript: })(); But would like this: })(jQuery); Does anyone know how to achieve this with the coffeescript compiler? Or what is the best way to get this done within coffeescript?

    Read the article

  • How can I insert a line at the beginning of a file with Perl's Tie::File?

    - by thebourneid
    I'm trying to insert/add a line 'COMMENT DUMMY' at the beginnig of a file as a first row if /PATTERN/ not found. I know how to do this with OPEN CLOSE function. Probably after reading the file it should look something like this: open F, ">", $fn or die "could not open file: $!"; ; print F "COMMENT DUMMY\n", @array; close F; But I have a need to implement this with the use of the Tie::File function and don't know how. use strict; use warnings; use Tie::File; my $fn = 'test.txt'; tie my @lines, 'Tie::File', $fn or die "could not tie file: $!"; untie @lines;

    Read the article

  • Any way to stringify a variable id / symbol in Python?

    - by otz
    I'm wondering if it is possible at all in python to stringify variable id/symbol -- that is, a function that behaves as follows: >>> symbol = 'whatever' >>> symbol_name(symbol) 'symbol' Now, it is easy to do it on a function or a class (if it is a direct reference to the object): >>> def fn(): pass >>> fn.func_name 'fn' But I'm looking for a general method that works on all cases, even for indirect object references. I've thought of somehow using id(var), but no luck yet. Is there any way to do it?

    Read the article

  • ruby on rails named scopes (searching)

    - by houlahan
    I have a named scope (name) combination of first and last name and I'm wanting to use this in a search box. I have the code below: named_scope :full_name, lambda { |fn| {:joins => :actor, :conditions => ['first_name LIKE ? OR second_name LIKE ?', "%#{fn}%", "%#{fn}%"]} } def self.search(search) if search self.find(:all, :conditions => [ 'full_name LIKE ?', "%#{search}%"]) else find(:all) end end but this doesn't work as it gives the following error: SQLite3::SQLException: no such column: full_name: SELECT * FROM "actors" WHERE (full_name LIKE '%eli dooley%') Thanks in advance Houlahan

    Read the article

  • private virtual function in derived class

    - by user1706047
    class base { public: virtual void doSomething() = 0; }; class derived : public base { **private:** virtual void doSomething(){cout<<"Derived fn"<<endl;} }; now if i do the following: base *b=new child; b->doSomething(); //it calls the derived class fn even if that is private. Question: 1.its able to call the derived class fn even if that is private.How is it possible? Now if i change the inheritance access specifier from public to protected/private then i get compilation error as "'type cast' : conversion from 'Derived *' to 'base *' exists, but is inaccessible" Notes: I am aware on the concepts of the inheritance access specifiers.So in second case as its derived private/protected, its inaccessible. But here it confuses me for the first question. Any input will be highly appreciated

    Read the article

  • Type classes or implicit parameters? What do you prefer and why? [closed]

    - by Petr Pudlák
    I was playing a bit with Scalaz and I realized that Haskell's type classes are very similar to Scala's implicit parameters. While Haskell passes the methods defined by a type class using hidden dictionaries, Scala allows a similar thing using implicit parameters. For example, in Haskell, one could write: incInside :: (Functor f) => f Int -> f Int incInside = fmap (+ 1) and the same function using Scalaz: import scalaz._; import Scalaz._; def incInside[F[_]](x: F[Int])(implicit fn: Functor[F]): F[Int] = fn.fmap(x, (_:Int) + 1); I wonder: If you could choose (i.e. your favorite language would offer both), what would you pick - implicits or type classes? And what are your pros/cons?

    Read the article

  • Which statically typed languages support intersection types for function return values?

    - by stakx
    Initial note: This question got closed after several edits because I lacked the proper terminology to state accurately what I was looking for. Sam Tobin-Hochstadt then posted a comment which made me recognise exactly what that was: programming languages that support intersection types for function return values. Now that the question has been re-opened, I've decided to improve it by rewriting it in a (hopefully) more precise manner. Therefore, some answers and comments below might no longer make sense because they refer to previous edits. (Please see the question's edit history in such cases.) Are there any popular statically & strongly typed programming languages (such as Haskell, generic Java, C#, F#, etc.) that support intersection types for function return values? If so, which, and how? (If I'm honest, I would really love to see someone demonstrate a way how to express intersection types in a mainstream language such as C# or Java.) I'll give a quick example of what intersection types might look like, using some pseudocode similar to C#: interface IX { … } interface IY { … } interface IB { … } class A : IX, IY { … } class B : IX, IY, IB { … } T fn() where T : IX, IY { return … ? new A() : new B(); } That is, the function fn returns an instance of some type T, of which the caller knows only that it implements interfaces IX and IY. (That is, unlike with generics, the caller doesn't get to choose the concrete type of T — the function does. From this I would suppose that T is in fact not a universal type, but an existential type.) P.S.: I'm aware that one could simply define a interface IXY : IX, IY and change the return type of fn to IXY. However, that is not really the same thing, because often you cannot bolt on an additional interface IXY to a previously defined type A which only implements IX and IY separately. Footnote: Some resources about intersection types: Wikipedia article for "Type system" has a subsection about intersection types. Report by Benjamin C. Pierce (1991), "Programming With Intersection Types, Union Types, and Polymorphism" David P. Cunningham (2005), "Intersection types in practice", which contains a case study about the Forsythe language, which is mentioned in the Wikipedia article. A Stack Overflow question, "Union types and intersection types" which got several good answers, among them this one which gives a pseudocode example of intersection types similar to mine above.

    Read the article

  • Dimming the backlight is irreversible on a Samsung Q210 notebook, what do I do?

    - by user27304
    I'm new to the community, although I have been using Ubuntu since 2010. I have a Samsung Q210 notebook; Specs: Intel® Core™2 Duo CPU P8400 @ 2.26GHz × 2 4 Gigs RAM Nvidia 9200m GS (although system information in Ubuntu doesn't know) 194 GB HD OS: Ubuntu 11.10 Kernel is 3.0.0-12-generic-pae Although Samsung seems to be infamous for problems with Ubuntu, after upgrading to Oneiric, finally the FN Brightness Buttons are recognized. The only problem is, after dimming the backlight for a fixed amount of steps (3 or 4, I dare not count now because that would mean rebooting because I can't see anything), the display goes completely dark and using the FN buttons to brighten the backlight does not work anymore (before reaching that threshold, going brighter after dimming works). Now what do I do? File a bug report? If not, what then? If yes, how? Not sure... guess I should ask here first.. thanks for answering in advance.

    Read the article

  • What is upcasting/downcasting?

    - by acidzombie24
    When learning about polymorphism you commonly see something like this class Base { int prv_member; virtual void fn(){} } class Derived : Base { int more_data; virtual void fn(){} } What is upcasting or downcasting? Is (Derived*)base_ptr; an upcast or downcast? I call it upcast because you are going away from the base into something more specific. Other people told me it is a downcast because you are going down a hierarchy into something specific with the top being the root. But other people seem to call it what i call it. When converting a base ptr to a derived ptr is it called upcasting or downcasting? and if someone can link to an official source or explain why its called that than great.

    Read the article

  • Unable to change Brightness Ubuntu 13.04 Toshiba Satellite A105

    - by RPi Awesomeness
    I have a Toshiba Satellite A105 s4384 running Ubuntu 13.04 and for some reason I cannot change the brightness. Neither the function keys (Fn + F6/Fn + F7) nor the settings work, and it is really bothersome, as I would like to occasionally decrease the brightness (long car trips where my battery doesn't last, etc.) Does anyone have any idea? Judging by the suggested questions this seems to be a rather prevalent issue, but none seem to have an answer! I had a similar problem with 12.04 LTS before I upgraded.

    Read the article

  • Creating classed in JavaScript

    - by Renso
    Goal:Creating class instances in JavaScript is not available since you define "classes" in js with object literals. In order to create classical classes like you would in c#, ruby, java, etc, with inheritance and instances.Rather than typical class definitions using object literals, js has a constructor function and the NEW operator that will allow you to new-up a class and optionally provide initial properties to initialize the new object with.The new operator changes the function's context and behavior of the return statement.var Person = function(name) {   this.name = name;};   //Init the personvar dude= new Person("renso");//Validate the instanceassert(dude instanceof Person);When a constructor function is called with the new keyword, the context changes from global window to a new and empty context specific to the instance; "this" will refer in this case to the "dude" context.Here is class pattern that you will need to define your own CLASS emulation library:var Class = function() {   var _class = function() {      this.init.apply(this, arguments);   };   _class.prototype.init = function(){};   return _class;}var Person a new Class();Person.prototype.init = function() {};var person = new Person;In order for the class emulator to support adding functions and properties to static classes as well as object instances of People, change the emulator:var Class = function() {   var _class = function() {      this.init.apply(this, arguments);   };   _class.prototype.init = function(){};   _class.fn = _class.prototype;   _class.fn.parent = _class;   //adding class properties   _class.extend = function(obj) {      var extended = obj.extended;      for(var i in obj) {         _class[i] = obj[i];      };      if(extended) extended(_class);   };   //adding new instances   _class.include = function(obj) {      var included = obj.included;      for(var i in obj) {         _class.fn[i] = obj[i];      };      if(included) included(_class);   };   return _class;}Now you can use it to create and extend your own object instances://adding static functions to the class Personvar Person = new Class();Person.extend({   find: function(name) {/*....*/},      delete: function(id) {/*....*/},});//calling static function findvar person = Person.find('renso');   //adding properties and functions to the class' prototype so that they are available on instances of the class Personvar Person = new Class;Person.extend({   save: function(name) {/*....*/},   delete: function(id) {/*....*/}});var dude = new Person;//calling instance functiondude.save('renso');

    Read the article

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