sometime I encounter code that have , sometimes have *, can any one expand what is * and ** means in Objective C, thz you. (I used to be a Java programmer, within experience in C/C++)
I'm working on an application that accepts TCP connections and reads in data until an </File> marker is read and then writes that data to the filesystem. I don't want to disconnect, I want to let the client sending the data to do that so they can send multiple files in one connection.
I'm using the StreamReader.EndOfStream around my outter loop, but it throws an IOException when the client disconnects. Is there a better way to do this?
private static void RecieveAsyncStream(IAsyncResult ar)
{
TcpListener listener = (TcpListener)ar.AsyncState;
TcpClient client = listener.EndAcceptTcpClient(ar);
// init the streams
NetworkStream netStream = client.GetStream();
StreamReader streamReader = new StreamReader(netStream);
StreamWriter streamWriter = new StreamWriter(netStream);
while (!streamReader.EndOfStream) // throws IOException
{
string file= "";
while (file!= "</File>" && !streamReader.EndOfStream)
{
file += streamReader.ReadLine();
}
// write file to filesystem
}
listener.BeginAcceptTcpClient(RecieveAsyncStream, listener);
}
I learned math in a non-English environment, I recently read some books about algorithm analysis, I found some math concepts were confusing, and seemed not the same as what I've learned. What math textbooks would you recommend that covers math concepts from the scratch and suitable for self-learning ?
I am using a notes client(v 7.0). I created a mail account with email id [email protected] in this client(obviously on domino server also). I want to auto reply to the mail which is sent to [email protected] with same subject line which must be appended with ";SUCCESS" at the end of subject line.
I'm making an outbound connection using a DNS name to a server other than the localhost, and I get this exception:
System.Net.WebException: Unable to connect to the remote server --- System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
127.0.0.1:5555
The text implies that the TARGET machine refused the connection, but the IP address and port are from the localhost, which is kind of confusing. So is that IP address really the outgoing IP and port, even though the exception was caused by the target refusing the connection? Or is the exception from the local firewall blocking the outgoing connection?
Whitespace is signification in Python in that code blocks are defined by their indentation.
Furthermore, Guido van Rossum recommends using four spaces per indentation level (see PEP 8: Style Guide for Python Code).
What was the reasoning behind not requiring exactly four spaces per indentation level as well? Are there any technical reasons?
It seems like all the arguments that can be made for making whitespace define code blocks can also be used to argument for setting an exact whitespace length for one indentation level (say four spaces).
I am using transaction replication with push subscription. I am developing a UI for replication using RMO in C#.NET between different instances of the same database within same machine holding similar schema and structure. I am using Single subscriber and multiple publisher topology. During creation of publication i want to set a few article properties such as Keep the existing object unchanged ,allow schema changes at subscriber to false a,copy foriegn key constarint and copy check constraints to true. How do i set the article properties using RMO in C# .NET. I am using Visual Studio 2008 SP1.I also want to know as how we can select all the objects including Tables,Views,Stored Procedures for publishing at one stretch. I could do it for one table but i want to select all the tables at one stretch. This is the code snippet i used for selecting single table for publishing.
TransArticle ta = new TransArticle();
ta.Name = "Article_1";
ta.PublicationName = "TransReplication_DB2";
ta.DatabaseName = "DB2";
ta.SourceObjectName = "person";
ta.SourceObjectOwner = "dbo";
ta.ConnectionContext = conn;
ta.Create();
Closures are poor man's objects and vice versa.
I have seen this statement at many places on the web (including SO) but I don't quite understand what it means. Could someone please explain what it exactly means?
If possible, please include examples in your answer.
Thanks.
This question isn't meant as flame-bait! As it might be apparent, I've been looking at Scalaz recently. I'm trying to understand why I need some of the functionality that the library provides. Here's something:
import scalaz._
import Scalaz._
type NEL[A] = NonEmptyList[A]
val NEL = NonEmptyList
I put some println statements in my functions to see what was going on (aside: what would I have done if I was trying to avoid side effects like that?). My functions are:
val f: NEL[Int] => String = (l: NEL[Int]) => {println("f: " + l); l.toString |+| "X" }
val g: NEL[String] => BigInt = (l: NEL[String]) => {println("g: " + l); BigInt(l.map(_.length).sum) }
Then I combine them via a cokleisli and pass in a NEL[Int]
val k = cokleisli(f) =>= cokleisli(g)
println("RES: " + k( NEL(1, 2, 3) ))
What does this print?
f: NonEmptyList(1, 2, 3)
f: NonEmptyList(2, 3)
f: NonEmptyList(3)
g: NonEmptyList(NonEmptyList(1, 2, 3)X, NonEmptyList(2, 3)X, NonEmptyList(3)X)
RES: 57
The RES value is the character count of the (String) elements in the final NEL. Two things occur to me:
How could I have known that my NEL was going to be reduced in this manner from the method signatures involved? (I wasn't expecting the result at all)
What is the point of this? Can a reasonably simple and easy-to-follow use case be distilled for me?
This question is a thinly-veiled plea for some lovely person like retronym to explain how this powerful library actually works.
I've been reading a lot about how Scala and Erlang does lightweight threads and their concurrency model (actors).
However, I have my doubts.
Do Scala and Erlang use an approach similar to the old thread model used by Java (green threads) ?
For example, suppose that there is a machine with 2 cores, so the Scala/Erlang environment will fork one thread per processor? The other threads will be scheduled by user-space (Scala VM / Erlang VM ) environment. Is this correct?
Under the hood, how does this really work?
I have installed the firewiresdk26 on my dev mac...
and in the Tools/ directory is FireLog.
I have run the FireLog 2.0.0.pkg installer on my dev mac,
but the payload it deploys is installed in my /System/Library
tree, as opposed to my /Developer/SDKs tree. so when I try to include the header iokit/firewire/FireLog.h it does not get found.
am I missing something? or doing something wrong?
or is this an error in the installer (either FW26 or FireLog installers?)
I realize that the FireLog installer is intended to be run on the machine to be debugged remotely and thus it makes sense that the framework is placed in the /System/Library path,
however none of the installers gets it into my developer path... I guess I just have to move it over there by hand, but before I do that I wanted to see if I'm just overlooking something silly and need to read the docs with more concentration or something...
anyone run into this before? [thx]
Over the last few years F# has evolved into one of Microsoft's fully supported languages employing many ideas incubated in OCaml, ML and Haskell.
Over the last several years C# has extended it's general purpose features by introducing more and more functional language features: LINQ (list comprehension), Lamdas, Closures, Anonymous Delegates and more...
Given C#'s adoption of these functional features and F#'s taxonomy as an impure functional language (it allows YOU to access framework libraries or change shared state when a function is called if you want to) there is a strong similarity between the two languages although each has it's own polar opposite primary emphasis.
I'm interested in any successful models employing these two languages in your production polyglot programs and also the areas within production software (web apps, client apps, server apps) you have written in F# in the past year or so that you would previously have written in C#.
EDIT: Edited based on feedback from close votes with the intent of reducing perceived ambiguity.
Can one expect some promotional prices for MSDN subscriptions after release of MS Studio 2010 happened today on april 12 ? Or are the MSDN prices usually irrelevant to Studio releases ? Thank you.
Consider the following code:
// module level declaration
Socket _client;
void ProcessSocket() {
_client = GetSocketFromSomewhere();
using (_client) {
DoStuff(); // receive and send data
Close();
}
}
void Close() {
_client.Close();
_client = null;
}
Given that that the code calls the Close() method, which closes the _client socket and sets it to null, while still inside the `using' block, what exactly happens behind the scenes? Does the socket really get closed? Are there side effects?
P.S. This is using C# 3.0 on the .NET MicroFramework, but I suppose the c#, the language, should function identically. The reason i am asking is that occasionally, very rarely, I run out of sockets (which is a very precious resource on a .NET MF devices).
It is a wonderful, very fast, mature and complete language. It exists for a very long time and has a big set of libraries. Yet, it appears not to be widely used. Why ? I suspect it is because it is pretty rough and unforgiving for beginners, and maybe because its lazy execution makes it even harder
i have search high and low on the internet and it does not exist. i cant find a single website that shows a few applications created with realbasic. i saw a video that shows the user going to realbasic.com/community/ and it shows a load of applications created using realbasic. would anyone know where i can find this information. that link that i gave doesnt even work by them.
Hi,
I'm testing some result from HttpClient that looks irrational. It seems that setting CoreConnectionPNames.CONNECTION_TIMEOUT = 1 has no effect because send request to different host return successfully with connect timeout 1 which IMHO can't be the case (1ms to setup TCP handshake???)
Am I misunderstood something or is something very strange going on here?
The httpclient version I'm using as can be seen in this pom.xml is
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0.1</version>
<type>jar</type>
</dependency>
Here is the code:
import java.io.IOException;
import java.util.Random;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
public class TestNodeAliveness {
private static Logger log = Logger.getLogger(TestNodeAliveness.class);
public static boolean nodeBIT(String elasticIP) throws ClientProtocolException, IOException {
try {
HttpClient client = new DefaultHttpClient();
// The time it takes to open TCP connection.
client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1);
// Timeout when server does not send data.
client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);
// Some tuning that is not required for bit tests.
client.getParams().setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
client.getParams().setParameter(CoreConnectionPNames.TCP_NODELAY, true);
HttpUriRequest request = new HttpGet("http://" + elasticIP);
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
if(entity == null) {
return false;
} else {
System.out.println(EntityUtils.toString(entity));
}
// Close just in case.
request.abort();
} catch (Throwable e) {
log.warn("BIT Test failed for " + elasticIP);
e.printStackTrace();
return false;
}
return true;
}
public static void main(String[] args) throws ClientProtocolException, IOException {
nodeBIT("google.com?cant_cache_this=" + (new Random()).nextInt());
}
}
Thank you.
What are common or recommended ways to organize an application written in a functional language?
Along what lines would you decide to create separate files, modules, directories, etc.?
I have an open source Java database migration tool (http://www.liquibase.org) which I am considering porting to .Net.
The majority of the tool (at least from a complexity side) is around logic like "if you are adding a primary key and the database is Oracle use this SQL. If database is MySQL use this SQL. If the primary key is named and the database is Postgres use this SQL".
I could fork the Java codebase and covert it (manually and/or automatically), but as updates and bug fixes to the above logic come in I do not want to have to apply it to both versions. What I would like to do is move all that logic into a form that can be compiled and used by both Java and .Net versions naively.
The code I am looking to convert does not contain any advanced library usage (JDBC, System.out, etc) that would vary significantly from Java to .Net, so I don't think that will be an issue (at worst it can be designed around).
So what I am looking for is:
A language in which I can code common parts of my app in and compile it into classes usable by the "standard" languages on the target platform
Does not add any runtime requirements to the system
Nothing so strange that it scares away potential contributors
I know Python and Ruby both have implementations on for the JVM and CLR. How well do they fit my requirements? Has anyone been successful (or unsuccesful) using this technique for cross-platform applications? Are there any gotcha's I need to worry about?
I want to help the Dev team identify areas of knowledge (practical and theoretical) that they can work on. Though I am big believer in focusing on people's strengths being a good programmer requires (I think) being challenged by concepts and ideas that don't always come naturally. We work largely in the web app space using PHP & MySQL but better skills in data modelling, query optimisation, use of MVC and OOP etc. would help the team and the company a lot.
I want to help the Dev team manage their careers, explore and expand their skills sets. Be all they can be and better than they were previously. I know its an idealistic goal but work must be about more than simply getting the work done. There should be some time to review, to learn, to grow and get better. Any thoughts, ideas, opinions and directions to tests or similar resources would be greatly appreciated.
Following watching Nick Partidge's presentation on deriving scalaz, I got to looking at this example, which is just awesome:
import scalaz._
import Scalaz._
def even(x: Int) : Validation[NonEmptyList[String], Int]
= if (x % 2 ==0) x.success else "not even: %d".format(x).wrapNel.fail
println( even(3) <|*|> even(5) ) //prints: Failure(NonEmptyList(not even: 3, not even: 5))
I was trying to understand what the <|*|> method was doing, here is the source code:
def <|*|>[B](b: M[B])(implicit t: Functor[M], a: Apply[M]): M[(A, B)]
= <**>(b, (_: A, _: B))
OK, that is fairly confusing (!) - but it references the <**> method, which is declared thus:
def <**>[B, C](b: M[B], z: (A, B) => C)(implicit t: Functor[M], a: Apply[M]): M[C]
= a(t.fmap(value, z.curried), b)
So I have a few questions:
How come the method appears to take a monad of one type parameter (M[B]) but can get passed a Validation (which has two type paremeters)?
How does the syntax (_: A, _: B) define the function (A, B) => C which the 2nd method expects? It doesn't even define an output via =>
Hi,
We're experiencing a strange problem with Oracle RAC and McAfee anti-virus.
As part of the installation of the Oracle RAC we disable anti virus as directed. We have had our RAC running fine, but when we came to re-enable the AV and reboot we got the BSOD.
Abnormal Program Termination (BugCheck, STOP: 0x00000035 (0x8E984678, 0x00000000, 0x00000000, 0x00000000
NO_MORE_IRP_STACK_LOCATIONS
Following the standard process of raising this problem with Microsoft they identify the problem and also a fix. Microsoft talk about too many file filter drivers being present and pushing the DFS upper limit beyond the default size. Upping this value, as per msdn, has no impact.
We're able to recover from this BSOD by disabling AV. We don't have the problem if we run the AV service manually whilst the system is up. However, if we make the service automatic we fail to boot.
Tech Details
2 Node Oracle 10g Cluster
2 * Windows 2003 SP2, 16GB RAM, Quad Core 3ghz Processor
SAN attached storage
McAfee VirusScan Enterprise 8.5.0i,
Scan Engine (5300.2777), DAT Version
(5536.0000)
Thanks
Lee