Hi All,
I've got a javascript application that sends a large amount of numerical data down the wire. This data is then stored in a database. I am having size issues (too much bandwidth, database getting too big). I am now ready to sacrifice some performance for compression.
I was thinking of implementing a base 62 number.toString(62) and parseInt(compressed, 62). This would certainly reduce the size of the data but before I go ahead and do this I thought I would put it to the folks here as I know there must be some outside the box solution I have not considered.
The basic specs are:
- Compress large number arrays into strings for JSONP transfer (So I think UTF is out)
- Be relatively fast, look I'm not expecting same performance as I have now but I also don't want gzip compression either.
Any ideas would be greatly appreciated.
Thanks
Guido Tapia
I am trying this technique but error is coming. Please help me to convert a number from string to integer.
#include<iostream>
using namespace std;
int main()
{
char *buffer[80];
int a;
cout<<"enter the number";
cin.get(buffer,79);
char *ptr[80] = &buffer;
while(*ptr!='\0')
{
a=(a*10)+(*ptr-48);
}
cout<<"the value"<<a;
delete ptr[];
return 0;
}
Errors are:
error C2440: 'initializing' : cannot convert from 'char ()[80]' to 'char *[80]'
error C2440: '=' : cannot convert from 'char *' to 'int'
I have to print the series shown below in java:
***1***
**2*2**
*3*3*3*
4*4*4*4
My current implementation is:
public static void printSeries(int number,int numberOfCharsinEachLine){
String s="*";
for(int i=1;i<=number;i++){
int countOfs=(numberOfCharsinEachLine-(i)-(i-1))/2;
if(countOfs<0){
System.out.println("Can't be done");
break;
}
for(int j=0;j<countOfs;j++){
System.out.print(s);
}
System.out.print(i);
for(int k=1;k<i;k++){
System.out.print(s);
System.out.print(i);
}
for(int j=0;j<countOfs;j++){
System.out.print(s);
}
System.out.println();
}
}
But there are lot of for loops, so I'm wondering whether this can be done in a better way or not?
How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of arity 1 or 2.
Example:
int myrandom(void){
static int x;
x = some_step1;
x = some_step2;
x = some_step3;
return x;
}
Basic arithmetic operations are +,-,%,and, not, xor, or, left shift, right shift, multiplication and division. Of course, no rand(), random() or similar staff is allowed.
I have a string like this:
33 00 4b 46 ff ff 03 10 30 t=25562
I am only interested in the five digits at the very end after the t=
How can I get this numbers with a regular expression out of it?
I tried grep t=..... but I also got all characters including the t= in the beginning, which I would like to drop?
After finding that five digit number, I would like to divide this by 1000. So in the above mentioned case the number 25.562. Is this possible with grep and regular expressions?
Thanks for your help.
I want to divide a list in "a specific number of" sublists.
That is, for example if I have a list List(34, 11, 23, 1, 9, 83, 5) and the number of sublists expected is 3 then I want List(List(34, 11), List(23, 1), List(9, 83, 5)).
How do I go about doing this? I tried grouped but it doesn't seem to be doing what I want.
PS: This is not a homework question. Kindly give a direct solution instead of some vague suggestions.
I have a label and I got some text from database.
text format like: Windows Server 2008 ...etc
But sometimes there are different fonts or something like style. How can I remove all of them quickly?
I know I can make it with replace command. But is there any quick way for it?
I know this might seem a controversial question but it really is not meant to be.
is there an optimal number of methods in an interface.
For example, I personally hate an interface with 20 methods. It is just difficult to implement. The contract seems to hard to maintain.
Similarly if the number of methods is just 1. It makes me wonder if it is really a good abstraction.
Any thoughts ?
If I have a 32 bit two's complement number and I want to know what is the easiest way to know of two numbers are equal... what would be the fastest bitwise operator to know this? I know xor'ing both numbers and check if the results are zero works well... any other one's?
how about if a number is greater than 0?? I can check the 31'st bit to see if it's greater or equal to 0..but how about bgtz?
I am having a problem in php switch case.
When i set $number=0 it should run very first case but here this code returns 10-20K that is in second case.
I checked comparison operators, tested them in if else case they return correct values but here first case do not run on $number=0
Why is this happening ? php consider 0 as false or something wrong in code ?
Link to codepad paste http://codepad.org/2glDh39K
also here is the code
<?php
$number = 0;
switch ($number) {
case ($number <= 10000):
echo "0-10K";
break;
case ($number > 10000 && $number <= 20000):
echo "10-20K";
break;
case ($number > 20000 && $number <= 30000):
echo "20-30K";
break;
case ($number > 30000 && $number <= 40000):
echo "30-40K";
break;
case ($number > 40000 && $number <= 50000):
echo "40-50K";
break;
case ($number > 50000 && $number <= 60000):
echo "50-60K";
break;
case ($number > 60000 && $number <= 70000):
echo "60-70K";
break;
case ($number > 70000 && $number <= 80000):
echo "70-80K";
break;
case ($number > 80000 && $number <= 90000):
echo "80-90K";
break;
case ($number > 90000):
echo "90K+";
break;
default: //default
echo "N/A";
break;
}
?>
Hi all,
My system is Vista Business 32 bits SP2.
When I click "Windows update", I can see there are 2 available optional updates. If I click the link "2 optional updates are available" to see what the updates are, I get:
http://leodip.s3.amazonaws.com/windows%5Fupdate2.PNG
The details about the updates are EMPTY. Any idea why this is happening? It doesn't happen only with optional updates, but with critical updates as well.
I would like to fix this, so I can see what the updates are.
Thanks!
I have a router that sets up rules like so:
TCP Any -> 5800
Any -> 5900
UDP Any -> 5800
Any -> 5900
Computer: ip-address
This would allow someone 'outside' to connect to my router's port 5800 and 5900 and forward that to the same port on my computer.
My issue is that I want the 'outside' port to be different without changing the port on my computer.
I have a MySQL table naming Invoice for a Inventory Monitoring site, invoice_number is bigint(19) AUTO_INCREMENT field.
Currently AUTO_INCREMENT value is 1.
Client want it to start the invoice_number from 50000.
With the following script reset the ALTER TABLE INVOICES AUTO_INCREMENT = 50000;
When I wrote an Insert Script to insert data in SQLDBX, it is putting the invoice_number from 50000.
But when i am trying to do insert a record using the application(web application), the invoice_number value is starting from 1.
We are making use of Spring-JDBC template to insert data into mysql database.
I have a virtual machine with Mandriva 2007.0 (yes, old - unfortunately we do not have a choice here). Anyway, the problem:
Before reboot: active network interface = eth0. No other interfaces present, and network manager confirms this. Static IP address set to 172.31.2.22. No issues, everything working properly, routing et al.
-------Reboot---------
After reboot: active network interface = eth1, with a DHCP address. Network manager shows eth0 as disconnected, and not connectable. When I try to set eth1 up with the static IP address (same one), it says "In Use". I then tried ifconfig eth0 172.31.2.29 just to free it up from the eth0 interface so I could use it with eth1 (since this is connected).
Result:
ifconfig eth0 172.31.2.29
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
Nothing else changed. Any ideas what could be happening, or at least how I can get my IP address back?
I have seen automated support ticketing systems which will email the user as soon as their ticket is created with a custom email address for that ticket.
For example, [email protected]
Does postfix support such a system? Are there any examples out there that might explain how this system might work?