Daily Archives

Articles indexed Tuesday March 30 2010

Page 15/126 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Rails STI: SuperClass Model Methods called from SubClass

    - by Karl
    I would like a little confirmation that I'm doing this correctly. Using rails single table inheritance I have the following models and class method: class PhoneNumber < ActiveRecord::Base def self.qual?(number) klass = self klass.exists?(:phone_number => phone_number) end end class Bubba < PhoneNumber end class Rufus < PhoneNumber end Bubba.qual?("8005551212") Tests pass and everything seems to work properly in rails console. Just wanted to confirm that I'm not headed for future trouble by using self in the superclass PhoneNumber and using that to execute class methods on subclasses from the parent. Is there a better way?

    Read the article

  • In this example, would Customer or AccountInfo properly be the entity group parent?

    - by Badhu Seral
    In this example, the Google App Engine documentation makes the Customer the entity group parent of the AccountInfo entity. Wouldn't AccountInfo encapsulate Customer rather than the other way around? Normally I would think of an AccountInfo class as including all of the information about the Customer. import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.KeyFactory; @PersistenceCapable public class AccountInfo { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; public void setKey(Key key) { this.key = key; } } // ... KeyFactory.Builder keyBuilder = new KeyFactory.Builder(Customer.class.getSimpleName(), "custid985135"); keyBuilder.addChild(AccountInfo.class.getSimpleName(), "acctidX142516"); Key key = keyBuilder.getKey(); AccountInfo acct = new AccountInfo(); acct.setKey(key); pm.makePersistent(acct);

    Read the article

  • TPL v/s Reactive Framework

    - by Abhijeet Patel
    When would one choose to use Rx over TPL or are the 2 frameworks orthogonal? From what I understand Rx is primarily intended to provide an abstraction over events and allow composition but it also allows for providing an abstraction over async operations. using the Createxx overloads and the Fromxxx overloads and cancellation via disposing the IDisposable returned. TPL also provides an abstraction for operations via Task and cancellation abilities. My dilemma is when to use which and for what scenarios?

    Read the article

  • PendingIntent from notification and application history conflicts

    - by synic
    I'm creating a notification with something similar to the following: Intent ni = new Intent(this, SomeActivity.class); ni.putExtra("somestring", "somedata"); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, ni, PendingIntent.FLAG_UPDATE_CURRENT|PendingIntent.FLAG_ONE_SHOT); Context context = getApplicationContext(); notification.setLatestEventInfo(context, res.getString(R.string.app_name), text, contentIntent); The key here is the extra data on the Intent for the notification. Once I click on the notification and it brings up SomeActivity, it brings up the activity and the extra data is available. However, if I exit the app, hold the home button until the recent activities list comes up, and choose to open the app again, the extra data is still passed. Is there a way I can make this data get passed only if the app is opened via the Notification, and not from the recent activities list?

    Read the article

  • AS3 - Unloaded AVM1 swfs trace out as unloaded but memory is not freed for the AVM2 machine

    - by puppbits
    I have a large project built in as3. Part of its main functionality is to load and unload various as2 swfs. The problem is that the memory ins't free up once they are unloaded. I have access to the as2 swfs code base and destroyed all objects, stopped and killed timers, listeners, removed from stage, destroyed all the MovieClip.protoypes that were created. They look to be clean as far as the AS2 debugger show no remnants of the object after the destroy function is run. In AS3 i've closed the local connection, cleaned all references/listeners to the AVM1Movie and ran Loader.unloadAndStop(). The trace out in flex says the swf was unloaded but looking at windows task manager the memory usage never drops to when it was before the as2 swf was loaded. Each as2 swf can take up to 80 megs each time it's run so memory gets eaten up fast and loading and unloading a few as2 files. At this point if the AS2 swfs are unloaded the only thing that I can assume that could be left is MovieClip.prototype and/or _global, _root variables add during the AS2's run time. But i've gone through those and can't find anything else that might be sticking. Has anyone ever seen problems before with the AVM1 machine not freeing up its memory?

    Read the article

  • Google Federated Login vs Hybrid Protocol vs Google Data Authentication. Whats's the Difference?

    - by johnfelix
    Hi, I am trying to implement Google Authentication in my website, in which I would also be pulling some Google Data using the Google Data API and I am using Google App Engine with Jinja2. My question is, so many ways are mentioned to do it. I am confused between Google Federated Login,Google Data Protocol, Hybrid Protocol. Are these things the same or different ways to do the same thing. From what I read and understood, which might be incorrect, Google Federated Login uses the hybrid protocol to authenticate and fetch the google data. Is there a proper guide to implement any one of these in python. Examples which I found at the google link are kind of different. From what I understood,correct me if i am wrong, I have to implement only the OpenID Consumer part. In order to implement Google Federated Login in Python, I saw that we need to download a separate library from the openid-enabled.com but I found a different library for the google data implementation at http://code.google.com/p/gdata-python-client/ As you can see, I am confused a lot :D. Please help me :) Thanks

    Read the article

  • BAR - Backup archiver program

    <b>Ubuntu Geek:</b> "BAR is backup archiver program to create compressed and encrypted archives of files that can be stored on a hard disk, CD, DVD, or directly on a server via FTP, SCP, or SFTP. A server mode and a scheduler are integrated for making automated backups in the background. A graphical front end that can connect to the (remote) server is included."

    Read the article

  • Subclassed django models with integrated querysets

    - by outofculture
    Like in this question, except I want to be able to have querysets that return a mixed body of objects: >>> Product.objects.all() [<SimpleProduct: ...>, <OtherProduct: ...>, <BlueProduct: ...>, ...] I figured out that I can't just set Product.Meta.abstract to true or otherwise just OR together querysets of differing objects. Fine, but these are all subclasses of a common class, so if I leave their superclass as non-abstract I should be happy, so long as I can get its manager to return objects of the proper class. The query code in django does its thing, and just makes calls to Product(). Sounds easy enough, except it blows up when I override Product.__new__, I'm guessing because of the __metaclass__ in Model... Here's non-django code that behaves pretty much how I want it: class Top(object): _counter = 0 def __init__(self, arg): Top._counter += 1 print "Top#__init__(%s) called %d times" % (arg, Top._counter) class A(Top): def __new__(cls, *args, **kwargs): if cls is A and len(args) > 0: if args[0] is B.fav: return B(*args, **kwargs) elif args[0] is C.fav: return C(*args, **kwargs) else: print "PRETENDING TO BE ABSTRACT" return None # or raise? else: return super(A).__new__(cls, *args, **kwargs) class B(A): fav = 1 class C(A): fav = 2 A(0) # => None A(1) # => <B object> A(2) # => <C object> But that fails if I inherit from django.db.models.Model instead of object: File "/home/martin/beehive/apps/hello_world/models.py", line 50, in <module> A(0) TypeError: unbound method __new__() must be called with A instance as first argument (got ModelBase instance instead) Which is a notably crappy backtrace; I can't step into the frame of my __new__ code in the debugger, either. I have variously tried super(A, cls), Top, super(A, A), and all of the above in combination with passing cls in as the first argument to __new__, all to no avail. Why is this kicking me so hard? Do I have to figure out django's metaclasses to be able to fix this or is there a better way to accomplish my ends?

    Read the article

  • How to avoid clobbering files when creating a tar archive

    - by Andrew Grimm
    This question notes that it is possible to overwrite files when creating a tar archive, and I'm trying to see how to avoid that situation. Normally, I'd use file roller, but the version installed is playing up a bit (using 1.1 Gb of memory), and I'm not the system administrator. I looked at --confirmation and --interactive, but that only asks me if I want to add file x to the archive, not whether I want to overwrite an existing file. For example, tar --interactive -czvf innocent_text_file.txt foo* Will ask me about each file, but is perfectly happy to overwrite innocent_text_file.txt Is there any switch that acts like -i for cp? Note I am asking about creating an archive, not extracting an archive. Clarification What I'm worried about is accidentally doing something like this tar -czvf * #Don't do this! which would overwrite the first file listed in the glob. To avoid it, I want tar to complain if the first file mentioned already exists, like cp -i * #Don't do this! would check if it would cause you to overwrite an existing file.

    Read the article

  • [C#] GrayScale (by ColorMatrix) causes OutOfMemoryException. Why ?

    - by Tony
    I have 2 forms, A and B. On the Form A, I click a button and an Image is being loaded to a PictureBox located ona the Form B. And, I want to set GrayScale to this image by: public void SetGrayScale(PictureBox pb) { ColorMatrix matrix = new ColorMatrix(new float[][] { new float[] {0.299f, 0.299f, 0.299f, 0, 0}, new float[] {0.587f, 0.587f, 0.587f, 0, 0}, new float[] {0.114f, 0.114f, 0.114f, 0, 0}, new float[] { 0, 0, 0, 1, 0}, new float[] { 0, 0, 0, 0, 0} }); Image image = (Bitmap)pb.Image.Clone(); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix); Graphics graphics = Graphics.FromImage(image); graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); graphics.Dispose(); pb.Image = image; } This code works properly when the PictureBox is on the same form (A). But, when it is on the Form B, the OutOfMemoryException is raised. Why ?

    Read the article

  • Copying file to client machine

    - by Shoba Anandhan
    Hi We have a requirement to copy a .txt file into the client machine and open the file using notepad.exe. We develop our application using MS Visual Studio 2008 VB .Net. Any experencied this kind of requirement? Help required... Thanks Shoba Anandhan

    Read the article

  • How to make an add friend/defriend function in PHP?

    - by user300371
    I have created a site where people can create a profile. But I am trying to figure out how to start on making an add friend button so users can have friends. In my user table, i have user_id, first_name, last_name, email, etc. Should I somehow relate the user_id of the user and the friend in a friend table? I am a novice to programming, so these things are still new to me. Thanks!

    Read the article

  • Learn ASP.NET or Python for web development?

    - by user300371
    I am new to programming and only know html,css,PHP and would like to start learning another new language. I am focused on web development and would just like to get your opinion on ASP.net and python. Which language would serve me best in making sites as to general programming? ASP.NET or django python? I know Python is "easy to learn" and similar to PHP, but ASP.net is also a good language.

    Read the article

  • C# Enterprise Block Application Settings and Settings.Settings designer

    - by Tab
    I am working with v4 of the Enterprise Application block and I am trying to learn how to access the Application Settings that I have added using the Enterprise Library Configuration tool. It's as if the code does not recognize the settings even though I can see them in the app.config. I DO have a Settings.Settings designer added and I CAN get to those settings the standard way even though the settings added in that designer do NOT show up in the app.config like they normally would if I am NOT using the Enterprise Block How do I access the App Settings that I added with the Enterprise Block?

    Read the article

  • Getting problem in accessing web cam.

    - by Chetan
    Hi... I have written code in Java to access web cam,and to save image... I am getting following exceptions : Exception in thread "main" java.lang.NullPointerException at SwingCapture.(SwingCapture.java:40) at SwingCapture.main(SwingCapture.java:66) how to remove this exceptions. here is the code: import javax.swing.*; import javax.swing.event.; import java.io.; import javax.media.; import javax.media.format.; import javax.media.util.; import javax.media.control.; import javax.media.protocol.; import java.util.; import java.awt.; import java.awt.image.; import java.awt.event.; import com.sun.image.codec.jpeg.; public class SwingCapture extends Panel implements ActionListener { public static Player player = null; public CaptureDeviceInfo di = null; public MediaLocator ml = null; public JButton capture = null; public Buffer buf = null; public Image img = null; public VideoFormat vf = null; public BufferToImage btoi = null; public ImagePanel imgpanel = null; public SwingCapture() { setLayout(new BorderLayout()); setSize(320,550); imgpanel = new ImagePanel(); capture = new JButton("Capture"); capture.addActionListener(this); String str1 = "vfw:iNTEX IT-308 WC:0"; String str2 = "vfw:Microsoft WDM Image Capture (Win32):0"; di = CaptureDeviceManager.getDevice(str2); ml = di.getLocator(); try { player = Manager.createRealizedPlayer(ml); player.start(); Component comp; if ((comp = player.getVisualComponent()) != null) { add(comp,BorderLayout.NORTH); } add(capture,BorderLayout.CENTER); add(imgpanel,BorderLayout.SOUTH); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { Frame f = new Frame("SwingCapture"); SwingCapture cf = new SwingCapture(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { playerclose(); System.exit(0);}}); f.add("Center",cf); f.pack(); f.setSize(new Dimension(320,550)); f.setVisible(true); } public static void playerclose() { player.close(); player.deallocate(); } public void actionPerformed(ActionEvent e) { JComponent c = (JComponent) e.getSource(); if (c == capture) { // Grab a frame FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl"); buf = fgc.grabFrame(); // Convert it to an image btoi = new BufferToImage((VideoFormat)buf.getFormat()); img = btoi.createImage(buf); // show the image imgpanel.setImage(img); // save image saveJPG(img,"\test.jpg"); } } class ImagePanel extends Panel { public Image myimg = null; public ImagePanel() { setLayout(null); setSize(320,240); } public void setImage(Image img) { this.myimg = img; repaint(); } public void paint(Graphics g) { if (myimg != null) { g.drawImage(myimg, 0, 0, this); } } } public static void saveJPG(Image img, String s) { BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = bi.createGraphics(); g2.drawImage(img, null, null); FileOutputStream out = null; try { out = new FileOutputStream(s); } catch (java.io.FileNotFoundException io) { System.out.println("File Not Found"); } JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi); param.setQuality(0.5f,false); encoder.setJPEGEncodeParam(param); try { encoder.encode(bi); out.close(); } catch (java.io.IOException io) { System.out.println("IOException"); } } }

    Read the article

  • How to use TJvBalloonWindow as the hint window for Virtual treeview?

    - by Edwin
    I have a 'hint window leftovers' problem with Virtual Treeview in an Office add-in, and now I want to customize the hint window to solve the problem. I want to use TJvBallonHint from the JVCL package, which is also used in other parts of my program. I inherited TVirtualStringTree and have overridden the GetHintWindowClass method like the following code. The TJvBallonHint window class is applied, but the hint text is not drawn. Any tips for me? Thank you! function TMyStringTree.GetHintWindowClass: THintWindowClass; begin Result :=TJvBalloonWindow;; end;

    Read the article

  • Actionscript base class in Flex AIR app

    - by Alan
    I'm trying to build a Flex AIR app using Flex Builder 3, which I'm just getting started with. In Flash CS4, there's a text field in the authoring environment where you can specify a class that will become the "base" class - your class inherits from Sprite and then "becomes" the Stage at runtime. Is there a a way to do the same thing with Flex/AIR? Failing that, can anyone explain how to create and use an external class? Originally I had this in TestApp.mxml: <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script source="TestApp.as"/> </mx:WindowedApplication> And this in TestApp.as: package { public class TestApp { public function TestApp() { trace('Hello World'); } } } That gives the error "packages cannot be nested", so I tried taking out the package statement: public class TestApp { public function TestApp() { trace('Hello World'); } } That gives an error "classes cannot be nested", so I finally gave up and tried to take out the class altogether, figuring I'd try to start with a bunch of functions instead: function init() { trace('Hello World'); } But that gives the error "A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package". I can't win! When I put my class in a package, it says I can't do that because it would be nested. When I don't, it says it needs to be in a package so it can be seen. Does anyone know how to fix this? If I can't do the custom-class-as-base-class thing, is there a way I could just have it like: <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script source="TestApp.as"/> <mx:Script> var app = new TestApp(); </mx:Script> </mx:WindowedApplication> At the moment I can't import the class definition at all, so even that won't work. Thanks in advance!

    Read the article

  • How can should I set up Flex 3 projects that reference common controls?

    - by Amy
    I'm not a flash developer, I'm having issues figuring out how I should set up these two projects that I have in Flex Builder. I've already created projA which has a .mxml that references several custom controls & skins from com.xxx.controls within projA I now have to build projB which also has a .mxml that will create a different .swf. I want to use some of the same controls from projA I currently build projA through the command line and nant and will need to do the same for projB. Should I create a new project to move all of the common controls into? How do I then use this library project in both the projects & compile via command? Thanks!

    Read the article

  • Anonymous user with proftpd on fedora

    - by stukerr
    Hi there, I am trying to setup an anonymous user account on our server to enable people to downlaod technical manuals for our products etc. and I would like this to be as secure as possible! I was just wondering if anyone knew a series of steps that will allow me to create an anonymous ftp account linked to a directory on the server that enables download only ? Also how could i make a corresponding ftp account with write priviledges to this account to allow people within our company to upload new files ? Sorry i'm a bit new to all this! Many Thanks, Stuart

    Read the article

  • LUNS access issue in ESX4 Cluster server

    - by rmustafa
    HI, I've created volumes in equallogic in PS 6000 XV(having 2 member which is in 1 pool), checked & those volumes can be easily detected my ISCSI software in windows. But the problem with ESX , not able to see the assigned disk on ESX server, I can explain what I've done: 1.Created Cluster with enabled HA & DRS 2.Added 3 ESX4 HOST 3.Added VMkernel & configured in all 3 ESX4, enabled vmotion & FT on the same adapter. 4.went to iSCSI storage adapter properties, enabled iSCSI 5.Trying to discover the available storage with the controller IP on dynamic discovery, but not able to see the assigned storage Note: the same volume is accessed to windows that means there is no issue from storage , am I right ???? Note: I wanted to mount the same volume in all 3 ESX host. Please suggest .... Thanks & Regards, Rashid Mustafa

    Read the article

  • Permission folders redhat10

    - by aryan
    Dear all, I have written a data DVD by k3b and now that I paste DVD on my system I have limitation in order to read and write on it's folders. I tried to set their permission but it's not possible. I mean that when I set File access to Read and write and press Apply permission to enclosed files botton, after a few seconds my setting (Read and write) will be disappeared and it returns to ---. Can any one guide m, please? Thanks

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >