Monday, 30 September 2013

Extracting a zip file in my machne givs me CRC error?

Extracting a zip file in my machne givs me CRC error?

I have a large zip that contain hundreds of file. I've unzip'ed it in more
than one machine and didn't have any problem before. However, for this
particular machine (Ubuntu Server 12.04) I keep getting CRC error for some
of the files inside my zip. I've unzip'ed the same file it on anther
machine just to and its fine.
Any clue?

Recurrence equation $g(k+n)=\sum_{j=1}^ng(k+n-j)$ and exponential function

Recurrence equation $g(k+n)=\sum_{j=1}^ng(k+n-j)$ and exponential function

pIf I have the recurrence equation: $$g(k+n)=\sum_{j=1}^ng(k+n-j)$$ with
$g(h)=1$ for $0\le h\lt (n-1)$, is it possible to find a value of $n$ such
that: $$\lim_{k\to\infty}\frac{\exp(k)}{g(k)}=0?$$ Thanks./p

VBA Excel Turning off Greyscale in Word Doc

VBA Excel Turning off Greyscale in Word Doc

been having an issue with an Excel Application controlling Word documents.
Basically the Excel auto fills a Word Doc and prints it on a network
printer of your choice. The issue is I need the Word Doc to be printed in
colour and I can't seem to turn off the Greyscale option when printing.
The Greyscale option is a print option in the print properties menu. I
have tried BlackAndWhite = false but with no luck.
Thanks for any help you can give me.

Handle specific german letters like ä, ö, ü

Handle specific german letters like ä, ö, ü

I have a little problem with my sencha touch app's SignIn-Function. It
seems like it cannot handle some german letters called "Umlaute" like 'ä',
'ü','ö' and 'ß'. By placing some information recieved by the server into
any view, it doesn't present the letters ä ö ü correctly.
Thank you very much for help in advance :)
onSignInCommand: function(view, username, password) {
var me = this;
loginView = me.getLoginView();
var data = Ext.JSON.encode({
"method": "getUserInfo",
"params": [username,password]
});
Ext.util.JSONP.request({
url: 'http://localhost',
headers: {
'content-type': 'application/x-www-form-urlencoded ;
charset=utf-8'
},
method: 'post',
params: {
"json": data
},
timeout: '4000',
callbackName: 'myCallback',
success: function (response) {
var loginResponse = response;
if (loginResponse.result.msg == "OK")
{
var userstore = Ext.data.StoreManager.lookup('myStore');
var userdata=response.result.user;
var usernamestore =
Ext.data.StoreManager.lookup('usernamestore');
var tokenstore = Ext.data.StoreManager.lookup('tokenstore');
var myusername = loginResponse.result.user.login;
var mytoken = loginResponse.result.user.token;
var records= userstore.getRange();
userstore.remove(records);
userstore.add(userdata);
var jsonArray = userstore.data.items;
usernamestore.add(myusername);
tokenstore.add(mytoken);
me.signInSuccess(myusername,mytoken);
var usertest = jsonArray[0].data.login;
var tokentest = jsonArray[0].data.token;
}
else{
loginView.showSignInFailedMessage('token null.');
}
},
failure: function (response) {
loginView.showSignInFailedMessage('token null.');
}
}
);
},

Sunday, 29 September 2013

How to GROUP BY on Oracle?

How to GROUP BY on Oracle?

I need help with sql oracle, my group by doesnt work and i'm working on a
shell so i don't have any help.
Can someone tell me how to group this next request by noArticle.
SELECT Article.noArticle, quantite
FROM Article LEFT JOIN LigneCommande ON Article.noArticle =
LigneCommande.noArticle
GROUP BY Article.noArticle
/
Thank you

haskell pretty print binary tree not displaying properly

haskell pretty print binary tree not displaying properly

I am trying to pretty print a binary tree in Haskell so that if you turn
your head to the left, it should look like a tree. Each level in the tree
should be indented 2 spaces from the previous level.
This is the expected output:
-- 18
-- 17
-- 16
-- 15
-- 14
-- 13
-- 12
-- 11
-- 10
-- 9
-- 8
-- 7
-- 6
-- 5
-- 4
-- 3
-- 2
-- 1
For this tree:
treeB = (Node (Node (Node (Node Empty 1 (Node Empty 2 Empty)) 3 (Node
Empty 4 Empty)) 5 (Node (Node Empty 6 Empty) 7 (Node (Node Empty 8 Empty)
9 Empty))) 10 (Node (Node (Node Empty 11 Empty) 12 (Node Empty 13 (Node
Empty 14 Empty))) 15 (Node (Node Empty 16 Empty) 17 (Node Empty 18
Empty))))
This is how tree is defined:
data BinTree a =
Empty
| Node (BinTree a) a (BinTree a)
deriving (Eq,Show)
However, my result does not look like that. Here is my result:
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
Here is my code:
prettyTree :: (Show a) => BinTree a -> String
prettyTree Empty = "\n"
prettyTree (Node Empty x Empty) = " " ++ show x ++ "\n"
prettyTree (Node Empty x r) = prettyTree' r ++ " " ++ show x ++ "\n"
prettyTree (Node l x Empty) = show x ++ "\n" ++ " " ++ prettyTree' l
prettyTree (Node l x r) = prettyTree' r ++ show x ++ "\n" ++ prettyTree' l
prettyTree' :: (Show a) => BinTree a -> String
prettyTree' Empty = "\n"
prettyTree' (Node Empty x Empty) = " " ++ show x ++ "\n"
prettyTree' (Node Empty x r) = " " ++ prettyTree' r ++ " " ++ show x ++
"\n"
prettyTree' (Node l x Empty) = " " ++ show x ++ " " ++ "\n" ++
prettyTree' l
prettyTree' (Node l x r) = " " ++ prettyTree' r ++ " " ++ show x ++ "\n"
++ " " ++ prettyTree' l
I don't understand what I'm doing wrong. Any help would be greatly
appreciated.

Code behaves differently in Android and Windows

Code behaves differently in Android and Windows

I try to draw on a bitmap. This works fine in Windows but creates a
segmentation fault in Android (anyhow, that's what Delphi says, I just see
no reaction on Android). I have a mobile project, form containing only a
TToolbar, TSpeedButton, two TLabels and a TImage. There's just one
eventhandler for the TSpeedButton click.
When I comment out everything below the comment the code works fine in
Android. When I try to follow with the debugger the code works fine to the
end of the procedure. without seeing a drawing or a segmantation fault.
When I let it run on the fault occurs.
What am I doing wrong?
procedure TForm2.Button_DrawClick (Sender: TObject);
var rct: TRectF;
h, w: Int32;
begin
h := Trunc (Image.Height);
w := Trunc (Image.Width);
Label_Height.Text := IntToStr (h);
Label_Width .Text := IntToStr (w);
rct := TRectF.Create(20, 20, w - 20, h - 20);
// can be commented out below //
Image.Bitmap.Create (w, h);
if Image.Bitmap.Canvas.BeginScene then
try
Image.Bitmap.Canvas.Stroke.Color := $FF0000FF;
Image.Bitmap.Canvas.StrokeThickness := 3;
Image.Bitmap.Canvas.DrawEllipse (rct, 20);
Image.Bitmap.Canvas.Stroke.Color := $FF00FF00;
Image.Bitmap.Canvas.DrawRect(rct, 0, 0, AllCorners, 40);
finally
Image.Bitmap.Canvas.EndScene;
end; // try..finally
end; // Button_DrawClick //

TypeError: 'int' object is not iterable // numpy

TypeError: 'int' object is not iterable // numpy

Here is my function:
import numpy as np
def calc_mean():
return np.loadtxt('GOOG.csv', skiprows=1, usecols=(5)).mean(axis=0)
Here is my GOOG.csv:
Date Open High Low Close Volume Adj Close # <--
column that I need
2013-09-27 874.82 877.52 871.31 876.39 1258800 876.39
2013-09-26 878.3 882.75 875 878.17 1259900 878.17
2013-09-25 886.55 886.55 875.6 877.23 1649000 877.23
2013-09-24 886.5 890.1 881.4 886.84 1467000 886.84
2013-09-23 896.15 901.59 885.2 886.5 1777400 886.5
2013-09-20 898.39 904.13 895.62 903.11 4345300 903.11
2013-09-19 905.99 905.99 895.4 898.39 1597900 898.39
2013-09-18 886.35 903.97 883.07 903.32 1934700 903.32
2013-09-17 887.41 888.39 881 886.11 1259400 886.11
2013-09-16 896.2 897 884.87 887.76 1336500 887.76
When I run it, i have the following error:
Traceback (most recent call last):
File "/home/misha/Documents/finance/finance.py", line 164, in <module>
security_mean(file_list)
File "/home/misha/Documents/finance/finance.py", line 125, in security_mean
return np.loadtxt('GOOG.csv', skiprows=1, usecols=(5)).mean(axis=0)
File "/usr/lib/python2.7/site-packages/numpy/lib/npyio.py", line 703, in
loadtxt
usecols = list(usecols)
TypeError: 'int' object is not iterable
How can I fix that?
Thanks.
NOTE: all data in GOOG.csv are strings

Saturday, 28 September 2013

Burninate [aardvark] (humanely) – meta.stackoverflow.com

Burninate [aardvark] (humanely) – meta.stackoverflow.com

With a grand total of 1 tagged question for this now defunct service, I
suggest burnination. Failing to find a humane method, I suggest unleashing
the flaming unicorn of aardvark incineration:

Access (read/write) to virtual memory process from another application

Access (read/write) to virtual memory process from another application

I have simple program:
#include <stdio.h>
int a = 5;
int
main(void)
{
while(1)
{
int i;
sleep(1);
printf("%p %i\n", &a, a);
}
return 0;
}
Output (Ubuntu x64):
0x601048 5
0x601048 5
0x601048 5
0x601048 5
I was learning about pointers in C and I already know that you can use
memcpy to write data wherever (almost) you want within virtual memory of
process. But, is it possible to modify value of int a, placed at 0x601048
address, by using another application(which is of course using its own
virtual memory)? How to do this? I'm interested in solutions only for C.

Access Django models with scrapy: defining path to Django project

Access Django models with scrapy: defining path to Django project

I'm very new to Python and Django. I'm currently exploring using Scrapy to
scrape sites and save data to the Django database. My goal is to run a
spider based on domain given by a user.
I've written a spider that extracts the data I need and store it correctly
in a json file when calling
scrapy crawl spider -o items.json -t json
As described in the scrapy tutorial.
My goal is now to get the spider to succesfully to save data to the Django
database, and then work on getting the spider to run based on user input.
I'm aware that various posts exists on this subject, such as these: link 1
link 2 link 3
But having spend more than 8 hours on trying to get this to work, I'm
assuming i'm not the only one still facing issues with this. I'll therefor
try and gather all the knowledge i've gotten so far in this post, as well
a hopefully posting a working solution at a later point. Because of this,
this post is rather long.
It appears to me that there is two different solutions to saving data to
the Django database from Scrapy. One is to use DjangoItem, another is to
to import the models directly(as done here).
I'm not completely aware of the advantages and disadvantages of these two,
but it seems like the difference is simply the using DjangoItem is just
more convenient and shorter.
What i've done:
I've added:
def setup_django_env(path):
import imp, os
from django.core.management import setup_environ
f, filename, desc = imp.find_module('settings', [path])
project = imp.load_module('settings', f, filename, desc)
setup_environ(project)
setup_django_env('/Users/Anders/DjangoTraining/wsgi/')
Error i'm getting is:
ImportError: No module named settings
I'm thinking i'm defining the path to my Django project in a wrong way?
I've also tried the following:
setup_django_env('../../')
How do I define the path to my Django project correctly? (if that is the
issue)

Team Foundation Server 2012 on what Windows Server 2012

Team Foundation Server 2012 on what Windows Server 2012

I am trying to find out the optimal version of OS that I need for my Team
Foundation Server 2012
As I can find it seems that TFS will run on Server 2012 but it is not
specified which versions. Should there be any problems running it on an
Essentials or Foundation edition?
Note: I am planning to run TFS is a virtualized environment with a Server
2012 R2 Datacenter as host

Friday, 27 September 2013

apply-strsplit-rowwise including sort and nested paste

apply-strsplit-rowwise including sort and nested paste

I guess I just don't see it, but all the similar thing I found on the Net,
in the Mailinglist archives or the FAQ could not really elucidate my
issue.
The closest I have found was this: apply strsplit rowwise
I have a df, with two character columns and one numerical column. Filled
like this:
df=data.frame(name1=c("A","B","C","D"),
name2=c("B","A","D","C"),
nums=c(1,1,4,4),
stringsAsFactors=F)
Now I would like to find the unique rows in this, however, only based on
the two name columns. And for those columns, the order of the columns has
no significance, thus i can not use duplicated, if I understood it
correctly.
So I thought about combining the two name columns row wise, make a rowwise
sorting, and print out a paste of the vector (length=2 in combination with
something like sapply).
However I did not get it to work.
So far, I used a for loop, but this takes ages on the original data.
for(i in 1:length(df$name1)){
mysort=sort(c(df$name1[i],df$name2[i]))
df$combname[i]=paste(mysort[1],mysort[2])
}
Any suggestions are welcome. Maybe I just understand unique and sapply in
a wrong way.

Why am I getting Stack Overflow error in Recursive C program while computing elements of pascal triangle?

Why am I getting Stack Overflow error in Recursive C program while
computing elements of pascal triangle?

I am writing a C program to compute (i,j)th element in Pascular Triangle
i.e f(n,1) = f(n,n) = n, and f(n,k) = f(n-1,k) + f(n-1,k-1) for 1 < k < n
I need to print value modulo 1000000007. The Code follows :
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
unsigned long returnModPascal(unsigned long n,unsigned long k);
int main()
{
int t;
unsigned long int ans,n,k;
scanf("%d",&t);
while(t--)
{
scanf("%lu %lu",&n,&k);
ans=returnModPascal(n,k);
printf("%lu",ans);
}
return 0;
}
unsigned long int returnModPascal(unsigned long int n,unsigned long int k)
{
unsigned long int tempans,tempans1,tempans2;
if(k==1 || k==n)
tempans=n;
else
{
tempans1=returnModPascal(n-1,k);
if (tempans1>=1000000007)
tempans1=tempans1%1000000007;
tempans2=returnModPascal(n-1,k-1);
if (tempans2>=1000000007)
tempans2=tempans2%1000000007;
if (tempans1+tempans2>=1000000007)
tempans=tempans1+tempans2-1000000007;
else
tempans=tempans1+tempans2;
}
return tempans;
}
When i give input for example 123456 3 as n & k Error is coming
Unhandled exception at 0x003C3D79 in DummyProject.exe: 0xC00000FD: Stack
overflow (parameters: 0x00000001, 0x003D2F70).
Any Help is appreciated.

Simple Calculator calculates wrong

Simple Calculator calculates wrong

Earlier I asked about the same topic, a simple calculator, but the thread
now is kind of cluttered and isn't up-to-date any more. I hope gets
annoyed by this, but I find a new thread kind of useful.
I got an JavaScript exercise to do, which is to script a calculator, which
has almost the same functionality than the built-in Windows (7) one. This
means that you have one field to enter some values, and a small one above
which displays the previously entered value plus the calculating
operation.
A user sent me some code for my needs which I liked because of it's
simplicity and I tried to adapt it.
I currently am working to get only one operation to work, but later there
will be the other three main operations, square root, etc..
Everything works just fine by now, only the, which is kind of disturbing,
calculating itself does not. For example: If you enter 5 + 5 (or any other
number), then click on equals, nothing happens. If you then again enter
any number (click on plus before) and then hit equals it gives you an
completely random result, or the result of your previous calculation.
This is what I got:
var number = 0; //the result
var operation = ' '; //the chosen calculating operation
var temp_Val = 0; //the last entered value (for the
subdisplay)
var print_equal = function () {
var displayVal = document.getElementById("display");
displayVal.value = number;
};
var num_add = function () {
var displayVal = document.getElementById("display");
temp_Val = displayVal.value; //saves the value of the display (for
the subdisplay)
console.log(temp_Val); //schreibt den Wert des Displays auf die
Konsole
number += parseFloat(displayVal.value); //calculates the result
operation = '+'; //saves the used operation (for the
subdisplay)
print_subdisplay(); //runs the function that's building the
value of the subdisplay
displayVal.value = ""; //resets the main display
};
var print_subdisplay = function () {
var subdisplayVal = document.getElementById("subdisplay");
subdisplayVal.value = temp_Val + operation; //creates a String with
both the first entered value and the operation
};
HTML:
<!-- Displays -->
<input type="text" name="display" id="display" value="0"
class="display">
<input type="text" name="subdisplay" id="subdisplay"
class="subdisplay" readonly>
<!-- Calculating operations -->
<input type="button" onclick="print_equal()" id="equal" value="=">
<input type="button" onclick="num_add()" id="plus" value="+">
<!-- Reset -->
<input type="button" value="C" onClick="reset()" class="reset">
Here's the JSFiddle: http://jsfiddle.net/hJfFd/1/
I would find it incredibly nice if you could help me, since I'm sitting
here trying to get this to work since nearly 4 hours (incl. researching).
Thanks in advance!

Function to get a value between 1 and N using DateTime.DayOfYear Property

Function to get a value between 1 and N using DateTime.DayOfYear Property

I'm developing an application that has a table with N rows. I'm using C#
and SQL Server.
I have to retrieve a different row each day. For example, on December,
22nd, I have to retrieve row 1. On December, 23rd, I have to retrieve row
2, etc.
I need a function that returns a number from 1 to N, using
DateTime.DayOfYear Property to get it.
Maaybe I need to do something like this (DateTime.DayOfYear mod N), to do
what I want to do.
What do I have to do?

mysql - Many tables to one table - multiple entries

mysql - Many tables to one table - multiple entries

I have a system which has (for the sake of a simple example) tables
consisting of Customers, Vendors, Products, Sales, etc. Total 24 tables at
present.
I want to add the ability to have multiple notes for each record in these
tables. E.g., Each Customers record could have 0 to many notes, each
Vendor record could have 0 to many notes, etc.
My thinking is that I would like to have one "Notes" table, indexed by a
Noteid and Date/time stamp. The actual note data would be a varchar(255).
I am looking for a creative way to bi-directionally tie the source tables
to the Notes table. The idea of having 24 foreign key type cross reference
tables or 24 Notes tables doesn't really grab me.
Programming is being done in PHP with Apache server. Database is
mysql/InnoDB.
Open to creative ideas.
Thanks
Ralph

Refresh page as GET request in Chrome

Refresh page as GET request in Chrome

I would like to do a refresh where I force the request method to be GET,
ignoring Form data if it exists.
Pressing F5 after a POST does another POST.
This behavior is the same as selecting the address bar and pressing enter.

CSS Sprite - is there a possible short way?

CSS Sprite - is there a possible short way?

E.g. I hava a 3 diffrent image as a sprite with hover.

<div class="sprite normal"></div>
i dont want this type!
/* small */
.small{ width:20px; height:20px; }
.small .sprite{ background:url(sprite.png) 0 0 no-repeat; }
.small .sprite:hover { background:url(sprite.png) 20px 0 no-repeat; }
/* normal*/
.normal{ width:50px; height:50px; }
.normal .sprite{ background:url(sprite.png) 0 0 no-repeat; }
.normal .sprite:hover { background:url(sprite.png) 50px 0 no-repeat; }
/* big */
.big{ width:100px; height:100px; }
.big .sprite{ background:url(sprite.png) 0 0 no-repeat; }
.big .sprite:hover { background:url(sprite.png) 100px 0 no-repeat; }
is there a short way? thank you..

Thursday, 26 September 2013

Delay when I'm resign the keyboard after scrolling the tableview

Delay when I'm resign the keyboard after scrolling the tableview

I implemented
scrollViewWillBeginDragging:(UIScrollView *)scrollView{ [searchBar
resignFirstResponder];} to dismiss the keyboard when I begin scrolling the
tableview on the search page. But there is a kink and a delay before the
table can smoothly scroll. Help?

Wednesday, 25 September 2013

What does Type Error "dist must be a Distribution instance" mean in python

What does Type Error "dist must be a Distribution instance" mean in python

I am getting an error while executing a python script.
Type Error "dist must be a Distribution instance"
What does it mean

Thursday, 19 September 2013

Basic knowledge about java programming

Basic knowledge about java programming

as I have said before, I am new to java programming(programming in
general) and would like to know some of the basics such as the syntax,
methods(what is a method?), class(what is a class?), object(what is an
object?), how to create loops, etc. I know that this might seem vague and
broad but I really need some help. Any info on the basics of java
programming would be really appreciated. Thanks in advance!

ExpressJs - where express.static(__dirname) point to?

ExpressJs - where express.static(__dirname) point to?

var express = require('express');
var app = express();
port = process.argv[2] || 8000;
app.configure(function () {
app.use(
"/",
express.static(__dirname)
);
});
app.listen(port);
I removed this piece of line below and i got an error while loading localhost
app.configure(function () {
app.use(
"/",
express.static(__dirname)
);
});
What does the app.use method do?.
What does the express.static method do? and where does the __dirname
points to?.

how to create array of instances?

how to create array of instances?

I have class Friend
#import "Friend.h"
#import "AFJSONRequestOperation.h"
#import "UIImageView+AFNetworking.h"
#import "AFHTTPClient.h"
@implementation Friend
-(id)init {
self = [super init];
return self;
}
-(id)initWithSecret:(NSString *)theSecret
userId:(NSString *)theUserId {
self = [super init];
if(self) {
secret = theSecret;
user_id = theUserId;
/// get friends
NSString *str = [NSString
stringWithFormat:@"https://api.vk.com/method/friends.get?fields=first_name,last_name&uid=%@&access_token=%@",
user_id, secret];
NSURL *url = [[NSURL alloc] initWithString:str];
NSURLRequest *friendRequest = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *friendOperation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:friendRequest success:^(NSURLRequest
*friendRequest, NSHTTPURLResponse *response, id JSON) {
//converting to array
NSArray *ar = [JSON valueForKey:@"response"];
NSData *jsonAr = [NSJSONSerialization dataWithJSONObject:ar
options:NSJSONWritingPrettyPrinted error:nil];
friendsAr = [NSJSONSerialization JSONObjectWithData:jsonAr
options:NSJSONReadingMutableContainers error:nil ];
self.firstName = [friendsAr valueForKey:@"first_name"];
self.lastName = [friendsAr valueForKey:@"last_name"];
self.uid = [friendsAr valueForKey:@"uid"];
} failure:^(NSURLRequest *friendRequest, NSHTTPURLResponse *response,
NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[friendOperation start];
}
return self;
}
@end
In my ViewController I can create an instance like that:
self.myFriend = [[Friend alloc] initWithSecret:self.secret
userId:self.user_id];
It works fine, but when I try to create an array:
NSMutableArray *persons = [NSMutableArray array];
for (int i = 0; i < 165; i++) {
self.myFriend = [[Friend alloc] initWithSecret:self.secret
userId:self.user_id];
[persons addObject: self.myFriend];
}
self.arrayOfPersons = [NSArray arrayWithArray:persons];
it crashes with the error: "Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '* +[NSJSONSerialization
dataWithJSONObject:options:error:]: value parameter is nil' ". Can anyone
tell me what I'm doing wrong? Thank you!

Ubuntu 13.04 on Samsung ATIV 700T: keyboard and trackpad do not work

Ubuntu 13.04 on Samsung ATIV 700T: keyboard and trackpad do not work

I created a bootable USB drive with Ubuntu 13.04 image. I managed to boot
my Samsung ATIV. the GUI, mouse and keyboard work perfectly, and the
installation works without problems.
When I boot the system for the first time, however, once the GUI of Ubuntu
loads, neither the keyboard nor the trackpad work. The system is therefore
rendered useless.
The keyboard works OK in Grub.
Any pointers on how to troubleshoot this problem?

Changing a value of a variable inside foreach loop PHP

Changing a value of a variable inside foreach loop PHP

I have a problem. I should change the value of a variable inside a foreach
loop in php, but the value holds predefined value all the time. Here is
the code:
$returnValue = "";
foreach($vinArray as $vinValue){
$sql_vin_check = "SELECT * FROM users WHERE vin LIKE '%:vin%'";
$stmtvincheck = $pdo->prepare($sql_vin_check);
$stmtvincheck->bindParam(':vin', $vinValue);
$stmtvincheck->execute();
$vinCheck = $stmtvincheck->rowCount();
$stmtvincheck->closeCursor();
echo $vinValue;
if($vinCheck != 0){
$returnValue = $vinValue; break;
}
}
return $returnValue;
And $returnValue holds the "" value. I tried echoing $vinValue variable
and it's not empty when the loop breaks.
What am I doing wrong?

Some errors i can not solve c#

Some errors i can not solve c#

I have some errors i can not fix.
This are the errors:
Error 1 'Communication.ComPort' is a 'type' but is used like a 'variable'
Error 2 Only assignment, call, increment, decrement, and new object
expressions can be used as a statement

This is the code where the errors apear:
private void BackgroundWorkerCompletedEvent(object sender,
RunWorkerCompletedEventArgs e)
{
Object result;
ComPort comport = ComPort();
try
{
result = e.Result;
}
catch (Exception exc)
{
MessageBox.Show("Sending file(s) failed: " +
exc.InnerException.Message, "", MessageBoxButtons.OK);
_dialog.Close();
return;
}
if (_aborted)
{
comport.Close;
MessageBox.Show("Sending file(s) aborted, Reset
programmer.", "", MessageBoxButtons.OK);
}
else if (Success)
MessageBox.Show("Sending File(s) succesfull", "",
MessageBoxButtons.OK);
else if (!Success)
comport.Close;
else if (_comPort == null)
MessageBox.Show("Programmer not found at port " + _port,
"", MessageBoxButtons.OK);
else
MessageBox.Show("Sending file(s) failed: ", "",
MessageBoxButtons.OK);
_dialog.Close();
}
Can someone explain to me what i am doeing wrong so i can learn from it.
Thanks in advance

Mako Templates: Mapping between line numbers before rendering and after rendering

Mako Templates: Mapping between line numbers before rendering and after
rendering

In our project we are using Mako Templates with tool version 0.4.0 . We
have created some base template files for a Python based Domain Specific
Language(DSL). In addition to these templates, some configurations in the
form of a dictionary are passed to MakoTemplate.render method to generate
the final internal DSL format file for further processing.
The template files include :
1. <% ... %> sections
2. %if ... %endif sections
3. %for ... %endfor sections.
For our project Mako is working great and generating the DSL files in
perfect formats as per our expectations.
The actual problem started when recently I initiated writing our DSL
specific editor which is capable of detecting some domain related errors
in the internally generated files (Mako output).
Now with some algorithm, I am able to detect the erroneous lines in these
generated file. But I need to mark these erroneous lines on the original
template file and to accomplish this I need a mapping between the line
numbers of the output generated file(internal) and the line numbers in
base template file which include Mako statements (listed above).
Is there a way which during rendering, can give me such a mapping ?
Please help.
thanks and regards, farhat

iOS-App crashes on touch of iputbox

iOS-App crashes on touch of iputbox

I am using custom keyboard for webview by hiding the default keyboard. But
my code is crashing whenever I tap on inputbox. It says
-[UITextInteractionAssistant containerIsTextField]: message sent to
deallocated
After a lot of debugging I found out that [self.view endEditing:YES]; is
reposnsible for UITextInteractionAssistant.
Can anyone help in this?
Help in advance!!!



// register for keyboard show event
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
hiding UIWebviewAccessary
-(void)keyboardWillShow:(NSNotification *)note {
[self.view endEditing:YES];
[self removeBar];
[self performSelector:@selector(adjustFrame) withObject:nil
afterDelay:0.03];
}
- (void)adjustFrame {
[self.webView
stringByEvaluatingJavaScriptFromString:@"window.scroll(0,0)"];
}
- (void)removeBar {
// Locate non-UIWindow.
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication]
windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description]
rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in
[possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description]
rangeOfString:@"UIWebFormAccessory"].location !=
NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}

Wednesday, 18 September 2013

returning query result to a list c#

returning query result to a list c#

I am working on a project where I am phasing out Entity framework from an
existing system.
I got
public List<GSP> GetOwnAirline()
{
var res = from own in entity.GSP where own.Description == "Own
Airline" select own;
return res.ToList();
}
To bypass this i did
public List<GSP> GetOwnAirline()
{
string get_ = "SELECT * FROM " + Adm.schema_ + "Adm.GSP WHERE
Description = 'Own Airline'";
ccs = new SqlConnection(Adm.COnnectionString);
//convey transaction to db
cmd = ccs.CreateCommand();
ccs.Open();
cmd.CommandText = get_;
var res =cmd.ExecuteScalar();
ccs.Close();
return res.ToList();
}
But the.ToList seems not to be recognised in this situation. Where did i
go wrong guys ?

Can I specify the projection matrix in Java3D

Can I specify the projection matrix in Java3D

Is there any way that I can specify the projection matrix of Java3D
instead of specifying the Transform3D of ViewingPlatform?

Wrong data loading from global to local memory in CUDA program which uses several kernels

Wrong data loading from global to local memory in CUDA program which uses
several kernels

I am writing a CUDA application. In the program, I have 6 kernel functions
which are getting called from the host machine and they are in a loop. So
it is basically a kind of simulation which goes on in a loop and those 5
kernels are getting called in a loop. Inside the kernels I am using the
shared memory where I bring the data from global memory. Now I am facing a
bizarre problem while I was debugging. When I run the whole simulation
with all the kernels then actually wrong data is getting copied from the
global memory to the shared memory and this is happening from 1st kernel.
But then when I comment out the 4th, 5th and 6th kernel, compile it and
debug, then correct data is getting copied to the shared memory. I know
that this is not a index mapping problem because of two reasons; 1.The
index mapping is fairly easy, 2. After commenting out the 4th kernel,
correct data is getting copied. I think there is something wrong in the
third kernel, but I am not able to figure out what exactly could happen in
between kernels which could affect the local memory data copy and
operation.
I just want to give few more information : My kernels have grid and block
structures which are different from one to another as I don't know if this
could be the reason :
#define env_end 48
tot_ag = 512
dim3 gridDim_1(env_end/16,env_end/16,1);
dim3 blockDim_1(16,16,1);
dim3 gridDim_2(1,tot_ag/32,1);
dim3 blockDim_2(8,32,1);
Kernel #1 : <<<gridDim_1,blockDim_1>>>
Kernel #2 : <<<tot_ag/256,256 >>>
Kernel #3 : <<<gridDim_2,blockDim_2>>>
Kernel #4 : <<<gridDim_1,blockDim_1>>>
Kernel #5 : <<<gridDim_2,blockDim_2>>>
Kernel #6 : <<<gridDim_1,blockDim_1>>>
I don't know if I have provide enough information to provide a solution as
I am not sure exactly what kind of information I should provide to solve
this. I am not even able to provide a dummy code which could replicate the
situation as I have tried to write a code to replicate the situation but
it all produced correct result with correct data copy from global to
shared and the original program is too long to provide here. I was just
thinking if someone have faced this thing and solved it or if someone
could provide me with a probable reason behind this or a favourable
procedure to find the reason. But please let me know if any further
information is required. Any help would be very much appreciated. Thank
you.

Why does Jersey say "Array of packages must not be null or empty" when I create my own PackagesResourceConfig?

Why does Jersey say "Array of packages must not be null or empty" when I
create my own PackagesResourceConfig?

I created my own PackagesResourceConfig that looks like this:
import com.sun.jersey.api.core.PackagesResourceConfig;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
public class ResourceConfigClass extends PackagesResourceConfig {
@Override
public Map<String, MediaType> getMediaTypeMappings() {
Map<String, MediaType> map = new HashMap<String, MediaType>();
map.put("xml", MediaType.APPLICATION_XML_TYPE);
map.put("json", MediaType.APPLICATION_JSON_TYPE);
return map;
}
}
But now when I start my app, it gives me an error that says:
Array of packages must not be null or empty
That comes from this source code in Jersey:
/**
* Search for root resource classes declaring the packages as an
* array of package names.
*
* @param packages the array package names.
*/
public PackagesResourceConfig(String... packages) {
if (packages == null || packages.length == 0)
throw new IllegalArgumentException("Array of packages must not be
null or empty");
init(packages.clone());
}
But I've already set the packages in my web.xml by setting the
com.sun.jersey.config.property.packages param so it shouldn't be null.

Raspberry Pi, PHP and I2C

Raspberry Pi, PHP and I2C

What is the best way of doing this? If it's even possible...
I want RPI to "talk" with Arduino somehow via PHP. The goal is to make a
web page to control the Arduino. So the page must be able to talk with the
Arduino. I2C is a good solution (using 3 wires), but I can't make it work.
I managed to install Apache, PHP, etc. The page works when I enter the IP
of the RPI. I found a class that uses shell_exec to call i2cset, to send
data to the Arduino. But it seems that shell_exec does not work.
If I copy the string and paste it in theterminal, it works: I see stuff in
the Arduino's serial monitor; but when it's called with shell_exec,
nothing happens.
My questions are, if someone did something like this:
Is this the "right" way of doing it? A web page, communication between RPI
and Arduino
Whether there's a "better" way of doing it.

JQuery / Javascript function requies both $(document).ready and $(document).ajaxSucces

JQuery / Javascript function requies both $(document).ready and
$(document).ajaxSucces

I have a JQuery / Javascript function that is to be used across my site
for some basic UI functionality. However, many of the elements that this
function effects, will be injected via Ajax, while others will be static
html.
Currenty I've been able to make my scripts work for me by duplicating the
function and applying both $(document).ready and $(document).ajaxSucces.
My question is: What is the appropriate accomplishing this?
Thanks, Mark

c++ : syntax for is_member_function_pointer in a template declaration

c++ : syntax for is_member_function_pointer in a template declaration

I have a template with a declaration similar to this:
template <typename Arg0, typename... Args>
class blah {};
I have two versions of the template, and I want to use one when Arg0 is a
member function pointer, otherwise use the other one. I'm trying to use
std::enable_if and std::is_member_function_pointer but I cannot find the
correct syntax. This is what I have for the true case:
template<typename = typename std::enable_if<
std::is_member_function_pointer<Arg0> >::type, typename... Args>
class blah() {}
But this obviously isn't syntactically correct.

How to change data-bind property in knockoutjs?

How to change data-bind property in knockoutjs?

How can i change to to edit data using knockout js ? for example i have a
table that i want to wheen user dbl clicked on an element the data in col
change to text box with element value.

Preventing GCC from automatically using AVX and FMA instructions when compiled with -mavx and -mfma

Preventing GCC from automatically using AVX and FMA instructions when
compiled with -mavx and -mfma

How can I disable auto-vectorization with AVX and FMA instructions? I
would still prefer the compiler to employ SSE and SSE2 automatically, but
not FMA and AVX.
My code that uses AVX checks for its availability, but GCC doesn't do it
when auto-vectorizing. So if I compile with -mfma and run the code on any
CPU prior to Haswell I get SIGILL. How to solve thi issue?

Tuesday, 17 September 2013

Understanding AJAX in web applications

Understanding AJAX in web applications

I'm using Symfony and have a very basic knowledge of JavaScript, but most
of the things I want to do require AJAX. It's a bit difficult for me to
understand it and to apply it with Symfony.
Let's say that a have a list of thing, which can be enabled and disabled.
The enabled has class="enabled", the disabled have class="disabled". I
want to be able to enable/disable them using AJAX. So what exactly should
happen? As I understand it, when for example you click the button to
disable an item, javascript changes the class immediately, while at the
same time, on the background, a query goes to the server, changing the
status of the item in the database. Then in the template I should have for
example an if statement, which is responsible for the class (like
{% if item.status == 1 %}
<p class="enabled">
{% else %}
<p class="disabled">
{% endif %}
{{item.name}}
</p>
)
So the js code for changing the status is run only on click, while the if
statement in the template is taken into accaunt on refresh.
I'm not quite sure about this, so I would be very grateful if someone says
it's ok, or says what is the proper way to do this and I would also really
appreciate some tutorials or examples and applications using Symfony and
Ajax, because I wasn't able to find anything except this, and I really
can't imagine how exactly to implement such things.
Thank you very much in advance! :)

Asymptotic analysis

Asymptotic analysis

I'm having trouble understanding how to make this into a formula.
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j += i) {
I realize what happens, for every i++ you have 1 level of multiplication
less of j.
i = 1, you get j = 1, 2, 3, ..., 100
i = 2, you get j = 1, 3, 5, ..., 100
I'm not sure how to think this in terms of Big-theta.
The total of j is N, N/2, N/3, N/4..., N/N (My conclusion)
How would be best to try and think this as a function of N?

Returning char pointer from function prints empty

Returning char pointer from function prints empty

i have two different programs that are very similar. The first one just
takes in an argument from the command line(so it stores it in argv). I
copy the string with strcpy into a pointer that was malloc'd and then pass
it to my function where it takes the characters one at a time from where
the pointer is pointing to another pointer where space was also malloc'd.
I return the result and print it. If my input is hii the output is hii. My
second program is very similar, it takes two arguments this time and we
copy each into two separate pointers that were malloc'd and then pass it
to my function. This time we only copy over characters that match from one
char pointer to the other one. Whatever matches we add it into the same
pointer that was malloc'd as we did with the first program. The problem is
when i return the pointer and have the resulted string printed i get a
blank line. So input would be hi fjdhddif and output is an empty line.
Programs:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct StructHolder {
char *words;
};
typedef struct StructHolder Holder;
char *GetCharacters(Holder *ptr){
int i=0;
char *words=malloc(sizeof(char));
for(i;i<strlen(ptr->words);i++){
words[i]=ptr->words[i];
words=realloc(words,sizeof(char)+i);
}
words[strlen(ptr->words)]='\0';
return words;
}
int main(int argc, char **argv){
Holder *structptr=malloc(sizeof(Holder));
structptr->words=malloc(strlen(argv[1]));
strcpy(structptr->words, argv[1]);
char *charptr;
charptr=(GetCharacters(structptr));
printf("%s\n", charptr);
return 0;
}
Program 2:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct StructHolder {
char *wordsA;
char *wordsB;
};
typedef struct StructHolder Holder
char *GetCharacters(Holder *ptr){
int i, j, c=0, f2;
char *words=malloc(sizeof(char));
for(i;i<strlen(ptr->wordsA);i++){
f2=0;
for(j=0;j<strlen(ptr->wordsB) && f2==0;j++){
if(ptr->wordsA[i]==ptr->wordsB[j]){
printf("both match\n");
f2=1; //just exits the loop so that we don't go through
the rest checking`
printf("adding\n");
words[c]=ptr->wordsB[j];
c++;
words=realloc(words,sizeof(char)+i);`
}
}
}
words[strlen(ptr->wordsA)]='\0';
return words;
}
int main(int argc, char **argv){
Holder *structptr=malloc(sizeof(Holder));
structptr->words=malloc(strlen(argv[1]));
strcpy(structptr->wordsB, argv[1]);
strcpy(structptr->wordsA, argv[2]);
char *charptr;
charptr=(GetCharacters(structptr));
printf("%s\n", charptr);
return 0;
}

Regular expression in sublime

Regular expression in sublime

I have this thing where I usual have something like (but not always)
- 30 30: 0 4 58 E
and that must be
- 30 30
: 0 4 58 E
or, in another case
- 32 32
: 0 2 63 All
must remain as it is
- 32 32
: 0 2 63 All
So any : must always be on the next line. Is there an regex for fixing
every case of this (so that it only does this when the : isn't already on
a new line?
I'm using Sublime text as editor

combine 2 Isotope scripts for swipebox effect

combine 2 Isotope scripts for swipebox effect

I'm using a isotope script to filter images but it doesn't support the
swipe control. Now I have found a isotope script that does suppot swipe
effect. (http://brutaldesign.github.io/swipebox/)
I try to combine my script with the script from swipebox,can you hep me to
figure this out ?
My isotope script
//select isotope menu
function selectMenuItem(indx){
for(var i=0;i<isotopeMenu.length;i++){
if(i==indx){
isotopeMenu[i].link.css('background-color',
'#'+selectedBackColor);
filterIsotopeItems(indx);
}else{
isotopeMenu[i].link.css('background', 'none');
}
}
}
function filterIsotopeItems(index){
var selector = "."+isotopeMenu[index].categoryID;
(selector==".*")?selector="*":null;
rx_gallery_ui.find('.isotopeContainer').isotope({
layoutMode : 'masonry',
filter: selector,
});
}
}
the swipebox script
// Use the swipebox only for visible elements
var swipeboxInstance = $(".swipebox-isotope:not(.isotope-hidden
.swipebox-` isotope)").swipebox();
// Callback function that fire the refresh method, once the animation is
finished
onAnimationCompleted = function(){
swipeboxInstance.refresh();
};
// Isotope stuff
optionFilterLinks = $('#filter').find('a');
optionFilterLinks.attr('href', '#');
optionFilterLinks.click( function(){
var selector = $(this).attr('data-filter');
$('#grid').isotope({
filter : '.' + selector,
itemSelector : '.item',
layoutMode : 'fitRows',
animationEngine : 'best-available',
}, onAnimationCompleted); // callback here
optionFilterLinks.removeClass('active');
$(this).addClass('active');
return false;
});

finding dates in long texts (strings) android

finding dates in long texts (strings) android

i have an appliaction in which i have to find dates in long strings (+-
500 words). The problem is one string can contain many date in many
formats.
My input can be for example :
"bla bla 11.09.2003 xxx 5/5/1993 and so on"
i already have many regular expressions for finding different dates and i
pass them to this method
public String extractWithRegEx(String regextype, String input) {
String matchedString = null;
if (regextype != null && input != null) {
Matcher matcher = Pattern.compile(regextype).matcher(input);
if (matcher.find()) {
matchedString = matcher.group(0);
if (matcher.groupCount() > 0) {
matchedString = matcher.group(1);
}
}
}
return matchedString;
}
Is there any library for android that handle this problem ? Or is there
better way for to this ?

Tablesorter non-functional after load even though its placed in the callback function

Tablesorter non-functional after load even though its placed in the
callback function

I had a similar question earlier and at the time placing the tablesorter
call in the .load() callback worked, but now, after what I thought was
unrelated changes, its devolved to its former behavior: It sorts
initially, but after the load clicking on the column headers has no
effect. Any help is appreciated.
JS code:
$(document).ready(function() {
var intervalId = window.setInterval(function(){
$('#status-tables').load('/dashboard/index #status-tables');
}, 5000);
$("#refresh-buttons").on("click", "button", function(event) {
var interval = 0;
switch(event.target.id) {
case "refresh-off" :
interval = 50000000;
$(this).parent().children().removeClass("pressed-button");
$(this).addClass("pressed-button");
break;
case "refresh-5-sec" :
interval = 5000;
$(this).parent().children().removeClass("pressed-button");
$(this).addClass("pressed-button");
break;
case "refresh-30-sec" :
interval = 30000;
$(this).parent().children().removeClass("pressed-button");
$(this).addClass("pressed-button");
break;
case "refresh-60-sec" :
interval = 60000;
$(this).parent().children().removeClass("pressed-button");
$(this).addClass("pressed-button");
break;
}
if (interval != 0)
{
clearInterval(intervalId);
intervalId = setInterval(function(){
$('#status-tables').load('/dashboard/index
#status-tables',
function(){$("#workstation-table").tablesorter(); });
}, interval);
}
});
$("#workstation-table").tablesorter();
});
HTML (from HAML template):
<!DOCTYPE html>
<html>
<head>
<title>Webui</title>
<link data-turbolinks-track="true" href="/assets/application.css"
media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/application.js"></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="YMkodi1Yy31wpZOA2dGdgbltM8M36Tiffo9PCMRlfsA="
name="csrf-token" />
</head>
<body>
<div class='whole-page'>
<div class='container'>
<h1 class='hero-unit' id='application-title'>
<div class='row-fluid'>
<div class='span1' id='replication-server'>
<img alt="Cog logo" src="/assets/cog_logo.png" />
<img alt="Crs" src="/assets/crs.png" />
Replication Server
<div class='span1 pull-right' id='refresh-label'>
<button class='btn' id='refresh-button'>Refresh Rate</button>
<div class='btn-group' id='refresh-buttons'>
<button class='btn btn-default' id='refresh-off'>Off</button>
<button class='btn btn-default' id='refresh-5-sec'>5
sec</button>
<button class='btn btn-default' id='refresh-30-sec'>30
sec</button>
<button class='btn btn-default' id='refresh-60-sec'>60
sec</button>
</div>
</div>
</div>
</div>
</h1>
<h2>
<small id='application-name-label'>Status Dashboard</small>
</h2>
<div id='status-tables'>
<div class='col-md-4'>
<h3>Reports</h3>
<div class='panel' id='report-table-panel'>
<a class='accordion-toggle' data-target='#collapse-cidne'
data-toggle='collapse'>CIDNE</a>
</div>
<div class='uncollapse in' id='collapse-cidne'>
<table class='table table-striped table-hover table-bordered'
id='report-table'>
<thead>
<tr>
<th id='table-header'>Source</th>
<th id='table-header'>Type</th>
<th id='table-header'>Count</th>
</tr>
</thead>
<tbody></tbody>
<tr>
<td>
CIDNE
</td>
<td>
ullam
</td>
<td>
1,578,262
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
adipisci
</td>
<td>
5,828,812
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
ullam
</td>
<td>
2,970,946
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
quae
</td>
<td>
7,918,186
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
quae
</td>
<td>
6,331,230
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
vero
</td>
<td>
9,082,103
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
ullam
</td>
<td>
9,681,110
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
vero
</td>
<td>
5,572,147
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
quia
</td>
<td>
502,000
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
quae
</td>
<td>
6,517,368
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
vero
</td>
<td>
8,603,032
</td>
</tr>
<tr>
<td>
CIDNE
</td>
<td>
ullam
</td>
<td>
8,716,460
</td>
</tr>
</table>
</div>
<div class='panel' id='report-table-panel'>
<a class='accordion-toggle' data-target='#collapse-dcgs'
data-toggle='collapse'>DCGS</a>
</div>
<div class='uncollapse in' id='collapse-dcgs'>
<table class='table table-striped table-hover table-bordered'
id='report-table'>
<thead>
<tr>
<th id='table-header'>Source</th>
<th id='table-header'>Type</th>
<th id='table-header'>Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>
DCGS
</td>
<td>
Reiciendis
</td>
<td>
3,286,731
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Sunt
</td>
<td>
3,269,134
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Reiciendis
</td>
<td>
6,720,385
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Reiciendis
</td>
<td>
4,965,628
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Dicta
</td>
<td>
4,318,889
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Reiciendis
</td>
<td>
1,060,083
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Sunt
</td>
<td>
7,625,906
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Reiciendis
</td>
<td>
2,863,118
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Dicta
</td>
<td>
1,294,952
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
Dicta
</td>
<td>
3,809,659
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='col-md-5'>
<h3 id='workstation-title'>Workstations</h3>
<div class='span-1'>
<div id='sort-instructions'>(click column name to sort)</div>
</div>
<table class='table table-striped table-hover table-bordered'
id='workstation-table'>
<thead>
<tr>
<th id='table-header'>Name</th>
<th id='table-header'>Downloaded</th>
<th id='table-header'>Available</th>
<th id='table-header'>Last Connect</th>
</tr>
</thead>
<tbody>
<tr>
<td>
dignissimos
</td>
<td>
19,787
</td>
<td>
1,278,685
</td>
<td>
2013-09-01 07:59:58
</td>
</tr>
<tr>
<td>
sint
</td>
<td>
23,634
</td>
<td>
5,673,401
</td>
<td>
2013-09-15 12:43:55
</td>
</tr>
<tr>
<td>
magnam
</td>
<td>
31,465
</td>
<td>
4,094,304
</td>
<td>
2013-09-03 09:56:55
</td>
</tr>
<tr>
<td>
enim
</td>
<td>
36,566
</td>
<td>
4,579,378
</td>
<td>
2013-09-01 08:09:41
</td>
</tr>
<tr>
<td>
quos
</td>
<td>
28,638
</td>
<td>
5,486,033
</td>
<td>
2013-07-16 01:56:16
</td>
</tr>
<tr>
<td>
voluptatibus
</td>
<td>
15,129
</td>
<td>
2,612,705
</td>
<td>
2013-07-14 04:35:11
</td>
</tr>
<tr>
<td>
ullam
</td>
<td>
17,624
</td>
<td>
3,661,141
</td>
<td>
2013-07-10 10:33:42
</td>
</tr>
<tr>
<td>
et
</td>
<td>
52,962
</td>
<td>
3,951,956
</td>
<td>
2013-07-10 09:24:28
</td>
</tr>
</tbody>
</table>
</div>
<div class='col-md-3'>
<h3>Source</h3>
<table class='table table-striped table-hover table-bordered'>
<tr>
<th id='table-header'>Type</th>
<th id='table-header'>Name</th>
<th id='table-header'>Status</th>
<tr>
<td>
CIDNE
</td>
<td>
http://lang.com/jarrett_reynolds
</td>
<td>
<div id='service-down'></div>
</td>
</tr>
<tr>
<td>
DCGS
</td>
<td>
http://mraz.net/coy
</td>
<td>
<div id='service-up'></div>
</td>
</tr>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
HAML (just in case its helpful):
.whole-page
.container
%h1#application-title.hero-unit
.row-fluid
.span1#replication-server
= image_tag "cog_logo.png"
= image_tag "crs.png"
Replication Server
.span1.pull-right#refresh-label
%button.btn#refresh-button Refresh Rate
.btn-group#refresh-buttons
%button.btn.btn-default#refresh-off Off
%button.btn.btn-default#refresh-5-sec 5 sec
%button.btn.btn-default#refresh-30-sec 30 sec
%button.btn.btn-default#refresh-60-sec 60 sec
%h2
%small#application-name-label Status Dashboard
#status-tables
.col-md-4
%h3 Reports
#report-table-panel.panel
%a.accordion-toggle{ :data => { :toggle => "collapse", :target
=> "#collapse-cidne"} } CIDNE
#collapse-cidne.uncollapse.in
%table#report-table.table.table-striped.table-hover.table-bordered
%thead
%tr
%th#table-header Source
%th#table-header Type
%th#table-header Count
%tbody
- @reports.each do |report|
- if report[:source] == "CIDNE"
%tr
%td
= report[:source]
%td
= report[:type]
%td
= report[:count]
#report-table-panel.panel
%a.accordion-toggle{ :data => { :toggle => "collapse", :target
=> "#collapse-dcgs"} } DCGS
#collapse-dcgs.uncollapse.in
%table#report-table.table.table-striped.table-hover.table-bordered
%thead
%tr
%th#table-header Source
%th#table-header Type
%th#table-header Count
%tbody
- @reports.each do |report|
- if report[:source].blank?
- elsif report[:source] == "DCGS"
%tr
%td
= report[:source]
%td
= report[:type]
%td
= report[:count]
.col-md-5
%h3#workstation-title Workstations
.span-1
#sort-instructions (click column name to sort)
%table#workstation-table.table.table-striped.table-hover.table-bordered
%thead
%tr
%th#table-header Name
%th#table-header Downloaded
%th#table-header Available
%th#table-header Last Connect
%tbody
- @workstations.each do |workstation|
%tr
%td
= workstation[:name]
%td
= workstation[:downloaded]
%td
= workstation[:available]
%td
= workstation[:last_connect]
.col-md-3
%h3 Source
%table.table.table-striped.table-hover.table-bordered
%tr
%th#table-header Type
%th#table-header Name
%th#table-header Status
- @data_sources.each do |data_source|
%tr
%td
= data_source[:type]
%td
= data_source[:name]
%td
- if data_source[:status] == "UP"
#service-up
- else
#service-down

Sunday, 15 September 2013

good enough 'is integer' check, javascript?

good enough 'is integer' check, javascript?

Is this good enough 'is-integer' check:
function isint( o ) {
return Number( o ) === parseInt( o );
}
I wanna get true for, say 12, 13, '14', '-1', and false for floats, and
anything else.

VB.NET Update BLOB in MySQL

VB.NET Update BLOB in MySQL

The code below that reads an image from the pic box into a memorystream
and inserts it into a MySQL BLOB in the database, works perfectly. Can
retrieve from the database and display in the pic box works perfectly (not
shown). Just a side note, I didn't write that code, it is from a tutorial
on the web.
The bit I wrote to UPDATE the database does not work. I have tried many
combinations of the brackets, single quotes, double quotes but no luck
yet. I get varies error messages from the CATCH, sometimes in plain
English referring to syntax and sometimes in a binary dump. When I do get
a successful update message, all that is written into the BLOB is the name
of what I am trying to update "VALUES(@image_data)". I have tried to
UPDATE from both a memorystream and a file but no luck yet.
The "rem'd" code works perfectly for INSERT and I can manually update the
BLOB but not practical. The BLOB would be updated for example when I
upgrade a SD-DVD to BD-DVD, I will change the small logo.
Before I get flamed, I know not good practice to store the images but in
this case, it is more practical I believe. The images are tiny 24x11 DVD
logo's that are read into a datagridview table, all my other images are
stored as files on the server (1000's of them) however, the test example
is just reading a cover image.
Can anyone help me correct the code or suggest a better method? Thanks….
Private Sub btnUpdate_Click(sender As System.Object, e As
System.EventArgs) Handles btnUpdate.Click
Dim FileSize As UInt32
'temp for testing
Dim carjackedfront As String = "8f17cd4a-8dd6-4ec1-9e7b-7f4d50460693"
'get picture from database
Dim nvcCover As String = carjackedfront
'Dim original As Image = Image.FromFile("D:\Pics\ae.jpg")
Dim original As Image = Image.FromFile(mediastorageCovers & nvcCover &
pictureformat)
Dim mstream As New System.IO.MemoryStream()
' -----this line saves image from picture box
'pic_box_save.Image.Save(mstream,
System.Drawing.Imaging.ImageFormat.Jpeg)
' -----This line saves image from file into memory stream
original.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim arrImage() As Byte = mstream.GetBuffer()
FileSize = mstream.Length
pic_box_get.Image = Image.FromStream(mstream)
mstream.Close()
MsgBox("File Size = " & FileSize)
Try
sql = "UPDATE image_in_db SET Test = VALUES(@image_Text) WHERE
id = '1'"
'sql = "INSERT INTO image_in_db(id, image_data) VALUES(@image_id,
@image_data)"
sql_command = New MySqlClient.MySqlCommand(sql, sql_connection)
' sql_command.Parameters.AddWithValue("@image_id", Nothing)
sql_command.Parameters.AddWithValue("@image_data", arrImage)
sql_command.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
MsgBox("Image has been UPDATED.")
End Sub

Emmet VIM trigger key remap issue

Emmet VIM trigger key remap issue

I just installed Emmet VIM plugin which looks very interesting. The
"trigger key combination" to activate the Emmet plugin functionality is
not the best it could be. Therefore I am trying to remap it in my vimrc
file. I have successfully done that to remap the Escape key as follows:
inoremap ;; <ESC>
This allows me to type the semi-colon character ";" in rapid succession to
get out of the insert mode and get in the normal mode. However it does not
work when I try to remap the Emmet trigger key which is , (to be read as
Control key and "y" key, followed by the "," key). I have tried the
following combinations:
inoremap hh <C-y> ,
inoremap hh <C-y>,
inoremap hh <C-y,>
As you can see above, I am trying to map "hh" key combination to the Emmet
VIM's trigger keys.
Thanks in advance for your time.
Bharat

Trouble reading table in MySQL

Trouble reading table in MySQL

I am trying to simply read a MySQL table names "songs" and write the
"title" column into HTML. I am just beginning with MySQL, so can anyone
explain why it is not working?
The (single-column) SQL table looks like this:
+---------+
| TITLE |
+---------+
| Hello |
| World |
| Table |
| Value |
+---------+
Here is the code I am using in the PHP page
<ul>
<?php
$dbc = mysqli_connect('localhost', 'root', 'pass', 'music');
$query = "SELECT title FROM songs";
$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);
while ($row = mysqli_fetch_array($result)) {
echo '<li id="' . $row['title'] . '" data-title="' .
$row['title'] . '">';
echo '<img class="X" src="X.png" style="width: 14px; margin:
2px 0 -2px -4px; display: none;" />';
echo '<span class="title">' . $row['title'] . '</span>';
echo '</li>';
}
?>
</ul>
There is no output.

Sql Query Using Joins

Sql Query Using Joins

I have 2 tables - student, exam
Student Table Schema:
id Name Course
1 Kavi Dr.
2 Priya Engg.
Exam Table Schema:
Examid Student_id Exam Date
1 1 22-03-2014
2 2 23-04-2014
My requirement is, i need to join these 2 tables,so that i can access all
columns in that table. So far i have tried Query using Innerjoin but i get
the result to be as
id Name Course
1 Kavi Dr.
2 Priya Engg.
1 1 22-03-2014
2 2 23-04-2014
But I need it like ,
id Name Course Exam Date
1 Kavi Dr. 22-03-2014
2 Priya Engg. 23-04-2014
Pls Help!

accessing session variable in second php page

accessing session variable in second php page

my first php file is basic.php
session_start();
?>
<html>
<body>
<a href="basic2.php? name=qadeerhussain"> click on it</a>
<?php
$_session['username']="qadeerhussain";
print $_session['username'];
?>
</body>
</html>
out put of basic.php is: click on it qadeerhussain my second basic2.php
page is
<?php
session_start();
?>
<html>
<body>
<?php
print $_SESSION['username'];
?>
</body>
</html>
but it give me the following exception... Notice: Undefined index:
username in C:\wamp\www\test\basic2.php on line 12

convert the original image to ROI marked image

convert the original image to ROI marked image

I have run this code and it gives me the same image as the black image
instead of the marked ROI image..
public class ROITest {
private static final String OUT_FILE = "img\\ROI.jpg";
public static void main(String[] args)
{
opencv_core.CvRect r =new opencv_core.CvRect();
args[0]="img\\2.jpg";
if (args.length != 1) {
System.out.println("Usage: run FaceDetection <input-file>");
return;
}
// preload the opencv_objdetect module to work around a known bug
// Loader.load(opencv_objdetect.class);
Loader.load(opencv_core.class);
// load an image
System.out.println("Loading image from " + args[0]);
IplImage origImg = cvLoadImage(args[0]);
// IplImage ROIimg = CvSetImageROI(origImg, opencv_core.cvRect(0, 0,
640, 480));
cvSetImageROI(origImg, cvRect(4,4, origImg.width(), origImg.height()));
IplImage ROIimg = IplImage.create(origImg.width(),
origImg.height(),origImg.depth(), origImg.nChannels());
cvCopy(ROIimg,origImg);
cvSaveImage(OUT_FILE, origImg);
final IplImage image = cvLoadImage(OUT_FILE);
CanvasFrame canvas = new CanvasFrame("Region of Interest");
cvResetImageROI(image);
canvas.showImage(image);
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
}
It gives error like .....
Loading image from img\2.jpg
OpenCV Error: Assertion failed (src.depth() == dst.depth() && src.size ==
dst.size) in unknown
function, file ......\src\opencv\modules\core\src\copy.cpp, line 557
#
A fatal error has been detected by the Java Runtime Environment:
#
Internal Error (0xe06d7363), pid=5828, tid=6652
#
JRE version: 6.0_18-b07
Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode windows-x86 )
Problematic frame:
C [KERNELBASE.dll+0xb9bc]
An error report file with more information is saved as:
C:\UWU_EX_09_0309_universityProject\test\hs_err_pid5828.log
If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
Can You please consider about this matter please...I am stuck with my
project here...

Saturday, 14 September 2013

Are iTunes auto-renewing subscriptions still only for publishers?

Are iTunes auto-renewing subscriptions still only for publishers?

I'm currently evaluating implementing auto-renewing subscriptions in our
SaaS product, and based on reading about Marco Arment's AppStore rejection
of Instapaper I want to make sure that this is worth pursuing.
As far as folks know, in late 2013, does Apple still expect auto-renewable
subscription apps to be providing new media content every month, or is it
finally ok to be simply providing a service? Will service apps be rejected
for using auto-renewing subscriptions?

Blob object in HTML5

Blob object in HTML5

After reading this question, I have finally turned a canvas into a Blob
object using the following code:
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
}
(From Vava720)
How would I instantiate the blob to catch the value coming from the return
statement? I am trying to use this so my canvases would work with
Resemble.js, which only accepts files as input. Would I be able to use
their apis like this:
resemble(Blob_name).compareTo(Blob_name2).onComplete(function(data){
if(data.misMatchPercentage == 0){
alert("hello");
}
});
Any help is appreciated. Thanks in advance!

parse string as date-time

parse string as date-time

Let's say I have the following string:
Sat, 14 Sep 2013 22:44:49 +0000
how would I turn it into the following format for Django models?
YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]
Thank you very much.

If condition not met execute function again - causing js error

If condition not met execute function again - causing js error

I have the following function
function randomNum(max, used){
newNum = Math.floor(Math.random() * max + 1);
if($.inArray(newNum, used) === -1){
console.log(newNum + " is not in array");
return newNum;
}else{
return randomNum(max,used);
}
}
Basically I am creating a random number between 1 - 10 and checking to see
if that number has already been created, by adding it to an array and
checking the new created number against it. I call it by adding it to a
variable..
UPDATED:
for(var i=0;i < 10;i++){
randNum = randomNum(10, usedNums);
usedNums.push(randNum);
//do something with ranNum
}
This works, but in Chrome I get the following error:
Uncaught RangeError: Maximum call stack size exceeded
Which I guess it's because I am calling the function inside itself too
many times. Which means my code is no good.
Can someone help me with the logic? what's a best way to make sure my
numbers are not repeating?

Rails View - How to escape special characters to include within a link

Rails View - How to escape special characters to include within a link

I am trying to escape special characters e.g. (space : / &) for inclusion
into a link. I have tried the following but it will only escape '#'
characters.
<a href="https://twitter.com/share?text=<%=location.title.html_safe%><%=h
root_url(:anchor =>
"_lat=#{location.latitude}&long=#{location.longitude}&zoom=17").html_safe%>">Tweet</a>
I have also tried <%=CGI.escapeHTML location.title%><%=CGI.escapeHTML
root_url(...)%> it does not escape spaces or the http:// in root_url
Thanks.

Doing mathematical operations on operands of various sizes, only known at runtime

Doing mathematical operations on operands of various sizes, only known at
runtime

I'm writing a small virtual computer, complete with its own instruction
set. The thing that's giving me problems is the arithmetical instructions
(add, mul, div, and so forth) because I want them to be able to work on
operands of various different sizes (8, 16, 32, and 64-bit signed and
unsigned integers, and 32 and 64-bit floating points - essentially, every
numeric C# primitive type). The type of the operands aren't known until
runtime.
I'm not sure of any elegant way to do this in C#, though. The operands,
which usually live on a special stack type I'm writing, will be returned
by a Pop method, but, as far as I know, methods can only have one return
type.
Likewise, in the methods that perform the arithmetical instructions,
having different operand sizes means I'd need to write a pretty unruly
switch block.
I've seen the dynamic keyword, but I've heard it was better suited for
interop with IronRuby/IronPython.
Is there any way I can solve this elegantly, without resorting to switch
blocks or boxing everything in objects?

How to speed up php execution in remote server

How to speed up php execution in remote server

How to optimize php page loading?. there any handy tricks ?/ I want to
speed up my server execution time.

Reload a DIV without reloading the whole page

Reload a DIV without reloading the whole page

I have a Div Tag that has a php include to fill that div with information
what I want to do is make it so that the page is called every 15s so it
can update the information there without having to reload the whole
webpage. I've tried to do this with JavaScript/jQuery and I just can't
seem to get it to work
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js" />
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('.View').load('Small.php').fadeIn("slow");
}, 15000); // refresh every 15000 milliseconds
</script>
<div class="View"><?php include 'Small.php'; ?></div>
this is what I have after searching some, and what happens is, it loads
the Small.php but it doesn't refresh it or update the info every 15
seconds.
please help!
I should add all my php arrays that should show up are all executed in the
Small.php and the page I'm including it into is just so it's isolated.

Friday, 13 September 2013

ServiceStack Application Structure

ServiceStack Application Structure

I have recently started looking at ServiceStack and how we could implement
it in our architecture. We have been using ASP.NET MVC 3/4 with the
Service/Repository/UnitOfWork pattern.
I am looking for resources of how to integrate ServiceStack into the mix.
What we usually have looks something like this:
MVC Controller/Action --> Service --> Repository --> Entity Framework
I want to re-use the domain model we have and expose it through
ServiceStack, so do I just have the operation's on the services return the
domain models?
E.G.
// Request DTO
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
}
// Response DTO
public class CustomerResponse
{
public List<Customer> Customers { get; set; }
}
// Customer Service
public class CustomerService : IService
{
public object Any(BrowseCustomers request)
{
var customers = new List<Customer>() {
new Customer {
FirstName = "Joe",
LastName = "Bob",
...
},
new Customer {
FirstName = "Jill",
LastName = "Bob",
...
}
};
return customers.Where(x =>
x.FirstName.ToLower().StartsWith(request.FirstName.ToLower()));
}
}

Mootools: wait until all ajax requests are done

Mootools: wait until all ajax requests are done

This is very similar to Wait until all jquery ajax request are done?,
except that I want to know the best practice of doing that in Mootools.

Adding integers to binary tree

Adding integers to binary tree

I need help to build a binary tree and put integers in it.
I need to write an add method in my MyArrayBinaryTree class (that extends
ArrayBinaryTree) that allows me to place the element to be added in the
very next available slot in the array.
I also need to write its constructors since MyArrayBinaryTree is derived
from ArrayBinaryTree, and therefore inherits all of its methods (except
the constructors). I cannot put my add method in ArrayBinaryTree class
because that is the implementation of the ADT.
To test this I want to create a demo that creates an instance of
MyArrayBinaryTree (calling it t) and puts the integer 0 in the root. Then,
using a loop, adds another 19 integers to the tree. So I can output the
size of the tree (the number of nodes, including the root).
Any coding help is APPRECIATED!
My work so far:
MyArrayBinaryTree class:
public class MyArrayBinaryTree extends ArrayBinaryTree {
//need help here
}
ArrayBinaryTree class:
import java.util.Iterator;
import binarytree.EmptyCollectionException;
import binarytree.ElementNotFoundException;
public class ArrayBinaryTree<T> implements BinaryTreeADT<T>
{
protected int count;
protected T[] tree;
private final int capacity = 50;
public ArrayBinaryTree()
{
count = 0;
tree = (T[]) new Object[capacity];
}
public ArrayBinaryTree (T element)
{
count = 1;
tree = (T[]) new Object[capacity];
tree[0] = element;
}
protected void expandCapacity()
{
T[] temp = (T[]) new Object[tree.length * 2];
for (int ct=0; ct < tree.length; ct++)
temp[ct] = tree[ct];
tree = temp;
}
public T getRoot() throws EmptyCollectionException
{
if (isEmpty())
throw new EmptyCollectionException("binary tree");
return tree[0];
}
public boolean isEmpty()
{
return (count == 0);
}
public int size()
{
return count;
}
public boolean contains (T targetElement)
{
boolean found = false;
for (int ct=0; ct<count && !found; ct++)
if (targetElement.equals(tree[ct]))
found = true;
return found;
}
public T find (T targetElement) throws ElementNotFoundException
{
T temp=null;
boolean found = false;
for (int ct=0; ct<count && !found; ct++)
if (targetElement.equals(tree[ct]))
{
found = true;
temp = tree[ct];
}
if (!found)
throw new ElementNotFoundException("binary tree");
return temp;
}
public String toString()
{
ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
inorder (0, templist);
return templist.toString();
}
public Iterator<T> iteratorInOrder()
{
ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
inorder (0, templist);
return templist.iterator();
}
protected void inorder (int node, ArrayUnorderedList<T> templist)
{
if (node < tree.length)
if (tree[node] != null)
{
inorder (node*2+1, templist);
templist.addToRear(tree[node]);
inorder ((node+1)*2, templist);
}
}
public Iterator<T> iteratorPreOrder()
{
ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
preorder (0, templist);
return templist.iterator();
}
protected void preorder (int node, ArrayUnorderedList<T> templist)
{
if (node < tree.length)
if (tree[node] != null)
{
templist.addToRear(tree[node]);
inorder (node*2+1, templist);
inorder ((node+1)*2, templist);
}
}
public Iterator<T> iteratorPostOrder()
{
ArrayUnorderedList<T> templist = new ArrayUnorderedList<T>();
postorder (0, templist);
return templist.iterator();
}
protected void postorder (int node, ArrayUnorderedList<T> templist)
{
if (node < tree.length)
if (tree[node] != null)
{
inorder (node*2+1, templist);
inorder ((node+1)*2, templist);
templist.addToRear(tree[node]);
}
}
public Iterator<T> iteratorLevelOrder()
{
ArrayUnorderedList<T> tempList = new ArrayUnorderedList<T>();
int ct = 0; // current number of elements added to list
int i = 0; // current position in array
while (ct < count)
{
if (tree[i] != null)
{
tempList.addToRear(tree[i]);
ct++;
}
i++;
}
return tempList.iterator();
}
}
BinaryTreeADT class:
import java.util.Iterator;
public interface BinaryTreeADT<T>
{
public T getRoot ();
public boolean isEmpty();
public int size();
public boolean contains (T targetElement);
public T find (T targetElement);
public String toString();
public Iterator<T> iteratorInOrder();
public Iterator<T> iteratorPreOrder();
public Iterator<T> iteratorPostOrder();
public Iterator<T> iteratorLevelOrder();
}
ElementNotFoundException class:
public class ElementNotFoundException extends RuntimeException
{
//Sets up this exception with an appropriate message.
public ElementNotFoundException (String collection)
{
super ("The target element is not in this " + collection);
}
}
EmptyCollectionException class:
public class EmptyCollectionException extends RuntimeException
{
//Sets up this exception with an appropriate message.
public EmptyCollectionException (String collection)
{
super ("The " + collection + " is empty.");
}
}