i have bunch of log files and I have to delete the files of some small sizes, which were erroneous files that got created. ( 63bytes ).
I have to copy only those files which have data in it .
Is there any way in standard C—or with GNU extensions—to append stuff to a macro definition? E.g., given a macro defined as
#define quux_list X(foo) X(bar)
can I append X(bas) so that it now expands as if I’d defined it
#define quux_list X(foo) X(bar) X(bas)?
I’m playing with discriminated/tagged unions along these lines:
struct quux_foo { int x; };
struct quux_bar { char *s; };
struct quux_bas { void *p; };
enum quux_type {quux_foo, quux_bar, quux_bas};
struct quux {
enum quux_type type;
union {
struct quux_foo foo;
struct quux_bar bar;
struct quux_bas bas;
} t;
};
I figure this is a good place for the X-macro. If I define a macro
#define quux_table X(foo) X(bar) X(bas)
the enumeration & structure can be defined thus, and never get out of sync:
#define X(t) quux_ ## t,
enum quux_type {quux_table};
#undef X
#define X(t) struct quux_ ## t t;
struct quux {
enum quux_type type;
union {quux_table} t;
};
#undef X
Of course, the quux_* structures can get out of sync, so I’d like to do something like this, only legally:
struct quux_foo { int x; };
#define quux_table quux_table X(foo)
struct quux_bar { char *s; };
#define quux_table quux_table X(bar)
struct quux_bas { void *p; };
#define quux_table quux_table X(bas)
(Well, what I really want to be able to do is something like
member_struct(quux, foo) { int x; };
but I’m well aware that macros cannot be (re)defined from within macros.)
Anyhow, that’s my motivating example. Is there a way to accomplish this?
Boost.Preprocessor examples are fine, if you can show me how to make the X-macro technique work with that library.
Hello,
My PHP code is split between many files, and often I find myself using code like this this:
require_once( "$preIP/functions.php" );
The problem is that I have to keep using this a lot, and sometimes these statements are becoming redundant.
What kind of system do yo use/would recommend for keeping track of all the inter-dependencies in all the PHP files?
Around how much space does a Sharepoint Collaboration Portal use up by default (when newly created)?
Just asking because I had one created but I'm thinking of using a Team Site site template--if the client won't be utilizing the default "features" of a Collaboration Portal.
I'm curious what a reasonable / typical value is for the ratio of test code to production code when people are doing TDD. Looking at one component, I have 530 lines of test code for 130 lines of production code. Another component has 1000 lines of test code for 360 lines of production code. So the unit tests are requiring roughly 3x to 5x as much code. This is for Javascript code. I don't have much tested C# code handy, but I think for another project I was looking at 2x to 3x as much test code then production code.
It would seem to me that the lower that value is, assuming the tests are sufficient, would reflect higher quality tests. Pure speculation, I just wonder what ratios other people see.
I know lines of code is an loose metric, but since I code in the same style for both test and production (same spacing format, same ammount of comments, etc) the values are comparable.
I know this isn't a direct programming question, but's it's kinda relevant as I'm trying to get a good testing environment set up before I embark on my latest project.
I'm trying to set up Opera Mobile for Windows to allow me to test a new website. The UserAgent I get is a fairly generic one, so my workaround is to tweak my mobile.browser file to have the correct screen width and height of the target device.
Is it possible to add to the list of "fake" user agents that Opera Mobile for Windows can pretend to be? It currently supports S60, Android and Windows Mobile.
I have the following Xaml (simplified for brevity, but will repro the problem in Xamlpad or Kaxaml):
<DockPanel Width="400">
<TextBlock DockPanel.Dock="Left" TextWrapping="Wrap">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vestibulum massa metus, ornare in fringilla nec, fringilla at orci.
Nunc pharetra enim sit amet sapien aliquet eu euismod turpis vehicula.
Aenean gravida tempus lectus ut ornare.
Nullam massa augue, suscipit vel consectetur fringilla, pretium vitae neque.
</TextBlock>
<Button MinWidth="100" VerticalAlignment="Center" HorizontalAlignment="Left">Hello world</Button>
</DockPanel>
My problem is that I want the Button to take its minimum 100px of space, and for the text to wrap suitably to leave that space. However, what happens is that the text wraps as close to 400px as possible, and then the Button is clipped.
If I Snoop the output I can see that the button is rendering at the desired 100px, but it's being clipped off the side of the DockPanel.
If I reverse the Dock (so the button is docked "Right" and the TextBlock fills) then I get the layout I want, but unfortunately that's not an option due to the surrounding layout.
Is there something I can do that will make the DockPanel a) not clip and b) layout in a way that respects the MinWidth? Or am I stuck finding an alternative layout mechanism?
Thanks in advance!
I'm building a system using django, Sphinx and MySQL that's very quickly becoming quite large. The database currently has about 2000 rows, and I've written a program that's going to populate it with another 40,000 rows in a couple days. Since the database is live right now, and since I've never had a database with this much information in it, I'm worried about some things:
Is adding all these rows going to seriously degrade the efficiency of my django app? Will I need to go back through it and optimize all my database calls so they're doing things more cleverly? Or will this make the database slow all around to the extent that I can't do anything about it at all?
If you scoff at my 40k rows, then, my next question is, at what point SHOULD I be concerned? I will likely be adding another couple hundred thousand soon, so I worry, and I fret.
How is sphinx going to feel about all this? Is it going to freak out when it realizes it has to index all this data? Or will it be fine? Is this normal for it? If it is, at what point should I be concerned that it's too much data for Sphinx?
Thanks for any thoughts.
Hi,
I have an issue with the stack limit in my webservice.
I was suggested to read this article by fellow members of this forum, but I do not have an idea how to run the EDITBIN.
I am using VS2008 on Windows 7 (IIS7)
Thanks!
#include <iostream>
using namespace std;
int main()
{
cout << "Do you need to encrypt or decrypt?" << endl;
string message;
getline(cin, message);
int letter2number;
for (int place = 1; place < sizeof(message); place++)
{
letter2number = static_cast<int>(message[place]);
cout << letter2number << endl;
}
}
Examples of problem: I type fifteen letters but only four integers are printed. I type seven letters but only four integers are printed.
The loop only occurs four times on my computer, not the number of characters in the string.
This is the only problem I am having with it, so if you see other errors, please don't tell me. (It is more fun that way.)
Thank you for your time.
I'm looking for a nice stackoverflow-style answer to the first question in this old blog post, which I'll repeat below:
"I’d really like some tool (ideally, g++ based) that shows me what parts of compiled/linked code are generated from what parts of C++ source code. For instance, to see whether a particular template is being instantiated for hundreds of different types (fixable via a template specialization) or whether code is being inlined excessively, or whether particular functions are larger than expected."
I'm trying to limit the number of objects in an array controller, but I still want to be able to access the full array, if necessary. A simple solution I came up with was to subclass NSArrayController, and define a new method named "limitedArrangedObjects", that returns a limited number of objects from the real set of arranged objects. (I've seen http://stackoverflow.com/questions/694493/limiting-the-number-of-objects-in-nsarraycontroller , but that doesn't address my problem.)
I want this property to be observable via bindings, so I set a dependency to arrangedObjects on it.
Problem is, when arrangedObjects is updated, limitedArrangedObjects seems not to be observing the value change in arrangedObjects. I've hooked up an NSCollectionView to limitedArrangedObjects, and zero objects are being displayed. (If I bind it to arrangedObjects instead, all the objects show up as expected.)
What's the problem?
Here's the relevant code:
@property (readonly) NSArray *limitedArrangedObjects;
- (NSArray *)limitedArrangedObjects;
{
NSArray *arrangedObjects = [super arrangedObjects];
NSUInteger upperLimit = 10000;
NSUInteger count = [arrangedObjects count];
if (count > upperLimit) count = upperLimit;
arrayToReturn = [arrangedObjects subarrayWithRange:NSMakeRange(0, count)];
return arrayToReturn;
}
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key;
{
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
if ([key isEqualToString:@"limitedArrangedObjects"]) {
NSSet *affectingKeys = [NSSet setWithObjects:@"arrangedObjects",nil];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
}
return keyPaths;
}
I am working on a system for reserving seats. A user inputs how many seats they wish to reserve and the database will return a set of suggested seats that are not previously reserved that matches the number of seats being reserved.
For instance if I had the table:
SeatID | Reserved
-----------------
1 | false
2 | true
3 | false
4 | false
5 | false
6 | true
7 | true
8 | false
9 | false
10 | true
And the user inputs that they wish to reserve 2 seats, I would expect the query to return that seats (3, 4), (4, 5), and (8, 9) are not reserved and match the given number of input seats. Seats are organized into sections and rows. Continuous seats must be in the same row.
How would I go about structuring this query to work in such a way that it finds all available continuous seats that match the given input?
I'm writing an application (A juggling pattern animator) in PLT Scheme that accepts Scheme expressions as values for some fields. I'm attempting to write a small text editor that will let me "explode" expressions into expressions that can still be eval'd but contain the data as literals for manual tweaking.
For example,
(4hss->sexp "747")
is a function call that generates a legitimate pattern. If I eval and print that, it becomes
(((7 3) - - -) (- - (4 2) -) (- (7 2) - -) (- - - (7 1)) ((4 0) - - -) (- - (7 0) -) (- (7 2) - -) (- - - (4 3)) ((7 3) - - -) (- - (7 0) -) (- (4 1) - -) (- - - (7 1)))
which can be "read" as a string, but will not "eval" the same as the function. For this statement, of course, what I need would be as simple as
(quote (((7 3...
but other examples are non-trivial. This one, for example, contains structs which print as vectors:
pair-of-jugglers
; -->
(#(struct:hand #(struct:position -0.35 2.0 1.0) #(struct:position -0.6 2.05 1.1) 1.832595714594046) #(struct:hand #(struct:position 0.35 2.0 1.0) #(struct:position 0.6 2.0500000000000003 1.1) 1.308996938995747) #(struct:hand #(struct:position 0.35 -2.0 1.0) #(struct:position 0.6 -2.05 1.1) -1.3089969389957472) #(struct:hand #(struct:position -0.35 -2.0 1.0) #(struct:position -0.6 -2.05 1.1) -1.8325957145940461))
I've thought of at least three possible solutions, none of which I like very much.
Solution A is to write a recursive eval-able output function myself for a reasonably large subset of the values that I might be using. There (probably...) won't be any circular references by the nature of the data structures used, so that wouldn't be such a long job. The output would end up looking like
`(((3 0) (... ; ex 1
`(,(make-hand (make-position ... ; ex 2
Or even worse if I could't figure out how to do it properly with quasiquoting.
Solution B would be to write out everything as
(read (open-input-string "(big-long-s-expression)"))
which, technically, solves the problem I'm bringing up but is... ugly.
Solution C might be a different approach of giving up eval and using only read for parsing input, or an uglier approach where the s-expression is used as directly data if eval fails, but those both seem unpleasant compared to using scheme values directly.
Undiscovered Solution D would be a PLT Scheme option, function or library I haven't located that would match Solution A.
Help me out before I start having bad recursion dreams again.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section != 0) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
view.backgroundColor = [UIColor redColor];
return view;
[view release];
} else {
return tableView.tableHeaderView;
}
}
This is my implementation of viewForHeaderInSection but whatever frame I make it's always showing me the same red frame. Do you see any problem with my code?
Can't post the picture because of my rep but here is the link ;-)
http://img638.imageshack.us/img638/3350/bildschirmfoto20100315uq.png
Can I configure my C# application to limit its memory consumption to, say, 200MB?
IOW, I don't want to wait for the automatic GC (which seems to allow the heap to grow much more than actually needed by this application).
I know that in Java there's a command line switch you can pass to the JVM that achieves this.. is there an equivalent in C#?
p.s.
I know that I can invoke the GC from code, but that's something I would rather not have to do periodically. I'd rather set it once upon startup somehow and forget it.
def mailTo(subject,msg,folks)
begin
Net::SMTP.start('localhost', 25) do |smtp|
smtp.send_message "MIME-Version: 1.0\nContent-type: text/html\nSubject: #{subject}\n#{msg}\n#{DateTime.now}\n", '[email protected]', folks
end
rescue => e
puts "Emailing Sending Error - #{e}"
end
end
when the HTML is VERY large I get this exception
Emailing Sending Error - 552 5.6.0 Headers too large (32768 max)
how can i get a larger html above max to work with Net::SMTP in Ruby
OK.
Some New Query Here.
Suppose user taps on a button & video begins to play. Now when video plays, it always in full screen mode.
But what do i need is explained below.
Video should be played in a portrait mode.
(but normally video is played in landscape mode ).
How?
Thanks in advance for sharing your knowledge with SO...
this is my model:
class Position(models.Model):
map = models.ForeignKey(Map,primary_key=True)
#members=models.CharField(max_length=200)
LatLng = models.CharField(max_length=40000)
infowindow = models.CharField(max_length=40000)
but it can't run ..
thanks
Hello All,
I have inherited some code that I need to maintain that can be less than stable at times. The previous people are no longer available to query as to why they ran the application in an environment with unlimited stack set, I am curious what the effects of this could be? The application seems to have some unpredictable memory bugs that we cannot find and running the application under valgrind is not an option because it slows the application down so much that we cannot actually run it. So any thoughts on what the effects of this might be are appreciated.
Thank you.
How do i display directory sizes in a sorted manner in Unix while listing only innermost sub-directories? For example, I don't want to something like this -
100270480 /a/b/BP/b/bat/qc3
100270416 /a/b/BP/b/bat/qc3/logs
99020464 /a/b/BP/b/bat/qc3/logs/i
99005456 /a/b/BP/b/bat/qc5
99005408 /a/b/BP/b/bat/qc5/logs
97726832 /a/b/BP/b/bat/qc5/logs/i
I just want -
99020464 /a/b/BP/b/bat/qc3/logs/i
97726832 /a/b/BP/b/bat/qc5/logs/i
I want to create a wizard for the logo badge below with 3 parameters. I can make the title dynamic but for image and gradient it's hardcoded because I can't see how to make them dynamic. Code follows after pictures:
custom-styles: stylize [
lab: label 60x20 right bold middle font-size 11
btn: button 64x20 font-size 11 edge [size: 1x1]
fld: field 200x20 font-size 11 middle edge [size: 1x1]
inf: info font-size 11 middle edge [size: 1x1]
ari: field wrap font-size 11 edge [size: 1x1] with [flags: [field tabbed]]
]
panel1: layout/size [
origin 0 space 2x2 across
styles custom-styles
h3 "Parameters" font-size 14 return
lab "Title" fld_title: fld "EXPERIMENT" return
lab "Logo" fld_logo: fld "http://www.rebol.com/graphics/reb-logo.gif" return
lab "Gradient" fld_gradient: fld "5 55 5 10 10 71.0.6 30.10.10 71.0.6"
] 278x170
panel2: layout/size [
;layout (window client area) size is 278x170 at the end of the spec block
at 0x0 ;put the banner on the top left corner
box 278x170 effect [ ; default box face size is 100x100
draw [
anti-alias on
line-width 2.5 ; number of pixels in width of the border
pen black ; color of the edge of the next draw element
fill-pen radial 100x50 5 55 5 10 10 71.0.6 30.10.10 71.0.6
; the draw element
box ; another box drawn as an effect
15 ; size of rounding in pixels
0x0 ; upper left corner
278x170 ; lower right corner
]
]
pad 30x-150
Text fld_title/text font [name: "Impact" size: 24 color: white]
image http://www.rebol.com/graphics/reb-logo.gif
] 278x170
main: layout [
vh2 "Logo Badge Wizard"
guide
pad 20
button "Parameters" [panels/pane: panel1 show panels ]
button "Rendering" [show panel2 panels/pane: panel2 show panels]
button "Quit" [Unview]
return
box 2x170 maroon
return
panels: box 278x170
]
panel1/offset: 0x0
panel2/offset: 0x0
panels/pane: panel1
view main
I have written a minimal wxWidgets application:
stdafx.h
#define wxNO_REGEX_LIB
#define wxNO_XML_LIB
#define wxNO_NET_LIB
#define wxNO_EXPAT_LIB
#define wxNO_JPEG_LIB
#define wxNO_PNG_LIB
#define wxNO_TIFF_LIB
#define wxNO_ZLIB_LIB
#define wxNO_ADV_LIB
#define wxNO_HTML_LIB
#define wxNO_GL_LIB
#define wxNO_QA_LIB
#define wxNO_XRC_LIB
#define wxNO_AUI_LIB
#define wxNO_PROPGRID_LIB
#define wxNO_RIBBON_LIB
#define wxNO_RICHTEXT_LIB
#define wxNO_MEDIA_LIB
#define wxNO_STC_LIB
#include <wx/wxprec.h>
Minimal.cpp
#include "stdafx.h"
#include <memory>
#include <wx/wx.h>
class Minimal : public wxApp
{
public:
virtual bool OnInit();
};
IMPLEMENT_APP(Minimal)
DECLARE_APP(Minimal)
class MinimalFrame : public wxFrame
{
DECLARE_EVENT_TABLE()
public:
MinimalFrame(const wxString& title);
void OnQuit(wxCommandEvent& e);
void OnAbout(wxCommandEvent& e);
};
BEGIN_EVENT_TABLE(MinimalFrame, wxFrame)
EVT_MENU(wxID_ABOUT, MinimalFrame::OnAbout)
EVT_MENU(wxID_EXIT, MinimalFrame::OnQuit)
END_EVENT_TABLE()
MinimalFrame::MinimalFrame(const wxString& title)
: wxFrame(0, wxID_ANY, title)
{
std::auto_ptr<wxMenu> fileMenu(new wxMenu);
fileMenu->Append(wxID_EXIT, L"E&xit\tAlt-X",
L"Terminate the Minimal Example.");
std::auto_ptr<wxMenu> helpMenu(new wxMenu);
helpMenu->Append(wxID_ABOUT, L"&About\tF1",
L"Show the about dialog box.");
std::auto_ptr<wxMenuBar> bar(new wxMenuBar);
bar->Append(fileMenu.get(), L"&File");
fileMenu.release();
bar->Append(helpMenu.get(), L"&Help");
helpMenu.release();
SetMenuBar(bar.get());
bar.release();
CreateStatusBar(2);
SetStatusText(L"Welcome to wxWidgets!");
}
void MinimalFrame::OnAbout(wxCommandEvent& e)
{
wxMessageBox(L"Some text about me!", L"About", wxOK, this);
}
void MinimalFrame::OnQuit(wxCommandEvent& e)
{
Close();
}
bool Minimal::OnInit()
{
std::auto_ptr<MinimalFrame> mainFrame(
new MinimalFrame(L"Minimal wxWidgets Application"));
mainFrame->Show();
mainFrame.release();
return true;
}
This minimal program weighs in at 2.4MB! (Executable compression drops this to half a MB or so but that's still HUGE!) (I must statically link because this application needs to be single-binary-xcopy-deployed, so both the C runtime and wxWidgets itself are set for static linking)
Any tips on cutting this down? (I'm using Microsoft Visual Studio 2010)
Hi,
I am using C#, and having an image stored in the object Bitmap.
Now I would like to convert this image into 8bit greyscale, then into a 4-bit greyscale image.
Do you have any tips how this can be made?
I was given the task of doing a facelift to our current site. I am moderately well versed in CSS so I am converting the bazillion tags to CSS styles and deleting about 2 times that many that were simply not necessary.
It's all going well until I run into a certain product page that is only a wrapper into which other HTML files are pulled by a server.execute(filename) command. (we're using aspx for the wrapper page.)
There are almost 700 of these pages and they all are cursed with this and that. Past editors with FrontPage that only know how to drag pretty things on the screen.
Anyway, I am wondering if there is a way to use CSS in the wrapper page to override the tag behavior so I can make it something sane that fits with the rest of my pages. I'd even be open to something JavaScript that would remove the tags, but that's my less preferred solution. Thanks!