to retrieve k random numbers from an array of undetermined size we use a technique called reservoir sampling. Can anybody briefly highlight how it happens with a sample code??
Any sample code to how to use DDraw & OpenGL in wince?
I have searched in net and i dint found any where
that how to implement hardware
acceleration in wince using DDraw &
OpenGL.
Please help me.
Thanks in Advance.
I have a complex project using SilverLight Toolkit's ListBoxDragDropTarget for drag-drop operations and it is maxing CPU. I tried to reproduce the issue in a small sample project, but then it works fine. The problem persists when I remove our custom styles and all other controls from the page, but the page is hosted in another page's ScrollView.
"EnableRedrawRegions" shows that the screen gets redrawn on every frame. My question is this: How can I track down the cause of this constant redrawing?
Let's say I have this:
NSString *str = @"This is a sample string";
How will I split the string in a way that each word will be added into a NSMutableArray?
In VB.net you can do this:
Dim str As String
Dim strArr() As String
Dim count As Integer
str = "vb.net split test"
strArr = str.Split(" ")
For count = 0 To strArr.Length - 1
MsgBox(strArr(count))
Next
So how to do this in Objective-C? Thanks
Does anyone know any sample Oracle SOAP XML requests that that queries the database?
For example, the url:
http://myoracle:7778/oracle/soap/soaprouter/
I'd like to program xml requests and get return xml database.
But I have no idea on the Oracle SOAP format.
Please provide an example.
I am working on an application with a few other people and we'd like to store our MySQL database in source control. My thoughts are two have two files: one would be the create script for the tables, etc, and the other would be the inserts for our sample data. Is this a good approach? Also, what's the best way to export this information?
Also, any suggestions for workflow in terms of ways to speed up the process of making changes, exporting, updating, etc.
Hello,
Whenever I try to create a custom window using NSBorderlessWindowMask and set an NSView (for example an NSImageView) as its contentView, I get a 1px gray border around the NSView and I don't seem to be able to get rid of it.
I have followed several approaches including Apple's RoundTransparentWindow sample code as well as several suggestions on StackOverflow.
I suspect the gray border is either coming from the window itself or the NSView.
Have any of you experienced this problem or do you have a possible solution?
Thanks
hello friends i am new to networking in iphone.i would like to see some sample code for cache its not based on image.i need for complete url. thanks in advance.
I have just tried using the NSArchiver but for some reason I am getting this error.
I have downloaded a sample project and get the same error too.
Could it be something wrong with my installation?!
Thanks
It seems like there should be a simpler way than:
import string
s = "string. With. Punctuation?" # Sample string
out = s.translate(string.maketrans("",""), string.punctuation)
Is there?
I am looking for some large public datasets, in particular:
Large sample web server logs that have been anonymized.
Datasets used for database performance benchmarking.
Any other links to large public datasets would be appreciated. I already know about Amazon's public datasets at: http://aws.amazon.com/publicdatasets/
I've heard this term used a lot in the same context as logging, but I can't seem to find a clear definition of what it actually is.
Is it simply a more general class of logging/monitoring tools and activities?
Please provide sample code/scenarios when/how instrumentation should be used.
I am trying to implement a multi threaded application with pthread.
I did implement a thread class which looks like the following and I call it later twice (or even more), but it seems to block instead of execute the threads parallel.
Here is what I got until now:
The Thread Class is an abstract class which has the abstract method "exec" which should contain the thread code in a derive class (I did a sample of this, named DerivedThread)
Thread.hpp
#ifndef THREAD_H_
#define THREAD_H_
#include <pthread.h>
class Thread {
public:
Thread();
void start();
void join();
virtual int exec() = 0;
int exit_code();
private:
static void* thread_router(void* arg);
void exec_thread();
pthread_t pth_;
int code_;
};
#endif /* THREAD_H_ */
And Thread.cpp
#include <iostream>
#include "Thread.hpp"
/*****************************/
using namespace std;
Thread::Thread(): code_(0) {
cout << "[Thread] Init" << endl;
}
void Thread::start() {
cout << "[Thread] Created Thread" << endl;
pthread_create( &pth_,
NULL,
Thread::thread_router,
reinterpret_cast<void*>(this));
}
void Thread::join() {
cout << "[Thread] Join Thread" << endl;
pthread_join(pth_, NULL);
}
int Thread::exit_code() {
return code_;
}
void Thread::exec_thread() {
cout << "[Thread] Execute" << endl;
code_ = exec();
}
void* Thread::thread_router(void* arg) {
cout << "[Thread] exec_thread function in thread" << endl;
reinterpret_cast<Thread*>(arg)->exec_thread();
return NULL;
}
DerivedThread.hpp
#include "Thread.hpp"
class DerivedThread : public Thread {
public:
DerivedThread();
virtual ~DerivedThread();
int exec();
void Close() = 0;
DerivedThread.cpp
[...]
#include "DerivedThread.cpp"
[...]
int DerivedThread::exec() {
//code to be executed
do {
cout << "Thread executed" << endl;
usleep(1000000);
} while (true); //dummy, just to let it run for a while
}
[...]
Basically, I am calling this like the here:
DerivedThread *thread;
cout << "Creating Thread" << endl;
thread = new DerivedThread();
cout << "Created thread, starting..." << endl;
thread->start();
cout << "Started thread" << endl;
cout << "Creating 2nd Thread" << endl;
thread = new DerivedThread();
cout << "Created 2nd thread, starting..." << endl;
thread->start();
cout << "Started 2nd thread" << endl;
What is working great if I am only starting one of these Threads , but if I start multiple which should run together (not synced, only parallel) . But I discovered, that the thread is created, then as it tries to execute it (via start) the problem seems to block until the thread has closed. After that the next Thread is processed.
I thought that pthread would do it unblocked for me, so what did I wrong?
A sample output might be:
Creating Thread
[Thread] Thread Init
Created thread, starting...
[Thread] Created thread
[Thread] exec_thread function in thread
[Thread] Execute
Thread executed
Thread executed
Thread executed
Thread executed
Thread executed
Thread executed
Thread executed
....
Until Thread 1 is not terminated, a Thread 2 won't be created not executed.
The process above is executed in an other class. Just for the information: I am trying to create a multi threaded server. The concept is like this:
MultiThreadedServer Class has a main loop, like this one:
::inet::ServerSock *sock; //just a simple self made wrapper class for sockets
DerivedThread *thread;
for (;;) {
sock = new ::inet::ServerSock();
this->Socket->accept( *sock );
cout << "Creating Thread" << endl; //Threads (according to code sample above)
thread = new DerivedThread(sock); //I did not mentoine the parameter before as it was not neccesary, in fact, I pass the socket handle with the connected socket to the thread
cout << "Created thread, starting..." << endl;
thread->start();
cout << "Started thread" << endl;
}
So I thought that this would loop over and over and wait for new connections to accept. and when a new client arrives, I am creating a new thread and give the thread the connected socket as a parameter.
In the DerivedThread::exec I am doing the handling for the connected client. Like:
[...]
do {
[...]
if (this-sock_-read( Buffer, sizeof(PacketStruc) ) 0) {
cout << "[Handler_Base] Recv Packet" << endl;
//handle the packet
} else {
Connected = false;
}
delete Buffer;
} while ( Connected );
So I loop in the created thread as long as the client keeps the connection.
I think, that the socket may cause the blocking behaviour.
Edit:
I figured out, that it is not the read() loop in the DerivedThread Class as I simply replaced it with a loop over a simple cout-usleep part. It did also only execute the first one and after first thread finished, the 2nd one was executed.
Many thanks and best regards,
Sebastian
what is annotation class. what is the use of it in java/android.
In iphone Annotation is used to drop a pin on the map..
java has java.lang.Annotation package... what is the use of it? can i have a examples, tutorials,sample codes, etc?
A fair bit is written about literate programming, but I've yet to see any project that uses it in any capacity, nor have I seen it used to teach programming. My sample may small, so I'm looking for evidence that literate programming exists and is successful in the real world.
I thought using colons in URIs was "illegal". Then I saw that vimeo.com is using URIs like http://www.vimeo.com/tag:sample.
What do you feel about the usage of colons in URIs?
How do I make my Apache server work with the "colon" syntax because now it's throwing the "Access forbidden!" error when there is a colon in the first segment of the URI?
Hi,
I am able to list Documents from "Public Folders"
Using this sample code :
session.LogonExchangeMailbox("[email protected]", "server");
RDOFolder folder = session.GetFolderFromPath(@"\Public Folders\All Public Folders");
Now i want to Extract this documents to another location.
The problem: combobox is databound to a DataView, first item in the dataview is DataRowView whose fields are DBNull.Value; Combo DropdownStyle = ComboBoxStyle.DropDownList
Loads fine, displays fine, selects fine, problem is to Unselect via code. Setting the SelectedIndex to 0 throws an exception. (Setting to -1 is a no-no as per msdn doco that says dont set SelectedIndex=-1 if databound)
So how to unselect without throwing an exception ?
For now i wrapped it into a try/catch to just ignore the error!
EDIT: As asked by Hubeza, i worked on sample code to post. Did a stripped down version of the original code in C# (original is in VB.NET) and could NOT reproduce it either. Converted to VB.NET and could NOT reproduce it either ! In other words, SelectedIndex = 0 does work in the stripped down version!
Currently further investigating what else could be wrong with the original code.
EDIT2: Case Closed. Call me a stupid fool if you like, and apologies for wasting anyone's time - The error was originating from MyComboBox_SelectedIndexChanged event, which i neglected to check !
May as well post the sample in case anyone finds useful.
private void LoadComboMethod() {
DataTable dtFruit = new DataTable("FruitTable");
//define columns
DataColumn colID = new DataColumn();
colID.DataType = typeof(Int32); //VB.NET GetType(Int32)
colID.ColumnName = "ID";
DataColumn colDesc = new DataColumn();
colDesc.DataType = typeof(String);
colDesc.ColumnName = "Description";
//add columns to table
dtFruit.Columns.AddRange(new DataColumn[] { colID, colDesc });
//add rows
DataRow row = dtFruit.NewRow();
row[colID] = 1; row[colDesc] = "Apples";
dtFruit.Rows.Add(row);
row = dtFruit.NewRow();
row[colID] = 1; row[colDesc] = "Bananas";
dtFruit.Rows.Add(row);
row = dtFruit.NewRow();
row[colID] = 1; row[colDesc] = "Oranges";
dtFruit.Rows.Add(row);
//add extra blank row.
DataRowView drv = dtFruit.DefaultView.AddNew();
drv.EndEdit();
//Bind combo box
DataView dv = new DataView(dtFruit);
dv.Sort = "ID ASC"; //ensure blank item on top
cboFruit.DataSource = dv;
cboFruit.DisplayMember = "Description";
cboFruit.ValueMember = "ID";
}
private void UnselectComboMethod() {
if (cboFruit.SelectedIndex > 0)
{
cboFruit.SelectedIndex = 0;
}
else
{
MessageBox.Show("no fruit selected");
}
}
GAE Datastore Table Display using JSON and Google Visualization Table?
Anyone has experience on this? How Google Visualization Table will render pagination with JSON? Really need an example on how to do this or another solution on achieving same result?
I just want to render my table just like this sample using above methode and source.
Thx
Hi, I'm new to R, and I'm having trouble figuring out how to replace the FOR loop in the function below. The function estimates a population mean. Any help at all would be much appreciated. Thank you!
myFunc<- function(){
myFRAME <- read.csv(file="2008short.csv",head=TRUE,sep=",")
meanTotal <- 0
for(i in 1:100)
{
mySample <- sample(myFRAME$TaxiIn, 100, replace = TRUE)
tempMean <- mean(mySample)
meanTotal <- meanTotal + tempMean
}
cat("Estimated Mean: ", meanTotal/100, "\n") #print result
}
I currently have a Service in Android that is a sample VOIP client so it listens out for SIP messages and if it recieves one it starts up an Activity screen with UI components.
Then the following SIP messages determine what the Activity is to display on the screen.
For example if its an incoming call it will display Answer or Reject or an outgoing call it will show a dialling screen.
At the minute I use Intents to let the Activity know what state it should display.
An example is as follows:
Intent i = new Intent();
i.setAction(SIPEngine.SIP_TRYING_INTENT);
i.putExtra("com.net.INCOMING", true);
sendBroadcast(i);
Intent x = new Intent();
x.setAction(CallManager.SIP_INCOMING_CALL_INTENT);
sendBroadcast(x);
Log.d("INTENT SENT", "INTENT SENT INCOMING CALL AFTER PROCESSINVITE");
So the activity will have a broadcast reciever registered for these intents and will switch its state according to the last intent it received.
Sample code as follows:
SipCallListener = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(SIPEngine.SIP_RINGING_INTENT.equals(action)){
Log.d("cda ", "Got RINGING action SIPENGINE");
ringingSetup();
}
if(CallManager.SIP_INCOMING_CALL_INTENT.equals(action)){
Log.d("cda ", "Got PHONE RINGING action");
incomingCallSetup();
}
}
};
IntentFilter filter = new IntentFilter(CallManager.SIP_INCOMING_CALL_INTENT);
filter.addAction(CallManager.SIP_RINGING_CALL_INTENT);
registerReceiver(SipCallListener, filter);
This works however it seems like it is not very efficient, the Intents will get broadcast system wide and Intents having to fire for different states seems like it could become inefficient the more I have to include as well as adding complexity.
So I was wondering if there is a different more efficient and cleaner way to do this?
Is there a way to keep Intents broadcasting only inside an application?
Would callbacks be a better idea? If so why and in what way should they be implemented?
I'm trying to run sample Perl script on Windows 7 and I configured IIS 7 to allow ActivePerl to run but I'm getting this error:
HTTP Error 502.2 - Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "Hello World. ".
Module CgiModule
Notification ExecuteRequestHandler
Handler Perl Script (PL)
Error Code 0x00000000
Requested URL http://localhost:80/hello.pl
Physical Path C:\inetpub\wwwroot\hello.pl
Logon Method Anonymous
Logon User Anonymous
and here is my Perl script:
#!/usr/bin/perl
print "Hello World.\n";
I'd set up a site a while back using Django-CMS and it was working fine. However, after upgrading to the latest version of both Django and Django-CMS, it doesn't work anymore...when I try to run the development server, I get this message:
"Signal recerivers must accept keyword arguments (**kwargs)."
AssertionError: Signal receivers must accept keyword arguments (**kwargs).
What could be the problem here? I've tried running the sample app that comes with the CMS and it works just fine.
When trying to run the sample code here: http://www.nikhilk.net/Live-Search-REST-API.aspx
I get:
Error 52 The type or namespace name 'IDynamicObject' could not be found (are you missing a using directive or an assembly reference?) E:\repo\NikhilK-dynamicrest-a93707a\NikhilK-dynamicrest-a93707a\Core\DynamicObject.cs 19 43 DynamicRest
The project is running .net 4 - shouldn't this be a part of the standard imports? am i missing something? What do i need to do to make this work?