How can I get status on a printer from a Cocoa app.
I would like to get the number of queued jobs and the current status of the printer (running, paused, error, etc).
Thanks
In one header file I have:
#include "BaseClass.h"
// a forward declaration of DerivedClass, which extends class BaseClass.
class DerivedClass ;
class Foo {
DerivedClass *derived ;
void someMethod() {
// this is the cast I'm worried about.
((BaseClass*)derived)->baseClassMethod() ;
}
};
Now, DerivedClass is (in its own header file) derived from BaseClass, but the compiler doesn't know that at the time it's reading the definition above for class Foo. However, Foo refers to DerivedClass pointers and DerivedClass refers to Foo pointers, so they can't both know each other's declaration.
First question is whether it's safe (according to C++ spec, not in any given compiler) to cast a derived class pointer to its base class pointer type in the absence of a full definition of the derived class.
Second question is whether there's a better approach. I'm aware I could move someMethod()'s body out of the class definition, but in this case it's important that it be inlined (part of an actual, measured hotspot - I'm not guessing).
I am interested in implementing an architecture that has two databases one for read operations and the other for writes. I have never implemented something like this and have always built single database, highly normalised systems so I am not quite sure where to begin. I have a few parts to this question.
1. What would be a good resource to find out more about this achitecture?
2. Is it just a question of replicating between two identical schemas, or would your schemas differ depending on the operations, would normalisation vary too?
3. How do you insure that data written to one database is immediately available for reading from the second?
Any further help, tips, resources would be appreciated. Thanks.
I have been using mach_absolute_time() for all my timing functions so far. calculating how long between frames ect.
I now want to get the exact time touch input events happen using event.timestamp in the touch callbacks.
the problem is these two seem to use completely different timers. sure, you can get them both in seconds, but their origins are different and seemingly random...
is there any way to sync the two different timers?
or is there anyway to get access to the same timer that the touch input uses to generate that timestamp property? otherwise its next to useless.
I'd like to turn off the accordian animation during page load, and then turn it back on after the page is loaded.
Basically I've got multiple forms inside the accordion sections and when submitted the page gets reloaded and the relevant section is reloaded. But during the reload the animation is triggered which looks a little ugly. But I like it when the page is not being loaded.
How do I achieve this effect?
I need to define a data structure recursively in Javascript. Here is a simple example of a circular linked list:
// List a very simplified example of what the actual (non list) code does.
function List(f, r) {
return function(){ return [f, r]; };
}
var head = List('a', List('b', List('c', head)));
When this is executed, head in List 'c' is resolved to undefined, not List 'a' as I need. List is an example function that returns a function (It is not an Javascript list that I can append to).
I tried to wrap the definition of head is a self executing named function, but that blew the stack when head was resolved.
What is the Javascript style solution that I am overlooking?
Having a little difficulty getting a function to call after a .load:
$(function(){
$('a.pageFetcher').click(function(){
$('#main').load($(this).attr('rel'));
});
});
The page loads, but the functions don't fire:
$(function(){
var $container = $('#container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.box',
});
});
$container.infinitescroll({
navSelector : '#page-nav',
nextSelector : '#page-nav a',
itemSelector : '.box',
loading: {
finishedMsg: 'Nothing else to load.',
img: 'http://i.imgur.com/6RMhx.gif'
}
},
function( newElements ) {
$.superbox.settings = {
closeTxt: "Close this",
loadTxt: "Loading your selection",
nextTxt: "Next item",
prevTxt: "Previous item"
};
$.superbox();
var $newElems = $( newElements ).css({ opacity: 0 });
$newElems.imagesLoaded(function(){
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
});
I've attempted to combine them so that the 2nd functions are called after .load (after doing some searching on this site and looking at given answers/examples) but nothing seems to work properly.
Suggestions?
I'm creating a CMS using jQuery and AJAX. When I click, my "Add Campaign" buttom, it creates a unique client ID in the DB and on a hard reload, the new client shows up in its container. I am trying to use ajax to reload the container on the fly and I'm not having the exact luck i am hoping for. I can get it to reload, but it's like it's pulling in descriptions of each of the clients as well!
function AddNewClient() {
dataToLoad = 'clientID=' + clientID + '&addClient=yes';
$.ajax({
type: 'post',
url: '/clients/controller.php',
datatype: 'html',
data: dataToLoad,
target: ('#clientssidebar'),
async: false,
success: function(html){
$('#clientssidebar').html(html);
},
error: function() {
alert('An error occured!');
}
});
};
ive made an xml schema all the code basically and was wonder is there a way that the code genarates something like this
http://www.novell.com/documentation/extend52/Docs/help/Director/books/PGImages/novell_portlet_xml_schema.gif
and if i can then how do you do it?
In C# how can I serialize a List to a byte[] in order to store it in a DB field?
I know how to serialize to a file on the disk, but how do I just serialize to a variable?
Here is how I serialized to the disk:
List<int> l = IenumerableofInts.ToList();
Stream s = File.OpenWrite("file.bin");
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(s, lR);
s.Close();
I'm sure it's much the same but I just can't wrap my head around it.
Don't know if this is possible, I am looking a writing social network-esque code but need a bit of help.
SELECT wall.Wid, wall.uid, wall.wcomment, wall.name, comment.wid, comment.comment,comment.wid
FROM wall
LEFT JOIN comment ON wall.Wid=comment.wid
WHERE wall.uid in (SELECT fid from friends where uid = 3)
Cheers guys
I am working on an ASP.NET website with VB.NET code-behind. I have a Silverlight mediaplayer object on one of the pages and the user may view that video in FullScreen mode. When changing to full-screen mode they are losing the title and chapter of the video series they are viewing. I have tried accessing properties and searched the web for examples on how I could put a title or some text over the player when in FullScreen mode to give the user an indication of where they are currently at while viewing each video. I am using OnClientMediaEnded to move through the videos after each video has ended so they are able to watch the whole series once in FullScreen mode. I am using a call to javascript in with this method to do that and want to know if there is any way to get a title or text up there and then change once the video switches to the next in the series?
The controls on the player also go away when going into FullScreen mode so any help with that would be greatly appreciated as well.
Thanks
Hi, i'm new to the realm to working with Files in .NET
I'm creating a WPF application in VB.NET with the 3.5 Framework. (If you provide an example in C#, that's perfectly fine.)
In my project I have a Template for an MS Access database. My desired behavior is that when the users clicks File--New, they can create a new copy of this template, give it a filename, and save it to their local directory.
The database already has the tables and some starting data needed to interface with my application (a user-friendly data editor)
I'm thinking the approach is to include this "template.accdb" file as a resource in the project, and write it to a file somehow at runtime?
Any guidance will be very, very appreciated.
Thanks!
the goal is to start with ['a','b','c'] and end up with {'a'={'b'={'c'={}}}}
so, getting my bearings, i did this:
ruby-1.8.7-p174 ['a','b','c'].inject({}){|h,v| h.update(v = {})}
= {"a"={}, "b"={}, "c"={}}
and then figured, if i actually pass on the result hash, it will recurse and nest, but:
ruby-1.8.7-p174 ['a','b','c'].inject({}){|h,v| h.update(v = {}); h[v]}
= {}
why is this? any idea how to achieve the desired result in an elegant one-liner?
How can I obtain the (IPv4) addresses for all network interfaces using only proc? After some extensive investigation I've discovered the following:
ifconfig makes use of SIOCGIFADDR, which requires open sockets and advance knowledge of all the interface names. It also isn't documented in any manual pages on Linux.
proc contains /proc/net/dev, but this is a list of interface statistics.
proc contains /proc/net/if_inet6, which is exactly what I need but for IPv6.
Generally interfaces are easy to find in proc, but actual addresses are very rarely used except where explicitly part of some connection.
There's a system call called getifaddrs, which is very much a "magical" function you'd expect to see in Windows. It's also implemented on BSD. However it's not very text-oriented, which makes it difficult to use from non-C languages.
Hi all,
I have a sorted ArrayList of values. I would like to get the distribution of the values. For example:
Say I have 500 values, ranging from 1-100.
I want to break them up into groups, say 10 groups: values 1-10, 11-20, 21-30, etc...
I want the counts of each of the 500 values that fall into each category. For example, 5 of the 500 are valued at 1-10, 20 between 11-20, etc...
However, I do not know the ranges of values in my ArrayList, it could be ranging from 1-30 or 1-200, but I want to break it up into, for example, 10 groups.
Does anyone know how to do this?
I'm new to java and i'm trying to find a way of incrementing through an user input IP address range.
For example from 192.168.0.1 to 192.168.0.255. However the way my application works at the moment is the take the from and to ip addresses as a String.
Is there a way I can increment through all the ip addresses the user input from and to?
Hope this makes sense and please dont flame me, I have looked for an answer!
I am looking to alter a stored procedure if a condition exists. I want to leave the stored procedure as is if the condition is not met, so drop/create is not really an option.
Trying to put the contents of ALTER PROC inside an IF block is throwing up errors for me. Any thoughts?
Hi,
I am running PHP on IIS 6 with mssql. I have uploaded a file to my webserver through a php script. Upon checking the file on the server the file is ok and not corrupt. However, when i then have a link on my website to try and download the file, it says the file is corrupt.
I know the file isnt corrupt as i can view it perfectly if i look at the file on the server.
Is seems like this is a common problem as a similar problem was posted here:
http://www.bigresource.com/Tracker/Track-php-1pAakBhT/
Any help would be much appreciated.
Thanks,
M
My download code is as follows:
$filesize = $rows->filesize;
$filepath = $rows->filepath;
header("Content-Disposition: attachment; filename=$filename");
header("Content-length: $filesize");
header("Content-type: application/pdf");
header("Cache-control: must-revalidate");
header("Content-Description: PHP Generated Data");
readfile($filepath);
I have a project in eclipse, that is unable to see maven dependencies. What is odd is when I build from the command line the build completes fine. They are both pointed at the same repository.
I would think that it is something with maven or project configuration but I have been through every piece with no success.
I would appreciate any help on this one.
ps using m2eclipse
I am getting the message:
* _NSAutoreleaseNoPool(): Object 0x3f43660 of class UICFFont
autoreleased with no pool in place -
just leaking
I have placed a break point using the symbol _NSAutoreleaseNoPool and the program does break, however, the stack trace does not show me any of my code only some UIView and Core Animation layer code.
Is there a better way to get to the bottom of the issue? There is apparently a thread that does not have an auto release pool, but I can't figure out where.
Thanks.
Hi, this code doesn't compile. I'm wondering what I am doing wrong:
private static Importable getRightInstance(String s) throws Exception {
Class<Importable> c = Class.forName(s);
Importable i = c.newInstance();
return i;
}
where Importable is an interface and the string s is the name of an implementing class.
The compiler says:
./Importer.java:33: incompatible types
found : java.lang.Class<capture#964 of ?>
required: java.lang.Class<Importable>
Class<Importable> c = Class.forName(format(s));
thanks for any help!
All the solutions
Class<? extends Importable> c = Class.forName(s).asSubclass(Importable.class);
and
Class<? extends Importable> c = (Class<? extends Importable>) Class.forName(s);
and
Class<?> c = Class.forName(format(s));
Importable i = (Importable)c.newInstance();
give this error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: class C1
has interface Importable as super class
where C1 is effectively a class implementing Importable, one of those i want to cast to Importable.
I'm trying to be able to dynamically expand / collapse multiple divs with the same code....
it's controlled with the click of a span (toggle) and then i'm trying to get the next id(the div that would slide up and down)
$('span').toggle(
function() {
$('#albumholder').slideToggle(600);
$(this).html('-');},
function() {
$('#albumholder').slideToggle(600);
$(this).html('+');}
);
This code works to expand 1 div... but assume i have a divs #downloadholder#linksholderetc...
How can i achieve the same effect with the same code? Thanks!