w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Character movement tied to keypress, increases animation speed with increased character speed
You'll need to manage your own animation system, but it's not as hard as it sounds :) Something like this should work (assuming frame 0 is standing, and frame 1-n is running): public var dir:int = 0; // direction you're going; -1 = left, 1 = right, 0 = not moving public var speed:Number = 0.0; // the speed of your char public var stickman:Stickman; // your stickman obj public var prevTime:Number = 0.0; // used to calculate delta time in the update public var currAnimTime:Number = 0.0; // our current animation time public var currAnimFrame:int = 0; // our current animation frame public function gameScreen():void { // create our stickman this.stickman = new Stickman(); this.stickman.gotoAndStop( 0 ); // stand frame … // add our listeners this.addEventListener( E

Categories : Actionscript

HCM (High Contrast Mode) white vs black detection
http://www.w3.org/WAI/PF/aria-practices/#accessiblewidget Scroll down to 2.12 Compensate for Background Images when in High Contrast Mode

Categories : Javascript

High Speed Collisions in Unity
It turns out I only needed to got to ProjectSettings -> Time -> Fixed TimeStep There you just need to raise the number by a little bit. Be careful though, if you raise the value too much it will freeze the program.

Categories : C#

High speed, between-frame, graphics architecture for java
instead of interacting through Graphics2D you should interact direct with image data. This is my code, with my laptop can run with 20 frame/second (fullscreen) @SuppressWarnings("serial") class TestPanel extends JPanel { int w, h; private static int WIDTH = 700; private static int HEIGHT = 500; private static final Color BACKGROUND_COLOR = Color.white; private BufferedImage bImg; private Color color = Color.black; public TestPanel() { bImg = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RGB); Graphics g = bImg.getGraphics(); g.setColor(BACKGROUND_COLOR); g.fillRect(0, 0, WIDTH, HEIGHT); Timer myTimer = new Timer(10, new ActionListener() { @Override public void actionPerformed(ActionEv

Categories : Java

High speed data acquisiton using REST Services
Using WCF yes. I'm not sure REST is the best architectural style for the type of problem you are trying to solve. I also wonder whether HTTP is appropriate. Having said that you might want to look into CORE which is an effort to apply REST in highly constrained environments like data acquisition.

Categories : Wcf

Is it possible to get "blur motion" by moving an object at high speed programatically
To get a blur effect in flash you need to apply a blur filter to it. You can create and apply this filter to an object in code and adjust the amount of blur as well. For a motion blur, you could apply filter and use the object's speed as a multiple for the amount of blur you want.

Categories : Actionscript

High clock speed vs multiple cores/CPUs in a web server
There are two different situations that we can consider: - One kind of processor that is just used for calculations for a single program. In this situation, the Processor speed is more important as the user want the ability to do quickly and efficiently. Its not the case with web server. - On the other hand the processor used for multiple programs running at the same time. ( concurrent processes) The second is where multiple cores come in handy, as each program can be assigned to a separate core, thus freeing each program from 'bottle-necking' each other. - From Intel :) Software developers can no longer rely on increasing clock speeds alone to speed up single-threaded applications; instead, to gain a competitive advantage, developers must learn how to properly design their applic

Categories : PHP

inserting zeros between the elements of vector with high performance and speed ( preferred to use STL)
The reason it is slow is because the members of the vector are getting moved multiple times. Think about the members in the last row of your image. They all have to be moved once for every row of the image. It would be faster to create a whole new image, copying just the pixels you need from the original image and adding zeros where appropriate. Here's an example: void padColumns( std::vector<unsigned char> &old_image, size_t old_width, size_t new_width ) { size_t height = image.size() / old_width; assert(image.size() == old_width*height); std::vector<unsigned char> new_image(new_width * height); for (size_t row=0; row!=height; ++row) { std::copy( old_image.begin() + row*old_width, old_image.begin() + row*old_width + old_width,

Categories : Visual Studio 2010

Socket and ports setup for high-speed audio/video streaming
I think it is better to use an object mechanism and send data in an interleaved fashion. This mechanism may work faster than multiple port mechanism. eg: class Data { DataType, - (Adio/Video) Size, - (Size of the Data buffer) Data Buffer - (Data depends on the type) } 'DataType' and 'Size' always of constant size. At the client side take the 'DataType' and 'Size' and then read the specifed size of corresponding sent data(Adio/Video).

Categories : C#

TCP/UDP high-performance server under linux
Your basic approach is right. Start by studying the infamous C10K problem and how it was overcome. Once you understand the major bottlenecks in various implementations, you need to consider the following as part your design process : Minimise thread creation/deletion cycles. Always choose an "event-based" model over a blocking model. Basically the one-thread-per-request model is preferred for its simplicity of implementation. But it does NOT scale well with the number of concurrent requests. When designing systems required to support more than a few 1000 concurrent requests, one prefers the use of sockets over threads. The optimum number of "worker-threads" to instantiate depends upon : Load (number of concurrent requests) System (CPU, RAM) Since this is a very popular probl

Categories : Linux

Linux free shows high memory usage but top does not
Don't look at the "Mem" line, look at the one below it. The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free). The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

Categories : Linux

How do i make 3D collision detection with my terrain and my character? LWJGL
I'd recommend you to use an existing game engine for the physics. It is because writing a collision detection (and collision resolving) may be very tricky. Especially in 3D. You also need to know trigonometry very well. If you don't want to use third party products and want to write your own engine, you'll have your collision detection look like this: Contact contact = Engine.getFirstHit(Terrain.getNearestPolygons(player), player); if (contact.isHit) { player.move(player.getVelocity().multiply(contact.getMoveAmount())); contact.resolve(); } else { player.move(player.getVelocity()); } where Engine.getFirstHit() and contact.resolve() will do all the work. You can check references and "see also" section on the Collision Detection wiki page.

Categories : Java

How to speed up compilation time in linux
The rule of thumb is to use the number of processors+1. Hyper-Thready counts, so a quad core CPU with HT should have -j9 Setting the value too high is counter-productive, if you do want to speed up compile times consider ccache to cache compiled objects that do not change in each compilation, and distcc to distribute the compilation across several machines.

Categories : Linux

How to check CPU name, model, speed on Windows/Linux C?
For Windows, you'll want the GetSystemInfo function; Microsoft has an example. On Linux, /proc/cpuinfo is perfectly "safe", whatever that means, but there's already an answer to this question.

Categories : C

Uart 16c950 linux speed above B4000000 (4Mbps)
This page has a Linux kernel patch that adds direct exposure of the registers, so that ioctl() can be used to program custom baud rates. It's pretty old though, but might be useful for you.

Categories : C

how can I see the values of RS232
There is some software here: http://www.serial-port-monitor.com/ Also search the net for "serial port snooping", "serial port analyzer"

Categories : Testing

ReadFile Rs232 Too Slow
I find and correct my problem, thanks to Hans Passant wich indicate me the right way ! So it's a driver issue, the big problem is that the latest Prolific driver made specially for Windows 8 and 7 and available on Windows Update and catalog.update.microsoft.com is buggy : So i downgrade to the 2010/12/03 version and now it's working perfectly. I made a procedure and you can find the working driver in this zip : http://www.soft-control.com/media/exe_soft/sav/ProlificDowngrade.3.11.zip I hope it will help anyone else who concerning by this problem !

Categories : C++

Android Rs232 Communication
You want to connect your Note 2 with your computer? So why dont you do this with adb? Add internet-permission to your app, activate port forwarding on your pc and create a tcp socket. adb commands

Categories : Android

get a character at a given position in a linux console application
The approach you're trying here is so fragile as to be impossible. GetCharAt() assumes that every character that's output is printable, and that nothing is moving the cursor around. Your SetCursorPosition() does exactly that, so the idea of tracking what has been output so far simply will not work. Plus, other processes may output stuff to the console right in the middle of your program, like a wall message from root. What you want instead is "ncurses", http://en.wikipedia.org/wiki/Ncurses, a library that probably already exists on your system. It has solved these problems already in a terminal-independent way, and provides a large suite of functions for moving around the screen, scrolling, drawing, colors, etc, all in the terminal.

Categories : C++

linux less command search invisible character
CtrlE means something special at the beginning of the search field regardless of how it is entered. Type another non-"special" character first, then press the sequence, then remove the first character.

Categories : Linux

Azure Could Computing high availoability vs NEO4J high availability?
The short answer is probably yes. Windows Azure provide you infrastructure that allow you to build high availability system, it won't make any system high available by magic. As NEO4J is state-full, each node (with only one node Azure don't give you any SLA, you instance will be down) will need to share some state and the way to do it will be dependent on how NEO4J is working. So you will need to rely on NEO4J mechanism to do it. I don't know how NEO4J is working but you won't be able to skip designing an high available architecture around NEO4J using Windows Azure infra. Cloud may be a magic buzz word that can make things append on management level, but when we are on hard real world level Harry magic wand doesn't exist.

Categories : Neo4j

rs232 communication creates error frequently
I finally can have an RS232 module that works freeing of the weird sudden stopping. Here I upload the new version of RS232.cpp The only different between the two versions is in new RS232_open(), I do not use GetCommState. Instead, the configuration is set by BuildCommDCBA using a string of setting baudr Thanks for the help of SO!

Categories : C++

Is there a way to display a vertical arrow character in a linux terminal using ncurses?
You can use the arrows in unicode, here you can find a list of unicode arrows and the relative codes. ncursesw has the support to wide character set, you should just set the locale: setlocale(LC_ALL, "")

Categories : Linux

how do I use browser detection code to run certain HTML depending on detection result?
if (isFirefox) { // do FireFox stuff here } else if (isChrome) { // do Chrome stuff here } else if (isSafari) { // do Safari stuff here } else if (isOpera) { // do Opera stuff here } else if (isIE) { // do IE stuff here } else { // other browser }

Categories : Javascript

OpenCV object detection from face detection code - ANDROID
sure, that's possible. the cascade classifier just finds, what the cascade-file was trained on, be it faces, eyes or soda-cans. lots of existing examples here , and ofc, you can train your own, opencv comes with tools for that ( cascade_training, haar_training )

Categories : Android

quicksand sorting price values low to high / high to low
val() gives you a string, so > and < comparisons are lexographical (not numeric). Try wrapping the values in parseInt() or parseFloat(). Make sure to add appropriate error handling as well.

Categories : Jquery

How do I communicate with a RS232 serial port on a remote device using TCP/IP?
You must use hardware solution. Something like this. Given it's quite expensive, you may consider looking at Rasperry PI or even Arduino-based solution.

Categories : Java

how to check line status(RS232) using Go serial library
The library you're using mentions that it doesn't support hardware flow control, so it looks like you'd have to modify it yourself. However, there is another Go serial library https://github.com/schleibinger/sio that allows you to read/set the RTS,CTS,DTR and DSR pins. If you are using a virtual serial port over USB this should allow you to do what you want to do. The source code is only 1 file--the relevant methods are near the bottom. However, if you are using the Raspberry Pi's GPIO pins, this library won't work for this.

Categories : Go

Send data to rs232/usb-adapter via socket in java
The writeUTF function writes the length of the string before its characters. What you can use is plain write: byte[] bytes = {0x1B, 0x40, ...}; out.write(bytes)

Categories : Java

How can we display * for every character we enter ( password prompt ) using system calls in linux?
You can use non-canonical mode without echo. See an example here In this example, I modified the following lines else putchar (c); with else { putchar (c+1); fflush(stdout); }

Categories : C

Barcode detection using Hough Transform & Edge Detection
So, the Hough transform MUST be used? Barcode analysis is usually much easier than this, since you know a priori that all the barcode lines are parallel. If you can guarantee that they will be scanned relatively accurately (ie: the bar code scanner is operated roughly perpendicular to the barcode lines, give or take 30 degrees each way), you can just take a single "slice" of the barcode image, so it goes from an MxN image to a 1xN image. You then just convert the image to plain black and white, either using thresholding, or segmentation (ie: K-means segmentation). You can then perform noise removal (a median or mode filter would be ideal) so that a single noisy pixel doesn't split a single barcode line into two separate lines. Finally, a single for loop can be used to calculate the width

Categories : Matlab

How multiscale detection loop works in OpenCV's HOG detection?
If you look at the source code for this function void HOGCache::init(const HOGDescriptor* _descriptor, const Mat& _img, Size _paddingTL, Size _paddingBR, bool _useCache, Size _cacheStride) You will see the following comments // Initialize 2 lookup tables, pixData & blockData. // Here is why: // // The detection algorithm runs in 4 nested loops (at each pyramid layer): // loop over the windows within the input image // loop over the blocks within each window // loop over the cells within each block // loop over the pixels in each cell // // As each of the loops runs over a 2-dimensional array, // we could get 8(!) nested loops in total, which is very-very slow. // // To speed the things up, we do the following: // 1. loop over windows is unrolle

Categories : C++

Varnish High DB Connections In High Traffic
Mostly spiking backend connections has little to do with your varnish configuration but alot to do with the cachability of your site. Are there cookies that prevents you from caching efficiently? You can chose to strip them or remove all but chosen ones, there are examples for both on the varnish site. Do a varnishstat and check your hit rates during peaks. Is it a good cache hitratio? Is it the same as during low load? If it's the same or higher in low load it's easy to work on improving it at any time. Do a varnishtop -i txurl to see what requests are the most frequently sent to backend servers. Maybe it's some URLs that are just not cached due to faulty headers? Maybe some pages can be cached longer? Maybe some parts of the pages can be cached with ESI? Make sure your varnish is not

Categories : Mysql

Reduce false detection in Pedestrian Detection
You could apply a background subtraction algorithm on your video stream. I had some success on a similar project using BackgroundSubtractorMOG2. Another trick I used is to eliminate all "moving pixels" that are too small or with a wrong aspect ratio. I did this by doing a blob/contour analysis of the background subtraction output image. You need to be careful with the aspect ratio to make sure you support overlapping pedestrians. Note that the model you're using (not sure which) is probably trained on a front faced pedestrian and not with a 45 degrees angle down. This will obviously affect your accuracy.

Categories : Opencv

PHP Download file, limit max speed and calculate downloading speed
How about (re)adding that sleep(1); thing to the WHILE loop? From what I can see the script outputs the file almost all at once (as fast as it can) and there's nothing that pauses it so it can actually limit the download speed. That way you will know that each second you send just 64kbytes (or whatever) and even though you can't be sure that the user can in fact recieve this much data/second (whoa, so fast!), it could be a bit more precise than what you have in there now. Or am I getting this wrong?

Categories : PHP

When to use low < high or low + 1 < high for loop invariant
If your invariant is that the target must lie in low <= i <= high, then you use while (low < high); if your invariant is that the target must lie in low <= i < high then you use while (low + 1 < high). [Thanks to David Eisenstat for confirming this.]

Categories : Algorithm

change update speed without changing loop speed?
To clarify on the concept of 'delta time', if you were to simply increment a counter without scaling it against real time, it would increment as fast as draw is called. However by scaling it, you are guaranteed a certain amount of frames per second. This way, you can always be sure that your animation is as slow or as fast as you want it. You can set your threshold to be for example 500 milliseconds (one frame every half a second), and so on. var counter = 0; function draw() { // deltaTime is how you plan on counting real seconds // against your frame ticks counter += deltaTime; ... // threshold would be your delay if (counter >= threshold) { hero.frames++; if (hero.frames >= 2) hero.frames = 0; counter = 0; } } setInterval( draw, 1000 / 5 );

Categories : Javascript

Deleting a character within a string an replacing with a different character from a list that includes the original character
Strings are immutable in python, you should re-assign the string returned from bases.replace(base, '') to bases. bases = bases.replace(base, '')

Categories : Python

how to exclude a character in a regex pattern character class if last character?
I don't think it's possible in a single regex check... someone might be able to correct me on that, but I don't think so at the moment (Or I can't think to optimise things at the moment). What you can do, on the other hand, is run a check. Run the input through an initial replace function first to see whether there is a dot at the end or not and replace it if there is one. From there you can just feed it through the previous regex. So this is how it could go... function dotCheck( $url ) { $noDotURL = preg_replace( '/.+$/', '', $url ); return $noDotURL; } urlCheck( dotCheck( $_POST['form'] ) ); Where urlCheck is the main check to see whether it is a valid link structure or not. The regex - in verbose form - checks for any dots as the last characters in the link and deletes them.

Categories : PHP

Linux terminal input: reading user input from terminal truncating lines at 4095 character limit
I do not have a workaround for you, but I can answer question 2. In linux PIPE_BUF is set to 4096 (in limits.h) If you do a write of more than 4096 to a pipe it will be truncated. From /usr/include/linux/limits.h: #ifndef _LINUX_LIMITS_H #define _LINUX_LIMITS_H #define NR_OPEN 1024 #define NGROUPS_MAX 65536 /* supplemental group IDs are available */ #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ #define LINK_MAX 127 /* # links a file may have */ #define MAX_CANON 255 /* size of the canonical input queue */ #define MAX_INPUT 255 /* size of the type-ahead buffer */ #define NAME_MAX 255 /* # chars in a file name */ #define PATH_MAX 4096 /* # chars in a path name including nul */ #define PIPE_BUF

Categories : Linux



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.