Monday, 30 September 2013

Why are certain greek characters used predominantly for certain purposes in mathematics?

Why are certain greek characters used predominantly for certain purposes
in mathematics?

For example, $\epsilon$ and $\delta$ are used in Real Analysis for proving
limits... $\phi$, $\nu$ and $\mu$ were introduced to me in the context of
number theory... and then $\pi$ is used for purposes other than its
canonical $3.14...$ value, such as to represent the equation of a plane,
or as a function name.

Reduce space between 'genfrac' and indices – tex.stackexchange.com

Reduce space between 'genfrac' and indices – tex.stackexchange.com

\documentclass{article} \usepackage{amsmath}% http://ctan.org/pkg/amsmath
\DeclareRobustCommand{\eulerian}{\genfrac<>{0pt}{}} \begin{document} %
Source: ...

Spring Transaction: How is there a way to auto evict after transaction

Spring Transaction: How is there a way to auto evict after transaction

I just committed a very large data and i wish to evict all the data after
the Transaction.
Is there anything I can add to @Transaction to make it auto evict apart
from calling evict manually?

Php I get this error Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in

Php I get this error Warning: mysqli_error() expects parameter 1 to be
mysqli, boolean given in

Hello i get the error below i need to create a login system for a project
for school. below is the code.This basically checks the username and
password if its correct.if the condition is true i want to return the user
id or otherwise it should return false.
function login($username , $password){
GLOBAL $dbc; //database connect
$user_id= user_id_from_username($username);
$username = sanatize($username);
$password = md5($password);
$query= mysqli_query($dbc,"SELECT COUNT(`user_id`) FROM `users` WHERE
`username` = '$username' AND `password ` = '$password'");
MYSQLI_ERROR($query);
$check= mysqli_fetch_array( $query , MYSQLI_BOTH); // even if i add this
set of code the query
still gives the above error.
}

Sunday, 29 September 2013

To enable Radio button of one radio group and disable the other radio group when selected

To enable Radio button of one radio group and disable the other radio
group when selected

I want to enable topping only after Pizza is selected I want to either
disable topping or from appearing before pizza is selected.
<legend>Choose the pizza wrap type ?</legend>
<div class="control-group">//radio group
<label class="radio">
<input type="radio" name="pizza" id="pizza3"value="3" {% if pizza.rel == 3%}
checked {% endif %}>
Vegan
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza2" value="2" {% if pizza.rel ==
2 %}
checked {% endif %}>
Vegetarian
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza1" value="1" {% if
pizza.rel == 1 %} checked {% endif %}>
Non vegetarian
</label><br>
<label class="radio">
<input type="radio" name="pizza" id="pizza0" value="0" {% if
pizza.rel == 0 %} checked {% endif %}>
Halal meat
</label>
<button type="button" class="btn btn-link" id="pizza"
onclick="captureSelection()">
</button>
</div>
<h5>Toppings?</h5>
<div class="control-group">
<label class="radio">
<input type="radio" name="topping" id="topping3" value="3" {% if
topping.top == 3
%} checked {% endif %}>
Vegan
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping2" value="2" {% if
topping.top == 2
%} checked {% endif %}>
Veggie
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping1" value="1" {% if
topping.top == 1
%} checked {% endif %}>
Meat
</label><br>
<label class="radio">
<input type="radio" name="topping" id="topping0" value="0" {% if
topping.top == 0
%} checked {% endif %}>
Halal meat
</label>
<button type="button" class="btn btn-link" id="topping"
onclick="captureSelection()">
</button>
</div>
function I am using to check if the radio button is checked or not should
I do the for loop to check with if one of the radio buttons is checked
from pizza ??
function captureSelection(){
var u = document.getElementById('relevance');
var t = document.getElementById ('topic');
if (u.value=='unchecked' && u.value ==''){
t.disable='true';
}
else (u.value=='checked'){
t.enable='true';
}
}

Groovy project won't build in GGTS

Groovy project won't build in GGTS

I have some Groovy code which will from fine from the command line, but
when I try to use Springsource's GGTS fails:
Caught: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
at empyrean.Empyrean.run(Empyrean.groovy:20)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.cli.ParseException
... 1 more
I know this is because I have not got paths or something similar set
correctly in GGTS but I cannot work out how to fix this (I used to use STS
without a problem, this is the first time I have tried GGTS)
The non-compiling code is this:
def empyreanParse = empyreanCli.parse(args)
if (empyreanParse.u || args.size() == 0)
empyreanCli.usage()
else {
def engine = new EmpyreanEngine()
if (empyreanParse.d)
engine.debug = true
if (empyreanParse.f)
engine.process(binsicParse.f)
else
engine.process(args[args.size() - 1])
}
Which, as I say, runs fine from the command line...

How to set numeric value containing comma and decimal point to an input type number

How to set numeric value containing comma and decimal point to an input
type number

I have an input tag in html
<input type="number" id="Amount" placeholder="Please enter somthing" />
I am setting value of this input using jQuery like :
$('#Amount').val("78,000.00");
I am unable to set this value unless I change the type of input tag to be
"text". I have also applied pattern regix like :
<input type="number" id="Amount" placeholder="Please...."
pattern="/^[0-9.,]+$/" />
Please help me to solve this problem.

The Definitive Java Book/Web Guide and List

The Definitive Java Book/Web Guide and List

This question attempts to collect the few pearls among the dozens of bad
C++ books that are released every year.
It is way too big and complex sorting out the books and web guides to get
into the best one. In fact, it is so big and complex, that there are very
many very bad Java books and web tutors out there. And we are not talking
about bad style, but things like sporting glaringly obvious factual errors
and promoting abysmally bad programming styles. And it's even worse with
online tutorials. (There is a reason nobody bothered to setup a similar
question for online tutorials.)
Please provide quality books and an approximate skill level — preferably
after discussing your addition in the Java chat room. (The regulars might
mercilessly undo your work if they disagree with a recommendation.) Add a
short blurb/description about each book that you have personally
read/benefited from. Feel free to debate quality, headings, etc. Books
that meet the criteria will be added to the list.

Saturday, 28 September 2013

Python functions and strings

Python functions and strings

How would i use a function to grab specific parts of a string?
Say for instance my string consisted of data such as the following:
'12345678 123456.78 Doe, John D.' # Data that could be representative of
bank software# How do i tell python to make the first chars of the string
an int, the second part of the string to be a float and the last part
should automatically remain a string right?
for line in file_obj:
print(line) #would yield something like this '12345678 123456.78 Doe,
John D.'
If i had functions like:
def find_balance():
return float
def find_acc_num():
return int
def find_name():
return str
What would my parameters be? Would for iteration be the best way to solve
the problem? I am new to using functions and am a bit unsure about how to
go about doing this...
Thanks in advance for any help i really appreciate it. =D

General Database/Data Access Layer API

General Database/Data Access Layer API

I'm currently building a web application with a RESTfull architecture.
Currently, I have 3 major collections: Users, Posts, and Comments with the
following relationships:
User --(hasMany)--> Post --(hasMany)--> Comment
And, the expected web-API's (GET /Users, GET /Users/Id, GET /Post/Id, POST
/Post/Id,...)
Currently, I'm using MongoDB for data persistence, which works perfectly
as I can setup 3 major Collections: Users, Posts, Comments and use either
Object _id references or actual document embedding to model the
relationships.
However, my employer is skeptical of MongoDB, and thus I'd like to leave
the door open in the event we switch to something more conventional
(mySQL, MS-SQL,...)
As such, I'm looking to loosely couple my database, and so I need to come
up with a data access layer api that I can tie to noSQL or SQL - based
databases.
Bonus: additionally, I need to connect to existing database
infrastructure, and would like to encapsulate these requests under the
same data-access umbrella as well.
Something like:
// mongo-inspired
db.find(<string bucket>).where(<string
attribute>).is(<string/number/object value)
// SQL-like
db.select(<[string] attribute1>).from(<string bucket>).where(...) ...
Is there any general database/data access API that I can emulate?
Thanks.

When going over a binary file in c, do I go by bits or bytes?

When going over a binary file in c, do I go by bits or bytes?

I have a long binary string which contains a number of bytes, I need to
use fseek to get to a specific byte in the string.
I know I need to calculate the offset but I'm not sure if the offset is
calculated by bits or bytes. If I need to get to the 3rd byte for example
I need to advance the indicator by 3 or by (3*8=)24?

Tree ADT keys and values, children

Tree ADT keys and values, children

I'm still a little confused about the Tree ADT concept when it comes to
keys and values and children.
If a tree has children as TreeNodes in a LinkedList and one of these
children has the value as a text string, and the other child has the value
as an array containing one text string per element.
How should the tree structure then look like?
Should the child with string as value be a leaf?
Should the child with an array as value be a leaf, or should the value
just say "it's an array", and then each array element should be added in
another LinkedList called "childrenList", each as TreeNodes?
Grateful for answers.

Friday, 27 September 2013

Use parents' property as variable with SASS

Use parents' property as variable with SASS

Is it possible to use a property of a parent as variables? For example in
this code, i'd like to be able to give the 'inner-box' element same color
as its parent 'box'.
Make it something like .inner-box {background-color: $Outer-Parent's-Color;}
Example on Fiddle
<div class="box">
<div class="box1">
<div class = "inner-box">
BOX
</div>
</div>
</div>
<div class="box red">
<div class="box1">
<div class = "inner-box">
RED BOX
</div>
</div>
</div>
and the css
.box {
width: 100px;
padding: 10px;
margin: 10px;
background-color: blue;
}
.box1 {
background-color: darkblue;
padding: 10px;
}
.box.red {
background-color: red;
}
.box.red .box1 {
background-color: darkred;
}
.inner-box {
background-color: $Outer-Parent's-Color;
}

How can i create files (automatically) through a vb.net program that act as input for other programs?

How can i create files (automatically) through a vb.net program that act
as input for other programs?

I have a program that uses some user input to automatically create files I
need for an upload process. The files are a .bas (qbasic program) and a
.lot (a voxco automaton file). The files are created perfectly, the syntax
is flawless. When I try to run the batch files that start the basic
program and the lot file stuff, it breaks down. The programs (voxco and
basic) don't seem to know how to read the files. I'm at a loss. I don't
think it is the encoding. I think my VB.net program is creating a text
file with a ".lot" and ".bas" extension, and the two other programs don't
know how to deal with that. But I have no idea how to create the proper
files other than naming them .lot and .bas. Anyone have any experience
with this?
Here's some of the code that creates the .LOT file:
'Create a copy of the old lot file
My.Computer.FileSystem.CopyFile(LotFilePath & OldStudy & ".LOT",
LotFilePath & "BackEnd\" & OldStudy & ".LOT")
System.IO.File.Create(LotFilePath & "BackEnd\" & StudyID &
".LOT").Dispose()
Dim LotText As String
LotText = Text to put into LOT file
Dim QuLines As String = Nothing
Dim Reader As New StreamReader(LotFilePath & OldStudy & ".LOT")
Dim SLine As String = Nothing
While Not Reader.EndOfStream
SLine = Reader.ReadLine()
If SLine.StartsWith("*QU") Then
QuLines = QuLines & SLine & vbCrLf
End If
End While
LotText = LotText & QuLines
Dim TempPath As String
TempPath = LotFilePath & "BackEnd\" & StudyID & ".LOT"
My.Computer.FileSystem.WriteAllText(TempPath, LotText, 0)
And here's the code that creates the BAS file:
Dim BasText As String = Nothing
BasText = Text to input into BAS file
TempPath = BasFilePath & StudyID & ".BAS"
My.Computer.FileSystem.WriteAllText(TempPath, BasText, 0)

Switching from user mode to kernel mode

Switching from user mode to kernel mode

In my operating systems class, I'm asked whether switching from user to
kernel mode is privileged. This is not OS-specific. At first I thought
yes, but it seems like a big Catch 22. I referred to my textbook:
The hardware allows privileged instructions to be executed only in kernel
mode. ...
The instruction to switch to kernel mode is an example of a privileged
instruction.
Gagne, Greg; Abraham Silberschatz; Peter B. Galvin (2010-01-26). Operating
System Concepts (p. 22). Wiley Higher Ed. Kindle Edition.
So we start in user mode. To switch to kernel mode requires a privileged
instruction. A privileged instruction must be done in kernel mode,
therefore we must switch to kernel mode to enable switching to kernel
mode.
I'm thinking the system does not allow a user to switch itself to kernel
mode directly, but that it is done by the kernel when the user seeks to
execute another privileged instruction. Is that correct?

deleting a mysql table row based on current date and table date

deleting a mysql table row based on current date and table date

I am trying to make a webpage that deals with seminars postings. I would
like the page to delete a seminar that is past its expiration date (or the
date that the seminar occurs) My table has 3 date slots, one for month,
one for day, one for year. They are all integers in the table.
if(date("Y") > $info['year']) //if the year is old
{ $sql = "DELETE FROM seminars WHERE ID = '$ID'";
mysql_query($sql); } //then delete this seminar
else if(date("Y") == $info['year'] && date("n") > $info['month']) //if we
are in the year of the seminar, but the month is now old
{ $sql = "DELETE FROM seminars WHERE ID = '$ID'";
mysql_query($sql);} // then delete this seminar
else if(date("Y") == $info['year'] && date("n") == $info['month'] &&
date("j") > $info['day']) //if we are in the year of the seminar and the
month of the seminar, but the day is old
{ $sql = "DELETE FROM seminars WHERE ID = '$ID'";
mysql_query($sql); } // then delete this seminar
else // if there is no reason to delete the seminar then print out this
seminar
as can be seen above I tried to use the system time for year month day and
compared each one to see if anything was old. However, it is never
deleting the seminars.
now, $info is the table row, because this statement is in a while loop so
that it can grab every row from the table. but even if the delete
statement wasnt working, then it wouldnt display the seminar right? the
last else statement is where displaying the seminar begins by the way.
if anyone knows a better way to do this I would appreciate it a lot. I
have been struggling with this for a while now.
Thanks!

Insert data to table where select statement has more columns

Insert data to table where select statement has more columns

Hello i would like to add some rows from my pricelist table to products
table. I am trying to fill my products table by testing data. Is possible
to make query where i can add random amount of rows to my products table?
The main problem is that i have more rows in select statement than in
insert statement.
INSERT INTO products(product_name, product_price)
SELECT name_product, price_product, IF(RAND() > 0.2,1,0) AS random
FROM pricelist
HAVING random = 1
Thanks for your help i hope that it's clear

How to include one html page(as header) in another html page?

How to include one html page(as header) in another html page?

I am trying to include an html page that will be header to my main page.
Both pages are deployed to different servers. I currently doing it using
frames. The header currently has some fixed width and I am not able to
change its width I need it to fit the screen of my main page. Is it
possible using frames or is there any other approach I could use for this?

Thursday, 26 September 2013

How can I get the contents of an iframe without putting the iframe on the page?

How can I get the contents of an iframe without putting the iframe on the
page?

How can I get the html of an iframe without physically putting the iframe
on the page? Can I put the iframe into a variable and get it that way?

Thursday, 19 September 2013

iOS 3+ programming a uiprogressview w/o a nib (I have theos)

iOS 3+ programming a uiprogressview w/o a nib (I have theos)

Ok, I have finally implemented FlowCover programmatically. On click of an
image in the cover flow, I would like a uiprogressview bar appear below
the image in the cover flow.
Here is my current code snippet for the area of concern:
- (void) flowCover:(FlowCoverView *)view didSelect:(int)deb {
NSLog(@"Downloading Track %d ...", deb); switch (deb % 6) {
case 0: default: system("wget -O
/some/Local/File/Name.blah
http://urlBeingDownloadedFrom.com/aFile.blah"); case
1:..... NSLog(@"Track %d Downloaded!", deb); } }
I would also like the UIProgressView to disappear when complete and alert
the user when it is fully downloaded, and if the file size is less than
the expected, alert the user of that. I know how to make alerts, so no
need to waste time saying how a UIAlertView is shown (just show "// Alert
goes here."). I am using theos for iOS, not Xcode to program. I am using
iOS 3 SDK, as I want to support a lot of users. This is for Cydia, not the
AppStore. Any help will be much appreciated!!!

Handling UntrustedSSLCertificates using Webdriver for FF

Handling UntrustedSSLCertificates using Webdriver for FF

I tried to use the below code for handling UntrustedSSLCertificates. But
getting Null pointer exception for the below lines:
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false);
Code: ProfilesIni allProfiles = new ProfilesIni();
System.setProperty("webdriver.firefox.profile","myprofile"); String
browserProfile = System.getProperty("webdriver.firefox.profile");
FirefoxProfile profile = allProfiles.getProfile(browserProfile);
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false); FirefoxDriver
webdriver = new FirefoxDriver(profile);
webdriver.get("https://www.google.com");

Receive buffer data is missing after first read in TcpServer

Receive buffer data is missing after first read in TcpServer

I try to send data shorter than 255 length in Client side.
i try to send data with this protocol :
Lenghth+String
Byte+string
sample :
string = ABCD
sentdata = 4ABCD
here is my server side code:
procedure TfrmServer.tcpsrvr1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
var
a : array of byte;
I : Cardinal;
mystr : string;
b,Len : Byte;
begin
ClientSocket.ReceiveBuf(b,1,0);// first try : get lenght
Len := b;
SetLength(a,Len+1);
mmoRerult.Lines.Add(DateTimeToStr(now) + ' Data Len ' +
IntToStr(Len));
ClientSocket.ReceiveBuf(a,Len,0); // second try : this lone is not worked.
mystr := '';
for I := 1 to 10 do
begin
mystr := mystr + Chr(a[i]);
end;
mmoRerult.Lines.Add(mystr);
//Creating a stream
mmoRerult.Lines.Add('--------------------');
end;
Problem is if I read all data in first possible first try, But if I read
data in second try is not possible.
And ClientSocket.BytesReceived don't give me count of byte received before
read.
How can I fix this problem, Please don't tell me read 255 byte in first I
know this way.

Adding new series for each row of data to a stacked column chart using a loop

Adding new series for each row of data to a stacked column chart using a loop

I am trying to add new series for each new row of data that I enter I want
the name of the series to be in column B and the values to be in columns E
to AH. The counter to loop from 71-206 and the j variables accounts for
the title and other offsets so I am matching the series to its data.
Any help would be greatly appreciated. Thanks!
Sub stacked()
'
' stacked Macro
'
Dim i As Integer
Dim j As Integer
For i = 71 To 206
ActiveChart.SeriesCollection.NewSeries
j = i + 5
ActiveChart.SeriesCollection(i).Name = "=Sheet1!B" & j
ActiveChart.SeriesCollection(i).Values = "=Sheet1!E:AH" & j ":AH"&j
Next i
End Sub

Unable to perform facebook iOS Native Login in custom Project

Unable to perform facebook iOS Native Login in custom Project

I need to perform a Facebook Native Login from my iOS App but it is not
working. Instead of showing me the in-app confirmation dialog (the
expected behavior) my App always switches to Safari to authenticate the
user.
The annoying thing is that i tried the all relevant samples
(SessionLoginSample, HelloFacebookSample, Scrumptious) and they are all
working as expected. The example Projects also work with my own Facebook
App but when i create a project by myself it does not work.
To make it even worse: When i copy the code from e.g. SessionLoginSample
(modified to Native Login and working as sample project) to my own project
it stops working and the app is switching to the browser again. If i copy
my code into one the sample projects it is working quite well again.
How i login with SessionLoginExample:
[appDelegate.session
openWithBehavior:FBSessionLoginBehaviorUseSystemAccountIfPresent
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// and here we make sure to update our UX according to the new
session state
[self updateView];
}];
What i tried to enable Native Login:
created a Facebook App with all necessary information according to
https://developers.facebook.com/docs/ios/getting-started/
on my iPhone i entered login credentials: Settings->Facebook (no test user)
i followed the steps described in
https://developers.facebook.com/docs/ios/ios-sdk-tutorial/authenticate/
i triple checked the configurations in Info.plist and even the entries in
the Xcode Build Settings Pane and they are all the same
Please help me, at least with a hint or something. Thanks in advance.

Create chat Application using c#?

Create chat Application using c#?

I want to create a chat application in c# (windows form) using socket,
TCP/IP communication Client should sent text to server and server should
respond and when server send message to client, client must receive that
message. All the sending should be performed on button click event. If
anyone have worked on it kindly help me i am new to socket programming.
Thanks in Advance
Regards: Mahmood Khan

Cannot read the first two columns of a row in a gridview

Cannot read the first two columns of a row in a gridview

I need to read the allcolumns of a row in a gridview. I use the following
code to do so.
foreach (GridViewRow row in gridvw.Rows)
{
DataRow dr;
dr = table.NewRow();
//string str = gridvw.Rows(0).Cells(0).Text;
for (int i =0; i <; row.Cells.Count-1; i++)
{
dr[i] = row.Cells[i].Text.Replace(&quot;&amp;nbsp;&quot;,
&quot; &quot;);
}
table.Rows.Add(dr);
}
Am adding all the values to a table. The above code returns nothing for
the first 2 columns of each and every row.
Can anybody help on this issue?
Thanks in Advance,
Joseph

Disable Back Key on a particular event on a particular Activity

Disable Back Key on a particular event on a particular Activity

Can we disable the back key in Android on a particular screen(Activity)
when a particular event happen on that screen. The case is like :- On a
screen showing some records on listview, if a refresh button is pressed,
an activity indicator appears on screen. At this time we have to disable
the back key.

Wednesday, 18 September 2013

Difficulties using arrays, beginner

Difficulties using arrays, beginner

I am just learning using arrays in java. I am trying to assign an array
with 10 random integers, though my code is returning arrays filled with
0's. What am I doing wrong? Help would be appreciated.
import java.util.Random;
public class E7point1
{
public static void main(String[] args)
{
int[] array = new int[10];
int i = 0;
Random random = new Random();
while (i < array.length)
{
array[i] = 1 + random.nextInt(100);
i++;
}
System.out.print(array[i]);
}
}

TCP sockets sending files only works in one direction, how to fix?

TCP sockets sending files only works in one direction, how to fix?

with this sockets code I can send a file like a pdf or datbase file from
the client to the server with no problems but it does not work the other
way, the file that is sent from server to the client arrives with size of
0 bytes, how to get this to work?
it is supposed to send files in both directions
main server code, the part that launches threads for each connection
server code runs on windows 7 PC as java desktop application some try
catch exceptions removed for readability
serversocket = new ServerSocket(6789, 100);
while(runner){
socket = serversocket.accept();
MultiThreader multi = new MultiThreader(socket);
Thread t = new Thread(multi);
t.start();
server code that launched for each connection as a thread, class is called
MultiThreader
public MultiThreader(Socket s) {
countForTimer = 0;
socket = s;
}
// this code is for receiving files from the client
@Override
public void run() {
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
is = socket.getInputStream();
bufferSize = socket.getReceiveBufferSize();
buffer = new byte[bufferSize];
while ((count = is.read(buffer)) > 0) {
bos.write(buffer, 0, count);
}
bos.flush();
bos.close();
is.close();
socket.close();
} // end run
// this code is for sending a file from this server to the client
private void sendOutPack(File file) {
long length = file.length();
System.out.println("lengtyh of fole " + file.length());
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
FileInputStream fis = null;
if (socket != null) {
byte[] bytes = new byte[(int) length];
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(socket.getOutputStream());
int count;
while ((count = bis.read(bytes)) > 0) {
bos.write(bytes, 0, count);
}
// bos.flush();
// bos.close();
fis.close();
bis.close();
socket.close();
} // end socket null check
} // end sendoutpack
Client code that runs on Android tablet, shows methods for connecting to
server for sending and receiving files
@Override
public void run() {
FileOutputStream fos = null;
FileInputStream fis = null;
BufferedOutputStream bos = null;
BufferedInputStream bis = null;
InputStream is = null;
File file = new File("/mnt/sdcard/JIS.db");
int count;
int bufferSize = 0;
byte[] buffer;
socket = new Socket(InetAddress.getByName(serverIP), 6789);
if (socket != null) {
connected = true;
}
// receive db file from server and put into directory on sd card
file2 = new File("/mnt/sdcard/JISSend.db");
new Thread(new SendOutPack()).start();
is = socket.getInputStream();
bufferSize = socket.getReceiveBufferSize();
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
byte[] bytes = new byte[bufferSize];
while (((count = is.read(bytes)) > 0) && (connected == true)) {
bos.write(bytes, 0, count);
}
bos.flush();
bos.close();
bos = null;
} // end if
} // end run method
// send file from local sd card to server
public class SendOutPack implements Runnable {
long length = file2.length();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
FileInputStream fis = null;
FileOutputStream fos = null;
@Override
public void run() {
if (socket != null) {
try {
byte[] bytes = new byte[(int) length];
fis = new FileInputStream(file2);
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(socket.getOutputStream());
int count;
while ((count = bis.read(bytes)) > 0) {
bos.write(bytes, 0, count);
}
fis.close();
bis.close();
fis = null;
bis = null;
socket.close();
// bos.flush();
// bos.close();
// socket.close();
} // end socket null check
} // end run method
} // end sendoutpack
} // end run
} // end StopTimer nested class

Why use an intent to create an activity?

Why use an intent to create an activity?

Folks,
This is a newbie question. I have read a few articles on intents but I am
a bit confused on what the main idea behind an intent is when it comes to
starting an activity. If I know that I have to create and show an
activity, why can't I do something as simple as the following?
MyActivity a = new MyActivity();
a.show();
Thank you in advance for your help.
Regards,
Peter

Replace a part of the string after being found in the text of an array element

Replace a part of the string after being found in the text of an array
element

I would like the fText string value int b=3, a, c=10; be changed into:
int _sc_b=3, _sc_a, _sc_c=10;
by using the text inside the array elements.
My code:
var fText = "int b=3, a, c=10;";
sc_var_int_temp[0] = "a";
sc_var_int_temp[1] = "b";
sc_var_int_temp[2] = "c";
for( var vi=0; vi<sc_var_int_temp.length; vi++ ){
//how would i do the replacing?
}//for
GOAL: fText value will be int _sc_b=3, _sc_a, _sc_c=10;

Form validation with SELECT field using Jquery

Form validation with SELECT field using Jquery

Jquery Isn't alerting me when their is no value selected from the Rating
form. Would it be because selected="selected" is actually being seen as a
value to jquery ?
<label for="rating">Rating</label>
<select id="rating" name="rating" />
<option selected="selected" disabled="disabled">Select a
Rating</option>
<option value="Terrible">Terrible</option>
<option value="Fair">Fair</option>
<option value="Ok">Ok</option>
<option value="Good">Good</option>
<option value="Excellent">Excellent</option>
</select>
$(document).ready(function(){
// No value for movie_title
if ($('#movie_title').val() == "" ) {
alert ("No Film");
}
// No Value for actor
if ($('#leading_name').val() == "") {
alert ("No actor");
}
// No value for rating
if ($('#rating').val() == "") {
alert ("No Rating");
}
//No value for review
if ($('#review').val() == "") {
alert ("No review");
}
// Focus on first form field.
$("input:text:visible:first").focus();
})

excess horizontal scrolling in foundation 4

excess horizontal scrolling in foundation 4

I am building a responsive site in foundation 4. My problem is when i
start to decrease the width in my browser or view it on an ipad or
handheld there seems to be a little bit of horizontal scrolling on my
site. I dont want someone to be able to scroll 20 or 30 pixels to the
right when on a handheld device. I am 99% sure the problem lies in
foundation because I built a new site with one div in a large-12 columns
div and set the width to 100% and had the same problem.
here is what I mean: http://seseng.s173701.gridserver.com/
if you go to this site and compress your browser you will see you can
scroll to the right a bit off the page. I have tried modifying the
max-width of the rows but that didn't work. Any ideas?

JSON - How to escape double quotes in json C#

JSON - How to escape double quotes in json C#

Response.ContentType = "text/plain";
System.IO.Stream inptStrm = Request.InputStream;
byte[] bytes = new byte[inptStrm.Length];
int i = inptStrm.Read(bytes, 0, Convert.ToInt32(inptStrm.Length));
string Input = Encoding.UTF8.GetString(bytes);
JsonTextParser parsor = new JsonTextParser();
JsonObject jsonObj = parsor.Parse(Input);
My input string is :::::
"shopname":"\""

MVVM - Does validation really have to be so cumbersome?

MVVM - Does validation really have to be so cumbersome?

In my application I have tons of forms, most of with having there own
models which they bind to! Of course data validation is important, but is
there not a better solution than implementing IDataErrorInfo for all of
your models and then writing code for all of the properties to validate
them?
I have created validation helpers which remove alot of the actual
validation code, but still I can't help but feel I am missing a trick or
two! Might I add that this is the first application which I have used MVVM
within so I am sure I have alot to learn on this subject!

Tuesday, 17 September 2013

How to associate posts to users if posts are already associated to another model?

How to associate posts to users if posts are already associated to another
model?

Im on rails 4. Im creating a wine review app and I have three models.
class User < ActiveRecord::Base
has_many :reviews
end
class Wine < ActiveRecord::Base
has_many :reviews
end
class Review < ActiveRecord::Base
belongs_to :user
belongs_to :wine
end
As of now I have my review form like this
<%= form_for [@wine, @review] do |f| %>
...
<% end %>
This associates the new review with the wine being reviewed. How would I
make it so when I create a new review, it associates the current_user with
the review? Thanks.

c# mvc4 Html.DropDownListFor calling the controller

c# mvc4 Html.DropDownListFor calling the controller

I have browsed through several posts and several codes and none of them
seems to work.
I need to reload a WebGrid based on a DropDown selected key on same page,
partial views. I am now building the dropdown element and using in the
view:
@Html.DropDownListFor(model => model.Users, Model.Users, new {
autopostback = "true" })
Along with the following javascript code:
<script type="text/javascript">
$(document).ready(function () {
$('select:[autopostback=true],input[type=checkbox]:[autopostback=true],input[type=radio]:[autopostback=true]').live('change',function
() {
$(this).closest('form').submit();
});
});
</script>
Javascript Console at browser says:
Uncaught Error: Syntax error, unrecognized expression:
select:[autopostback=true],input[type=checkbox]:[autopostback=true],input[type=radio]:[autopostback=true]
No calls are being done at Controller. What shall I be doing wrong?
Thanks.

How to add pages to a website with the page name at the front

How to add pages to a website with the page name at the front

The title is probably confusing. Sorry.
Anyways, I finally got my website up and running at www.ersherm.com, but I
need to add a page for myself.
Now, I've seen websites with addresses like "page.domain.com" - with the
page name before the domain name. I want to make a page for myself with
the address "www.andex.ersherm.com".
Maybe I'm mislead, maybe that's not possible- I don't know that much about
this- but if it is possible, could somebody tell me how to do that?
Thanks.
=-=-=-=-=
[-AndeX]

Trying to use $ holders to capitalize the first letter of each sentence in a regular expression

Trying to use $ holders to capitalize the first letter of each sentence in
a regular expression

so I'm stumped. I've been looking at this for a couple days now and
honestly it's probably a very easy fix since I am new to this
I have string like the following example>>
THiS is a Li?ne of text
!THiS is a Line of text
((THiS is a Line of text.X
THiS is a Line of text
and I want to capitalize each line but keep it in orginal form so far I have
puts the_string.gsub(/(^\W*?)([a-z])/) { |x| "#{$2.capitalize}"}
But this gets rid of the whitespace :( please help

Querying a MySQL database to show a selected row and ALL rows

Querying a MySQL database to show a selected row and ALL rows

I have a problem at the moment where I'm trying to get all rows plus a
selected row from my tables.
So I have three tables - users, tasks, and a joining table called tasks_users
The latter table just contains two columns - task_id and user_id, for the
purpose of normalization.
I have a form to edit a task. The problem arises when I want to retrieve
ALL users (so the task can be reassigned) and I also want to show the
CURRENT user. Given my current queries I can only get all the users, or
just the single related user.
Am I overlooking something obvious, or do I need a more complex query? Or
perhaps a couple of queries?
Further clarification:
Imagine you have an "edit task" form and on it you have the user currently
assigned. I want to also show all other users, so that I may reassign.
Given that I have three tables I'm struggling to construct a query that
returns what I want. Currently I can only return ALL user OR the single
assigned user.

cannot find symbol in my java wordcount program

cannot find symbol in my java wordcount program

import java.io.*;
import java.util.Scanner;
import java.lang.*;
class WordCount{
static String word;
public static void main(String args[])
{
int count=0;
Scanner in=new Scanner(System.in);
System.out.println("Enter the sentence");
word=in.nextLine();
for(int i=0;i<word.length();i++){
if(i!=word.length())
if(word.charAt(i)==' ' || word.charAt(i)!='.' && isNotSpace(word,i))
{
count++;
}
}
System.out.println("The number of words in the sentence are : " +count);
}
static boolean isNotSpace(String word,int i)
{
if(word.charAt[i+1]!=' ')
return true;
else
return false;
}
}
Here I declared a static variable called word and called the "isNotSpace"
method by passing the word variable from the main method. But I get an
error in the "isNotSpace" method:
WordCount.java:23: error: cannot find symbol
if(word.charAt[i+1]!=' ')
^
symbol: variable charAt
location: variable word of type String
1 error

Sunday, 15 September 2013

JQuery Automatic Image Click

JQuery Automatic Image Click

I'm not quite good in programming, but I can write basic stuff. How to
click the image after 10 seconds using Jquery without adding any
attributes into HTML?
HTML code:
<a href="http://www.google.com" class="google">
<img src="google.png" alt="Click here">
</a>
Thanks in advanced.

XE4 Delphi TListView small Icon badly arrangd icons

XE4 Delphi TListView small Icon badly arrangd icons

I'm using TListView in my form (which inherits from TCustomListView) and
when I change ListView style to "vsSmallIcon" the icons gets badly
arranged. We found this issue ever since we ported our Code from Borland
2006 to XE4. Rest all "ViewStyle"s like vsIcon, vsList & vsReport are
working fine. Did anyone faced similar issue with VCL's TlistView
component? I'm on Windows 7 and using RAD Studio XE4 with Update1.
Thanks, ![enter image description here][1]Santosh Thankachan PS:
Stackoverflow says that I need atleast 10 reputations to Post images so
could not attach Snapshots showing the issue with this query.

Java: Accessing another package's class's public static instance variable

Java: Accessing another package's class's public static instance variable

Is it possible to access a class's public static instance variables when
you are in a class that is in a different package?

Missing argument php

Missing argument php

I have a function that accepts one argument.
And I want in case that on argument is retrieved to redirect to a page ,
instead of displaying the following error:
Warning: Missing argument 1 for Widget::id(), called in
/home/wurlcom/public_html/beta/libs/Bootstrap.php on line 42 and defined
in /home/wurlcom/public_html/beta/controllers/widget.php on line 16
Any ideas?

Add a library from Github to Android Studio 0.2.8

Add a library from Github to Android Studio 0.2.8

I am trying to add a library greenDAO from Github to an Android project
created in Android Studio. The content of latest build.gradle created are
as follow
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
How to go about doing it?
Any pointer to latest blog on Gradle build system with added help.

Merge images with .dll or .exe

Merge images with .dll or .exe

I'm using 10-20 images in XAML and I don't want to distribute the app with
all that files. I've read this question which refers to this article. It
explains how to use Embedded Resources. The problem is that it seems to
use that resources code behind using Reflection. In my case I have my
images declared this way:
<Rectangle Width="30" Visibility="{Binding IsChecked,
ElementName=maxCheck, Converter={StaticResource BoolVisConverter}}"
Margin="-1 0 0 0">
<Rectangle.Fill>
<ImageBrush ImageSource="../Images/max.jpg" Stretch="Uniform"/>
</Rectangle.Fill>
</Rectangle>
I also have a SplashScreen that I want to merge among the others too. If
possible I would like to include the icon as well.
I've searched a lot but still cannot find an easy solution to this
problem. The ideal scenario would be to be able to merge ALL files needed
for the execution of the program in a single .exe. That's because I expect
this program to be movable, the users would easily forget copy some files
when they will share the program.
Is there any guide, trick or whatever to achieve this? Thank you very much.
I'm using VS2012 and targeting .NET 4

Getting HTML content from a url with PHP

Getting HTML content from a url with PHP

Lines 167,168, and 169 from $url=https://vine.co/v/hn5brq3UaHP are as follows
<!-- line 167 below -->
<video id="post" class="video-js vjs-default-skin"
x-webkit-airplay="allow" loop preload="auto" autobuffer
poster="https://v.cdn.vine.co/r/thumbs/29AD67879D990648189290192896_14096826fa9.3.2.mp4_nNcN9Ok6.hyO9kxwd6rznoLbYb2LcPw6Ss4qNBHWVTDGWcGm2G3ApNGVbXnaj_zq.jpg?versionId=qWXCou5WAMoRucswR.ke.5U04tWc7Mto">
<source
src="https://v.cdn.vine.co/r/videos/F40EF02473990648229186416640_1759c5147f9.3.2_2Cbzl51yYCSVHD0ExDjxom4K.m9TMMBW8oqWb6uAUVjXC0S7K0XF0x9LFQVEk8aL.mp4?versionId=hhunAfm0cfHpHS7pFD274yaX4rn8FSmA"
type="video/mp4">
</video>
I would like to get from line 167
$poster =
https://v.cdn.vine.co/r/thumbs/29AD67879D990648189290192896_14096826fa9.3.2.mp4_nNcN9Ok6.hyO9kxwd6rznoLbYb2LcPw6Ss4qNBHWVTDGWcGm2G3ApNGVbXnaj_zq.jpg
and from line 168
$videourl=
https://v.cdn.vine.co/r/videos/F40EF02473990648229186416640_1759c5147f9.3.2_2Cbzl51yYCSVHD0ExDjxom4K.m9TMMBW8oqWb6uAUVjXC0S7K0XF0x9LFQVEk8aL.mp4

How to upload using php when we have x-cordinate, y-cordinate, width, height

How to upload using php when we have x-cordinate, y-cordinate, width, height

I have the x-cordinate, y-cordinate, width, height. I want to crop the
image using php and upload it. please let me know..

Saturday, 14 September 2013

Backbone: Inserting Collection Just Once

Backbone: Inserting Collection Just Once

How many times is the Collection View below writing to the DOM: once for
the entire Collection, or once for each item in the Collection?
If it is writing multiple times, is there a way to store the Views and
then append them all at once?
App.Views.Tasks = Backbone.View.extend({
tagName: 'ul',
initialize: function() {
this.render();
},
render: function() {
this.collection.each(this.addOne, this);
return this;
},
addOne: function(task) {
var taskView = new App.Views.Task({ model: task });
this.$el.append(taskView.render().el);
}
});
var tasksCollection = new App.Collections.Tasks([
{{a bunch of tasks}}
]);
var tasksView = new App.Views.Tasks({ collection: tasksCollection });
$(.tasks).html(tasksView.render().el);

how to sort this python code alphabetically

how to sort this python code alphabetically

i've tried so hard to sort these code alphabetically but still not
working. tis is the error message :
Traceback (most recent call last): File "D:\Eclipse
Workspace\tugas1\src\h.py", line 15, in for word in set(l): TypeError:
'NoneType' object is not iterable
here the code :
from re import compile
l=compile("(\w[\w']*)").findall(open(raw_input('Input file:
'),'r').read().lower()).sort()
f=open(raw_input('Output file: '),'w')
for word in set(l):
print>>f, word, ':', '\t', l.count(word), 'kata'
f.close()

Comparing a single string to an array of strings in C

Comparing a single string to an array of strings in C

My program is accepting user input and then taking the first word inputted
and comparing it to an array of accepted commands. What would be the best
way to compare the first word inputted (after it has been tokenized) to an
array of strings?
Example:
comparing the string "pwd" to an array containging {"wait", "pwd", "cd",
"exit"}
Thanks in advance for your help!

SFML Drawing Pixel Array

SFML Drawing Pixel Array

I found this (http://lodev.org/cgtutor/raycasting.html) tutorial on the
Internet and was interested and wanted to make my own. I wanted to do it
in SFML though, and I wanted to extend it, and make a 3D version, so there
could be different levels the player can walk on. Thus, you would need 1
ray for every pixel, and thus each pixel would have to be drawn
independently. I found this
(http://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php)
tutorial, and it seemed easy enough to have the array be of individual
vertices. To start, I figured the best thing to do would be to create a
class that could read the pixels returned by the rays, and draw them to
the screen. I used the VertexArray, but things were not working for some
reason. I tried to isolate the problem, but I've had little success. I
wrote a simple vertex array of just green pixels that should fill up part
of the screen, and still there are problems. The pixels only show my code
and the pic. of what I mean.
#include "SFML/Graphics.hpp"
int main() {
sf::RenderWindow window(sf::VideoMode(400, 240), "Test Window");
window.setFramerateLimit(30);
sf::VertexArray pointmap(sf::Points, 400 * 10);
for(register int a = 0;a < 400 * 10;a++) {
pointmap[a].position = sf::Vector2f(a % 400,a / 400);
pointmap[a].color = sf::Color::Green;
}
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(pointmap);
//</debug>
window.display();
}
return 0;
}
Apparently I can't post images or more links so here...
htt p://oi43.tinypic.com/s5d9aw.jpg
I meant for this to just fill in the top 10 rows with Green, but
apparently that is not what I did... I think if I can figure out what is
causing this not to work, I can probably fix the main problem. Also if you
think there is a better way to do this instead, you could let me know :)
Thanks!

Why are some browsers faster

Why are some browsers faster

Assuming the same machine, there are cases when the same website is
rendered faster/slower on different browsers. Some of the possible reasons
that I could think of: 1. Different javascript/DOM rendering engines. 2.
Differnt browser implicit caching
What can be other reasons because of which this happens.

Objective-C - MVC Model using both local and remote data stores

Objective-C - MVC Model using both local and remote data stores

If I had a Game model which controlled when Targets were fired and
received when these Targets were hit from the Controller, how would be the
best and preferred way to handle the possibility for the Game model to
have both a local and remote option?
Such that, a Game model could run a whole game offline locally by
controlling all game logic itself, however if the remote property was set
to true then it would send the Targets hit value to the remote server
which in turn would process the logic and return the data to be
stored/fired.
I would like the Game model to be reusable as possible, and all games
(local and remote) to be stored within a Players game array property.
The possibilities I can think of are..
1) To create a LocalGame and RemoteGame class which subclass Game
2) To create a remote property which determines the logic called in the
Game model, such that if remote == true then call server, otherwise run
local code
3) Create class addition files which are loaded by the controller (i.e.
Game+Remote.h) which separates the local/remote code as opposed to 2)

Remeber the state of the dropdownbox after a call from the action class

Remeber the state of the dropdownbox after a call from the action class

Hai I have a Dropdown box that populated dynamically from DB When user
submits the data he selected the control goes to action and comes back ..
I want to keep the dropdown box state as user selected previously .. I am
very new to JQuery please be expressive thanks in advance.
I am using Struts2 select tag for dropdown

Friday, 13 September 2013

Follow BETA Inviter

Follow BETA Inviter

I have created a BETA Invitation system by following this tutorial.
http://railscasts.com/episodes/124-beta-invitations. Users can also follow
one another in my Rails app.
How can I have the Invitee follow the person who Invited him on sign up?
Currently, I am trying to establish this in my User Model using a method,
but I am having trouble creating the method that allows the Invitee to
follow the Inviter via sender_id/user_id.
ERROR
wrong number of arguments (0 for 1)
This is the code I have used so far.
SCHEMA
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.integer "invitation_id"
t.integer "invitation_limit"
t.timestamp "created_at", :null => false
t.timestamp "updated_at", :null => false
t.string "password_reset_token"
t.timestamp "password_reset_sent_at"
end
create_table "invitations", :force => true do |t|
t.integer "sender_id"
t.string "recipient_email"
t.string "token"
t.datetime "sent_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
MODELS
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation,
:invitation_token
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :followed_users, through: :relationships, source: :followed
has_many :reverse_relationships, foreign_key: "followed_id",
class_name: "Relationship",
dependent: :destroy
has_many :followers, through: :reverse_relationships, source: :follower
has_many :sent_invitations, :class_name => 'Invitations', :foreign_key
=> 'sender_id'
belongs_to :invitation
after_create :follow_inviter #---------- HERE!!
def follow_inviter
inviters = Invitation.find_by_sender_id
inviters.each do |invite|
self.follow!(invite)
end
end
def invitation_token
invitation.token if invitation
end
def invitation_token=(token)
self.invitation = Invitation.find_by_token(token)
end
def following?(other_user)
relationships.find_by_followed_id(other_user.id)
end
def follow!(other_user)
relationships.create!(followed_id: other_user.id)
end
def unfollow!(other_user)
relationships.find_by_followed_id(other_user.id).destroy
end
private
def set_invitation_limit
self.invitation_limit = 5
end
end
class Relationship < ActiveRecord::Base
attr_accessible :followed_id
belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User"
validates :follower_id, presence: true
validates :followed_id, presence: true
end
class Invitation < ActiveRecord::Base
attr_accessible :recipient_email, :sender_id, :sent_at, :token
belongs_to :sender, :class_name => "User"
has_one :recipient, :class_name => "User"
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
before_create :generate_token
private
def generate_token
self.token = Digest::SHA1.hexdigest([Time.now, rand].join)
end
end

Massive insert query shifting somewhere

Massive insert query shifting somewhere

Is there any tool or any easy accessible way to get a mysql insert to have
the fields and the values to be entered listed side by side ?
I have some big inserts with over 80 fields and at some point they start
to shift, meaning the value is one ahead or behind of the field and all
gets messed up from there.

SQL Query (max of sum per year)

SQL Query (max of sum per year)

I will try to describe my problem here. Let's say that i have 3 tables:
1. sales
salesID (PK)
productID(FK) - FK that points to the sold product
storeID(FK) - FK that points to the store that sold the product
month - month in which the product was sold
year - year in which the product was sold
amount - amount(of money) for which the product was sold
2. product
productID (PK)
productName
3. store
storeID (PK)
storeName



I need the following query: For every store show the top selling product
in that store for the specified year. So the result should look something
like:
STORE PRODUCT AMOUNT
store1 product1 XXX amount
store2 product2 YYY amount
store3 product1 XYX amount
Where each amount would be the highest sum of all amounts in that year.
What I can do now is:
SELECT store.storeName
, product.ProductName
, SUM(sales.ammount)
FROM sales
JOIN product ON sales.productID = product.productID
JOIN store ON sales.storeID = store.storeID
GROUP BY store.storeName
, product.ProductName
WHERE sales.year = 'XXXX'
;
Where I get a sum per product and per store. After this I can use the
cursor to go thru the entire table row by row and check which one has the
highest amount for that store.
But I was wondering if it is possible to do that in a 'simple' query?
I'm using SQL Developer for Oracle 11g database. And I would appreciate
any help.

UDP packet does not arrive

UDP packet does not arrive

I'm not sure if this is the right place to ask this question. If not, i
will remove it...
Anyway, i have made driver for enc28j60 for LPC1788 and I'm trying to send
UDP message to it from iOS. Sending fails. Communication starts by iOS
sending the ARP request. On LPC i make response and send it to iOS MAC
address. I have read RFC for ARP and created packet by the specification,
but for some reason i dont see the response in network sniffer.
That would for sure indicate that my response routine does not work, if
there was not this case when i send udp message from OSX (nc -u
xxx.xxx.xxx.xxx port) that comes correctly to LPC.
The difference that i observed is that OSX sends the request which is
42bytes long and gets 60bytes long response with last 18bytes of 0's
(padding bytes), and iOS sends the 60byte long request with last 4bytes as
90 eb 58 96.
I tried to respond with all padding zeros, and with copying those 4 bytes,
but neither approach worked.
OSX ARP(req, res) and UDP package is visible in sniffer. iOS ARP req is
visible in sniffer and nothing else.
Any idea ?
EDIT:
IOS code:
CFSocketRef sock = CFSocketCreate(kCFAllocatorDefault, PF_INET,
SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
if ( sock == NULL) {
NSLog(@"CfSocketCreate Failed");
}else{
struct sockaddr_in remoteAddress;
memset(&remoteAddress, 0, sizeof(remoteAddress));
remoteAddress.sin_family = AF_INET;
remoteAddress.sin_len = sizeof(remoteAddress);
remoteAddress.sin_port = htons(1200);
remoteAddress.sin_addr.s_addr = inet_addr("192.168.5.8");
char data[] = "test";
NSData *message_data = [NSData dataWithBytes:&data length:4];
NSData* remoteAddressData = [NSData dataWithBytes:&remoteAddress
length:sizeof(remoteAddress)];
CFSocketError er = CFSocketSendData(sock, (__bridge
CFDataRef)(remoteAddressData), (__bridge CFDataRef)message_data, 0);
}

Secure deployment of SSIS package

Secure deployment of SSIS package

We are in the process of completing SSIS packages. However as we move
towards the deployment phase surprisingly we realized that deployment of
SSIS package is not really straight forward as terms of security.
we need to run a SSIS package using either batch file or .NET program in
production server. The caller (batch or .NET) should call the SSIS package
by supplying parameters (such as source file, destination database,
userid, password etc) and also read return code (Success/Error) from SSIS.
The user id and password should not be in clear text format visible to
anyone. We did some research and found that deployment can be done using
many options such as XML config, SQL server Configuration, environment
variables, Registry etc but did not mentioned any about password
encryption. How can we achieve security and ensure flexibility deploying
same package in multiple environment (DEV,UAT,PROD) and simple changing
the environment specific variables at the time of deployment.
I am looking for somthing where MVC/Entity framework the connection
strings are automatically encypted when the application is run first time
using following code.
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
ConfigurationSection section =
config.GetSection("connectionStrings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
}

Thursday, 12 September 2013

Verbose exception catch clauses

Verbose exception catch clauses

Background
I have a case where my logic requires surround with try/catch, I have a
lots of catch clauses, which makes my code a bit ugly. What I do in catch
clause is only log the error using log4j.
Question Is it ok to use one catch clause with parent exception type
instead of bunch of catch clauses? Instead of this:
try{
//some statements
} catch (KeyStoreException e) {
LOGGER.error(e);
} catch (CertificateException e) {
LOGGER.error(e);
} catch (NoSuchAlgorithmException e) {
LOGGER.error(e);
} catch (FileNotFoundException e) {
LOGGER.error(e);
} catch (IOException e) {
LOGGER.error(e);
} catch (UnrecoverableKeyException e) {
LOGGER.error(e);
} catch (NoPropertyFoundException e) {
LOGGER.error(e);
}
using :
try{
//some statements
} catch (Exception e) {
LOGGER.error(e);
}
Which one is better?

Memory warning when I go to google Images

Memory warning when I go to google Images

Has anyone experienced something similar? When I google 'red' and select
images everything is fine. But when i select one of the images i get a
memory warning. And the functionality of the app goes to hell from there.
this is how i handle my URLCache in my app delegate
int cacheSizeMemory = 4*1024*1024; // 4MB int cacheSizeDisk =
32*1024*1024; // 32MB NSURLCache *URLCache = [[NSURLCache alloc]
initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk
diskPath:@"nsurlcache"]; [NSURLCache setSharedURLCache:URLCache];
and
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo { DLog(@"Hello");
NSString *alertText =userInfo[@"aps"][@"alert"]; UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"Received a remote notification"
message:alertText delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil]; [alert show];
Any help or direction to research would be really helpful. Thanks

Apache POI and HashMap printing out in wrong order

Apache POI and HashMap printing out in wrong order

I am building a program that prints out info into an .xlsx file using
Apache POI and it seems to be working great, but a hiccup has developed as
I have added more lines to the print out process. I am using a HashMap
with an integer key and a string object array to store the info and then
it writes to the excel file. Everything works great until the line with
key 17. The program starts to mix up the lines and prints them out of
order. Here is the code and below that is how it prints out. Notice how
lines 17 and 18 get mixed and how the 2 blank line are left out. What am I
missing that could be causing this craziness? Thanks all!
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Estimate");
//Create a new row in current sheet
Row row = sheet.createRow(0);
//Create a new cell in current row
Cell cell = row.createCell(0);
//Set value to new value
cell.setCellValue("");
Map<Integer, Object[]>
data = new HashMap<Integer, Object[]>();
data.put(0, new Object[] {"", "SIZE 1 (in inches)", "SIZE 2
(in inches)", "PRICE"});
data.put(1, new Object[] {"P-BOARD:" });
data.put(2, new Object[] {""});
data.put(3, new Object[] {"","AMOUNT PER SQFT", "COUNT",
"PRICE"});
data.put(4, new Object[] {"SCREWS:"});
data.put(5, new Object[] {""});
data.put(6, new Object[] {"", "PRICE 50 lb BAG", "PRICE 25 lb
BAG"});
data.put(7, new Object[] {"MORTAR:"});
data.put(8, new Object[] {""});
data.put(9, new Object[] {"", "PRICE"});
data.put(10, new Object[] {"TROWEL"});
data.put(11, new Object[] {""});
data.put(12, new Object[] {"", "PRICE"});
data.put(13, new Object[] {"GROUT FLOAT"});
data.put(14, new Object[] {""});
data.put(15, new Object[] {"", "PRICE"});
data.put(16, new Object[] {"LARGE BUCKET"});
data.put(17, new Object[] {""});
data.put(18, new Object[] {""});
data.put(19, new Object[] {"TILE DIMENSION 1", "TILE DIMENSION
2", "BRAND", "PRICE"});
Set<Integer> keyset = data.keySet();
int rownum = 0;
for (Integer key : keyset)
{
Row row1 = sheet.createRow(rownum++);
Object [] objArr = data.get(key);
int cellnum = 0;
for (Object obj : objArr)
{
Cell cell1 = row1.createCell(cellnum++);
if(obj instanceof Date)
cell1.setCellValue((Date)obj);
else
if(obj instanceof Boolean)
cell1.setCellValue((Boolean)obj);
else
if(obj instanceof String)
cell1.setCellValue((String)obj);
else
if(obj instanceof Double)
cell1.setCellValue((Double)obj);
}
}

how to edit a java .class file and recompile ,save it

how to edit a java .class file and recompile ,save it

I need to open .class file and do some modificications then I need to save
and re-compile it. I tried google-ing, but most of all posts suggesting
jadEclipse. But I wasn't able to modify the .class file with the
jadEclipse. It is allowing me to view only. So can anyone please suggest
the eclipse plug-in that supports the modifications allowed to the .class
file?

saveAll() with return ID

saveAll() with return ID

I have a form where people sign up/make a payment all together.
I'm using saveAll() to add both a row to the payments table, and a row to
the users table. The only problem is, my user_id isn't getting saved along
with the payment data.
Whats the best way to get the newly created user_id and save it with the
payment data?

Update query failing with error : 1175

Update query failing with error : 1175

I am trying to update a table using the following query
update at_product A join
(
SELECT atbillfields.billeditemguid,count(*) as
numberOfPeopleBought,sum(atbillfields.billeditemqty) As soldquantity
FROM jtbillingtest.at_salesbill atsalesbill join
jtbillingtest.at_billfields atbillfields
on atsalesbill.billbatchguid=atbillfields.billbatchguid
where atsalesbill.billcreationdate BETWEEN'2013-09-09'AND
date_add('2013-09-09', INTERVAL 1 DAY)
group by atbillfields.billeditemguid) B on B.billeditemguid=A.productguid
set A.productQuantity=A.productQuantity-B.soldquantity
but i am getting the following exception
Error Code: 1175. You are using safe update mode and you tried to update a
table without a WHERE that uses a KEY column To disable safe mode, toggle
the option in Preferences -> SQL Queries and reconnect.
When i gave a where clause with update likeA.productQuantity= 1 it updated
that particular . Can someone point why i am unable to execute the query
and how to solve the issue?

automatically create db in Zend

automatically create db in Zend

I was wondering if Zend has any way to automatically construct a database
from model declarations. I could not find any documentation on the matter.
I'm talking now from the point of view of someone who has experience in
Python, where both Django ORM and SQLAlchemy provide a way to
automatically create all database tables by some simple introspection of
the models. Is something like this available for Zend or do I have to
manually create my database ?

Wednesday, 11 September 2013

How tag a struct in go such that it reads values from JSON but does not write them?

How tag a struct in go such that it reads values from JSON but does not
write them?

I have the following struct that I want to read from JSON and Write to
JSON. I want to read the PasswordHash property (deserialize it) but skip
when writing the object (serialize it).
Is it possible to tag the object such that it that it is read when
deserializing but ignored when serializing? the json:"-" seems to skip the
field in both operations.
type User struct {
// Must be unique
UserName string
// The set of projects to which this user has access
Projects []string
// A hash of the password for this user
// Tagged to make it not serialize in responses
PasswordHash string `json:"-"`
// Is the user an admin
IsAdmin bool
}
My deserialization code is as follows:
var user User
content = //Some Content
err := json.Unmarshal(content, &user)
and the serialization code is:
var userBytes, _ = json.Marshal(user)
var respBuffer bytes.Buffer
json.Indent(&respBuffer, userBytes, "", " ")
respBuffer.WriteTo(request.ResponseWriter)

How do I "refresh" my ImageViews when starting an activity using startActivity?

How do I "refresh" my ImageViews when starting an activity using
startActivity?

The problem:
The problem I'm having is that when I go from my main activity to another
activity I have a few ImageViews that simply display .png images. When I
start the app, the main activity is started from the launcher, and upon
tapping one of the image views of this activity it moves the user to
another activity which has other ImageViews. The first time navigating to
this "secondary" activity the ImageViews here are displayed correctly. But
when navigating away from this activity and back to it by tapping the same
icon from the main activity the image views that are associated with this
activity show up "black". I can clearly see that they are "there" but the
.png graphics that are applied to them are not being displayed correctly.
Here is the .xml file that defines the layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenGLMain">
<com.toonCam.main.MainGLSurfaceView
android:id="@+id/mainGLSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- Back Button. -->
<ImageButton
style="@style/OpenGLStyle"
android:id="@+id/back_button"
android:src="@drawable/back_button"
android:layout_marginTop="0dip"
android:layout_marginLeft="0dip"
android:scaleX="0.8"
android:scaleY="0.8"
android:onClick="onClick"/>
<!-- Snap Photo Button. -->
<ImageButton
style="@style/OpenGLStyle"
android:id="@+id/snap_photo_button"
android:src="@drawable/snap_photo_button"
android:layout_marginTop="600dp"
android:layout_marginLeft="600dp"
android:scaleX="2.0"
android:scaleY="2.0"
android:onClick="onClick"/>
<!-- Facebook Share Button. -->
<ImageButton
style="@style/OpenGLStyle"
android:id="@+id/share_photo_button"
android:src="@drawable/share_button"
android:layout_marginTop="650dp"
android:layout_marginLeft="1100dp"
android:scaleX="2.0"
android:scaleY="2.1"/>
<!-- Exit Photo Preview Button -->
<ImageButton
style="@style/OpenGLStyle"
android:id="@+id/return_to_camera_button"
android:src="@drawable/return_to_camera_button"
android:layout_marginTop="0dp"
android:layout_marginLeft="0dp"
android:scaleX="1.0"
android:scaleY="1.0"
android:onClick="onClick"/>
<!-- Save Image Button -->
<ImageButton
style="@style/OpenGLStyle"
android:id="@+id/save_image_button"
android:src="@drawable/save_image_button"
android:layout_marginTop="600dp"
android:layout_marginLeft="600dp"
android:scaleX="1.5"
android:scaleY="1.6"
android:onClick="onClick"/>
Also here is a screenshot of what the ImageViews look like when navigating
to this "secondary" activity for the first time:

Here is the screenshot of the what the ImaveViews look like when
navigating to this "secondary" activity for the second time and beyond,
they never look correct again at this point:

Can I use a single Play WebSocket for both broadcasting and private messages?

Can I use a single Play WebSocket for both broadcasting and private messages?

I need to send a private response to the client for which I'm currently
handling a Play WebSocket message, while for other messages I need to
broadcast responses to all clients.
In the Play chat example, incoming messages are immediately offloaded to a
single Actor:
case Connected(enumerator) =>
// Create an Iteratee to consume the feed, assuming all requests have
// a JSON "text" node, and delegate all to the Akka Actor:
val iteratee = Iteratee.foreach[JsValue] { event =>
default ! Talk(username, (event \ "text").as[String])
}.map { _ =>
default ! Quit(username)
}
(iteratee,enumerator)
Above, once the connection is approved enumerator is passed back, which
refers to the single chatEnumerator that was already created by that same
Actor:
val (chatEnumerator, chatChannel) = Concurrent.broadcast[JsValue]
I assume this does not allow me to send a message to just a single client?
Should I remove the broadcast functionality and create and keep track of
enumerators for each client, and then iterate myself?
(I understand that built-in flexibility depends on the implementation, but
this use case seems quite common to me. Like when using WebSockets with
Socket.IO, I can easily send messages to either all clients, all clients
except the sender of the current request, or just a single client. That's
what I'm trying to achieve in Play 2.1.x as well.)

Batch game map generator

Batch game map generator

It says "set was unexpected at this time" the code:
@echo off
set x=5
set y=5
for /l %%x in (0,1,9) do (
for /l %%y in (0,1,9) do (
set /a map=%random% %% 5+1
if %map% == 5 set m%%x%%y=#
if not %map% == 5 set m%%x%%y=.
)
)
The problem is here:
set /a map=%random% %% 5+1
if %map% == 5 set m%%x%%y=#
if not %map% == 5 set m%%x%%y=.

Can "dynamic Ajax" exist? One that updates itself?

Can "dynamic Ajax" exist? One that updates itself?

Is there a way to make ajax update its own code while executing? I work
with sessions a lot and this would very much ease my job if it's possible.
This is something like what I'm attempting to (unsuccessfully) do:
<!-- index.php (lots of code omitted) -->
<div id="ajax"><?php include 'ajax.php' ?></div>
and
<!-- ajax.php -->
<?php
session_start();
if(!isset($_SESSION["test"])) $_SESSION["test"] = "not set";
else $_SESSION["test"] = "set";
?>
<script>
$('#somebutton').click(function(){
$.ajax({
url: 'ajax.php',
dataType: 'html',
success: function(result){
$('#ajax').html(result);
$('#somediv').html('<?php echo $_SESSION["test"] ?>');
}
});
});
</script>
If what I'm trying to do is possible, what is wrong with this code?

navigation menu bar cant be centrally aligned

navigation menu bar cant be centrally aligned

I am using meganizr mega menu.usually it is available either left-aligned
or right-aligned.but for my requirement i tried to make it
center-aligned.Here i made an online gist.
On the line No.35 if i remove float:left and give text-align:center to
either ul or li, it will be vertical. I tried left:240px; it is in center
but its not responsive. I tried solutions on other questions here for a
whole day.but could not center-align menu and responsive at same time.can
any one help me please?

rails: array of objects, how to sum values of object attributes?

rails: array of objects, how to sum values of object attributes?

I have an array of objects obtained from some queries and the all the
object have the attributes: id, title and quantity. The question is : How
can I sum the quantity by id and save each fields? I've tried this snippet
h=Hash.new(0)
a.each do |el|
h[el.id] += el.quantity
end
and this goes, but I lose the title! How can I have the title inside the
hash h?
thanks!

Runnable handler correct execution

Runnable handler correct execution

I've got a function with a handler where I execute other functions. These
functions are via bluetooth writing and reading functions where a string
is send and then a another string is read.
I've got the function created this way:
status= 0;
handler.post(new Runnable() {
@Override
public void run() {
try {
if (status== 0) {
initThread_send(); //Strings that send the command to
initialize transmission to the PCB
status= 1;
}
else if (status== 1) {
writeClimb_send(); //Sent string with writing command
status= 2;
}
else if (status== 2 && <Another condition>) {
readClimbConf_send(); //Received string that confirms
the writing
status= 3;
}
else if (estado == 3) {
writePlatform_send(); //Sent string with writing command
estado = 4;
}
else if (status== 4 && <Another condition>) {
readPlatformConf_send(); //Received string that
confirms the writing
status= 5;
}
else if (status== 5) {
writeFast_send(); //Sent string with writing command
status= 6;
}
else if (status== 6 && <Another condition>) {
readFastConf_send(); //Received string that confirms
the writing
status= 7;
}
else if (status== 7) {
saveReq_send();
saveStat_send();
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), R.string.com_error
+ e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
The question that I pose here is about how to structure this function in
the right way to meet this requiriments:
* The first problem that I encounter is that when I send a string with the
write command,
in the next state I have to receive the write confirmation from the PCB
and read it,
so, I would need some kind of delay to give to the thread the need time
to process this.
* The thread must be executed linearly, and in this way i think that after
executing the
first function, it goes out of the run.

Tuesday, 10 September 2013

Core Text or not Core Text?

Core Text or not Core Text?

I'm building a Bible app. I read that Core Text does not aid you in
searching or bookmarking, and I'm not sure how to display a text document.
I have the documentation in .pages format, and I display it with a
webView, but I'm not sure if this can solve my problems. Can someone give
me a suggestion on these questions, please?
1) Which framework should I use for displaying the text documentation
(bible) and still cover searching, bookmarking...
2) Should I change the document type to handle it better?

mysql select statement with alias fails with column not found

mysql select statement with alias fails with column not found

mysql select statement with alias fails with column not found
Developemt Environment Reference: Fedora FC18 Tomcat Server 7.0.39
(localhost config) Eclipse Juno Release 2 Mysql-connecor-java Ver. 5.1.26
(jar) Mysql-server Ver. 5.5.32 (jar)
The following select statment fails with "column 'depth' not found:
"select node.subEntityID, node.lft, node.rgt, (count(parent.subEntityID) -
1) as depth from ENTITY as node, ENTITY as parent where node.lft between
parent.lft and parent.rgtgroup by node.subEntityID order by node.lft";
This select statement succeeds using command level mysql as use dbName;
select node.subEntityID, node.lft, node.rgt, (count(parent.subEntityID) -
1) as depth from ENTITY as node, ENTITY as parent where node.lft between
parent.lft and parent.rgtgroup by node.subEntityID order by node.lft;
The select statement also succeeds when using an sql query in Mysql
Workbench Ver. 5.2.4.7
The relevant java code fragment is given below:
rs = stmt.executeQuery(typeEntityList);
// The depth alias does not print out in this for loop
for (int i=1; i<rs.getMetaData().getColumnCount()+1; i++) {
System.out.println(rs.getMetaData().getColumnName(i));
System.out.println(rs.getMetaData().getColumnLabel(i));
}
while (rs.next()) {
// "depth" fails at the following statement
System.out.println("depth: " + rs.getInt("depth"));
String s = rs.getString("lft") + " "
+ rs.getString("subEntityID") + " "
+ rs.getString("rgt");
System.out.println(s);
entityList.add(s);
}
Also, I found on a Google search that mysql alias behavior changed in
recent versions of mysql. A suggested fix was to append
"?useOldAliasMetadataBehavior=true" to the mysql connection string to
revert back to the original behavior, but that did not correct the problem
Any help with this problem is greatly appreciated.
Thanks, Roy W. roycwhitt@gmail.com

How does Javascript return work?

How does Javascript return work?

pThis is what I have/p precode$wrapper.find('li').sort(function (a, b) {
return +a.getAttribute('data-val') - +b.getAttribute('data-val'); });
/code/pre pIt works, as I see in Chrome dev tool an array of objects is
indeed returned but...my question is: What's up with that return? How can
I use that array? /p pWhat I want to do i to take the returned array, and
stick it inside a tag./p

Add the same calculated property to every Symfony2 Controller in bundle

Add the same calculated property to every Symfony2 Controller in bundle

I'm converting an application over from a legacy framework to Symfony2.
One of the things the app has is a tiny little message in the bottom
corner of the rendered page that says
served by appserver3 in 200ms
or similar. It changes depending on the appserver you're on and the amount
of time it took to serve the request. The value for the appserver is set
in
Should I create a BaseController type class that extends Controller and
then have all my controllers extend that? If so, how would I go about
making sure that the BaseController always adds the responseTime and
appServerName to the list of variables that will be passed to my twig
template without having to add it manually in every controller like this:
return $this->render('MyBundle:Default:index.html.twig', array('var1' =>
$var1, 'appServerName' => $this->getAppServerName(), 'responseTime' =>
$this->getResponseTime()));
(Obviously this would assume that I created the getAppServerName and
getResponseTime methods in my BaseController.)
This seems like a lot of copypasta and my whole reason for moving to
Symfony2 is to avoid that :\

ERROR 1006 (HY000) Can't create database (errno: 13) MySQL 5.6.12

ERROR 1006 (HY000) Can't create database (errno: 13) MySQL 5.6.12

I am facing problem in creating the database and it results in following
error.
mysql> show grants for 'admin'@'%';
+---------------------------------------------------------------------------------------------------------------------------------+
| Grants for admin@%
|
+---------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' IDENTIFIED BY PASSWORD
'*4ACFE3202A5FF5CF467898FC58AAB1D615029441' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> create database abc;
ERROR 1006 (HY000): Can't create database 'abc' (errno: 13)
mysql>
Here are my users table.
SELECT * FROM mysql.`user` u;
+-------------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+------------------+
| Host | User | Password |
Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv |
Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv |
Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv |
Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv |
Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv |
Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv |
Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher |
x509_issuer | x509_subject | max_questions | max_updates | max_connections
| max_user_connections | plugin | authentication_string | password_expired
|
+-------------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+------------------+
| localhost | root | *0ED7CCB23F57AFBB530688A270C080BD4956882B | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| N |
|test_dat-DGW | root | *292891EE28681A07B26BD53600C18994D66E8583 | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| Y |
| 127.0.0.1 | root | *292891EE28681A07B26BD53600C18994D66E8583 | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| Y |
| ::1 | root | *292891EE28681A07B26BD53600C18994D66E8583 | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| Y |
| % | admin | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| N |
| localhost | admin | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 | Y
| Y | Y | Y | Y | Y |
Y | Y | Y | Y | Y | Y
| Y | Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| Y | Y | Y | Y
| | | | |
0 | 0 | 0 | 0 | |
| N |
+-------------+-------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+------------------+
6 rows in set (0.00 sec)
I can create and remove table in the existing database.
The data directory already has mysql:mysql privileges and also the logged
in user has privilege to create the new database.
Please guide what configuration is missed here.
Thank you in advance.