on-internet

TCP Server in VB.NET

I am not a software programmer but I have a task to create a TCP Server (a program that is listening on its network card interfaces for incoming data streams). I have searched on the internet and I found that I can use two methods: Socket or TCPListener class. I have created an example for the Socket class, but I was wondering how I can test it? If another computer in the network sends some string data to the listener computer, then the message should be displayed. Here is the example from Microsoft that I am using for the TCP server using a Socket: Public Shared Sub Main() ' Data buffer for i

Join the discussion →

2d trilateration

I am writing some code to participate in an AI challenge. The main objective for the AI challenge is to take a simulated robot and navigate it through a maze to a destination zone. The secondary objective which is optional is to find a recharger placed in the maze at an unknown location. This is all done in a 2D grid. My program can call a method to get a distance measurement from the recharger. So using trilateration I should be able to locate the recharger by calling this method, recording my ai's current position and the distance the recharger is away from that point 3 times over. I found t

Join the discussion →

How to get the CUDA version?

Is there any quick command or script to check for the version of CUDA installed? I found the manual of 4.0 under the installation directory but I'm not sure whether it is of the actual installed version or not.

Join the discussion →

Disable scrolling on ``

Is it possible to disable the scroll wheel changing the number in an input number field? I've messed with webkit-specific CSS to remove the spinner but I'd like to get rid of this behavior altogether. I like using type=number since it brings up a nice keyboard on iOS.

Join the discussion →

Using Named Captures with regex match in Ruby's case...when?

I want to parse user input using named captures for readability. When they type a command I want to capture some params and pass them. I'm using RegExps in a case statement and thus I can't assign the return of /pattern/.named_captures. Here is what I would like to be able to do (for example): while command != "quit" print "Command: " command = gets.chomp case command when /load (?<filename>\w+)/ load(filename) end end

Join the discussion →

How to set Java environment path in Ubuntu

I just installed JDK in Ubuntu with sudo apt-get install openjdk-6-jdk command, after the installation where's the Java bin directory located? And how can I set the environment path for that directory? I have little experience with Ubuntu, can anyone give some advice or suggest any good website for reference?

Join the discussion →

"IOException: There is not enough space on the disk." while there is enough space

I made sequence of operations (on local disk): Copy file to ###.bak Save file to ### Delete file ###.bak Code: File.Copy(filename, filename + ".bak"); TextWriter writer = new StreamWriter(filename); writer.Write(content); writer.Close(); File.Delete(filename + ".bak"); During deleting I got exception: IOException: There is not enough space on the disk. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) Size of both files is maximum few MB. And I checked - there is enough free space

Join the discussion →

Default array values if key doesn't exist?

If I have an array full of information, is there any way I can a default for values to be returned if the key doesn't exist? function items() { return array( 'one' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), 'two' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), 'three' => array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, ), ); } And in my code $items = items(); echo $items['one']['a']; // 1 But can I have a default value to be returned if I give a key that doesn't exist like, $items = items(); echo $items['four']['a']; // DOESN'T EXIST RETURN DEFAULT OF 99

Join the discussion →

Make your own certificate for signing files

Is there a way to make your own signing certificate in order to sign files, such as installation packages? Is the problem that the certificate supplier has to be a trusted source with Windows, otherwise you will get warning messages?

Join the discussion →

How can I find and count number of files matching a given string?

I want to find and count all the files on my system that begin with some string, say "foo", using only one line in bash. I'm new to bash so I'd like to avoid scripting if possible - how can I do this using only simple bash commands and maybe piping in just one line? So far I've been using find / -name foo*. This returns the list of files, but I don't know what to add to actually count the files.

Join the discussion →

How to prevent an abstract class with public derived classes from being inherited in other assemblies?

I want to write something like the following: internal class InternalData { } public class PublicData { } abstract internal class Base { internal Base() { } private static InternalData CreateInternalDataFromPublicData(PublicData publicData) { throw new NotImplementedException(); } abstract protected void DoProcess(InternalData internalData); public void Process(PublicData publicData) { InternalData internalData = CreateInternalDataFromPublicData(publicData); DoProcess(internalData); } } public sealed class Derived : Base { protected override void DoProcess(InternalData internalData) { throw ne

Join the discussion →

Non-blocking on STDIN in PHP CLI

Is there anyway to read from STDIN with PHP that is non blocking: I tried this: stream_set_blocking(STDIN, false); echo fread(STDIN, 1); and this: $stdin = fopen('php://stdin', 'r'); stream_set_blocking($stdin, false); echo 'Press enter to force run command...' . PHP_EOL; echo fread($stdin, 1); but it still blocks until fread gets some data. I noticed a few open bug reports about this (7 years old), so if it can't be done, does any one know any crude hacks that could accomplish this (on Windows and Linux)? https://bugs.php.net/bug.php?id=34972 https://bugs.php.net/bug.php?id=47893 https://bugs

Join the discussion →

Set position absolute and margin

I would like to set an element's position to absolute and have a margin-bottom, but it seems that the margin-bottom doesn't have an effect. HTML: <div id='container'></div> CSS: #container { border: 1px solid red; position: absolute; top: 0px; right: 0px; width: 300px; margin-bottom: 50px; // this line isn't working }

Join the discussion →

Run .bat file from C#

i am facing a strange issue , i have a .bat file which contains a code for renaming a file , when i open the .bat file manually it does what it is written on it which is renaming a file , but when i try to open it programtically from C# , it doesnt do anything , it jsut open the file and do not compile what it is written into . i typed that code : Process.Start(@"file.bat"); I also knew if you typed the path into cmd and pressed enter it will open the file and compile it , so i wrote that : ProcessStartInfo psi3 = new ProcessStartInfo("cmd", "/c " + '"'+"D:\\my Work\\My Soft\\CA Delete\\CA Del

Join the discussion →

Failed to instantiate SLF4J LoggerFactory on Spring 'mvc-basic' tutorial

I'm trying a Spring 3.x tutorial on Eclipse 3.7 with m2e and Maven Integration for WTP plugins installed. I converted the above tutorial to Maven Project, but when i deploy the web application i get the following exception: Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level My pom.xml look like this: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0

Join the discussion →

Get n-th bit of an integer

I am given a large integer a, and a (relatively small) integer n. What is the fastest way to get the nth bit (with the least significant bit being 0) of the binary representation of a using native Python?

Join the discussion →

ExecuteReader: CommandText property has not been initialized

I've done a few hours of research but nothing seems to apply to my current situation. Using: Visual Studio 2010 .net 4.0, Language: C# Issue: I created a form and then drag and dropped the Specific Table from my Datasources onto the form to have VS2010 create the data table for me. When I attempted to change or add values to the database using the data table, I get the error listed above "ExecuteReader: CommandText property has not been initialized". As from my previous research, NO, I have not defined a CommandText nor do I know where to create one considering VS2010 created all the datatable

Join the discussion →

What is ':-!!' in C?

I bumped into this strange macro code in /usr/include/linux/kernel.h: /* Force a compilation error if condition is true, but also produce a result (of value 0 and type size_t), so the expression can be used e.g. in a structure initializer (or where-ever else comma expressions aren't permitted). */ #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) What does :-!! do? Update: In recent times, the macro has been moved to /usr/include/linux/build_bug.h

Join the discussion →

MATLAB C API: What does mxDestroyArray(NULL) do?

I use MATLAB's mxDestroyArray() function and wonder how to do proper error handling. If I called mxCreate*Array() or similiar, I get a valid pointer on success and NULL on failure, i. e. if memory is full. If I create several arrays in this way and at least one fails, I would like to free all what I don't need any longer. Here I am wondering: Do I need to explicitly check every value? if (error) { if (a) mxDestroyArray(a); if (b) mxDestroyArray(b); if (c) mxDestroyArray(c); } or can I just omit the checks? if (error) { mxDestroyArray(a); mxDestroyArray(b); mxDestroyArray(c); }

Join the discussion →

ZK Listbox: Horizontal scrollbar not appearing with hflex=min (in other container/Tabbox)

Here's a snap of the problem: Link to a picture of the problem Layout works correctly without hflex="min" - but of course then the columns are too narrow. Here is the blowup: <?xml version="1.0" encoding="UTF-8"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <zk> <style> .module-alternative-amount-cell { text-align: right; } .cost-entry-alternative-amount-cell { text-align: right; } </style> <window id="thisEditor" width="99%"> <!-- header label --> <vbox> <space height="5px" /> <hbox> <space width="5px" /> <label id="header" value="A header" style="font-weight:bold;font-

Join the discussion →

Recover the deleted files in amazon ec2

How I would recover the recent deleted files from amazon ec2 ubuntu server.For example The all "tar" files are removed unfortunately in amazon ec2 + ubuntu 11.04 instance. The removed files should be retrieved. Could you suggest for this problem?

Join the discussion →

Connect to SQL Server instance using pymssql

I'm attempting to connect to a SQL Server instance from a Windows box using pymssql (version 2.0.0b1-dev-20111019 with Python 2.7.1). I've tried the most basic approach from the console: import pymssql c = pymssql.connect(host = r'servername\instance', user = 'username', password = 'userpassword') In response to this, I get the very helpful error: InterfaceError: Connection to the database failed for an unknown reason. I am reasonably confident that the connection information is correct, as it works when I use adodbapi, with the following commands: import adodbapi c = adodbapi.connect(r'Provid

Join the discussion →

what does curly brackets {} do in a PHP string? [duplicate]

For example, check this following query; $query = "SELECT * FROM users WHERE user='{$_POST['username']}'; What's the use? In string contexts, I do understand the problem it solves. I can do stuff like $animal = "cat" echo "{$animal}s." // outputs cats but in the SQL I posted above, I just don't get it. Wouldn't the following be equally good? $query = "SELECT * FROM users WHERE user='$_POST['username']' AND password='$_POST['password']'"; So, Where does using the { and } get handy? Appreciate any example in SQL context?

Join the discussion →
Older stories