Thursday, 3 October 2013

Configuring firewalld on a router, how to allow FORWARDing?

Configuring firewalld on a router, how to allow FORWARDing?

I've just installed Fedora 19 and I'm using firewalld instead of iptables,
but I'm having difficulty interpretting the new terminology.
I have 2 NICs. One is specificed ZONE="internal" and the other "external"
in the ifcfg-* files, I have set ipv4.forwarding = 1 in /etc/sysctl.conf,
and run firewall-cmd --zone=external --add-masquerade
However, when I attempt to route from any machine on the internal network
I'm getting Destination Host Prohibited and of course if I disable
firewalld the error goes away but then I lose masquerading.
In iptables there was a ruleset called FORWARD, but in firewalld I can
only find --add-port-forward which isn't the same thing.
How do I allow routing in firewalld ?
TIA.

Wednesday, 2 October 2013

not get the android map V2 in emulator

not get the android map V2 in emulator

10-03 02:03:53.220: W/GooglePlayServicesUtil(841): Google Play services
out of date. Requires 3265100 but found 2012110 10-03 02:03:53.240:
W/GooglePlayServicesUtil(841): Google Play services out of date. Requires
3265100 but found 2012110 10-03 02:03:53.260:
W/GooglePlayServicesUtil(841): Google Play services out of date. Requires
3265100 but found 2012110 10-03 02:03:53.270:
W/GooglePlayServicesUtil(841): Google Play services out of date. Requires
3265100 but found 2012110 10-03 02:03:53.290:
W/GooglePlayServicesUtil(841): Google Play services out of date. Requires
3265100 but found 2012110 10-03 02:03:53.330:
W/GooglePlayServicesUtil(841): Google Play services out of date. Requires
3265100 but found 2012110 10-03 02:03:53.330: D/AndroidRuntime(841):
Shutting down VM 10-03 02:03:53.341: W/dalvikvm(841): threadid=1: thread
exiting with uncaught exception (group=0x40a71930) 10-03 02:03:53.360:
E/AndroidRuntime(841): FATAL EXCEPTION: main 10-03 02:03:53.360:
E/AndroidRuntime(841): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{info.tekguc.umut.googlemapsmapsandroidv2/info.tekguc.umut.googlemapsmapsandroidv2.MainActivity}:
java.lang.NullPointerException 10-03 02:03:53.360: E/AndroidRuntime(841):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.os.Handler.dispatchMessage(Handler.java:99) 10-03 02:03:53.360:
E/AndroidRuntime(841): at android.os.Looper.loop(Looper.java:137) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.main(ActivityThread.java:5041) 10-03
02:03:53.360: E/AndroidRuntime(841): at
java.lang.reflect.Method.invokeNative(Native Method) 10-03 02:03:53.360:
E/AndroidRuntime(841): at java.lang.reflect.Method.invoke(Method.java:511)
10-03 02:03:53.360: E/AndroidRuntime(841): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-03 02:03:53.360: E/AndroidRuntime(841): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 10-03
02:03:53.360: E/AndroidRuntime(841): at
dalvik.system.NativeStart.main(Native Method) 10-03 02:03:53.360:
E/AndroidRuntime(841): Caused by: java.lang.NullPointerException 10-03
02:03:53.360: E/AndroidRuntime(841): at
info.tekguc.umut.googlemapsmapsandroidv2.MainActivity.onCreate(MainActivity.java:23)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.Activity.performCreate(Activity.java:5104) 10-03 02:03:53.360:
E/AndroidRuntime(841): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-03 02:03:53.360: E/AndroidRuntime(841): ... 11 more 10-03 02:03:53.360:
E/AndroidRuntime(841): FATAL EXCEPTION: main 10-03 02:03:53.360:
E/AndroidRuntime(841): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{info.tekguc.umut.googlemapsmapsandroidv2/info.tekguc.umut.googlemapsmapsandroidv2.MainActivity}:
java.lang.NullPointerException 10-03 02:03:53.360: E/AndroidRuntime(841):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.access$600(ActivityThread.java:141) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.os.Handler.dispatchMessage(Handler.java:99) 10-03 02:03:53.360:
E/AndroidRuntime(841): at android.os.Looper.loop(Looper.java:137) 10-03
02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.main(ActivityThread.java:5041) 10-03
02:03:53.360: E/AndroidRuntime(841): at
java.lang.reflect.Method.invokeNative(Native Method) 10-03 02:03:53.360:
E/AndroidRuntime(841): at java.lang.reflect.Method.invoke(Method.java:511)
10-03 02:03:53.360: E/AndroidRuntime(841): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-03 02:03:53.360: E/AndroidRuntime(841): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 10-03
02:03:53.360: E/AndroidRuntime(841): at
dalvik.system.NativeStart.main(Native Method) 10-03 02:03:53.360:
E/AndroidRuntime(841): Caused by: java.lang.NullPointerException 10-03
02:03:53.360: E/AndroidRuntime(841): at
info.tekguc.umut.googlemapsmapsandroidv2.MainActivity.onCreate(MainActivity.java:23)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.Activity.performCreate(Activity.java:5104) 10-03 02:03:53.360:
E/AndroidRuntime(841): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-03 02:03:53.360: E/AndroidRuntime(841): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-03 02:03:53.360: E/AndroidRuntime(841): ... 11 more 10-03 02:03:56.960:
I/Process(841): Sending signal. PID: 841 SIG: 9

WMI query and event works in single class but not application?

WMI query and event works in single class but not application?

I am using WMI to find events where a USB device is plugged in. I made a
standalone class to try this out, and it worked great! As soon as I call
the class from my application, it does not work. The code is identical,
with the exception of the main() when I compile the class as a stand-alone
exe. The code follows:
ManagementScope scope = new ManagementScope("root\\CIMV2"); //set the
scope
WqlEventQuery query = new WqlEventQuery("SELECT * FROM
__InstanceCreationEvent WHERE TargetInstance ISA 'Win32_PnPEntity'");
//set the events
watcher = new ManagementEventWatcher(scope, query);
watcher.EventArrived += new
EventArrivedEventHandler(this.DeviceChangeEventReceived);
watcher.Start();
The DeviceChangeEventReceived method is never called when built into the
larger application. I thought it might be the scope, but it seems not to
be. I am sure that it's something simple, but I'm out of ideas. Thanks!

Vector of pairs or pair of vectors?

Vector of pairs or pair of vectors?

In my code I'm dealing with a set of measurements (a vector of float), in
which each element has two associated uncertainties (say +up/-down). Let's
say I want to dump on screen these values, something like
Loop over the vector of the measurements
{
cout << i-th central value << " +" << i-th up uncertainty << " / -" <<
i-th down uncertainty << end;
}
What's the most efficient/elegant way to do it?
1) Using a pair of vectors
vector<float> central; //central measurement
pair<vector<float>, vector<float>> errors; //errors
for( int i = 0; i < central.size ; i++ )
{
cout << central.at(i) << " +" << errors.first.at(i) << " / -" <<
errors.second.at(i) << endl;
}
2) Using a vector of pairs:
vector<float> central; //central measurement
vector<pair<float,float>> errors; //errors
for( int i = 0; i < central.size ; i++ )
{
cout << central.at(i) << " +" << errors.at(i).first << " / -" <<
errors.at(i).second << endl;
}
3) Two separate vectors:
vector<float> central; //central measurement
vector<float> errUp; //errors up
vector<float> errDown; //errors down
for( int i = 0; i < central.size ; i++ )
{
cout << central.at(i) << " +" << errUp.at(i) << " / -" <<
errDown.at(i) << endl;
}

Web mobile upload using C#

Web mobile upload using C#

i'm trying to develop a web mobile app using C#. its just a simple upload
picture module, and get its exif. the app is working fine on normal
browser on PC. file can be upload and exif can be read.
however when tested on most mobile browsers, this exception was thrown:
'Could not find a part of the path 'c:\inetpub\wwwroot\Temp\1.jpg'.
here's the line in .aspx file
<input id="imgUpload" type="file" runat="server" />
and the lines in .aspx.cs file
string filename = myProfile.ID.ToString() + ".jpg";
string physiclPath = HttpContext.Current.Server.MapPath("..\\..\\Temp\\");
imgUpload.PostedFile.SaveAs(physiclPath + filename);
Response.Write("File uploaded successfully!");
is there anything important i miss for web mobile uploads?

Tuesday, 1 October 2013

Advice with range function and or statements python

Advice with range function and or statements python

I am just trying to add up all the multiples of 3 and 5 up to 1000, while
making sure that I do not add the coinciding multiples twice hence the or.
I only want it to add the multiple of 5 if it is not a multiple of 3.
Thanks in advance
a=range(0, 1000,3 ) or range(0,1000,5)
b=sum(a)
print (b)

Cookies wont set if i specify an expiry date

Cookies wont set if i specify an expiry date

this works:
setcookie('$id', $date);
But this doesnt set a cookie:
setcookie('$id', $date, 1000);
Any ideas?

GUEST MEM - VMWARE

GUEST MEM - VMWARE

I am reviewing an esxi 4.1 host memory usage I would like to lower some of
the memory usage on some virtual machines.
For example here I have a windows 2003 server
This server is using 1GB Ram one more than it needs, I want to have a lean
environment for the ESXI hosts.
Here is an example of my usage, am I correct thinking the lower guest
memory VMs can have the memory resources lowered.
GUEST OS HOST MEM - MB GUEST MEM - %
Microsoft Windows 7 (32-bit) 2089 15%
Microsoft Windows Server 2003, Standard Edition (32-bit) 3037 10%
Microsoft Windows Server 2008 R2 (64-bit) 0 0%
Microsoft Windows Server 2003, Standard Edition (64-bit) 2065 4%
Microsoft Windows Server 2003, Standard Edition (32-bit) 2043 11%
Microsoft Windows Server 2003, Standard Edition (32-bit) 2016 12%
Microsoft Windows 7 (64-bit) 1058 14%
Microsoft Windows XP Professional (32-bit) 2091 12%
Microsoft Windows Server 2008 R2 (64-bit) 16549 12%
Microsoft Windows XP Professional (32-bit) 995 12%
Microsoft Windows Server 2003, Standard Edition (32-bit) 2020 4%
Microsoft Windows Server 2003, Standard Edition (32-bit) 1013 6%
Microsoft Windows Server 2003, Standard Edition (32-bit) 2010 13%
Microsoft Windows XP Professional (32-bit) 3047 10%
Microsoft Windows XP Professional (32-bit) 2972 18%
Microsoft Windows XP Professional (32-bit) 2031 16%
Microsoft Windows XP Professional (32-bit) 1993 9%
Microsoft Windows XP Professional (32-bit) 2038 16%
Microsoft Windows XP Professional (32-bit) 3118 1%
Microsoft Windows XP Professional (32-bit) 2022 45%
Microsoft Windows XP Professional (32-bit) 870 1%
Microsoft Windows Server 2003, Standard Edition (64-bit) 4123 0%
Microsoft Windows Server 2003, Standard Edition (32-bit) 3025 30%
Microsoft Windows Server 2003, Standard Edition (32-bit) 2007 1%
Microsoft Windows Server 2003, Standard Edition (32-bit) 4098 1%
Microsoft Windows Server 2003, Standard Edition (64-bit) 0 0%

Multiple domains, same website in plesk

Multiple domains, same website in plesk

I have a domain with a SSL at https:/www.domain1.com
I want that http:/www.domain2.com shows the same website as domain1 (same
website folder)
I've tried with domain alias in Plesk but it's redirecting to
https:/www.domain1.com
Any ideas please?
Thank you

Monday, 30 September 2013

Invalid byte sequence for character encoding 0x00 after upgrading from 8.3 to 8.4

Invalid byte sequence for character encoding 0x00 after upgrading from 8.3
to 8.4

I'm trying to upgrade a database from PostgreSql 8.3 to 8.4, I backed up
the data from 8.3 and restored from 8.4 without issues, but, when I try to
use the same program that is working perfectly connected to 8.3, it throws
the error:
Invalid byte sequence for character encoding <<WIN1252>>: 0x00
Does anyone know what can be happening?.
SOLVED: Pg 8.4 is more strict when dealing with characters, hence the
error. It was my program that was trying to insert \0 on a field. This
forced me to debug my program and solve the problem.

SD mounting in my Sony Xperia L

SD mounting in my Sony Xperia L

I have recently bought a Sony Xperia l and when I insert my sd card it
doesn't mount. Nothing shows that there is a memory card inserted, thus
the files do not appear and yet in other phones the card shows.I don't
know whether it's because the sd has a password. Please help :-/

Comparing php array key value

Comparing php array key value

I am trying to compare two array value. My array1 is like
$a1= array('123' => 'test1, '456' => 'test2', '789' => 'test3')
array2 is like
a2=array('456' => 'match2', '99' => 'match3')
a3 = array();
I want to compare the key value. If array1 key matches array2 key, push
array1 element to a new array
I have
for($i=0; $i < count($a1); $i++){
//i am not sure how to write my codes heree......
if($a1[$i]==a2[$i]{
$a3[]=a1$[$i];
}
}
Can someone help me out on this? Thanks a lot!

How to replace duplicate strings of words in each row using regular expressions with vi?

How to replace duplicate strings of words in each row using regular
expressions with vi?

How to replace duplicate strings of words in each row using regular
expressions with vi? For instance, I have the following list of seaports
having duplicated text. My goal is to achieve the following output below:
(input) Duplicated List
Andorra La Vella Andorra La Vella
Al Ain Al Ain
Abu al Bukhoosh Abu al Bukhoosh
Ajman Ajman
Arzanah Island Arzanah Island
Abu Dhabi Abu Dhabi
Das Island Das Island
Al Dhafra Al Dhafra
Ras Zubbaya (Ras Dubayyah) Ras Zubbaya (Ras Dubayyah)
Dubai Dubai
Fateh Terminal Fateh Terminal
Fujairah (Al-Fujairah) Fujairah (Al-Fujairah)
Musafa Musafa
Hamriyah Hamriyah
Jebel Ali Jebel Ali
Jebel Dhanna Jebel Dhanna
Khor Al Fakkan Khor Al Fakkan
Masfut Masfut
Mubarras Island Mubarras Island

(output) Corrected List

Andorra La Vella
Al Ain
Abu al Bukhoosh
Ajman
Arzanah Island
Abu Dhabi
Das Island
Al Dhafra
Ras Zubbaya (Ras Dubayyah)
Dubai
Fateh Terminal
Fujairah (Al-Fujairah)
(...)

Any insight?

(full list of ports available in http://www.photius.com/seaports/)

Sunday, 29 September 2013

PHP Oracle Prevent Double Submit Data With My Case

PHP Oracle Prevent Double Submit Data With My Case

I want to prevent submit data with double data with 2 parameters, model_no
and date_added.
Here is my code :
$query_2 = "SELECT M.MODEL_NO, M.MODEL_NAME, P.MODEL_NO, P.DATE_ADDED FROM
SEIAPPS_MODEL M, SEIAPPS_PRODUCTION_STATUS P WHERE M.MODEL_NO = P.MODEL_NO
AND P.MODEL_NO='$model'";
$result2 = oci_parse($c1, $query_2);
oci_execute($result2);
while ($data_1 = oci_fetch_array($result2))
{
$date_added_a = $data_1['DATE_ADDED'];
$model_a = $data_1['MODEL_NO'];
$model_name = $data_1['MODEL_NAME'];
}
if
((!empty($model)) &&
(!empty($production_status)) &&
(!empty($remarks)))
{
if($model_a == "$model" && $date_added_a ==
"$date_added")
{
echo "<div class='error'>Duplicate data
information not allowed!</div>";
}
else
{
$submit_query = "INSERT INTO
SEIAPPS_PRODUCTION_STATUS(FORM_NO, MODEL_NO,
PRODUCTION_STATUS, REMARKS, QTY_PLAN, DATE_ADDED,
TIME, IP_ADDRESS)
VALUES('$form_no', '$model',
'$production_status', '$remarks',
'$qty_plan', '$date_added',
'$time', '$ip_address')
";
$result_query = oci_parse($c1, $submit_query);
oci_execute($result_query);
if($result_query)
{
echo "<div class='success'>Data production
plan and status for <b>$model_name</b> has
been added.</div>";
}
}
}
else
{
echo "<div class='error'>All field are required!</div>";
}
I tried this code, but when I try to submit with the same data, it will
saved the data. So the data will double in table.
Any advice how to prevent double submit with my case ?

JavaFX WebView load local Javascript file

JavaFX WebView load local Javascript file

I am experimenting with the JavaFX WebView control and I want to use the
MathJax Javascript library to render mathematical content inside the
WebView control.
As a test I have created a basic JavaFX FXML project, added a WebView to
the FXML and updated the controller code like so:
public class SampleController implements Initializable {
@FXML
private WebView webView;
@Override
public void initialize(URL url, ResourceBundle rb) {
webView.getEngine().load("file:///Users/benjamin/Desktop/Page.html");
}
}
The html file looks like this:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'],
['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="/Users/benjamin/Downloads/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\)
and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</body>
</html>
This works as expected and produces the following result:

My next step was to package the html as a resource that is bundled with
the application. The controller code is updated to look up the page like
this:
@Override
public void initialize(URL url, ResourceBundle rb) {
webView.getEngine().load(this.getClass().getResource("Page.html").toExternalForm());
}
but this produces the following result:

As you can see, the mathematical content is no longer rendered (the html
has not been changed).
If I change the html to load the Javascript from the CDN, then everything
works as in the original example but for the time being I am interested in
loading the local Javascript file. Is this possible?

Finding Pathname for a file from Enviornment Variable in Linux using c++

Finding Pathname for a file from Enviornment Variable in Linux using c++

So i am trying to create a Command Line Interpretor in Ubuntu using C/C++
It is part of our lab task for college The basic feature of the CLI is to
take input from the user , parse it to find the command and its arguments
, then look up the pathname for the command from the Environment Variable
I have been able to parse the String , get the command and its arguments ,
I have also been able to read to the Path Environment Variables to get the
directories of all the paths. Now i must look through these directories to
find where the file (command) lies , and then return the complete path so
it can be sent to execve for execution in the child process i have to
create a lookup function which takes the arguments array (the 0th index
position contains the command name ) and the array of directories Here is
an outline of the function that has been provided to us
// Search the directories identified by the dir argument to see
// if the argv[0] (the filename) appears there. Allocate a new
// string, place the full path name in it, then return the string.
//
char* lookupPath(char **argv, char **dir){
char* result;
char pName[MAX_PATH_LEN];
// check if is already an absolute path name
if( *argv[0] == '/' ) .....
// look in PATH directories, use access() to see if the
// file is in the dir
for( i = 0 ; i < MAX_PATHS ; i++ ) .....
// File name not found in any path variable
fprintf(stderr, "%s: command not found\n", argv[0]);
return NULL;
}
here argv is the array of arguments (0th index contains the command and
the following index contains arguments) and dir[] contains an array of all
the directories
Now how em i suppose to traverse trough the directories to find the full
path for the give command ?

I did that the form1 will move slowly to the left. How can i make that it will start from the center of the screen?

I did that the form1 will move slowly to the left. How can i make that it
will start from the center of the screen?

At the top of Form1 i did:
private IntPtr ID;
private int counter = 0;
In the constructor i did:
ID = this.Handle;
timer2.Enabled = true;
Then in timer2 tick event i did:
private void timer2_Tick(object sender, EventArgs e)
{
if (counter <= Screen.PrimaryScreen.Bounds.Right)
MoveWindow(ID, counter++, 0, this.Width, this.Height, true);
else
counter = 0;
}
But the form start to move from the top left corner at 0,0 to the right. I
want the form will start to move from the center of the screen to the left
untill it hit the left border/bound and stop and stay there.
How can i do it ?
I found now how to make it to move to the left and stop on the left
border/bound:
private void timer2_Tick(object sender, EventArgs e)
{
if (counter >= Screen.PrimaryScreen.Bounds.Left)
MoveWindow(ID, counter--, 0, this.Width, this.Height, true);
else
counter = 0;
}
But how do i make that it will start to move from the middle/center of the
screen ? I did in the designer change the property: StartPosition to
CenterScreen But the form start to move from the top left corner 0,0

Saturday, 28 September 2013

How apex get executed in Salesforce

How apex get executed in Salesforce

i write a Batch apex.i write an execute method .which is using a static
variable of another class.because it is shhared.any one can use it and
change it.
public void execute(Database.BatchableContext BC, List<sObject> scope){
x=GMirror.x;
...........
...........
.........
y =GMirror.x;
}
i want to know each batch of 5 in my case will run in transaction or means
at this time only this method is running nothing else or in other words i
want to know if using another class's method execution in between time
first statement execute x=GMirror.x;
and second statement y =GMirror.x;
its possible by another parallel execution of another class's method that
these value of GMirror.x get changed ?? these execution this necessary
that no one changed value of GMirror.x or value of GMirror.x can be
changed by another parallel execution.Please clarify .

Broadcast Receiver for multiple database Cursor

Broadcast Receiver for multiple database Cursor

I have been stuck on this problem for a while.
Is there any good example for Broadcast Receiver?

JPA mapping primary key in one table with 2 foreign keys in another table

JPA mapping primary key in one table with 2 foreign keys in another table

I have a primary key in one table and which is linked to 2 foreign keys in
other table. how to do mapping in this scenario and how to decide fetching
type and cascading type. I am new to JPA so any inputs will be usefull.

Friday, 27 September 2013

asp.net c# - Toggle display the child DataList

asp.net c# - Toggle display the child DataList

I am try to toogle the display subnet data(childList). This codes below
are working fine, but not able to toogle the display. When I click on the
(+) sign, the ChildList dataList expands and displays the list subset data
(Contact). However, I want to change the (+) to (-) when childList data
expanded. And when user clicks on (-), it will collapse back (the child
list disappear)
Any idea how to do this? an example code would be great since I am a
newbie of ASP.NET.
Thanks,
<table width="595px">
<asp:DataList BackColor="#ffffff" id="DataList1"
DataSourceID="dsCompanyList" runat="server" Width="100%"
DataKeyField="Company">
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" Text="+"
CommandArgument='<%#Container.ItemIndex%>'
OnCommand="LinkButton1_Command"
></asp:LinkButton>
</td>
<td><%#Eval("Row")%></td>
<td><%#Eval("Company")%></td>
</tr>
<asp:Panel ID="pnlChildView" runat="server">
<asp:DataList ID="childList" runat="server" Width="100%">
<ItemTemplate>
<tr>
<td><%#Eval("FirstName")%></td>
<td><%#Eval("LastName")%></td>
</tr>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
</ItemTemplate>
</asp:DataList>
</table>
Code Behind:
public partial class _CompanyList2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
//pass index of item in command argument
int itemIndex = Convert.ToInt32(e.CommandArgument);
//depending on your needs bind the details on demand
//or preload during ItemDataBound
Panel childViewPanel =
(Panel)DataList1.Items[itemIndex].FindControl("pnlChildView");
if (childViewPanel != null)
{
//toggle visibility of childViewPanel and bind child list if
panel is visible
DataList childList =
(DataList)childViewPanel.FindControl("childList");
if (childList != null)
{
//int keyValue = (int)DataList1.DataKeys[itemIndex];
string keyValue = (string)DataList1.DataKeys[itemIndex];
using (SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["connApps"].ConnectionString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT
FirstName, LastName FROM dbo.Import_CompanyContact
WHERE REPLACE(Company, '''', '') = '" + keyValue +
"'", con))
{
cmd.CommandType = CommandType.Text;
using (SqlDataReader dr = cmd.ExecuteReader())
{
childList.DataSource = dr;
childList.DataBind();
}
}
}
}
}
}
}

Reading files line by line in by using for loop bash script

Reading files line by line in by using for loop bash script

Say for example I have a file called "tests",it contains
a
b
c
d
I'm trying to read this file line by line and it should output
a
b
c
d
I create a bash script called "read" and try to read this file by using
for loop
#!/bin/bash
for i in ${1}; do //for the ith line of the first argument, do...
echo $i // prints ith line
done
I execute it
./read tests
but it gives me
tests
Does anyone know what happened? Why does it print "tests" instead of the
content of the "tests"? Thanks in advance.

bash script sftp exit terminate script

bash script sftp exit terminate script

Im new in bash scripting and Ive met a problem here is the example of my
script
NOW=$(date +"%m-%d-%Y-%H")
echo -e "\nSFTP connection"
sftp username@ip <<EOT
lcd local_folder/
cd remote_folder/
mget *.txt
exit
EOT
##here it stops
echo -e "\nNew folder"
cat email_list | while read line
do
mail -s "topic" $line < text.txt
done
echo -e "\nSent"
}
When im closing the connection with ftp the script stops and doesnt return
the second part of the script:(
Please give me suggestions about what im doing wrong
Thank you!

Contiguous Printing in Crystal Reports

Contiguous Printing in Crystal Reports

I have developed a Crystal report (more like modified a default one that
came with Epicor) that prints out parts and descriptions on a sales order.
At our company, we have a generic part number that is representative of a
particular type of finished product. In the description, we provide
detailed information on the specific product being supplied, like sizes
and various other specifications. As a result, these descriptions can get
pretty lengthy. The problem is that Crystal prints the descriptions as a
block rather than flowing text. Meaning that if a description is too large
to fit in the remaining space on a page, it will jump it to the next page
leaving a large gap on the previous page, instead of printing the text
that does fit and then starting over on a new page with the remaining
text. This really causes problems when a description is roughly the same
size as a page, as it duplicates the description, sometimes more than a
dozen times. So my question is, is there a way to make Crystal print these
as flowing, contiguous text rather than blocks?

Notify when thread is complete, without locking calling thread

Notify when thread is complete, without locking calling thread

I am working on a legacy application that is built on top of NET 3.5. This
is a constraint that I can't change. I need to execute a second thread to
run a long running task without locking the UI. When the thread is
complete, somehow I need to execute a Callback.
Right now I tried this pseudo-code:
Thread _thread = new Thread(myLongRunningTask) { IsBackground = True };
_tread.Start();
// wait until it's done
_thread.Join();
// execute finalizer
The second option, which does not lock the UI, is the following:
Thread _thread = new Thread(myLongRunningTask) { IsBackground = True };
_tread.Start();
// wait until it's done
while(_thread.IsAlive)
{
Application.DoEvents();
Thread.Sleep(100);
}
// execute finalizer
Of course the second solution is not good cause it overcharge the UI. What
is the correct way to execute a callback when a _thread is complete? Also,
how do I know if the thread was cancelled or aborted?
*Note: * I can't use the BackgroundWorker and I can't use the Async
library, I need to work with the native thread class.

jquery tagit not wokting with IE9

jquery tagit not wokting with IE9

I have a problem with the jquery tag-it plugin found at:
http://aehlke.github.io/tag-it/
I want to fetch my data using AJAX, and only pass along the id while
preserving the label in the tagfield to show.
This works perfectly in every major browser (chrome,FF,safari) Except IE9
(havent tried higher versions, since i need to support IE9).
Here is my code:
$("#myTags").tagit({
placeholderText: window.inviteTxt,
fieldName: "tag[]",
//minLength: 2,
autocomplete: {
delay: 0,
minLength: 2,
source: function( request, response ) {
$.ajax({
url: "/service/search.php",
dataType: "json",
data: {
cmd: "getTags",
txt: request.term
},
success: function( data ) {
response( $.map( data , function( item ) {
return {
label: item.label,
value: item.uid
}
}));
}
});
},
select : function(event,ui) {
window.itemId = ui.item.value;
console.log(window.itemId);
$("#myTags").tagit("createTag", ui.item.label);
return false;
},
focus: function(event, ui) {
window.itemId = ui.item.value;
$(this).val(ui.item.label);
return false;
},
},
allowSpaces:true,
beforeTagAdded: function(event, ui) {
// do something special
//if(!contains(window.data,ui.tagLabel)) return false;
},
afterTagAdded: function(event, ui) {
console.log(window.itemId);
if (window.itemId) {
$(ui.tag).find('input').attr('name', "tag[" +
window.itemId+ "]");
window.itemId = null;
}
}
});
In all other browsers, the value is passed along in the tag-array as key,
but in IE9, the value is just 0.
Is there an obvious mistake in my code, or is it something deeper?
Thanks in advance.

Thursday, 26 September 2013

Printing a 2D array multiple times depending on user input

Printing a 2D array multiple times depending on user input

I posted about this assignment before, and I have the program pretty much
working with the exception of one thing. The program asks the user what
file they want to print, how many times they want to tile it across and
how many times they want to tile it down. My program reads the file into a
2d array, and then it is supposed to tile it out. I am using three for
loops to try to print it and it is printing the correct amount, however it
is only printing vertically. I tried putting in a blank println to see if
that would get it to print correctly but it is not working. Anyone have
any ideas? Here's the part of the code that stores the txt file into the
2d array and the method that is supposed to tile it:
import java.io.*;
import java.util.*;
class TileMap
{
public static boolean yes;
public static char response;
public static int MAXSIDE = 100;
public static Scanner scan = new Scanner(System.in);
public static String fileName = "";
public static int tilesAcross = 0;
public static int tilesDown = 0;
public static int imageHeight = 0;
public static int imageWidth = 0;
public static char userInput = 0;
static char [][] buffer = new char[MAXSIDE][MAXSIDE];
static FileInputStream fstream = null;
public static void getImage()
{
System.out.println("Getting Image...");
try
{
File file = new File(fileName);
Scanner fstream = new Scanner(file);
imageHeight = fstream.nextInt();
imageWidth = fstream.nextInt();
buffer = new char[imageHeight][imageWidth];
int i = 0;
while(fstream.hasNextLine())
{
String line = fstream.nextLine();
for(int l = 0; l < line.length(); l++)
{
buffer[i][l] = line.charAt(l);
}
i++;
}
/*
for(int i = 0; i < imageHeight; i++)
{
String element = fstream.nextLine();
for(int j = 0; j < imageWidth; j++)
{
buffer[i][j] = element.charAt(j);
}
}
*/
fstream.close();
}
catch (Exception e)
{
System.err.println("Error: " + e.getMessage());
}
}
public static void doTileJob ()
{
for(int m = 0; m < tilesDown; m++)
{
for (int n = 0; n < tilesAcross;n++)
{
for(int i= 0; i < buffer.length; i++)
{
int w = 0;
System.out.print(buffer[i]);
System.out.println(buffer[w]);
w++;
}
System.out.println();
}
}
}
}

Wednesday, 25 September 2013

how to improve the homography accuracy?

how to improve the homography accuracy?

I used opencv's cv::findHomography API to caculate the homography matrix
of two planar images. The matched key points are extracted by Sift and
matched by BFMatcher. As I know, cv:findHomography use ransac iteration to
find out the best four corresponding points to get the homography matrix.
So I draw the selected four pairs of points with the calculated contour
using homograhy matrix of the edge of the object. The result are as the
links:
http://postimg.org/image/5igwvfrx9/
As we can see, the selected matched points by ransac are correct, but the
contour shows that the homography is not accurate.
But these test shows that, both the selected matched points and the
homography are correct:
http://postimg.org/image/dvjnvtm53/
My guess is that if the selected matched points are too close, the small
error of the pixel position will lead to the significant error of the
homography matrix. If the four points are in the corner of the image, then
the shift of the matched points by 4-6 pixels still got good homography
matrix. (According the homogenous coordinate, I think it is reasonable, as
the small error in the near plane will be amplified in the far away)
My question is:
1.Is my guess right? 2.Since the four matched points are generated by the
ransac iteration, the overall error of all the keypoints are minal. But
How to get the stable homography, at least making the contour's mapping is
correct? The theory proved that if the four corresponding points in a
plane are found, the homography matrix should be caculated, but is there
any trick in the engineer work?
Thank you.

Thursday, 19 September 2013

split some string variabel into array[] in php

split some string variabel into array[] in php

i have script in php, like this > "pax_name":"vicky,toni,ivhan" ;
"pax_name" variabel have a string value
is there any idea to make array like this >
"pax_name":["vicky","toni","ivhan"]
thanks before

ios 7 - UIView animate method with delay is not delayed

ios 7 - UIView animate method with delay is not delayed

I'm currently testing new iOS 7 views controller transition. What i want
is a custom modal presenting transition that present your next view cut
into several strip from top off screen. Each strip should appear after an
incremental delay to give the desired effect.
So my code looks like this :
-
(void)presentModalWithContext:(id<UIViewControllerContextTransitioning>)context
{
UIView *inView = [context containerView];
UIView *fromView = [context
viewControllerForKey:UITransitionContextFromViewControllerKey].view;
UIView *toView = [context
viewControllerForKey:UITransitionContextToViewControllerKey].view;
NSTimeInterval stripTime = 1.0;
NSTimeInterval stripDelay = 1.0;
NSInteger stripCount = 10;
CGFloat stripHeight = toView.frame.size.height / stripCount;
for (NSInteger i = 0; i < stripCount; i++)
{
CGFloat offsetY = i*stripHeight;
CGRect snapRect = CGRectMake(0, offsetY, toView.frame.size.width,
stripHeight);
UIView *view = [toView resizableSnapshotViewFromRect:snapRect
afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero];
CGRect stripRect = CGRectMake(0, -(stripCount-i)*stripHeight,
snapRect.size.width, snapRect.size.height);
view.frame = stripRect;
[inView insertSubview:view aboveSubview:fromView];
NSTimeInterval interval = stripDelay*(stripCount-i);
[UIView animateWithDuration:stripTime delay:interval options:0
animations:^{
CGPoint center = view.center;
center.y += stripCount*stripHeight;
view.center = center;
} completion:^(BOOL finished) {
NSLog(@"complete");
if (i == stripCount-1)
[context completeTransition:YES];
}];
}
}
I've already checked initial and final position of each strip and already
is OK. My interval variable is also properly set at each loop.
But it seems that this is not delayed at all. All strips are moving
together, giving the impression that the complete view is moving.
A quick look to basic log shows that all animations are performed at the
same time :
2013-09-20 01:11:32.908 test_transition[7451:a0b] complete
2013-09-20 01:11:32.909 test_transition[7451:a0b] complete
2013-09-20 01:11:32.910 test_transition[7451:a0b] complete
2013-09-20 01:11:32.910 test_transition[7451:a0b] complete
2013-09-20 01:11:32.911 test_transition[7451:a0b] complete
2013-09-20 01:11:32.911 test_transition[7451:a0b] complete
2013-09-20 01:11:32.912 test_transition[7451:a0b] complete
2013-09-20 01:11:32.912 test_transition[7451:a0b] complete
2013-09-20 01:11:32.913 test_transition[7451:a0b] complete
2013-09-20 01:11:32.913 test_transition[7451:a0b] complete
Do someone is able to spot what's wrong here ?

Converting image to imagedata and vice versa without drawing to canvas

Converting image to imagedata and vice versa without drawing to canvas

I'm wondering if there's a way to convert images to imagedata and vice
versa without drawing to canvas.
I know the methods getImageData() and toDataURL() can be used to copy the
canvas but what if I'd prefer to take an imc.src path and convert that
directly to imagedata. Or convert imagedata directly to a DataURL without
passing it to canvas.

Difference between Thread.sleep() vs Object.sleep()

Difference between Thread.sleep() vs Object.sleep()

I have a function that:
Thread myThread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(500);
myThread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
Is it same if i use "Thread.sleep(500);" or "myThread.sleep(500);" ?
Is there any differences between two different use?

Is there a Keyboard Shortcut in Chrome Developer Tools to switch Source File?

Is there a Keyboard Shortcut in Chrome Developer Tools to switch Source File?

Checking the list
https://developers.google.com/chrome-developer-tools/docs/shortcuts?csw=1#sources-panel
I cannot find any way to navigate through the source files inside Chrome
Dev Tools. Anyone with an idea how to switch source files without using
the mouse?

Subtract a generic list from another

Subtract a generic list from another

Hi friends I am really stuck,
I am trying remove a list of firmIDs from one list from another. I don't
really understand linq but I am pretty sure I need to use it.
List<Firm> firms = GetBusinessDevelopmentFirms(database);
List<Firm> trackedFirms = GetAllCLIFirmsBeingTrackedByUser();
var result = firms.Contains(i => trackedFirms.Contains(i.FirmID));
The last line doesn't work and the system says "unknown method
Contains(?)" even though I have put "using System.Linq;" At the top of the
class.
My idea was to remove a list of tracked firms from a list of all firms to
find the untracked firms.
I hope this makes sense.

How to get Tablename ,ForeignKey and Constraints

How to get Tablename ,ForeignKey and Constraints

I have written the Query in which i am getting TableName,Columns,Precision
but how can i get Table related Foreign key and Constraints
SELECT DISTINCT
QUOTENAME(SCHEMA_NAME(tb.[schema_id])) AS 'Schema',
QUOTENAME(OBJECT_NAME(tb.[OBJECT_ID])) AS 'Table',
C.NAME AS 'Column',
T.NAME AS 'DataType',
C.max_length,
C.is_nullable,
c.precision,
c.scale
FROM SYS.COLUMNS C
INNER JOIN SYS.TABLES tb ON tb.[object_id] = C.[object_id]
INNER JOIN SYS.TYPES T ON C.system_type_id = T.user_type_id
WHERE tb.[is_ms_shipped] = 0
ORDER BY tb.[Name]
Suugest me

Getting full file path in vb.net

Getting full file path in vb.net

Is there a way to get full file path of specified file?
If you enter for example "file.dat" in textbox it show you full file path
if it exist?
Thanks in advance.

Wednesday, 18 September 2013

Downloading and extracting zip files with RestKit 0.20.x

Downloading and extracting zip files with RestKit 0.20.x

I am upgrading my project from RestKit 0.10 to 0.20.2. Successfully done.
Now i need to download a zip file from URL and extract it. I could not
find any method in RestKit to do so. Can any one know about this.
Thanks

PHP - Using a variable condition in a do-while loop?

PHP - Using a variable condition in a do-while loop?

I'm wanting to set the condition of a do-while loop with a variable.
Here's my code...
$ans_type = mt_rand(1, 2);
if ($ans_type == 1){
$condition = '$work_b != $c';
$symbol = '=';
$final_note = '1';
} else {
$condition = '$work_b == $c';
$symbol = '&ne;';
$final_note = '2';
}
do{
$a = mt_rand(-25, 25);
$b = mt_rand(-25, 25);
$c = mt_rand(-25, 25);
$d = mt_rand(-25, 25);
if($op_1 == '&ndash;'){
$work_b = $b * -1;
} else {
$work_b = $b;
}
if($op_2 == '&ndash;'){
$work_d = $d * -1;
} else {
$work_d = $d;
}
} while ($a == 0 || $b == 0 || $c == 0 || $d == 0 || $condition);
Note the $condition variable that I want to put in the while() part of the
loop. This produces an infinite loop though.
So, is there a way to use variables as conditions in loops?

Call function without resetting variables

Call function without resetting variables

I am making a card game, when it gets to the end I want people to be able
to play more rounds but when it replays it must go through the variables
again.. resetting the score. I am looking for a way to fix it without a
whole new block of complicating code, I'm hoping I'm just missing a really
easy fix.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Imports
import time
def play_game():
# Variables
acard = int()
bcard = int()
apoints = int()
bpoints = int()
# Repeat
repeat = True
# Hand out cards
print 'Cards have been served'
input('\nPress Enter to Reveal')
# Cards Turn
time.sleep(0.5)
t = time.time()
acard = int(str(t - int(t))[2:]) % 13
print '\nYour card value is ' + str(acard)
time.sleep(0.1)
t = time.time()
bcard = int(str(t - int(t))[2:]) % 13
# Number Check & Point Assign
time.sleep(2)
if acard > 5:
apoints += 1
print '\nYour points have increased by one, your total is now ' \
+ str(apoints)
if acard < 5:
apoints -= 1
print '\nYour points have decreased by one, your total is now ' \
+ str(apoints)
if bcard > 5:
bpoints += 1
print '\nYour opponent got ' + str(bcard) \
+ ', their points have increased by one,\ntheir total is now ' \
+ str(bpoints)
if bcard < 5:
bpoints -= 1
print '\nYour opponent got ' + str(bcard) \
+ ', their points have decreased by one,\ntheir total is now ' \
+ str(bpoints)
# Card Reset
bcard = 0
acard = 0
# Shuffle
input('\nPress enter to shuffle deck')
print '\nCards being shuffled'
time.sleep(1)
print '.'
time.sleep(1)
print '.'
time.sleep(1)
print '.'
print 'Cards have been shuffled'
global enda
global endb
enda = apoints
endb = bpoints
# Loop
time.sleep(1)
answer = 'y'
while answer.lower() == 'y':
play_game()
answer = input('\nDo you wish to play again? (Y/N)')
# Scores
if enda > endb:
print '\nYou Win!'
print '\nScores'
print 'You: ' + str(enda) + ' Opponent: ' + str(endb)
if endb > enda:
print '\nYou Lost!'
print '\nScores'
print 'You: ' + str(enda) + ' Opponent: ' + str(endb)

Regarding the implementation of typescript as to how it fits into a project

Regarding the implementation of typescript as to how it fits into a project

I need to know how a typescript code is implemented in a project in
asp.net mvc, what is its role and how its linked in a view and how it
retrieves data from the model to the view

Strange behaviour with WAMP and an Ajax query

Strange behaviour with WAMP and an Ajax query

I'm currently trying to run a script which works on my LAMP environment
but not on a WAMP environment :
$.ajax(
{
url: '<?php echo ROOT_DIR;?>/member/login-process',
type: "post",
data: $('form').serialize(),
success: function(data)
{
if (data == 'success')
{
setTimeout(function(){window.location.href = '<?php
echo ROOT_DIR;?>/dashboard';}, 2000);
}
else
{
$("#alert").html('<div class="alert alert-error"><i
class="icon-exclamation-sign"></i> '+data+'</div>');
}
}
});
When I try it on LAMP, it works fine: i'm redirected. With WAMP, I don't
know why, but I have the following error message (generated by the
"else"):
success
I've tried typeof(data) and I have "string" as result. The value returned
by the Ajax query is therefore the "success" string, so Why the "if" is
ignored?

Invoking Method on Object causing error Obj-C

Invoking Method on Object causing error Obj-C

In my code I take an object, dynamically create a new class make that new
class subclass from the objects class and dynamically set the object's
class to this new class.
I made it so that every method call runs some code as I implement the
methods. However I then try to invoke/forward the method onto the original
class. But I have no luck.
Is their anyway to do this?
Here is my code
//Register Object For Verification
void register_object_for_verification(id object){
Class objectClass = object_getClass(object);
char * objectClassName = (char *)class_getName(objectClass);
char * proxyClassPrefix = "Proxied_";
char * proxyClassName = malloc(strlen(objectClassName) +
strlen(proxyClassPrefix) + 1);
if(proxyClassName == NULL) {
//out of memory
return;
}
strcat(proxyClassName, proxyClassPrefix);
strcat(proxyClassName, objectClassName);
Class proxyClass = objc_lookUpClass((const char *)proxyClassName);
NSLog(@"Creating Proxy Class %s", proxyClassName);
if (!proxyClass) {
NSLog(@"Attaching Proxy Class");
proxyClass = objc_allocateClassPair(objectClass, (const char
*)proxyClassName, 0);
SEL methodSignatureSelector = @selector(methodSignatureForSelector:);
Method methodSignatureMethod = class_getInstanceMethod(objectClass,
methodSignatureSelector);
int unsigned numMethods;
Method * objectMethods = class_copyMethodList(objectClass, &numMethods);
for (int i = 0; i < numMethods; i++) {
Method method = objectMethods[i];
SEL methodSelector = method_getName(method);
if ( methodSelector != @selector(class) || methodSelector ==
@selector(superclass) || methodSelector ==
methodSignatureSelector){
class_addMethod(proxyClass, methodSelector,
(IMP)verify_object, method_getTypeEncoding(method));
}
}
class_addMethod(proxyClass, methodSignatureSelector,
(IMP)proxy_method_signature,
method_getTypeEncoding(methodSignatureMethod));
objc_registerClassPair(proxyClass);
object_setClass(object, proxyClass);
}
}
//Proxies the method siganture
id proxy_method_signature(id self, SEL _cmd, SEL _selector){
NSLog(@"Proxying Method Signature for %s", sel_getName(_selector));
//Create Super Struct needed to proxy message
struct objc_super super = {self, class_getSuperclass([self class])};
//Forward method signature request
NSMethodSignature * result = (NSMethodSignature
*)objc_msgSendSuper(&super, _cmd, _selector);
NSLog(@"Number of arguments %i", [result numberOfArguments]);
NSLog(@"Method Return Type %s", [result methodReturnType]);
return result;
}
//Verify Security Object
id verify_object(id self, SEL _cmd, ...){
Class objectClass = object_getClass(self);
Class super = class_getSuperclass(objectClass);
NSLog(@"Verifying [%s %s]", class_getName(objectClass), sel_getName(_cmd));
//Verfication Code Goes Here
NSInvocation *invocation = [NSInvocation
invocationWithMethodSignature:[self methodSignatureForSelector:_cmd]];
[invocation setSelector:_cmd];
[invocation setTarget:self];
va_list args;
va_start(args, _cmd);
Method objectMethod = class_getInstanceMethod(super, _cmd);
int numberOfArgs = method_getNumberOfArguments(objectMethod);
for (NSUInteger i = 0; i < numberOfArgs; i++) {
id arg = va_arg( args, id);
[invocation setArgument:&arg atIndex:i];
}
[invocation invoke];
va_end(args);
id ret;
[invocation getReturnValue:&ret];
return ret;
}

PHP Insert Into not Working?

PHP Insert Into not Working?

For some reason the php insert into is not working for me and just goes to
the die.
<form action="user_create.php" method="post">
Forename: <input type="text" name="forename"><br>
Surname: <input type="text" name="surname"><br>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Create User"><br>
</form>
And here is my php code:
$forename = $_POST['forename'];
$surname = $_POST['surname'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$insert = "INSERT INTO users (id, forename, surname, username, password,
email)
VALUES(
''
,$forename
,$surname
,$username
,$password
,$email)";
echo("$forename");
echo("$surname");
echo("$username");
echo("$password");
echo("$email");
mysqli_query($con, $insert) or die ('Error');
mysqli_close($con);
?>
For some reason the code does not complete the mysqli_query, it runs the
die code.

escaping curly braces for string.format

escaping curly braces for string.format

void f(string message)
{
string.Format(message,"x",y");
}
f() is called by g:
g()
{
f(SomeJson+"{0}");
}
the curly braces in json are being interpreted as placeholders for values
by string.format() in f(). IS there a way to have the curly braces
escaped?

Tuesday, 17 September 2013

FindControl GridTemplateColumn Outside of radGrid Events with out using foreach statement

FindControl GridTemplateColumn Outside of radGrid Events with out using
foreach statement

Find Control Grid Template Column Outside of rad Grid Events with out
using for each statement.I am using for each mean all the value inserted
.I will insert particular row Only
below my code foreach (GridItem item in gvStudents.MasterTableView.Items)
{ if (item is GridItem) { // GridItem cmdItem =
gvStudents.MasterTableView.Items;
GridDataItem dataItem = (GridDataItem)item;
TextBox txtRemark = (TextBox)item.FindControl("txtRemarks");
// TextBox txtRemark =
(TextBox)this.gvStudents.FindControl("txtRemarks");
objPatient.Remarks = txtRemark.Text;
objPatient.UID =
_common.Utility.ToString(this.gvStudents.MasterTableView.Items[dataItem.ItemIndex].GetDataKeyValue("UID"));
int returnval = objPatient.InsertRemarks();
}}

Rails/Rspec: uninitialized constant Rails (NameError)

Rails/Rspec: uninitialized constant Rails (NameError)

When I run bundle exec rake spec I keep running into this error:
uninitialized constant Rails (NameError)
Here is my gemfile:
group :development do
gem 'guard-rspec'
gem 'guard-spork'
end
group :development, :test do
gem "debugger-ruby_core_source", "~> 1.2.2"
gem 'debugger'
gem 'faker'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'spork-rails', "~> 3.2"
gem "database_cleaner", "~> 0.9"
end
group :test do
gem 'capybara'
gem 'guard-rspec'
gem 'launchy'
gem "shoulda-matchers", "~> 2.0"
gem "selenium-webdriver"
gem "rspec-sidekiq"
end
I can't figure out why this is happening...

Taking two lines as the input

Taking two lines as the input

If I have two lines in a file that look like this:
1 222 333
4 555 666
Is there a way to access these all at once such that:
$1 = 1, $2 = 222, $3 = 333, $4 = 444, $5 = 555, $6 = 666
Any thoughts?

Grid won't load when toggled on

Grid won't load when toggled on

Can someone explain why this isn't loading when I toggle on. Whenever I
click the menu UI button for toggle grid, the console prints out the right
boolean values but the grid won't draw.
I tried the repaint method and tried calling the method that loaded the
grid again as well.
private boolean toggleGrid = false;
public Editor() {
width = DEFAULT_WIDTH;
height = DEFAULT_HEIGHT;
setTitle("Map Editor");
setSize(width, height);
mouse = new Mouse();
addMouseListener(mouse);
addMouseMotionListener(mouse);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
loadMenuUI();
loadTileContainer();
loadEditContainer();
}
private void loadMenuUI(){
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);
JMenuItem mntmNewProject = new JMenuItem("New Project");
mntmNewProject.setAccelerator(KeyStroke.getKeyStroke('N',
InputEvent.CTRL_MASK));
mnFile.add(mntmNewProject);
JMenuItem mntmSave = new JMenuItem("Save...");
mntmSave.setAccelerator(KeyStroke.getKeyStroke('S', Event.CTRL_MASK));
mnFile.add(mntmSave);
JMenuItem mntmLoad = new JMenuItem("Load...");
mntmLoad.setAccelerator(KeyStroke.getKeyStroke('O', Event.CTRL_MASK));
mnFile.add(mntmLoad);
mnFile.addSeparator();
JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.setAccelerator(KeyStroke.getKeyStroke('N',
InputEvent.CTRL_MASK));
mnFile.add(mntmExit);
JMenu mnOptions = new JMenu("Options");
menuBar.add(mnOptions);
JMenuItem mntmChangeGridSize = new JMenuItem("Change Grid Size");
mnOptions.add(mntmChangeGridSize);
JMenuItem mntmChangeScreenSize = new JMenuItem("Change Screen Size");
mnOptions.add(mntmChangeScreenSize);
JMenuItem mntmToggleGrid = new JMenuItem("Toggle Grid");
mntmToggleGrid.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(toggleGrid) toggleGrid = false;
else {
toggleGrid = true;
repaint();
}
}
});
mnOptions.add(mntmToggleGrid);
}
private void loadTileContainer(){
tileContainer = new JPanel(new GridLayout(20,20));
tileContainer.setBackground(Color.LIGHT_GRAY);
tileContainer.setBounds(0, 0, width - 15, height - 200);
tileContainer.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
if(toggleGrid){
System.out.println("Working");
for(int i = 0; i < 400; i++){
JLabel label = new JLabel();
label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
tileContainer.add(label);
}
}
contentPane.add(tileContainer);
}

Obfuscating a command within a shell script

Obfuscating a command within a shell script

There are a lot of tips (and warnings) on here for obfuscating various
items within scripts. I'm not trying to hide a password, I'm just
wondering if I can obfuscate an actuall command within the script to
defeat the casual user/grepper. Background: We have a piece of software
that helps manage machines within the environment. These machines are
owned by the enterprise. The users sometimes get it in their heads that
this computer is theirs and they don't want "The Man" looking over their
shoulders.
I've developed a little something that will check to see if a certain
process is running, and if not, clone it up and replace. Again, the
purpose of this is not to defeat anyone other than the casual user.
It was suggested that one could echo an octal value (the 'obfuscated'
command) and use it as a variable within the script. e.g.:
strongBad=`/bin/echo "\0150\0157\0163\0164\0156\0141\0155\0145\0015\0012"`
I could then use $strongBad within the shell script to slyly call the
commands that I wanted to call with arguments?
/bin/$strongBad -doThatThingYouDo -DoEEET
Is there any truth to this? So far it's worked via command line directly
into shell (using the -e flag with echo) but not so much within the
script. I'm getting unexpected output, perhaps the way I'm using it?
Thanks for any info.

SQL Server 2008 Trigger Sql Job from bat file

SQL Server 2008 Trigger Sql Job from bat file

How can i trigger an SQL job from a bat file?
I will need to input my credentials: user and password, the bat file will
be sitting on the server and i want folks to execute bat by double click
over windows explorer.

Sunday, 15 September 2013

JavaScript - Wait unitl ajax and its callback function finish

JavaScript - Wait unitl ajax and its callback function finish

I am building a web app that allows users to perform a number of actions
simultaneously. For example, user can open a list, delete a list, or add a
new list.
Each action makes an ajax call and executes a callback function to update
UI upon success. I want to make sure these actions are performed in a
serialized manner, so that the UI does not go out of sync. For example, if
user opens a list, but deletes a list a fraction of a second later,
depending on which ajax call finsihes first, it may display the list which
is supposed to be now deleted.
To accomplish this, for each action, I want to wait until an ajax call and
its callback function are finished. How can I achieve this?

How do you send a Twilio SMS with a session already started?

How do you send a Twilio SMS with a session already started?

I am trying to track a twilio converation between text messages. I want
the sent message to contain a session variable ($gameID), but I seem to
only be able to set it on reply?
Is it possible to set a session variable on send?

Keep getting [object] [Object] from variable

Keep getting [object] [Object] from variable

I am trying to get the value of the variable $target but when I print it I
keep getting [object] [Object] for the value. I am new to jQuery so this
is probably a very simple problem something I am missing.
$("body").click(function(event) {
var $target = $(event.target.id);
$("#log").html("clicked: " + $target);
});

How can I get an index value from A to Z using data-ng-repeat?

How can I get an index value from A to Z using data-ng-repeat?

I have been using before the index value like this:
{{ $index }}
What I really need is instead of getting a number I would like to get an
uppercase character going from A to Z. There should be no problem of
running out of characters as I have at the most only 10 things that are
repeated.
Can someone tell me how I can do this?

How to write a MATLAB script to execute some tasks, and play a video with specific timing?

How to write a MATLAB script to execute some tasks, and play a video with
specific timing?

I am doing some research in Biomedical Engineering, a prosthetic hand more
specifically. We have a DAC interfacing with MATLAB. Summerizing, this DAC
is responsible for delivering some neuronal signals into a human subject.
These signals are related to some haptic sensing in the human subject.
I need to synchronize this signal with a video, which will be displayed
for the subject. The video will display a simulation of the event that
would be generating the signal of the sensory input, so that the subject
will be trained to assimilate the signal to the event.
So, i need to play the video and run the code for driving the DAC in a
synchronized way (no more than 1msec of delay). I don`t have a lot of
experience with MATLAB. I have researched a bit, and found a little about
the funcion implay, but that is still a little confusing. Would appreciate
very much some help with this.

How to represent service, registry and dao service without IoC container?

How to represent service, registry and dao service without IoC container?

Im writing and app in c++, and have layers like:
some points in app --> service --> registry --> dao
Without IoC container I dont really know how to represent them.
static is not an option, because service and dao layers use interfaces and
AFAIK statics are not a good solution
singletons are bad either
Im left with creating an instance of service every time I need it. Is that
really only availible option?

Saturday, 14 September 2013

Stopping an NSTimer

Stopping an NSTimer

Hi I am trying to stop an NSTimer by using "invalidate" however from
everything that I have tried I cant seem to get the timer to stop. Here is
the code that I have to make this work. I am trying to stop the timer from
a different class.
My Timer
_tripTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateTimerLabel:)
userInfo:[NSDate date]
repeats:YES];
which is synthesized and is strong
and the stopping method:
-(void)stopTimer
{
[_tripTimer invalidate];
}
and in my other class to get it to stop I am doing this:
[_carTripViewController stopTimer];
however that is not working. It is performing the method but not stopping
the timer. Im not sure if i am creating a new instance and that is why it
is not working. How can I get it to invalidate from another class?
Thank you! I am fairly new to objective-c and not sure how to access it

parsing HTML with native DomDocument instead of simple html parser

parsing HTML with native DomDocument instead of simple html parser

for the past months i was using Simple html Dom it's pretty easy and i
accustomed to but with big file sizes i am getting problem and slow
performance.
so i decided to use the native php DomDocument the problem now is that i
am not familiar with it and mean time have very tight schedule so i am
posting to get urgent help to convert my code to native domdocument
my current code with the simple html parser
<?php
foreach ($events->find('div.lshpanel') as $content) {
$url = 'http://www.domain.com/some-words-';
$url .= str_replace(' ', '-', $content->find('span.section',
0)->plaintext) . '_';
$url .= str_replace(array(' ', '/', '\\', ',', ':'), '-',
$content->find('span.category', 0)->plaintext) . '-';
$url .= str_replace(array(' ', '/', '\\', ',', ':'), '-',
$content->find('span.lshevent', 0)->plaintext) . '-';
$url .= filter_var($content->id, FILTER_SANITIZE_NUMBER_INT) . '.html';
$finalUrl = str_replace('_', '-', $url);
$finalUrl = preg_replace('!-+!', '-', $finalUrl);
//$finalUrl = $url;
$content->style = null;
$content->find('h3.lshjpane-toggler', 0)->onclick = null;
$el = $content->find('.category', 0);
$link = "<a class=\"openevent\" href=\"$finalUrl\"
target=\"_blank\">Open Event</a>";
$content->find('.category', 0)->innertext = $el->innertext . $link;
}
?>
i want to rewrite the same code but to work with domdocument really i am
on tight schedule any help appretiated.

Changing the code from an array to single value

Changing the code from an array to single value

I have the following code:
<?php
$cts = array('tv', 'movie', 'game', 'music', 'application', 'anime');
$z = 1;
foreach($cts as $c) {
echo '<div class="boxindex">
<div class="cathead" id="c'.substr($c, 0, 2).'">
<h2><a href="'.print_category_link($c, 'latest').'"><span>'.ucfirst($c).'
stuff</span></a></h2>
</div> <!-- EOF div:'.substr($c, 0, 2).' -->
<div class="box pad">
<div class="innards">
<table class="list">';
latest($$c, $c);
echo '
</table>
<p><a href="'._domain.'/rss/'.$c.'" style="text-decoration:none"><img
src="'._domain.'/images/rss_orange.png" width="16"
style="vertical-align:middle" alt="Latest '.ucfirst($c).' Feed" /> Latest
'.ucfirst($c).' Feed</a></p>
</div>
</div> <!-- EOF div:box pad -->
</div>';
if($z%2 == 0)
echo '<div class="clear"></div>';
$z++;
}
?>
Here is the problem:
I not being able to change this code to print just one category. I need
the 'tv' results and not the full array because i will put on other
section/button the others results separatly. What should i be doing? This
code is not mine and i dont understand php very much. Thanks

Can I use phpMyAdmin command line?

Can I use phpMyAdmin command line?

My ISP only accept PHP cron jobs.
Can I use phpMyAdmin command line?
Like: http://demo.phpmyadmin.net/STABLE/export.php
or: http://myhosting.com/phpmyadmin/index.php?db=user_phpbb&passw=xxxxx
Thanks, Francisco

A Book in an app

A Book in an app

I'm creating an app for iOS which is very simple. Taking contents of a
book and put it in a slide menu where each page is a menu item. The title
of the page is the menu item name and when you click on the item in the
menu the content of the page shows up. So when you open up the app there
is a little button on the top left hand side which slides over the list of
all pages. You click on the page and the content show up. Now, what I've
been doing is that for every single page I've created a ViewController
screen and within that screen I have UITextView. Now for a book that is
400 pages, this is a lot of work. I'm new to iOS, so posting this design
problem to see if there are better simpler suggestions. Thank you.

How to determine processed database table rows of a query?

How to determine processed database table rows of a query?

Question in short: how can I get a list of row IDs of rows processed when
a query is processed?
Edit note: I am not looking for returned rows. When a user has 5 posts on
Facebook and I do a '''SELECT * FROM posts WHERE user=Mark ORDER BY date
desc LIMIT 1''' I know, that the returned number will be 1, but I'd like
to know how many rows have been processed (in this case without indices,
probably all rows). And I am primarily looking at SELECT statements.
Hello,
I am currently working on a project that aims in the direction of data
aging. I.e., we are trying to determine which tuples are accessed
regularly and which are not. We've got a decent workload (i.e., a query
log of the system) with the corresponding data and would like to know,
what rows have been processed.
Besides the question, what rows we're also interested in what attributes,
but that can be done parsing the query (projection, join attributes, and
where conditions). Leaving the question open how to get the actually
processed rows.
We are aware that many queries will (let's assume there are no indices)
process all rows, because there is a where-condition that requires a full
table scan. We are aware of that problem, but still wan't to find out,
which rows have been accessed.
My final question is now: How can we achieve that?
I have been looking into MySQL and Postgres but could not find sufficient
information (e.g., MySQL's 'explain' just returns an estimate for the
number of rows processed, but not any row IDs). I am guess that we will
have to modify the source code of a DB to achieve that kind of logging
(performance of that logging is not an issue, it's offline analytics). Has
anybody any recommendations how to achieve that/done that?

Fix css fade background issue

Fix css fade background issue

I added an fade background to my website but when i upload it to the
internet it kinda fucks up.
website
You can see the repeated area in the right side it stops. how can i get
rid of the scroll at the bottom ?

Friday, 13 September 2013

Is there a python equivalent to Laravel 4?

Is there a python equivalent to Laravel 4?

I'm a PHP developer and have been using and following the Laravel 4
framework since the release of v3. With the Laravel 4 being heavily
embraced by the PHP community, having composer support, namespacing and
bringing together all the great features from other frameworks such as
Symphony2. It's my opinion that Laravel 4 is at the cutting edge of PHP
web frameworks. It enables me to develop both small scale and enterprise
scale app's easily and efficiently, and its modular concepts allow me to
extend it core, build custom reusable packages, and easily follow TDD
practices.
Alongside my PHP development, I have been diving into the wonderful world
of python (v3) and wondered what the equivalent web framework would be in
the python community? A framework that follows some of the same core
concepts built into Laravel 4 such as MVC design pattern, easy testing,
modular design, packages etc.

Android service boot start running 2.3 but not running 4.0

Android service boot start running 2.3 but not running 4.0

please help me!
Alow to you help me..app android start boot complete running 2.3. but not
running 4.x
code: BroadcastReceiver
@Override
public void onReceive(final Context context, Intent intent) {
Log.v(TAG, "try to start service out");
try{
if
("android.intent.action.BOOT_COMPLETED".equals(intent.getAction()))
{
Log.v(TAG, "try to start service");
ComponentName comp = new
ComponentName(context.getPackageName(),
LocationService.class.getName());
// Wait 10 s to ensure all the service run ok
try {
Log.v(TAG, "try to start service - sleeping");
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
Log.v(TAG, "exception");
e.printStackTrace();
} catch (Exception ex) {
Log.v(TAG, "exception" + ex.toString());
}
ComponentName service = context.startService(new Intent()
.setComponent(comp));
Log.v(TAG, "started the service");
if (null == service) {
// something really wrong here
Log.e(TAG, "Could not start service " + comp.toString());
}
} else {
Log.e(TAG, "Received unexpected intent " + intent.toString());
}
}catch (Exception e) {
// TODO: handle exception
Log.v("Start","Error");
}
}
in android AndroidManifest setting focus to sevices

How to change color of QDockWidget float-button

How to change color of QDockWidget float-button

I can't seem to change the close and float button color in a dock widget
from back to white.
Here is what i have tried:
borderStyle.append(
"QDockWidget::close-button {color: rgb(255, 255, 255); background:
rgb(100, 100, 100) }")
The background color changes but the black 'X' and black float images don't.
Why? Anybody know how to accomplish this?
Thanks

How do I correctly use 'else' in a batch file?

How do I correctly use 'else' in a batch file?

I've been working something, and the point where I'm stuck is this:
set /p !=
if %!% == yahoo.com goto YAHOO
if %!% == facebook.com goto FACEBOOK
if %!% == mail.google.com goto GMAIL
if %!% == youtube.com goto YOUTUBE
if %!% == google.com goto GOOGLE
else goto ELSE
Btw, this is just an example. Well, the problem is, the else doesn't work
correctly... Idk how I should do it so I hope someone can help...

500 error when binding index and other routes to a single callback in Bottle

500 error when binding index and other routes to a single callback in Bottle

Following this tutorial:
http://bottlepy.org/docs/dev/tutorial.html#request-routing
It shows the example:
@route('/')
@route('/hello/<name>')
def greet(name='Stranger'):
return template('Hello {{name}}, how are you?', name=name)
And states:
This example demonstrates two things: You can bind more than one route to
a single callback, and you can add wildcards to URLs and access them via
keyword arguments.
I'm trying to test this with the following code but I am getting a 500
error when accessing the index eg /.
import bottle
import pymongo
custom = bottle
@custom.route('/')
@custom.route('/hello/<name>')
@custom.view('page2.tpl')
def index(name):
# code
bottle.run(host='localhost', port=8082)
The error only seems to occur when accessing the site's index, eg /.
The index does not work in the following example, but the other two routes
do.
import bottle
import pymongo
custom = bottle
@custom.route('/') # this doesn't work
@custom.route('/milo/<name>') # this works
@custom.route('/hello/<name>') # this works
@custom.view('page2.tpl')
def index(name):
# code
bottle.run(host='localhost', port=8082)

target a custom page using plugin function in wordpress

target a custom page using plugin function in wordpress

i created a custom page named custom_page.php in wordpress and use this as
a page template.
i wanted to create my own functions and only target my custom_page.php.
this function will be installed as a plugin.
what kind of WP HOOKS should i use, for example i have this code below
function your_function() {
if ( is_page_template('custom_page.php') ) {
echo '<p>This is inserted at the bottom</p>';
{
}
add_action('wp_footer', 'your_function');
i want to only execute this code in my custom_page.php footer area.
[EDIT]

Thursday, 12 September 2013

loginRedirect in cakephp not working correctly

loginRedirect in cakephp not working correctly

In our cakephp application, we tried auth component for login.
This is the AppControllere:
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'homes', 'action' =>
'dashboard'),
'logoutRedirect' => array('controller' => 'pages', 'action' =>
'home')
)
);
public function beforeFilter() {
$this->Auth->allow('index','logout','display','home');
}
This is the UsersController:
class UsersController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('add');
}
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Invalid username or password,
try again'));
}
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
public function add() {
if ($this->request->is('post')) {
$this->User->create();
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Checkin now'));
$this->redirect(array('action' => 'login'));
} else {
$this->Session->setFlash(__('The user could not be saved.
Please, try again.'));
}
}
}
}
The the following the steps:
we took the url in browser as http://localhost/cakephp/
Then there have a link in home.ctp page for login, clicked on that go to
http://localhost/cakephp/users/login/
username and password entered and clicked the login button
then it goes to the same home.ctp page not the page we mentioned in
AppController
Second attempt:
we took the direct url as http://localhost/cakephp/users/login/
then entered login details , then it will go the correct page.
So what will happen here, Why auth componet behave like this.....

Issue of display record in oracle form 10g

Issue of display record in oracle form 10g

I'm new to Oracle Form and pl/sql. Here is my problem In my form, I got 3
data blocks that display records that I retrieve from a table named
BOS_M_HOLIDAY. But somehow only the last record displayed in each
datablocks after the loop. The way I retrieve the records is using the
PRE-FORM Trigger and WHEN-TIME-EXPIRED Trigger. Here is my code in
PRE-FORM Trigger:
DECLARE
CURSOR a_aa is SELECT HOL_DATE FROM BOS_M_HOLIDAY WHERE
REGEXP_LIKE(HOL_DATE, '.......12') ORDER BY HOL_DATE;
CURSOR a_bb is SELECT HOL_DATE FROM BOS_M_HOLIDAY WHERE
REGEXP_LIKE(HOL_DATE, '.......13') ORDER BY HOL_DATE ;
CURSOR a_cc is SELECT distinct DESCR FROM BOS_M_HOLIDAY WHERE
REGEXP_LIKE(HOL_DATE, '.......13')ORDER BY 1;
Timer_ID TIMER;
BEGIN
OPEN a_aa;
LOOP
FETCH a_aa INTO :holiday_2012.HOL_DATE;
EXIT WHEN a_aa%notfound;
Timer_ID := FIND_TIMER('CALL_NEXT_RECORD');
IF NOT Id_Null(Timer_ID) THEN
Delete_Timer(Timer_ID);
END IF;
Timer_ID := Create_Timer('CALL_NEXT_RECORD',1,NO_REPEAT);
END LOOP;
CLOSE a_aa;
OPEN a_bb;
LOOP
FETCH a_bb INTO :holiday_2013.HOL_DATE;
EXIT WHEN a_bb%notfound;
Timer_ID := FIND_TIMER('CALL_NEXT_RECORD');
IF NOT Id_Null(Timer_ID) THEN
Delete_Timer(Timer_ID);
END IF;
Timer_ID := Create_Timer('CALL_NEXT_RECORD',1,NO_REPEAT);
END LOOP;
CLOSE a_bb;
OPEN a_cc;
LOOP
FETCH a_cc INTO :description.DESCR;
EXIT WHEN a_cc%notfound;
Timer_ID := FIND_TIMER('CALL_NEXT_RECORD');
IF NOT Id_Null(Timer_ID) THEN
Delete_Timer(Timer_ID);
END IF;
Timer_ID := Create_Timer('CALL_NEXT_RECORD',1,NO_REPEAT);
END LOOP;
CLOSE a_cc;
END;
and here is my code in WHEN-TIME-EXPIRED Trigger:
DECLARE
v_Timer VARCHAR2(30) := Get_Application_Property(TIMER_NAME);
BEGIN
IF (v_Timer = 'CALL_NEXT_RECORD') THEN
NEXT_RECORD;
END IF;
END;
This code works when I use WHEN-BUTTON-PRESSED Trigger without the TIMER
part. Bare with my English and feel free to ask me if any parts that you
do not understand. Thanks!

Debugging filter mapping issues with Netbeans

Debugging filter mapping issues with Netbeans

I believe that I am having issues with the URL mapping/filter mapping with
my J2EE web applications. Is there a way to debug where the requests are
being mapped? I am using Netbeans 7.3.

Using CSV for data

Using CSV for data

I wish to replace this portion of my script (from a dashingd3js tutorials)
with a reference to a CSV file with the same data.
var lineData = [ { "x": 1, "y": 5}, { "x": 20, "y": 20},
{ "x": 40, "y": 10}, { "x": 60, "y": 40},
{ "x": 80, "y": 5}, { "x": 100, "y": 60}];
The csv is located in the same directory and named 'dataFile.csv'
dataFile.csv:
x,y 1,5 20,20 40,10 60,40 80,5 100,60
Edit: Trying to incorporate feedback from Lars, this is what I tried:
//The data for our line
d3.csv("testData.csv", function(error, d){
//This is the accessor function we talked about above
var lineFunction = d3.svg.line()
.x(function(d) { return d.x; })
.y(function(d) { return d.y; })
.interpolate("linear");
//The SVG Container
var svgContainer = d3.select("body").append("svg")
.attr("width", 200)
.attr("height", 200);
//The line SVG Path we draw
var lineGraph = svgContainer.append("path")
.attr("d", lineFunction(lineData))
.attr("stroke", "blue")
.attr("stroke-width", 2)
.attr("fill", "none");
}

Using an editable table with HighChart and having the chart refresh with change

Using an editable table with HighChart and having the chart refresh with
change

I am building a prototype that uses High charts - Data defined in a HTML
table, I have applied an editable feature using jQuery so that the cells
can be edited by the user. The question is:
How do I get the chart to update/refresh after a user edits a cell without
using a database? I would like to use a button with an .click event
listener to reload the chart from the edited table.
This is just a prototype so I have no need for an actual Ajax call or
database connection. Basically I need user interaction with the table to
reflect in the chart.
Here is a very simplified version:
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/data.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script>
$(function () {
$('#container').highcharts({
data: {
table: document.getElementById('datatable')
},
chart: {
type: 'column'
},
title: {
text: 'Data extracted from a HTML table in the page'
},
yAxis: {
allowDecimals: false,
title: {
text: 'Units'
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.y +' '+ this.x.toLowerCase();
}
},
});
});
$("#refresh").click(function() {
var options = chart.options;
chart = new Highcharts.Chart(options);
});
</script>
<script>
$(function () {
$("#datatable td").dblclick(function () {
var OriginalContent = $(this).text();
$(this).addClass("cellEditing");
$(this).html("<input type='text' value='" +"' />");
$(this).children().first().focus();
$(this).children().first().keypress(function (e) {
if (e.which == 13) {
var newContent = $(this).val();
$(this).parent().text(newContent);
$(this).parent().removeClass("cellEditing");
}
});
$(this).children().first().blur(function(){
$(this).parent().text(OriginalContent);
$(this).parent().removeClass("cellEditing");
});
});
});
</script>
</head>
<body>
<div id="container" style="min-width: 310px; height: 400px; margin: 0
auto"></div>
<table id="datatable">
<thead>
<tr>
<th></th>
<th>Jane</th>
<th>John</th>
</tr>
</thead>
<tbody>
<tr>
<th>Apples</th>
<td>9</td>
<td>4</td>
</tr>
<tr>
<th>Pears</th>
<td>2</td>
<td>0</td>
</tr>
<tr>
<th>Plums</th>
<td>5</td>
<td>11</td>
</tr>
<tr>
<th>Bananas</th>
<td>1</td>
<td>1</td>
</tr>
<tr>
<th>Oranges</th>
<td>2</td>
<td>4</td>
</tr>
</tbody>
</table>
</body>
<button id="refresh">Refresh</button>

javascript iterate trough object to get dirnames and get files from them with phonegap (solved)

javascript iterate trough object to get dirnames and get files from them
with phonegap (solved)

_verhalen = JSON.parse(verhalen);
for(key in _verhalen){
console.log(_verhalen[key]);
requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(filesys) {
filesys.root.getDirectory("story/save/"+_verhalen[key], {create:
false }, function(dirName) {
console.log(_verhalen[key]);
var directoryReader = dirName.createReader();
directoryReader.readEntries(function(entries){
$("#swipe").append('<div class="img_wrapper"><img
height="205" width="300"
src="file://'+entries[0].fullPath+'?'+Math.random()+'"
onclick="loadproject(&#39;'+_verhalen[key]+'&#39;)"/></div>');
},function (error) {
alert("couldn't load image");
});
},function (error) {
alert("couldn't load directory");
});
},function (error) {
alert("couldn't load filesystem");
});
}
well to start of i need to do some explanation, i get directoryname from
variable _verhalen[key] it sits in a loop while i iterate over it. on
first console output i get value1 and value2, but from the second output
which sits in requestFileSystem i get value2 and value2
i think this bug comes because requestFileSystem runs asynchronous so the
iteration finishes before filesystem could finish first operation and
that's why second output has same values.
any ideas on how to fix such issue ?
found soulution moved requestFileSystem to a function so now my code looks
like : iteration { call_to_function(_verhalen[key]); } and function has
requestFileSystem loop