Change style of XML defined SharedPreferences Activity, to match newer
Holo style
I have an existing Preference Activity (created using the standard XML
style, and calling with the Preferences intent).
My problem, is this looks like the old style (2.3) preferences, even on
4.0+ devices. I would like it to look like the newer settings style. Is
there some way to make this appearance change (perhaps applying a specific
style attribute or something)?
I launch the Activity (note: using ApplicationContext, which I think is
correct), in the following manner:
final Context cxt = this.getApplicationContext();
final Intent i5 = new Intent(cxt, Preferences.class);
startActivity(i5);
The XML is:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/pref_notification_time" >
<com.wolfsoft.dotd.util.TimePickerPreference
android:defaultValue="07:30"
android:key="notif_time"
android:summary="@string/summary_notif_time"
android:title="@string/title_notif_time" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_notif_onoff" >
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_pref"
android:summary="@string/summary_notif_preference"
android:title="@string/title_notif_preference" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_notif_category" >
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_game_pref"
android:summary="@string/pref_game_notif_sum"
android:title="@string/pref_game_notif_sum_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_business_pref"
android:summary="@string/pref_business_notif_sum"
android:title="@string/pref_business_notif_sum_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_entertainment_pref"
android:summary="@string/pref_entertainment_notif_sum"
android:title="@string/pref_entertainment_notif_sum_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_lifestyle_pref"
android:summary="@string/pref_lifestyle_notif_sum"
android:title="@string/pref_lifestyle_notif_sum_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_personalization_pref"
android:summary="@string/pref_personalization_notif_sum"
android:title="@string/pref_personalization_notif_sum_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="notif_local_pref"
android:summary="@string/pref_local_notif_sum"
android:title="@string/pref_local_notif_sum_title" />
</PreferenceCategory>
</PreferenceScreen>
My current screen looks like this:
I would like it to look like this:
Friday, 27 September 2013
Am I allowing 3 guesses or 2?
Am I allowing 3 guesses or 2?
I am learning Python on Codecademy, and I am supposed to give the user 3
guesses before showing "you lose". I think my code allows 3 entries, but
the website shows "Oops, try again! Did you allow the user 3 guesses, or
did you incorrectly detect a correct guess?" unless the user guesses
correctly within 3 trials. Can someone tell me what's wrong?
from random import randrange
random_number = randrange(1, 10)
count = 0
# Start your game!
guess= int(raw_input("Please type your number here:"))
while count < 2:
if guess==random_number:
print "You win!"
break
else:
guess=int(raw_input("Please guess again:"))
count+=1
else:
print "You lose!"
print random_number
I am learning Python on Codecademy, and I am supposed to give the user 3
guesses before showing "you lose". I think my code allows 3 entries, but
the website shows "Oops, try again! Did you allow the user 3 guesses, or
did you incorrectly detect a correct guess?" unless the user guesses
correctly within 3 trials. Can someone tell me what's wrong?
from random import randrange
random_number = randrange(1, 10)
count = 0
# Start your game!
guess= int(raw_input("Please type your number here:"))
while count < 2:
if guess==random_number:
print "You win!"
break
else:
guess=int(raw_input("Please guess again:"))
count+=1
else:
print "You lose!"
print random_number
Under what circumstances would a .NET program just terminate?
Under what circumstances would a .NET program just terminate?
I have a WPF application written for the .NET 4 Full Framework. The
application uses SQL Anywhere as its database. My application has an
unhandled exception handler, which always logs errors to a custom event
log for the program. It then displays the error message to the user. The
program also sends messages to the event log whenever it's about to do
something in order too make debugging it easier.
The application is installed on a user's laptop, which is running Windows
7 and has 8 GB of RAM. When it is started on this machine, the splash
screen is displayed and then the program's main window is displayed. Less
than a second after being drawn, the program dies. There are no error
messages displayed.
Checking the event log shows that the program's last message written was
that it was doing a check for the existence of a user in the database.
There are no error messages.
The code that follows the last message that was displayed is a call to a
method that does some parameter checking and then executes the following
EF query:
LPRCore.CarSystem.User user = null;
IQueryable<User> query = from u in context.Users
from m in context.Members.Where( m => m.UserId ==
u.UserId )
.DefaultIfEmpty()
where u.LoweredUserName == userName.ToLower() &&
m == null
select u;
try {
user = query.SingleOrDefault();
} catch ( Exception ex ) {
....
}
I can't tell if the code in the catch block is ever called. My suspicion
is that it is getting called and an exception is occurring in there.
My question is, if an exception occurs in a catch block, won't that
exception be caught by the Unhandled Exception handler at the upper level,
if there is no other exception handler to catch the error? Or would it
cause the program to die without reporting anything?
I have a WPF application written for the .NET 4 Full Framework. The
application uses SQL Anywhere as its database. My application has an
unhandled exception handler, which always logs errors to a custom event
log for the program. It then displays the error message to the user. The
program also sends messages to the event log whenever it's about to do
something in order too make debugging it easier.
The application is installed on a user's laptop, which is running Windows
7 and has 8 GB of RAM. When it is started on this machine, the splash
screen is displayed and then the program's main window is displayed. Less
than a second after being drawn, the program dies. There are no error
messages displayed.
Checking the event log shows that the program's last message written was
that it was doing a check for the existence of a user in the database.
There are no error messages.
The code that follows the last message that was displayed is a call to a
method that does some parameter checking and then executes the following
EF query:
LPRCore.CarSystem.User user = null;
IQueryable<User> query = from u in context.Users
from m in context.Members.Where( m => m.UserId ==
u.UserId )
.DefaultIfEmpty()
where u.LoweredUserName == userName.ToLower() &&
m == null
select u;
try {
user = query.SingleOrDefault();
} catch ( Exception ex ) {
....
}
I can't tell if the code in the catch block is ever called. My suspicion
is that it is getting called and an exception is occurring in there.
My question is, if an exception occurs in a catch block, won't that
exception be caught by the Unhandled Exception handler at the upper level,
if there is no other exception handler to catch the error? Or would it
cause the program to die without reporting anything?
100% width div with child span won't right align
100% width div with child span won't right align
Given this fiddle, I want my menu to be at the right edge of the overall
"card", but for some reason it won't work. I've tried a couple different
methods (margins, right: 0, float) but they either don't work or I lose
the background color of the parent div (in the case of float where it
basically collapses the parent div).
Here is my current HTML and CSS, as seen in the fiddle.
<div class="server">
<div class="name">Server01</div>
<div class="menu">
<span class="items">
<span>Menu01</span>
<span>Menu02</span>
<span>Menu03</span>
</span>
</div>
<div class="content">
</div>
</div>
.server {
position: relative;
width: 400px;
height: 200px;
margin: 10px;
background-color: #686868;
}
.name {
font-size: large;
position: relative;
top: 0px; left: 0px; right: 0px;
padding-left: 10px;
background-color: cornflowerblue;
color: white;
cursor: default;
}
.menu {
font-size: small;
position: relative;
width: 100%;
background-color: cornflowerblue;
color: white;
}
.menu .items span {
margin-left: 10px;
}
.menu .items {
display: inline-block;
position: relative;
right: 0px;
text-align: right;
cursor: pointer;
}
Given this fiddle, I want my menu to be at the right edge of the overall
"card", but for some reason it won't work. I've tried a couple different
methods (margins, right: 0, float) but they either don't work or I lose
the background color of the parent div (in the case of float where it
basically collapses the parent div).
Here is my current HTML and CSS, as seen in the fiddle.
<div class="server">
<div class="name">Server01</div>
<div class="menu">
<span class="items">
<span>Menu01</span>
<span>Menu02</span>
<span>Menu03</span>
</span>
</div>
<div class="content">
</div>
</div>
.server {
position: relative;
width: 400px;
height: 200px;
margin: 10px;
background-color: #686868;
}
.name {
font-size: large;
position: relative;
top: 0px; left: 0px; right: 0px;
padding-left: 10px;
background-color: cornflowerblue;
color: white;
cursor: default;
}
.menu {
font-size: small;
position: relative;
width: 100%;
background-color: cornflowerblue;
color: white;
}
.menu .items span {
margin-left: 10px;
}
.menu .items {
display: inline-block;
position: relative;
right: 0px;
text-align: right;
cursor: pointer;
}
UISlider not animating in iOS7
UISlider not animating in iOS7
When I switched from iOS 6 to iOS 7 design, I noticed that using the
method setValue:animated: no longer animates the sliding process. Has
anyone else came across this problem and found a solution?
I'll just add some code to show I've done nothing complicated:
//Variable declaration
IBOutlet UISlider *s; //Connected in the .xib
//Button pressed
- (IBAction)buttonPressed:(id)sender
{
[s setValue:1 animated:YES];
}
And it jumps straight to 1 after I press the button.
When I switched from iOS 6 to iOS 7 design, I noticed that using the
method setValue:animated: no longer animates the sliding process. Has
anyone else came across this problem and found a solution?
I'll just add some code to show I've done nothing complicated:
//Variable declaration
IBOutlet UISlider *s; //Connected in the .xib
//Button pressed
- (IBAction)buttonPressed:(id)sender
{
[s setValue:1 animated:YES];
}
And it jumps straight to 1 after I press the button.
HashMap overridden by last value
HashMap overridden by last value
Statement selectStatement = connection.createStatement();
ResultSet selectResultSet = selectStatement.executeQuery(query);
logger.info("sql query " + selectStatement.toString());
ResultSetMetaData rsmd = selectResultSet.getMetaData();
int columnsNumber = rsmd.getColumnCount();
String[] row = new String[columnsNumber];
int ctr = 0;
logger.info("Reading from database...");
while(selectResultSet.next())
{
for(int i=0;i<columnsNumber;i++){
row[i] = selectResultSet.getString(i+1);
}
System.out.println();
dataFromQuery.put(ctr++, row);
}
selectResultSet.close();
On reading back from HashMap, it prints only the last row 'n' number of
times.
Statement selectStatement = connection.createStatement();
ResultSet selectResultSet = selectStatement.executeQuery(query);
logger.info("sql query " + selectStatement.toString());
ResultSetMetaData rsmd = selectResultSet.getMetaData();
int columnsNumber = rsmd.getColumnCount();
String[] row = new String[columnsNumber];
int ctr = 0;
logger.info("Reading from database...");
while(selectResultSet.next())
{
for(int i=0;i<columnsNumber;i++){
row[i] = selectResultSet.getString(i+1);
}
System.out.println();
dataFromQuery.put(ctr++, row);
}
selectResultSet.close();
On reading back from HashMap, it prints only the last row 'n' number of
times.
Thursday, 26 September 2013
Load an Image error
Load an Image error
I have a question. I have 2 classes, 1 SampleController class and 1 other
normal Class that i have made by myself. (And offcourse the FXML file). I
want to load an Image through a Pane at a click of a button. But i want to
load the image in through the other Class. But those classes have to have
controle to eachother, which results in this error:
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
Does anyone know how i can solve this problem? Thankyou very much.
I have a question. I have 2 classes, 1 SampleController class and 1 other
normal Class that i have made by myself. (And offcourse the FXML file). I
want to load an Image through a Pane at a click of a button. But i want to
load the image in through the other Class. But those classes have to have
controle to eachother, which results in this error:
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
at
blackjack.ControllerToImagesBridge.<init>(ControllerToImagesBridge.java:23)
at blackjack.SampleController.<init>(SampleController.java:27)
Does anyone know how i can solve this problem? Thankyou very much.
Thursday, 19 September 2013
hotlink prevention for images on subdomain not working
hotlink prevention for images on subdomain not working
I currently am rewriting image requests to my site and redirecting them to
my sub-domain which handles all the images.
what I want to do is prevent one site from hot-linking those images. I've
already implemented,
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?bannedsite\.com/ [NC]
RewriteRule \.(jpg|gif|bmp|png|JPE?G)$ - [F]
and this works for images on my main domain, But fails for the sub-domain.
Any info would be awesome. Thanks.
I currently am rewriting image requests to my site and redirecting them to
my sub-domain which handles all the images.
what I want to do is prevent one site from hot-linking those images. I've
already implemented,
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?bannedsite\.com/ [NC]
RewriteRule \.(jpg|gif|bmp|png|JPE?G)$ - [F]
and this works for images on my main domain, But fails for the sub-domain.
Any info would be awesome. Thanks.
How do I create a custom walker that displays this submenu?
How do I create a custom walker that displays this submenu?
I'm looking to display a menu that mirrors my primary menu as a submenu in
the sidebar. Suppose my site menu is:
Page A
Page B
-Subpage A
-Subpage B
--SubSubpage A
-Subpage C
Page C
If you're on Page B, I'd want this to show:
Page B
-Subpage A
-Subpage B
-Subpage C
If you're on Subpage B, I'd want this to show:
Page B
-Subpage A
-Subpage B
--SubSubpage A
-Subpage C
I know I can do this with a custom walker, but after hours of searching, I
need help.
I'm looking to display a menu that mirrors my primary menu as a submenu in
the sidebar. Suppose my site menu is:
Page A
Page B
-Subpage A
-Subpage B
--SubSubpage A
-Subpage C
Page C
If you're on Page B, I'd want this to show:
Page B
-Subpage A
-Subpage B
-Subpage C
If you're on Subpage B, I'd want this to show:
Page B
-Subpage A
-Subpage B
--SubSubpage A
-Subpage C
I know I can do this with a custom walker, but after hours of searching, I
need help.
Java servelet issue when changing src folder path
Java servelet issue when changing src folder path
I'm new to Java inherited a project that is in dire need of some
refactoring. One of the issues is the src has a couple unnecessary folders
e.g. "src/Alpha/Beta/ClassGroupFolders". I want to get rid of folders
"Alpha" and "Beta" since they have nothing in them. This means my class
paths will no longer be "Alpha.Beta.ClassGroup.ClassName" They will be
"ClassGroup.ClassName". I moved the ClassGroup folders up two levels and
did a global replace to change "Alpha.Beta.ClassGroup" to just
"ClassGroup" and did the same for "Alpha/Beta/ClassGroup".
Eclipse is showing no errors but when a servlet is being called I'm
getting "HTTP Status 404 - Servlet Logon is not available". It worked
before I changed the folder structure and that is the only change. My
web.xml file has an entry for the servlet that is being called by the form
and the servlet-class node has been updated to match the updated folder
structure. I'm sorry I can't provide more information on how the site is
set up but I can tell you it's not using struts. It's using inline code in
the JSP files for the most part.
What can I do to track down the source of this issue?
I'm new to Java inherited a project that is in dire need of some
refactoring. One of the issues is the src has a couple unnecessary folders
e.g. "src/Alpha/Beta/ClassGroupFolders". I want to get rid of folders
"Alpha" and "Beta" since they have nothing in them. This means my class
paths will no longer be "Alpha.Beta.ClassGroup.ClassName" They will be
"ClassGroup.ClassName". I moved the ClassGroup folders up two levels and
did a global replace to change "Alpha.Beta.ClassGroup" to just
"ClassGroup" and did the same for "Alpha/Beta/ClassGroup".
Eclipse is showing no errors but when a servlet is being called I'm
getting "HTTP Status 404 - Servlet Logon is not available". It worked
before I changed the folder structure and that is the only change. My
web.xml file has an entry for the servlet that is being called by the form
and the servlet-class node has been updated to match the updated folder
structure. I'm sorry I can't provide more information on how the site is
set up but I can tell you it's not using struts. It's using inline code in
the JSP files for the most part.
What can I do to track down the source of this issue?
Need free download link for Jboss Soa platform 5.3
Need free download link for Jboss Soa platform 5.3
Can any one suggest me the free download link for jboss soa platform 5.3.
I already searched in the redhat site
https://access.redhat.com/site/downloads/ . But i did not find the Jboss
SOA. Please any one suggest me the download link
Thanks, Lalitha
Can any one suggest me the free download link for jboss soa platform 5.3.
I already searched in the redhat site
https://access.redhat.com/site/downloads/ . But i did not find the Jboss
SOA. Please any one suggest me the download link
Thanks, Lalitha
SQL Command Not Properly Ended driving me bananas
SQL Command Not Properly Ended driving me bananas
I am trying to run this query, but i repeatedly get an error message. Any
suggestions?
SELECT DD_INTERVAL, VENDOR_ID, COUNTRY, "SUM"(VOLUME) as Volume,
"SUM"(COST) as Cost
FROM Table_1
WHERE VENDOR_ID ='35', DD_INTERVAL = '7', COUNTRY =
('idn','lao','mys','phl','sgp','tha','vnm')
GROUP BY DD_INTERVAL, Vendor_ID, COUNTRY;
I am trying to run this query, but i repeatedly get an error message. Any
suggestions?
SELECT DD_INTERVAL, VENDOR_ID, COUNTRY, "SUM"(VOLUME) as Volume,
"SUM"(COST) as Cost
FROM Table_1
WHERE VENDOR_ID ='35', DD_INTERVAL = '7', COUNTRY =
('idn','lao','mys','phl','sgp','tha','vnm')
GROUP BY DD_INTERVAL, Vendor_ID, COUNTRY;
Warning: SimpleXMLElement::addAttribute(): string is not in UTF-8
Warning: SimpleXMLElement::addAttribute(): string is not in UTF-8
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: SimpleXMLElement::addAttribute(): string is not in UTF-8 in
W:\public_html\Project\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Export\Driver\XmlExporter.php
line 162
I have no idea why?
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: SimpleXMLElement::addAttribute(): string is not in UTF-8 in
W:\public_html\Project\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Export\Driver\XmlExporter.php
line 162
I have no idea why?
Find and return a class based on a string
Find and return a class based on a string
I have multiple classes of the parent class "command_functions"
example
class Empty_Command : command_functions
each of the command classes override a value
public override string command_display_name { get { return "Empty"; } }
is there anyway to search types of command_functions looking for where
command_display_name is set to a matching string and return that.
so I could use it like so
command_functions find = FindCommand("Empty");
if(find != null)
{
new find();
}
I have multiple classes of the parent class "command_functions"
example
class Empty_Command : command_functions
each of the command classes override a value
public override string command_display_name { get { return "Empty"; } }
is there anyway to search types of command_functions looking for where
command_display_name is set to a matching string and return that.
so I could use it like so
command_functions find = FindCommand("Empty");
if(find != null)
{
new find();
}
Building Shared Library from static Library *.a file
Building Shared Library from static Library *.a file
I have read other questions similar to this on stack overflow but they are
not having same like scenario.
I have FreeImage.a(23 MB file ) file which precompild static library for
android. I also have source code of FreeImage Project which have header
files.
I want to build .SO file from (.a) file I have with my JNI
code(FreeImageCompilation.cpp) Below code compiles fine but it does
produces SO File of (5KB only ) whre (*.a file is 23 MB )?
can somebody check if my code below for using *.a file is correct or not ?
In My Android.mk I have following code.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := FreeImage
LOCAL_SRC_FILES := libFreeImage.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/FreeImage/Source/
include $(PREBUILT_STATIC_LIBRARY)
#My Own SO file
LOCAL_STATIC_LIBRARIES := FreeImage
include $(CLEAR_VARS)
LOCAL_MODULE := FreeImageSo
LOCAL_SRC_FILES := FreeImageCompilation.cpp
LOCAL_STATIC_LIBRARIES := FreeImage
include $(BUILD_SHARED_LIBRARY)
I have read other questions similar to this on stack overflow but they are
not having same like scenario.
I have FreeImage.a(23 MB file ) file which precompild static library for
android. I also have source code of FreeImage Project which have header
files.
I want to build .SO file from (.a) file I have with my JNI
code(FreeImageCompilation.cpp) Below code compiles fine but it does
produces SO File of (5KB only ) whre (*.a file is 23 MB )?
can somebody check if my code below for using *.a file is correct or not ?
In My Android.mk I have following code.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := FreeImage
LOCAL_SRC_FILES := libFreeImage.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/FreeImage/Source/
include $(PREBUILT_STATIC_LIBRARY)
#My Own SO file
LOCAL_STATIC_LIBRARIES := FreeImage
include $(CLEAR_VARS)
LOCAL_MODULE := FreeImageSo
LOCAL_SRC_FILES := FreeImageCompilation.cpp
LOCAL_STATIC_LIBRARIES := FreeImage
include $(BUILD_SHARED_LIBRARY)
Wednesday, 18 September 2013
JavaScript stack size exceeded when using thick-box for multiple divisions approximately 6K
JavaScript stack size exceeded when using thick-box for multiple divisions
approximately 6K
I have a table displayed on the page with item details displayed . When
total cells are less than 5K then there is no JavaScript error but when
table has 6K rows or more then stack exceeding error occurs and JavaScript
doesn't works.
$(document).ready(function() {
$('body').click(function(e){
var Elem = e.target;
var itemgroup = $(Elem).attr('rel');
var itemid = $(Elem).attr('itemno');
if (Elem.className == 'additem'){
tb_show('Add' ,
'add_item.html'+'?&itemid='+itemid+'&itemgrp='+itemgroup+'&TB_iframe=true&height=420width=500',
'/images/items.jpg');
}
else if (Elem.className == 'showsoldqty'){
tb_show('Show' ,
'show_sold_qty.html'+'?&itemid='+itemid+'&itemgrp='+itemgroup+'&TB_iframe=true&height=420width=500',
'/images/items.jpg');
}
});
The table structure is as mentioned below with one row as sample (the
column in this row is being repeated and displayed more than 6K times) :
<table>
<tr>
<td>
<div class="additem" rel="G1" itemno="21">Add Item</div>
<div class="showsoldqty" rel="G2" itemno="22">Show Sold
Quantity</div>
</td>
</tr>
</table>
approximately 6K
I have a table displayed on the page with item details displayed . When
total cells are less than 5K then there is no JavaScript error but when
table has 6K rows or more then stack exceeding error occurs and JavaScript
doesn't works.
$(document).ready(function() {
$('body').click(function(e){
var Elem = e.target;
var itemgroup = $(Elem).attr('rel');
var itemid = $(Elem).attr('itemno');
if (Elem.className == 'additem'){
tb_show('Add' ,
'add_item.html'+'?&itemid='+itemid+'&itemgrp='+itemgroup+'&TB_iframe=true&height=420width=500',
'/images/items.jpg');
}
else if (Elem.className == 'showsoldqty'){
tb_show('Show' ,
'show_sold_qty.html'+'?&itemid='+itemid+'&itemgrp='+itemgroup+'&TB_iframe=true&height=420width=500',
'/images/items.jpg');
}
});
The table structure is as mentioned below with one row as sample (the
column in this row is being repeated and displayed more than 6K times) :
<table>
<tr>
<td>
<div class="additem" rel="G1" itemno="21">Add Item</div>
<div class="showsoldqty" rel="G2" itemno="22">Show Sold
Quantity</div>
</td>
</tr>
</table>
XSL value-of doesn't seem to get value from the xml
XSL value-of doesn't seem to get value from the xml
I have an xml file which contains following:
<?xml version="1.0"?>
<mods xmlns="http://www.loc.gov/mods/v3"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink">
<titleInfo><title>A-Title-01</title></titleInfo>
</mods>
And an XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<h2>Description</h2>
<p>Hello</p>
<p><xsl:value-of select="titleInfo/title"/></p>
</xsl:template>
</xsl:stylesheet>
My problem is I don't get the title value in the xHTML. I could only see
Description
Hello
But If I remove default namespace from the xml like this:
<?xml version="1.0"?>
<mods xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink">
<titleInfo><title>A-Title-01</title></titleInfo>
</mods>
and change the style sheet's match to <xsl:template match="/mods"> I can
see the title value.
But I can not remove the default namespace from the xml because xml is
generated by a form and it won't work if I remove the default namespace. I
don't even have a clue how to get around this or if I am doing something
wrong. Please help.
Thanks in Advance.
I have an xml file which contains following:
<?xml version="1.0"?>
<mods xmlns="http://www.loc.gov/mods/v3"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink">
<titleInfo><title>A-Title-01</title></titleInfo>
</mods>
And an XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<h2>Description</h2>
<p>Hello</p>
<p><xsl:value-of select="titleInfo/title"/></p>
</xsl:template>
</xsl:stylesheet>
My problem is I don't get the title value in the xHTML. I could only see
Description
Hello
But If I remove default namespace from the xml like this:
<?xml version="1.0"?>
<mods xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink">
<titleInfo><title>A-Title-01</title></titleInfo>
</mods>
and change the style sheet's match to <xsl:template match="/mods"> I can
see the title value.
But I can not remove the default namespace from the xml because xml is
generated by a form and it won't work if I remove the default namespace. I
don't even have a clue how to get around this or if I am doing something
wrong. Please help.
Thanks in Advance.
Why do I get 'undefined method `>=' for nil:NilClass' in do loop?
Why do I get 'undefined method `>=' for nil:NilClass' in do loop?
I have the following data architecture:
:tplangroups has_many :tplans
:tplans belongs_to :tplangroups
:tplans has attr_accessible :favrank
I need to get the id of the tplan with the highest favrank from each
tplangroup, this routine below is how I'm trying to accomplish that:
<% @tplangroups.each_with_index do |tplangroup, index| %>
<% @highest_favrank = 0 %>
<% @highest_id = tplangroup.tplans[0] %>
<% tplangroup.tplans.each do |tplan| %>
<% if tplan.favrank >= @highest_favrank %>
<% @highest_favrank = tplan.favrank %>
<% @highest_id = tplan.id %>
<% end %>
<% end %>
#does stuff with tplangroup
<% end %>
However, I keep getting the following error:
undefined method `>=' for nil:NilClass
Any ideas? I really have no idea why it's throwing this error. I know that
all of the attributes/variables I am referencing have values, I have
tested this. I am not sure where I'm going wrong, thanks in advance!
I have the following data architecture:
:tplangroups has_many :tplans
:tplans belongs_to :tplangroups
:tplans has attr_accessible :favrank
I need to get the id of the tplan with the highest favrank from each
tplangroup, this routine below is how I'm trying to accomplish that:
<% @tplangroups.each_with_index do |tplangroup, index| %>
<% @highest_favrank = 0 %>
<% @highest_id = tplangroup.tplans[0] %>
<% tplangroup.tplans.each do |tplan| %>
<% if tplan.favrank >= @highest_favrank %>
<% @highest_favrank = tplan.favrank %>
<% @highest_id = tplan.id %>
<% end %>
<% end %>
#does stuff with tplangroup
<% end %>
However, I keep getting the following error:
undefined method `>=' for nil:NilClass
Any ideas? I really have no idea why it's throwing this error. I know that
all of the attributes/variables I am referencing have values, I have
tested this. I am not sure where I'm going wrong, thanks in advance!
I would like to set my variables at the top of my class instead of in the method
I would like to set my variables at the top of my class instead of in the
method
I can't seem to tackle this confusing problem, I have lots and lots of
things that I would like to add at the top of my class to help cut down on
clutter.
Since multiple methods use these checkbox variables.
I would like to have everything at the top directly under the opening
bracket.
Here's what works, but not what I want.:
public class MyClass extends Activity implements View.OnClickListener {
//leaving out most code like onCreate. Just pretend it's there.
public void checkboth(View view) {
CheckBox cb1 = (CheckBox) findViewById(R.id.cb1);
CheckBox cb2 = (CheckBox) findViewById(R.id.cb2);
cb1.setchecked(true);
cb2.setchecked(true);
}
@Override
public void onClick(View v) {
}
}
But for the life of me I can't figure out why I can't do this:
public class MyClass extends Activity implements View.OnClickListener {
CheckBox cb1 = (CheckBox) findViewById(R.id.cb1);
CheckBox cb2 = (CheckBox) findViewById(R.id.cb2);
//leaving out most code like onCreate. Just pretend it's there.
public void checkboth(View view) {
cb1.setchecked(true);
cb2.setchecked(true);
}
@Override
public void onClick(View v) {
}
}
method
I can't seem to tackle this confusing problem, I have lots and lots of
things that I would like to add at the top of my class to help cut down on
clutter.
Since multiple methods use these checkbox variables.
I would like to have everything at the top directly under the opening
bracket.
Here's what works, but not what I want.:
public class MyClass extends Activity implements View.OnClickListener {
//leaving out most code like onCreate. Just pretend it's there.
public void checkboth(View view) {
CheckBox cb1 = (CheckBox) findViewById(R.id.cb1);
CheckBox cb2 = (CheckBox) findViewById(R.id.cb2);
cb1.setchecked(true);
cb2.setchecked(true);
}
@Override
public void onClick(View v) {
}
}
But for the life of me I can't figure out why I can't do this:
public class MyClass extends Activity implements View.OnClickListener {
CheckBox cb1 = (CheckBox) findViewById(R.id.cb1);
CheckBox cb2 = (CheckBox) findViewById(R.id.cb2);
//leaving out most code like onCreate. Just pretend it's there.
public void checkboth(View view) {
cb1.setchecked(true);
cb2.setchecked(true);
}
@Override
public void onClick(View v) {
}
}
re-using ServiceStack DTO in C# client
re-using ServiceStack DTO in C# client
I've successfully created the Hello World example from the ServiceStack
web site and modified it for my needs. Read: Basic authentication, a bit
of database access. etc.
I'd like to access the hello service from the test client
[Authenticate]
[Route("/hello/{Name}")]
public class HelloRequest : IReturn<HelloResponse>
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
public class HelloService : Service
{
public object Any(HelloRequest request)
{
var userSession = SessionAs<CustomUserSession>();
var roles = string.Join(", ", userSession.Roles.ToArray());
return new HelloResponse { Result = "Hello, " + request.Name + ",
your company: " + userSession.CompanyName};
}
}
I see a few examples out there which appear to be using the "HelloRespnse"
and "Hello" types, but I cannot quite figure out how one would properly
import the DTO(s) created in the service. From the ServiceStack wiki:
HelloResponse response = client.Get(new Hello { Name = "World!" });
response.Result.Print();
So the summary of my question: How do I easily re-use DTOs created in my
service within a C# client?
Sorry in advance for my lack of totally understanding SS and thanks for
the help.
I've successfully created the Hello World example from the ServiceStack
web site and modified it for my needs. Read: Basic authentication, a bit
of database access. etc.
I'd like to access the hello service from the test client
[Authenticate]
[Route("/hello/{Name}")]
public class HelloRequest : IReturn<HelloResponse>
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
public class HelloService : Service
{
public object Any(HelloRequest request)
{
var userSession = SessionAs<CustomUserSession>();
var roles = string.Join(", ", userSession.Roles.ToArray());
return new HelloResponse { Result = "Hello, " + request.Name + ",
your company: " + userSession.CompanyName};
}
}
I see a few examples out there which appear to be using the "HelloRespnse"
and "Hello" types, but I cannot quite figure out how one would properly
import the DTO(s) created in the service. From the ServiceStack wiki:
HelloResponse response = client.Get(new Hello { Name = "World!" });
response.Result.Print();
So the summary of my question: How do I easily re-use DTOs created in my
service within a C# client?
Sorry in advance for my lack of totally understanding SS and thanks for
the help.
Garbage collection - why is c3 not eligible for collection in this example (SCJP 6)
Garbage collection - why is c3 not eligible for collection in this example
(SCJP 6)
Taken from SCJP 6 prep book -
Given:
class CardBoard {
Short story = 200;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
}
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
// do Stuff
}
}
When // doStuff is reached, how many objects are eligible for GC?
A. 0
B. 1
C. 2
D. Compilation fails
E. It is not possible to know
F. An exception is thrown at runtime
The correct answer is C - " Only one CardBoard object (c1) is eligible,
but it has an associated Short wrapper object that is also eligible."
My question is why is c3 not eligible for collection?
My thoughts are -
c1.go(c2) sets the local reference variable, cb (which is a copy of c2),
to null and then returns cb which is assigned to c3. I know that the
reference variable for c2 itself cannot be modified in the method, only
the object behind it. However it would appear to me that the copy of the
reference variable, cb, is set to null and assigned to c3. Why is c3 not
set to the returned null in this instance?
(SCJP 6)
Taken from SCJP 6 prep book -
Given:
class CardBoard {
Short story = 200;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
}
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
// do Stuff
}
}
When // doStuff is reached, how many objects are eligible for GC?
A. 0
B. 1
C. 2
D. Compilation fails
E. It is not possible to know
F. An exception is thrown at runtime
The correct answer is C - " Only one CardBoard object (c1) is eligible,
but it has an associated Short wrapper object that is also eligible."
My question is why is c3 not eligible for collection?
My thoughts are -
c1.go(c2) sets the local reference variable, cb (which is a copy of c2),
to null and then returns cb which is assigned to c3. I know that the
reference variable for c2 itself cannot be modified in the method, only
the object behind it. However it would appear to me that the copy of the
reference variable, cb, is set to null and assigned to c3. Why is c3 not
set to the returned null in this instance?
Navigate from tableViewcell to new tableview to new view, Xcode
Navigate from tableViewcell to new tableview to new view, Xcode
I am working with a Xcode project where I have two tableviews and one
ordinary view. The first tableview have 9 different cells and when you
click one of theese I want to navigate to the second tableview and fill it
with contents from a different array depending on which cell you clicked
on in the first tableview.
After that I want to be able to click on a cell in the second tableview
and from there navigate to a view controller that shows different pictures
and text in textfields depending on which cell i clicked there.
I don't know if I'm gonna use prepare for segue or something else.
I am stuck and in a hurry so I would be very grateful for help.
This is the code I have for the first tableView:
#import "ValjKategoriViewController.h"
#import "ValjKupongViewController.h"
#import "Kupong.h"
@interface ValjKategoriViewController ()
@end
@implementation ValjKategoriViewController
@synthesize kategoriArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSArray *array = [[NSArray alloc] initWithObjects:@"Alla aktuella
kuponger",@"Restauranger & Cafeer",@"Dagens lunch",@"Friskvård &
Hälsa", @"Dagligvaror", @"Frisörer",@"Shopping",@"Bil &
Motor",@"Upplevelser & Nöje",nil];
self.kategoriArray = array;
self.title = @"Kategori";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [kategoriArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"SimpleTableIdentifier"];
}
cell.textLabel.text = [kategoriArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
I am working with a Xcode project where I have two tableviews and one
ordinary view. The first tableview have 9 different cells and when you
click one of theese I want to navigate to the second tableview and fill it
with contents from a different array depending on which cell you clicked
on in the first tableview.
After that I want to be able to click on a cell in the second tableview
and from there navigate to a view controller that shows different pictures
and text in textfields depending on which cell i clicked there.
I don't know if I'm gonna use prepare for segue or something else.
I am stuck and in a hurry so I would be very grateful for help.
This is the code I have for the first tableView:
#import "ValjKategoriViewController.h"
#import "ValjKupongViewController.h"
#import "Kupong.h"
@interface ValjKategoriViewController ()
@end
@implementation ValjKategoriViewController
@synthesize kategoriArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSArray *array = [[NSArray alloc] initWithObjects:@"Alla aktuella
kuponger",@"Restauranger & Cafeer",@"Dagens lunch",@"Friskvård &
Hälsa", @"Dagligvaror", @"Frisörer",@"Shopping",@"Bil &
Motor",@"Upplevelser & Nöje",nil];
self.kategoriArray = array;
self.title = @"Kategori";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [kategoriArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"SimpleTableIdentifier"];
}
cell.textLabel.text = [kategoriArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
How can i add wrapper to the current xml while defining the keyvalue pair using c#
How can i add wrapper to the current xml while defining the keyvalue pair
using c#
I need to provide wrapper to my current xml from which i am obtaining the
keyvalye pair values. Here is my current code :
string SID_Environment = "SID_" + EnvironmentID.ToString();
XDocument XDoc = XDocument.Load(FilePath_EXPRESS_API_SearchCriteria);
var Dict_SearchIDs = XDoc.Elements().ToDictionary(a =>
(string)a.Attribute("Name"), a => (string)a.Attribute("Value"));
string Search_ID = Dict_SearchIDs.Where(IDAttribute => IDAttribute.Key ==
SID_Environment).Select(IDAttribute =>
IDAttribute.Value).FirstOrDefault();
Console.WriteLine(Search_ID);
Here is my sample xml as follows:
<APIParameters>
<Parameter Name="SID_STAGE" Value="101198" Required="true"/>
<Parameter Name="SID_QE" Value="95732" Required="true"/>
</APIParameters>
Please note that this code is working fine with the sample xml but after
modifying my xml with some wrappers i am facing the issue. I need to
provide some wrapper to my xml to modify my sample xml as follows:
<DrWatson>
<Sets>
<Set>
<APIParameters>
<Parameter Name="SID_STAGE" Value="101198" Required="true"/>
<Parameter Name="SID_QE" Value="95732" Required="true"/>
</APIParameters>
</Set>
</Sets>
</DrWatson>
But when i do it and run my code it throws me an error.Please suggest.
using c#
I need to provide wrapper to my current xml from which i am obtaining the
keyvalye pair values. Here is my current code :
string SID_Environment = "SID_" + EnvironmentID.ToString();
XDocument XDoc = XDocument.Load(FilePath_EXPRESS_API_SearchCriteria);
var Dict_SearchIDs = XDoc.Elements().ToDictionary(a =>
(string)a.Attribute("Name"), a => (string)a.Attribute("Value"));
string Search_ID = Dict_SearchIDs.Where(IDAttribute => IDAttribute.Key ==
SID_Environment).Select(IDAttribute =>
IDAttribute.Value).FirstOrDefault();
Console.WriteLine(Search_ID);
Here is my sample xml as follows:
<APIParameters>
<Parameter Name="SID_STAGE" Value="101198" Required="true"/>
<Parameter Name="SID_QE" Value="95732" Required="true"/>
</APIParameters>
Please note that this code is working fine with the sample xml but after
modifying my xml with some wrappers i am facing the issue. I need to
provide some wrapper to my xml to modify my sample xml as follows:
<DrWatson>
<Sets>
<Set>
<APIParameters>
<Parameter Name="SID_STAGE" Value="101198" Required="true"/>
<Parameter Name="SID_QE" Value="95732" Required="true"/>
</APIParameters>
</Set>
</Sets>
</DrWatson>
But when i do it and run my code it throws me an error.Please suggest.
suddenly password column throws: SQLSTATE[42S22]: Column not found
suddenly password column throws: SQLSTATE[42S22]: Column not found
I am trying to use PHP PDO to do a one-off replace of plain-text passwords
in my dev database (see below).
I use numerous other PDO INSERT and UPDATE statements without any trouble
- or at least without this issue, so what is going wrong here? It seems
that it suddenly translates the column name password as a reserved word,
and sets the column name to the hashed value! Why is this a problem now,
but never when I updated passwords and other member details before? (Have
tried with and without backticks.)
foreach($pwdArr as $key => $value)
{
$value = strtolower ($value);
$value = password_hash($value, PASSWORD_DEFAULT);
$updatePwdSQL = "UPDATE `member` SET `password` = $value WHERE
`id` = $key";
$update = $PDOdbObject->prepare($updatePwdSQL);
$update->execute();
}
Thanks if anyone can clarify!
I am trying to use PHP PDO to do a one-off replace of plain-text passwords
in my dev database (see below).
I use numerous other PDO INSERT and UPDATE statements without any trouble
- or at least without this issue, so what is going wrong here? It seems
that it suddenly translates the column name password as a reserved word,
and sets the column name to the hashed value! Why is this a problem now,
but never when I updated passwords and other member details before? (Have
tried with and without backticks.)
foreach($pwdArr as $key => $value)
{
$value = strtolower ($value);
$value = password_hash($value, PASSWORD_DEFAULT);
$updatePwdSQL = "UPDATE `member` SET `password` = $value WHERE
`id` = $key";
$update = $PDOdbObject->prepare($updatePwdSQL);
$update->execute();
}
Thanks if anyone can clarify!
Tuesday, 17 September 2013
What actually happens in early and late binding
What actually happens in early and late binding
I have created two objects of Manager class in Main() as below:
Manager mgr = new Manager();
Employee emp= new Manager();
What I theoretically understand is that 1st object creation [mgr] is
compile time binding whereas 2nd object creation [emp] is run time
binding. But I want to understand it practically what actually happens
that decides that function call will be binded to Function name at compile
time [in my case, mgr] or run time [in my case, emp].
What I understand here is that, in both these situations objects are to be
created at run time only. If I say new Manager() then it has to create
object of Manager only. So, Please suggest what actually happens at run
time that is not the case with compile time.
namespace EarlyNLateBinding
{
class Employee
{
public virtual double CalculateSalary(double basic, double hra,
double da)
{
return basic + hra + da;
}
}
class Manager:Employee
{
double allowances = 4000;
public override double CalculateSalary(double basic, double hra,
double da)
{
return basic + hra + da+allowances;
}
}
class Program
{
static void Main(string[] args)
{
Employee emp= new Manager();
double empsalary = emp.CalculateSalary(35000, 27000, 5000);
Console.WriteLine(empsalary.ToString());
Manager mgr = new Manager();
double mgrsalary = mgr.CalculateSalary(35000, 27000, 5000);
Console.WriteLine(mgrsalary.ToString());
Console.Read();
}
}
}
I have created two objects of Manager class in Main() as below:
Manager mgr = new Manager();
Employee emp= new Manager();
What I theoretically understand is that 1st object creation [mgr] is
compile time binding whereas 2nd object creation [emp] is run time
binding. But I want to understand it practically what actually happens
that decides that function call will be binded to Function name at compile
time [in my case, mgr] or run time [in my case, emp].
What I understand here is that, in both these situations objects are to be
created at run time only. If I say new Manager() then it has to create
object of Manager only. So, Please suggest what actually happens at run
time that is not the case with compile time.
namespace EarlyNLateBinding
{
class Employee
{
public virtual double CalculateSalary(double basic, double hra,
double da)
{
return basic + hra + da;
}
}
class Manager:Employee
{
double allowances = 4000;
public override double CalculateSalary(double basic, double hra,
double da)
{
return basic + hra + da+allowances;
}
}
class Program
{
static void Main(string[] args)
{
Employee emp= new Manager();
double empsalary = emp.CalculateSalary(35000, 27000, 5000);
Console.WriteLine(empsalary.ToString());
Manager mgr = new Manager();
double mgrsalary = mgr.CalculateSalary(35000, 27000, 5000);
Console.WriteLine(mgrsalary.ToString());
Console.Read();
}
}
}
Select a line in a d3.js or nvd3.js line graph
Select a line in a d3.js or nvd3.js line graph
In a D3 or NVD3.js line graph, how can I select a particular line once the
graph is rendered? For example, suppose I want to animate the stroke width
on a line, like this:
d3.selectAll('path').transition().duration(2000).style("stroke-width", "20");
The above will select all paths, obviously, but I would like to select a
particular series—for example, the Oranges series in a data set defined
like this:
var data = [{key: "Apples", values: array1},{key: "Oranges", values: array2}]
I thought something this might work, but it did not:
d3.select('#chart svg').datum(data[1]).transition... // or alternatively,
d3.select('#chart svg').datum(data[1].values).transition...
I've been trying to figure it out using the Cumulative Line Chart example
in the code editor here, with no success:
http://nvd3.org/livecode/#codemirrorNav
This is a very basic question, but I'm new to D3 and have been unable to
figure it out.
In a D3 or NVD3.js line graph, how can I select a particular line once the
graph is rendered? For example, suppose I want to animate the stroke width
on a line, like this:
d3.selectAll('path').transition().duration(2000).style("stroke-width", "20");
The above will select all paths, obviously, but I would like to select a
particular series—for example, the Oranges series in a data set defined
like this:
var data = [{key: "Apples", values: array1},{key: "Oranges", values: array2}]
I thought something this might work, but it did not:
d3.select('#chart svg').datum(data[1]).transition... // or alternatively,
d3.select('#chart svg').datum(data[1].values).transition...
I've been trying to figure it out using the Cumulative Line Chart example
in the code editor here, with no success:
http://nvd3.org/livecode/#codemirrorNav
This is a very basic question, but I'm new to D3 and have been unable to
figure it out.
How do I force declared parameters to require explicit naming?
How do I force declared parameters to require explicit naming?
I'm having a hard time thinking this through. if I wanted all declared
parameters to require explicit naming when they're set and I wanted to
pick up anything unnamed from the $args variable, how would I do it?
If my script declared the following parameters:
param($installdir, $compilemode, $whatever)
then passing a list of files (in which case I don't want to specify the
installation directory, a compile mode, etc.) the first three parameters
would gobble my arguments. So, I would like to pass:
c:\> MyScript file-1.cs file-2.cs file-3.cs file-4.cs
and get all 4 strings appear $args, or alternatively, call:
c:\> MyScript -CompileMode simple file-1.cs -InstallDir c:\temp file-2.cs
and get values for $compilemode and $installdir with $args containing 2
files... how can I do that?
I'm having a hard time thinking this through. if I wanted all declared
parameters to require explicit naming when they're set and I wanted to
pick up anything unnamed from the $args variable, how would I do it?
If my script declared the following parameters:
param($installdir, $compilemode, $whatever)
then passing a list of files (in which case I don't want to specify the
installation directory, a compile mode, etc.) the first three parameters
would gobble my arguments. So, I would like to pass:
c:\> MyScript file-1.cs file-2.cs file-3.cs file-4.cs
and get all 4 strings appear $args, or alternatively, call:
c:\> MyScript -CompileMode simple file-1.cs -InstallDir c:\temp file-2.cs
and get values for $compilemode and $installdir with $args containing 2
files... how can I do that?
Java: Display ArrayList elements as columns in 2d ArrayList
Java: Display ArrayList elements as columns in 2d ArrayList
I have an ArrayList like this:
ArrayList<ArrayList<Double>> someArray = new ArrayList<ArrayList<Double>>();
It has values like this:
[1,3,2,1,3,4,5,5],[7,2,1,3,4,5,4,2,4,3],....
I want the output to look like this:
1 7 . . .
3 2
2 1
1 3
..
..
..
i.e each list in the ArrayList should be displayed as one column. I tried
various ways but code displays them in rows..
for(int i=0;i<someArray.size();i++){
System.out.println(someArray.get(i));
}
Looks simple but unable to figure it out :-!
I have an ArrayList like this:
ArrayList<ArrayList<Double>> someArray = new ArrayList<ArrayList<Double>>();
It has values like this:
[1,3,2,1,3,4,5,5],[7,2,1,3,4,5,4,2,4,3],....
I want the output to look like this:
1 7 . . .
3 2
2 1
1 3
..
..
..
i.e each list in the ArrayList should be displayed as one column. I tried
various ways but code displays them in rows..
for(int i=0;i<someArray.size();i++){
System.out.println(someArray.get(i));
}
Looks simple but unable to figure it out :-!
twitter bootstrap select silviomoreto increase height
twitter bootstrap select silviomoreto increase height
I´m using twitter bootstrap select component from silviomoreto. I´m just
trying to style the field by increasing the height to 45px.
While in other bootstrap input components I have no problem, it is not
working in this select component.
I´m using twitter bootstrap select component from silviomoreto. I´m just
trying to style the field by increasing the height to 45px.
While in other bootstrap input components I have no problem, it is not
working in this select component.
Why is it prohivited to use fork without exec in mac?
Why is it prohivited to use fork without exec in mac?
My question is quite simple. On Linux it is quite popular to use fork
without exec
However, I have found that on MacOS this is not possible (see fork manual)
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/fork.2.html
There are limits to what you can do in the child process. To be totally
safe you should restrict your-self yourself self to only executing
async-signal safe operations until such time as one of the exec functions
is called. All APIs, including global data symbols, in any framework or
library should be assumed to be unsafe after a fork() unless explicitly
documented to be safe or async-signal safe. If you need to use these
frameworks in the child process, you must exec. In this situation it is
reasonable to exec your-self. yourself. self.
This seems strange to me? What is the reason? Is it possible to workaround
it?
My question is quite simple. On Linux it is quite popular to use fork
without exec
However, I have found that on MacOS this is not possible (see fork manual)
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/fork.2.html
There are limits to what you can do in the child process. To be totally
safe you should restrict your-self yourself self to only executing
async-signal safe operations until such time as one of the exec functions
is called. All APIs, including global data symbols, in any framework or
library should be assumed to be unsafe after a fork() unless explicitly
documented to be safe or async-signal safe. If you need to use these
frameworks in the child process, you must exec. In this situation it is
reasonable to exec your-self. yourself. self.
This seems strange to me? What is the reason? Is it possible to workaround
it?
Sunday, 15 September 2013
Using aggregation to sorting in complex conditional
Using aggregation to sorting in complex conditional
I create a topic about using $match which was solved, but now I'm stuck in
a more complex example. For example, consider the struct of my Json:
{
user: 'bruno',
answers: [
{id: 0, value: 3.5},
{id: 1, value: "hello"}
]
}
I would like to add or order, apply some transformations on the values
contained in 'value' only the identifier 'id' equal to 0, for example a
sort method.
Consider the following data:
db.my_collection.insert({ user: 'bruno', answers: [ {id: 0, value: 3.5},
{id: 1, value: "hello"}]})
db.my_collection.insert({ user: 'bruno2', answers: [ {id: 0, value: 0.5},
{id: 1, value: "world"}]})
I tried using:
db.my_collection.aggregate ({$sort: {"answers": {"$elemMatch": {id: 0,
value: -1}}}})
But, it didn't work. The expected result was: {user: 'bruno2' answers:
[{id: 0, value: 0.5}, {id: 1, value: "world"}]}, {user: 'bruno' answers:
[{id: 0, value: 3.5}, {id: 1, value: "hello"}]})
Thank you.
I create a topic about using $match which was solved, but now I'm stuck in
a more complex example. For example, consider the struct of my Json:
{
user: 'bruno',
answers: [
{id: 0, value: 3.5},
{id: 1, value: "hello"}
]
}
I would like to add or order, apply some transformations on the values
contained in 'value' only the identifier 'id' equal to 0, for example a
sort method.
Consider the following data:
db.my_collection.insert({ user: 'bruno', answers: [ {id: 0, value: 3.5},
{id: 1, value: "hello"}]})
db.my_collection.insert({ user: 'bruno2', answers: [ {id: 0, value: 0.5},
{id: 1, value: "world"}]})
I tried using:
db.my_collection.aggregate ({$sort: {"answers": {"$elemMatch": {id: 0,
value: -1}}}})
But, it didn't work. The expected result was: {user: 'bruno2' answers:
[{id: 0, value: 0.5}, {id: 1, value: "world"}]}, {user: 'bruno' answers:
[{id: 0, value: 3.5}, {id: 1, value: "hello"}]})
Thank you.
CoreData release memory in private moc
CoreData release memory in private moc
I'm using Zarra's way of importing large dataset into CoreData, by using 3
contexts, one is private.
http://www.cocoanetics.com/2012/07/multi-context-coredata/ (the last one).
However the import uses and retains large amount of memory. I tried to add
an autoreleasepool in the process, but it's not sorting effects.
How can I modify this code to save memory during or at the end of the
process? Should I also [temporaryContext reset] at some point?
Thanks for any input, simplified controller code follows:
// import routine
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext
alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
temporaryContext.parentContext = self.managedObjectContext;
temporaryContext.undoManager = nil;
[temporaryContext performBlock:^{
@autoreleasepool {
// Perform operations, create, update, delete and finally save.
[temporaryContext save:nil];
}
[self.managedObjectContext performBlock:^{
[self.managedObjectContext save:nil];
[self.privateWriterContext performBlock:^{
[self.privateWriterContext save:nil];
self->refreshInProgress = NO;
dispatch_async(dispatch_get_main_queue(), ^{
[self.refreshControl endRefreshing];
});
}];
}];
}];
I'm using Zarra's way of importing large dataset into CoreData, by using 3
contexts, one is private.
http://www.cocoanetics.com/2012/07/multi-context-coredata/ (the last one).
However the import uses and retains large amount of memory. I tried to add
an autoreleasepool in the process, but it's not sorting effects.
How can I modify this code to save memory during or at the end of the
process? Should I also [temporaryContext reset] at some point?
Thanks for any input, simplified controller code follows:
// import routine
NSManagedObjectContext *temporaryContext = [[NSManagedObjectContext
alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
temporaryContext.parentContext = self.managedObjectContext;
temporaryContext.undoManager = nil;
[temporaryContext performBlock:^{
@autoreleasepool {
// Perform operations, create, update, delete and finally save.
[temporaryContext save:nil];
}
[self.managedObjectContext performBlock:^{
[self.managedObjectContext save:nil];
[self.privateWriterContext performBlock:^{
[self.privateWriterContext save:nil];
self->refreshInProgress = NO;
dispatch_async(dispatch_get_main_queue(), ^{
[self.refreshControl endRefreshing];
});
}];
}];
}];
Batch script, copying filename to a txt file
Batch script, copying filename to a txt file
Could anyone assist, i crate a batch script that will create bunch of txt
files from the list i have, the txt then needs to contain a few lines on
text and parts of it will need to have the name of a file. So eg. mkdir
file1.txt then the .txt file needs to have: this file contains info owner
of the file is 'file.txt' data for this file is in C:\Users\'file.txt'
Please let me know should this not be clear enough Thanks
Could anyone assist, i crate a batch script that will create bunch of txt
files from the list i have, the txt then needs to contain a few lines on
text and parts of it will need to have the name of a file. So eg. mkdir
file1.txt then the .txt file needs to have: this file contains info owner
of the file is 'file.txt' data for this file is in C:\Users\'file.txt'
Please let me know should this not be clear enough Thanks
How to copy a file from my local disk to remote applicatin in Unix
How to copy a file from my local disk to remote applicatin in Unix
Let's say I have created XML file inside C:/path/MyFolder/MyFile.xml. I
want to copy them to my remote account in a Unix machine. ~/Home/www.
I read the tutorial, no where I see where I can copy or move file from my
local to the remote system.
Let's say I have created XML file inside C:/path/MyFolder/MyFile.xml. I
want to copy them to my remote account in a Unix machine. ~/Home/www.
I read the tutorial, no where I see where I can copy or move file from my
local to the remote system.
Translation of java-mail to imap command
Translation of java-mail to imap command
I am learning imap and trying to retrieve mailbox/folder/message commands
as per rfc3501 at imap console. e.g.tag list "" % .etc. I also came to
know about java mail api using which i can connect to imap store and
retrieve folder/messages details and attributes I am just wondering how
java mail api commands are translated to imap commands and
vice-versa.Would be better if low level explanation is provided
I am learning imap and trying to retrieve mailbox/folder/message commands
as per rfc3501 at imap console. e.g.tag list "" % .etc. I also came to
know about java mail api using which i can connect to imap store and
retrieve folder/messages details and attributes I am just wondering how
java mail api commands are translated to imap commands and
vice-versa.Would be better if low level explanation is provided
Why does checkbox gets checked on a click event for submit
Why does checkbox gets checked on a click event for submit
I am using a jquery form to submit the interests for users. What I am
using is something like a checkbox value, they are seperate and I use
className to get their values.
The issue that I have to face is whether I select both of them or none of
them or just a single of them. I get them both checked when I click the
button that will submit the form using Ajax, so that results in an
opposite result.
Here is the code that I am using:
var getInterest = "";
if ($(".interestedInMale").attr('checked', 'checked') &&
$(".interestedInFemale").attr('checked', 'checked')) {
getInterest = "Females, Males";
} else if ($(".interestedInMale").attr('checked', 'checked')) {
getInterest = "Males";
} else if ($(".interestedInFemale").attr('checked', 'checked')) {
getInterest = "Females";
} else {
getInterest = "";
}
What should happen is that it should just provide me with the values, not
alter the values but what it does is opposite, it first changes the value
I mean checks them both, and then submits the form having the total value
Females, Males. And this is not what I want.
Below this code is the ajax submit block. And above this is the function
declaration as:
function submitThis() {
Any help for what I am doing wrong? Also, you can give me a better
suggestion for getting the values of Checkbox fields in jQuery Ajax.
I am using a jquery form to submit the interests for users. What I am
using is something like a checkbox value, they are seperate and I use
className to get their values.
The issue that I have to face is whether I select both of them or none of
them or just a single of them. I get them both checked when I click the
button that will submit the form using Ajax, so that results in an
opposite result.
Here is the code that I am using:
var getInterest = "";
if ($(".interestedInMale").attr('checked', 'checked') &&
$(".interestedInFemale").attr('checked', 'checked')) {
getInterest = "Females, Males";
} else if ($(".interestedInMale").attr('checked', 'checked')) {
getInterest = "Males";
} else if ($(".interestedInFemale").attr('checked', 'checked')) {
getInterest = "Females";
} else {
getInterest = "";
}
What should happen is that it should just provide me with the values, not
alter the values but what it does is opposite, it first changes the value
I mean checks them both, and then submits the form having the total value
Females, Males. And this is not what I want.
Below this code is the ajax submit block. And above this is the function
declaration as:
function submitThis() {
Any help for what I am doing wrong? Also, you can give me a better
suggestion for getting the values of Checkbox fields in jQuery Ajax.
Regarding HashMap and LinkedList [on hold]
Regarding HashMap and LinkedList [on hold]
I was going through an Article about how HashMap work.Through that article
I came to know that HashMap key value pair as a object of Map.Entry.
my question is does this Map.Entry object gets stored in LinkedList.
I was going through an Article about how HashMap work.Through that article
I came to know that HashMap key value pair as a object of Map.Entry.
my question is does this Map.Entry object gets stored in LinkedList.
Installing Qt5.1.1 and making it run with Visual Studio 2010
Installing Qt5.1.1 and making it run with Visual Studio 2010
I am trying to install Qt5.1.1 and have already installed VStudio 2010
Pro, but I stll get the error saying Qt needs a compiler set up to build.
I looked it up, and I only find very complex solutions that are impossible
for me to implement.
Can anyone give me specific directions on how I can get Qt5.1.1 working in
my laptop?
Btw in case you couldn't tell, I'm a newbie.
Thanks
I am trying to install Qt5.1.1 and have already installed VStudio 2010
Pro, but I stll get the error saying Qt needs a compiler set up to build.
I looked it up, and I only find very complex solutions that are impossible
for me to implement.
Can anyone give me specific directions on how I can get Qt5.1.1 working in
my laptop?
Btw in case you couldn't tell, I'm a newbie.
Thanks
Saturday, 14 September 2013
dynamic seo url for already existing static title
dynamic seo url for already existing static title
I am having multiple table which has 100's of rows which has a name field.
The name field has content like some name
My current url is
http://localhost:3000/posts/show/2
how to convert it into
http://localhost:3000/some-name
For dynamic inserting datas i used friendly url gem thats fine.
I am having multiple table which has 100's of rows which has a name field.
The name field has content like some name
My current url is
http://localhost:3000/posts/show/2
how to convert it into
http://localhost:3000/some-name
For dynamic inserting datas i used friendly url gem thats fine.
Different UITableViewCells doing different things when tapped
Different UITableViewCells doing different things when tapped
I have a UITableView with 5 cells. When each are tapped, they do different
things. But for now (in order for the code to not be too long), when
tapped, they all call out an NSLog.
Here is the code.
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *newCell = [_randomCells
cellForRowAtIndexPath:indexPath];
if ([(newCell) isEqualToString:@"Random cell 1"]) {
NSLog(@"foo bar 1.");
} else if ([(newCell) isEqualToString:@"Random cell 2"]) {
NSLog(@"foo bar 2.");
} else if ([(newCell) isEqualToString:@"Random cell 3"]) {
NSLog(@"foo bar 3.");
} else if ([(newCell) isEqualToString:@"Random cell 4"]) {
NSLog(@"foo bar 4.");
} else if ([(newCell) isEqualToString:@"Random cell 5"]) {
NSLog(@"foo bar 5.");
}
}
I figured that this would be the most appropriate way to detect tapped
UITableViewCells with Storyboards since I couldn't find another way to do
it.
In all five if statements, however, I receive this error message:
No visible @interface for 'UITableViewCell' declares the selector
'isEqualToString:'
How would I fix this issue? Thanks in advance.
Please note, I am using typing the code with Objective-C ARC and using
Storyboards.
I have a UITableView with 5 cells. When each are tapped, they do different
things. But for now (in order for the code to not be too long), when
tapped, they all call out an NSLog.
Here is the code.
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *newCell = [_randomCells
cellForRowAtIndexPath:indexPath];
if ([(newCell) isEqualToString:@"Random cell 1"]) {
NSLog(@"foo bar 1.");
} else if ([(newCell) isEqualToString:@"Random cell 2"]) {
NSLog(@"foo bar 2.");
} else if ([(newCell) isEqualToString:@"Random cell 3"]) {
NSLog(@"foo bar 3.");
} else if ([(newCell) isEqualToString:@"Random cell 4"]) {
NSLog(@"foo bar 4.");
} else if ([(newCell) isEqualToString:@"Random cell 5"]) {
NSLog(@"foo bar 5.");
}
}
I figured that this would be the most appropriate way to detect tapped
UITableViewCells with Storyboards since I couldn't find another way to do
it.
In all five if statements, however, I receive this error message:
No visible @interface for 'UITableViewCell' declares the selector
'isEqualToString:'
How would I fix this issue? Thanks in advance.
Please note, I am using typing the code with Objective-C ARC and using
Storyboards.
Using JOptionPane in JSF works but it's correct?
Using JOptionPane in JSF works but it's correct?
Well, i'm surpresid when i try to use JOptionPane in my ManagedBean and
Works fine. I like ideia to use JOptionPane because i think this is more
easy and practice, BUT this is correct ? Can i have some problem with this
?
Well, i'm surpresid when i try to use JOptionPane in my ManagedBean and
Works fine. I like ideia to use JOptionPane because i think this is more
easy and practice, BUT this is correct ? Can i have some problem with this
?
scala regexp stackoverflow
scala regexp stackoverflow
Typing this in scala (pattern matching with a regexp to find the value of
the id field
val str = """<path sodipodi:nodetypes="csszsscsscssssscssssscc"
inkscape:connector-curvature="0" id="basarbre" d="M 111.11111,111.11111 C
101.11111,111.1001 111.11111,111.11111 111.1011,101.01111
111.11111,111.1111 111.11111,110.11111 111.10111,111.11101
110.01111,111.11111 110.11111,111.11101 111.11111,111.01111
110.11111,111.1111 101.11111,111.10111 111.11111,111.11111
111.11111,101.11111 111.11111,111.11111 111.11111,111.11111
111.11111,111.11101 111.11111,101.11111 111.11111,101.11111
111.11111,101.11111 111.111,111.11101 101.01111,110.11111
111.11111,111.11111 101.1111,111.11111 101.11101,110.11111
111.10111,110.11101 101.11111,111.11111 101.11111,111.11111
101.11111,111.11111 111.11111,110.1111 111.10111,111.11111
111.11011,111.11111 111.11101,111.11111 111.01111,111.11111
110.11111,111.11111 111.11111,111.11111 110.01111,111.11111
111.11111,111.11111 111.11111,111.11111 111.01111,101.11111
111.11111,111.11101 110.11011,110.11111 101.11111,111.01111
11.111111,111.11111 11.111111,111.11111 11.111111,111.11111
11.111111,111.11111 11.111111,111.1111 10.111111,111.11111
11.111111,101.11111 11.010111,100.11111 11.111111,110.11111
11.111111,110.11111 11.111111,111.11111 11.111111,111.11111
11.010111,111.1111 11.101111,111.01111 11.11011,101.11111
-11.111111,110.11111 11.011111,111.11111 11.111111,111.10101
11.11111,111.11111 111.11101,111.01011 111.11101,111.01011 z"
style="fill:#511b00;fill-opacity:1;stroke:none"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"/>"""
val Idpattern = """.*id="([^"]*)"(?:[\n\r\t]|.)*""".r
str match {
case Idpattern(id) => id
case _ => "no id"
}
Yields the following exception trace:
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694)
at java.util.regex.Pattern$Branch.match(Pattern.java:4502)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556)
at java.util.regex.Pattern$Loop.match(Pattern.java:4683)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694)
...
How can I overcome this problem? I could try parsing xml with a library
but I don't need something so obfuscated. I thought regexp could be fast
and reliable.
Typing this in scala (pattern matching with a regexp to find the value of
the id field
val str = """<path sodipodi:nodetypes="csszsscsscssssscssssscc"
inkscape:connector-curvature="0" id="basarbre" d="M 111.11111,111.11111 C
101.11111,111.1001 111.11111,111.11111 111.1011,101.01111
111.11111,111.1111 111.11111,110.11111 111.10111,111.11101
110.01111,111.11111 110.11111,111.11101 111.11111,111.01111
110.11111,111.1111 101.11111,111.10111 111.11111,111.11111
111.11111,101.11111 111.11111,111.11111 111.11111,111.11111
111.11111,111.11101 111.11111,101.11111 111.11111,101.11111
111.11111,101.11111 111.111,111.11101 101.01111,110.11111
111.11111,111.11111 101.1111,111.11111 101.11101,110.11111
111.10111,110.11101 101.11111,111.11111 101.11111,111.11111
101.11111,111.11111 111.11111,110.1111 111.10111,111.11111
111.11011,111.11111 111.11101,111.11111 111.01111,111.11111
110.11111,111.11111 111.11111,111.11111 110.01111,111.11111
111.11111,111.11111 111.11111,111.11111 111.01111,101.11111
111.11111,111.11101 110.11011,110.11111 101.11111,111.01111
11.111111,111.11111 11.111111,111.11111 11.111111,111.11111
11.111111,111.11111 11.111111,111.1111 10.111111,111.11111
11.111111,101.11111 11.010111,100.11111 11.111111,110.11111
11.111111,110.11111 11.111111,111.11111 11.111111,111.11111
11.010111,111.1111 11.101111,111.01111 11.11011,101.11111
-11.111111,110.11111 11.011111,111.11111 11.111111,111.10101
11.11111,111.11111 111.11101,111.01011 111.11101,111.01011 z"
style="fill:#511b00;fill-opacity:1;stroke:none"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"/>"""
val Idpattern = """.*id="([^"]*)"(?:[\n\r\t]|.)*""".r
str match {
case Idpattern(id) => id
case _ => "no id"
}
Yields the following exception trace:
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694)
at java.util.regex.Pattern$Branch.match(Pattern.java:4502)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556)
at java.util.regex.Pattern$Loop.match(Pattern.java:4683)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3694)
...
How can I overcome this problem? I could try parsing xml with a library
but I don't need something so obfuscated. I thought regexp could be fast
and reliable.
C# List to date time to listbox
C# List to date time to listbox
I have a server with a .txt file. The program is saving the page to a
textfile and then it is being processed per line using count. I then need
to add it to datetime and then add it to a list.
So far it is pretty good except that last part datetime and the list. I
always get format exception. I have tried a few variations of try parse
and parse without luck.
The times are in a list like so: 06:06 AM 06:07 12:12 12:50
Message box shows each result at a time with no error and correct infomation.
while ((line = file.ReadLine()) != null)
{
// MessageBox.Show(line);
List<DateTime> Busarrivetime = new List<DateTime>();
// DateTime tryme = DateTime.Parse(line,
CultureInfo.InvariantCulture);
// MessageBox.Show(tryme.ToString());
DateTime date;
Busarrivetime.Add(date = DateTime.ParseExact(line,"hh:mm tt",
System.Globalization.CultureInfo.InvariantCulture)); // ERRORS
ON THIS LINE
count++;
}
file.Close();
Console.ReadLine();
I have a server with a .txt file. The program is saving the page to a
textfile and then it is being processed per line using count. I then need
to add it to datetime and then add it to a list.
So far it is pretty good except that last part datetime and the list. I
always get format exception. I have tried a few variations of try parse
and parse without luck.
The times are in a list like so: 06:06 AM 06:07 12:12 12:50
Message box shows each result at a time with no error and correct infomation.
while ((line = file.ReadLine()) != null)
{
// MessageBox.Show(line);
List<DateTime> Busarrivetime = new List<DateTime>();
// DateTime tryme = DateTime.Parse(line,
CultureInfo.InvariantCulture);
// MessageBox.Show(tryme.ToString());
DateTime date;
Busarrivetime.Add(date = DateTime.ParseExact(line,"hh:mm tt",
System.Globalization.CultureInfo.InvariantCulture)); // ERRORS
ON THIS LINE
count++;
}
file.Close();
Console.ReadLine();
Is JSONP obsolete?
Is JSONP obsolete?
With various methods to get around the same-origin policy, such as CORS
(if you have access to the server hosting the files), or by using parsing
methods such as the getJSON method in jQuery, does JSONP ever now need to
be used?
(I actually struggled for a long time to get my head round JSONP anyway -
I don't think it helped that some sites seemed to overlook it - for
example, the Google Map developer docs state that they return data as
JSON, but make no mention of the Same Origin Policy - is this naïve of
them for assuming most people know of the issues and can get round of it,
or naïve of me for getting too bogged down with trying to understand the
technical differences between JSON and JSONP?)
With various methods to get around the same-origin policy, such as CORS
(if you have access to the server hosting the files), or by using parsing
methods such as the getJSON method in jQuery, does JSONP ever now need to
be used?
(I actually struggled for a long time to get my head round JSONP anyway -
I don't think it helped that some sites seemed to overlook it - for
example, the Google Map developer docs state that they return data as
JSON, but make no mention of the Same Origin Policy - is this naïve of
them for assuming most people know of the issues and can get round of it,
or naïve of me for getting too bogged down with trying to understand the
technical differences between JSON and JSONP?)
Modifiy a variable in c++ program with the android UI in openframewroks?
Modifiy a variable in c++ program with the android UI in openframewroks?
I'm develloping an application with openframeworks, for android. I wish to
use the android UI for navigate into my app. But i block at the point how
to communicate my interaction with the android ui to my openframeworks'
code . I read a lot about JNI, but as far i understand it's allow to use
c++ code into java, but i don't find how to make it interact with the rest
of my code. When i write my jni/c++ function, i need to call it into that
:
extern "C" {
...
}
But i'm unable to modify any variable of my openframeworks program. How
can i do for by example get a boolean or a int from the android UI into
openframeworks ? Maybe i ask something impossible or i miss a point.
Regards
I'm develloping an application with openframeworks, for android. I wish to
use the android UI for navigate into my app. But i block at the point how
to communicate my interaction with the android ui to my openframeworks'
code . I read a lot about JNI, but as far i understand it's allow to use
c++ code into java, but i don't find how to make it interact with the rest
of my code. When i write my jni/c++ function, i need to call it into that
:
extern "C" {
...
}
But i'm unable to modify any variable of my openframeworks program. How
can i do for by example get a boolean or a int from the android UI into
openframeworks ? Maybe i ask something impossible or i miss a point.
Regards
Friday, 13 September 2013
How can interleave Bulk transfer and Interrupt probing?
How can interleave Bulk transfer and Interrupt probing?
I'm writing a huge bulk tranfer to a real time USB device, but I would
like to receive some interrupts at the same time. It looks like the bulk
is stalling the interrupt probing, and even with a perpetual interrupt
probing loop they get "stuck", and I get a few interrupts after each bulk,
but not everything in the queue and all the new ones are stuck (generated
after the end of the bulk).
At the theoretical level javascript is visibly mono-thread, and the bulk
transfer seem to be in the main thread albeit its non-blockig-friendly API
(it freezes the browser). So I don't even know what I'm supposed to do.
Is there some demo code for that somewhere ? I can't find any non-trivial
uses of the chrome USB api on google.
It's very difficult to post code do a custom device, but the thing is
there:
https://github.com/nraynaud/webgcode/blob/gh-pages/webapp/index.js#L110
I'm writing a huge bulk tranfer to a real time USB device, but I would
like to receive some interrupts at the same time. It looks like the bulk
is stalling the interrupt probing, and even with a perpetual interrupt
probing loop they get "stuck", and I get a few interrupts after each bulk,
but not everything in the queue and all the new ones are stuck (generated
after the end of the bulk).
At the theoretical level javascript is visibly mono-thread, and the bulk
transfer seem to be in the main thread albeit its non-blockig-friendly API
(it freezes the browser). So I don't even know what I'm supposed to do.
Is there some demo code for that somewhere ? I can't find any non-trivial
uses of the chrome USB api on google.
It's very difficult to post code do a custom device, but the thing is
there:
https://github.com/nraynaud/webgcode/blob/gh-pages/webapp/index.js#L110
variable scope and recrusion in python
variable scope and recrusion in python
Can you please tell me why the parent-child relationship needs to be
appended inside the for loop to get the expected output. I am not
understanding scope in Python.
#a unique id to be given to each node
current_id = 0
#ids = [parent_id, current_id]; stores parent_child tree data
ids = []
#MWE of depth first search
def bt(parent_id):
global ids
global current_id
#increament current id because we just created a new node
current_id = current_id +1
#store the parent to child relationship in the list called ids
ids.append([parent_id,current_id])
#show the parent child relationship that is getting append to the ids list
print 'parent-child (outside loop)', [parent_id,current_id]
if(parent_id) > 1:
return
for i in range(2):
print 'parent-child (inside loop)', [parent_id,current_id]
bt(current_id)
#run depth first search
print bt(0)
#print list of parent to child relationships
print 'list of parent-child relationships\n',ids
print 'expected output',[[0,1],[1,2],[1,3],[0,4]]
Can you please tell me why the parent-child relationship needs to be
appended inside the for loop to get the expected output. I am not
understanding scope in Python.
#a unique id to be given to each node
current_id = 0
#ids = [parent_id, current_id]; stores parent_child tree data
ids = []
#MWE of depth first search
def bt(parent_id):
global ids
global current_id
#increament current id because we just created a new node
current_id = current_id +1
#store the parent to child relationship in the list called ids
ids.append([parent_id,current_id])
#show the parent child relationship that is getting append to the ids list
print 'parent-child (outside loop)', [parent_id,current_id]
if(parent_id) > 1:
return
for i in range(2):
print 'parent-child (inside loop)', [parent_id,current_id]
bt(current_id)
#run depth first search
print bt(0)
#print list of parent to child relationships
print 'list of parent-child relationships\n',ids
print 'expected output',[[0,1],[1,2],[1,3],[0,4]]
Python SQLITE insert into not working
Python SQLITE insert into not working
So I am trying to get a simple program to insert information into a sqlite
db.
The line that is breaking is the cur.execute
sitename = "TEST sitename2"
siteusername = "TEST siteusername2"
sitepasswd = "TEST sitepassword2"
cur.execute("INSERT INTO mytable(sitename, siteusername, sitepasswd)
VALUES(%s, %s, %s)", (sitename, siteusername, sitepasswd))
Error that I receive from Python:
sqlite3.OperationalError: near "%": syntax error
So I am trying to get a simple program to insert information into a sqlite
db.
The line that is breaking is the cur.execute
sitename = "TEST sitename2"
siteusername = "TEST siteusername2"
sitepasswd = "TEST sitepassword2"
cur.execute("INSERT INTO mytable(sitename, siteusername, sitepasswd)
VALUES(%s, %s, %s)", (sitename, siteusername, sitepasswd))
Error that I receive from Python:
sqlite3.OperationalError: near "%": syntax error
verify or not the column in where clause
verify or not the column in where clause
I need to verify 2 columns but sometimes the second one will be empty then
i need to verify the second column just if it's not empty otherwise it
will just verify the first one
SELECT *
FROM table
WHERE column1 = $_GET['id']
and column2 IS NOT NULL = $_GET['id']
I need to verify 2 columns but sometimes the second one will be empty then
i need to verify the second column just if it's not empty otherwise it
will just verify the first one
SELECT *
FROM table
WHERE column1 = $_GET['id']
and column2 IS NOT NULL = $_GET['id']
Identify a app connecting, and redirect it based on a identifiant. (mac adress?)
Identify a app connecting, and redirect it based on a identifiant. (mac
adress?)
I am currently trying to create a app which would run 24h/24 7d/7 on a
dedicated computer.
This app must download a file at regular interval. In this app, all is
coded and functionning.
But the link to the file is hardcoded in it, and need to be updated too.
The found solution is to detect when the app connect to the server,
identify it, and redirect him on the new file.
Since there would be hundred of computer, we can t hardcode a new link in
each app, and change the file in the server for each computer, nor point
every computer on the same file since the client may not want all of them
play the same file.
The solution to identify each computer we found was to use the MAC adress,
since it s unique and don t change if the computer is disconnected and
recconnected.
The problem is, how, server side, get the MAC adress of the client?
All solution I ve saw are for browser and are stated as security flaw.
Here, I have no browser, and their is no data to be secure.
I do know pure javascript don t allow this either, but maybe there 's a
node.js module for that that I didn t found?
Or is there other way to identify the computer?
EDIT:
I can get the mac adress in the app, using a node.js module, is there a
way to send it to the server and either get the right file (redirect?) or
the link in some sort I can store it in a variable?
EDIT2:
Since it seems to be important, the computer will be on linux.
Also, is there any way to send a variable from the client to the server in
a html request?
adress?)
I am currently trying to create a app which would run 24h/24 7d/7 on a
dedicated computer.
This app must download a file at regular interval. In this app, all is
coded and functionning.
But the link to the file is hardcoded in it, and need to be updated too.
The found solution is to detect when the app connect to the server,
identify it, and redirect him on the new file.
Since there would be hundred of computer, we can t hardcode a new link in
each app, and change the file in the server for each computer, nor point
every computer on the same file since the client may not want all of them
play the same file.
The solution to identify each computer we found was to use the MAC adress,
since it s unique and don t change if the computer is disconnected and
recconnected.
The problem is, how, server side, get the MAC adress of the client?
All solution I ve saw are for browser and are stated as security flaw.
Here, I have no browser, and their is no data to be secure.
I do know pure javascript don t allow this either, but maybe there 's a
node.js module for that that I didn t found?
Or is there other way to identify the computer?
EDIT:
I can get the mac adress in the app, using a node.js module, is there a
way to send it to the server and either get the right file (redirect?) or
the link in some sort I can store it in a variable?
EDIT2:
Since it seems to be important, the computer will be on linux.
Also, is there any way to send a variable from the client to the server in
a html request?
Thursday, 12 September 2013
Is it possible to jsonify string within mysql query?
Is it possible to jsonify string within mysql query?
I need to get the values from a table in json format , directly using
mysql query (no post processing in php etc at application level). Most of
the field of the table are integer and its not hard to build a json string
for the records , but one column is a text type and my contain all the
garbage .
Is is possible to stringify that text type column data to build a valid
json string ?
query:
select concat('var sp_json= [',
group_concat(
'{"sp_no":',sp_no,',
"sp_group_no":',sp_group_no,',
"sp_weight":',sp_weight,',
"dg_list":[',dg_list,'],
"comments":\'',coalesce(comments,''),'\'}'
order by sp_group_no
),
']') as sp_json
from sp_dg where pm_id=1 group by pm_id
This outputs a javascript json objects etc
var sp_json=[{},,,]
I need way to stringify comments using a built-in mysql function if there
is one. Please share your thoughts .
I need to get the values from a table in json format , directly using
mysql query (no post processing in php etc at application level). Most of
the field of the table are integer and its not hard to build a json string
for the records , but one column is a text type and my contain all the
garbage .
Is is possible to stringify that text type column data to build a valid
json string ?
query:
select concat('var sp_json= [',
group_concat(
'{"sp_no":',sp_no,',
"sp_group_no":',sp_group_no,',
"sp_weight":',sp_weight,',
"dg_list":[',dg_list,'],
"comments":\'',coalesce(comments,''),'\'}'
order by sp_group_no
),
']') as sp_json
from sp_dg where pm_id=1 group by pm_id
This outputs a javascript json objects etc
var sp_json=[{},,,]
I need way to stringify comments using a built-in mysql function if there
is one. Please share your thoughts .
How to update when using angularFireCollection instead of angularFire?
How to update when using angularFireCollection instead of angularFire?
I have read the docs and I see there is an update method. However I am not
having any luck with it. I get "Cannot call method 'update' of undefined".
I can however change update to 'add' and the function works. I am doing
something wrong, I just don't know what..
Here is my code:
(function() {
'use strict';
angular.module('myApp').controller('MainCtrl',['$scope','angularFireCollection',
function($scope, angularFireCollection) {
var url = 'https://myapp.firebaseio.com/genre';
$scope.genres = angularFireCollection(new Firebase(url), $scope,
'genres');
$scope.vote = function(){
this.artist.votes=this.artist.votes + 1;
$scope.genres.update(this); // this update is not working.
}
}]);
}).call(this);
Thanks for your help.
I have read the docs and I see there is an update method. However I am not
having any luck with it. I get "Cannot call method 'update' of undefined".
I can however change update to 'add' and the function works. I am doing
something wrong, I just don't know what..
Here is my code:
(function() {
'use strict';
angular.module('myApp').controller('MainCtrl',['$scope','angularFireCollection',
function($scope, angularFireCollection) {
var url = 'https://myapp.firebaseio.com/genre';
$scope.genres = angularFireCollection(new Firebase(url), $scope,
'genres');
$scope.vote = function(){
this.artist.votes=this.artist.votes + 1;
$scope.genres.update(this); // this update is not working.
}
}]);
}).call(this);
Thanks for your help.
Map resized image coordinates back to the original
Map resized image coordinates back to the original
So here is an interesting one (or at least I think it is).
Turns out that I have two copies of the same image, the original and one
resized to fit the window.
The user then creates a polygon over the resized version of the image and
with some javascript I send the coordinates to a php script which then
merges the polygon into the original image.
The problem is, the resized coordinates are not the same for the original
image, still there is a relation between them.
Here is the code of how I resize the image in js:
if(h > 610 || w > 815){
while(h > 610 || w > 815){
h = Math.ceil(h*0.80);
w = Math.ceil(w*0.80);
}
}
This code allows me to keep the image inside the workspace (which is 610 x
815) and at the same time keeping some aspect ratio.
Then in php I attempt to revert the resize within each coordinate, but
here is where Im stuck:
$values = array();
$num_points = count($polyCoords);
foreach($polyCoords as $coord){
array_push($values, intval($coord['x']) /* +- RELOCATE
FACTOR? */ );
array_push($values, intval($coord['y']) /* +- RELOCATE
FACTOR? */ );
}
Can someone give me a hand of how to calculate this "relocate factor" for
each point? I have the original size and the resized... size.
Any ideas will be must apreciated. Thanks.
So here is an interesting one (or at least I think it is).
Turns out that I have two copies of the same image, the original and one
resized to fit the window.
The user then creates a polygon over the resized version of the image and
with some javascript I send the coordinates to a php script which then
merges the polygon into the original image.
The problem is, the resized coordinates are not the same for the original
image, still there is a relation between them.
Here is the code of how I resize the image in js:
if(h > 610 || w > 815){
while(h > 610 || w > 815){
h = Math.ceil(h*0.80);
w = Math.ceil(w*0.80);
}
}
This code allows me to keep the image inside the workspace (which is 610 x
815) and at the same time keeping some aspect ratio.
Then in php I attempt to revert the resize within each coordinate, but
here is where Im stuck:
$values = array();
$num_points = count($polyCoords);
foreach($polyCoords as $coord){
array_push($values, intval($coord['x']) /* +- RELOCATE
FACTOR? */ );
array_push($values, intval($coord['y']) /* +- RELOCATE
FACTOR? */ );
}
Can someone give me a hand of how to calculate this "relocate factor" for
each point? I have the original size and the resized... size.
Any ideas will be must apreciated. Thanks.
Rails: How can I put the sections together to form a book automatically?
Rails: How can I put the sections together to form a book automatically?
I'm a freshman to learn Rails and working on my first project about
"online book writing".
I've already made the MVC of user,book and section. Association like this:
class User < ActiveRecord::Base
has_many :sections , dependent: :destroy
end
class Section < ActiveRecord::Base
belongs_to :book
belongs_to :user
end
class Book < ActiveRecord::Base
has_many :sections
end
So I made a relationship between user and section,but no relationship
between user and book. for example,user.1 write section.1 of book.1 ,the
user.2 write section.2 of book.1.
Then I want to use all the sections of book.1 which written by different
users,to form a book.1 automatically. (connect the text field directly in
one text field,book_content is sum of section_content)
What should I do in the views or models?
I'm a freshman to learn Rails and working on my first project about
"online book writing".
I've already made the MVC of user,book and section. Association like this:
class User < ActiveRecord::Base
has_many :sections , dependent: :destroy
end
class Section < ActiveRecord::Base
belongs_to :book
belongs_to :user
end
class Book < ActiveRecord::Base
has_many :sections
end
So I made a relationship between user and section,but no relationship
between user and book. for example,user.1 write section.1 of book.1 ,the
user.2 write section.2 of book.1.
Then I want to use all the sections of book.1 which written by different
users,to form a book.1 automatically. (connect the text field directly in
one text field,book_content is sum of section_content)
What should I do in the views or models?
Django custom UsernameField form validation not working
Django custom UsernameField form validation not working
So I created a custom form field to validate for duplicate usernames. I'm
using Django + Mongoengine as my database. I have that plugged and working
with the django authentication system so I'm assuming it can be accessed
from forms.py? Maybe that assumption is incorrect. So I have the field
class UsernameField(CharField):
def to_python(self, value):
if not value:
return ""
return value
def validate(self, value):
super(CharField, self).validate(value)
try:
# If the user object exists it won't throw an Error/Exception
user=User.objects.get(username=value)
raise ValidationError("Username already exists")
except:
pass
But when I actually use it in my form, it always seems to validate
correctly even though I've called checked if form.is_valid() is True
So I created a custom form field to validate for duplicate usernames. I'm
using Django + Mongoengine as my database. I have that plugged and working
with the django authentication system so I'm assuming it can be accessed
from forms.py? Maybe that assumption is incorrect. So I have the field
class UsernameField(CharField):
def to_python(self, value):
if not value:
return ""
return value
def validate(self, value):
super(CharField, self).validate(value)
try:
# If the user object exists it won't throw an Error/Exception
user=User.objects.get(username=value)
raise ValidationError("Username already exists")
except:
pass
But when I actually use it in my form, it always seems to validate
correctly even though I've called checked if form.is_valid() is True
Get the time from {date}T{time}Z
Get the time from {date}T{time}Z
I want to get the hour and the minute from this string:
2013-09-12T11:00:00Z. How can I do this with date()? date('H:i',
strtotime('2013-09-12T11:00:00Z')) prints 13:00 and date('H:i',
'2013-09-12T11:00:00Z') prints nothing.
I want to get the hour and the minute from this string:
2013-09-12T11:00:00Z. How can I do this with date()? date('H:i',
strtotime('2013-09-12T11:00:00Z')) prints 13:00 and date('H:i',
'2013-09-12T11:00:00Z') prints nothing.
Oracle data access sql query having like %parameter%
Oracle data access sql query having like %parameter%
I am trying to run a oracle query using ODP.net. The query is having like
%parameter%. Code is provided below.
string query = @"select col1,col2,col3 from table where name like
'%:cus_name%'";
OracleParameter p1 = new OracleParameter();
p1.OracleDbType = OracleDbType.Char;
p1.Value = name;
p1.ParameterName = "cus_name";
OracleCommand sql = new OracleCommand(query, conn);
sql.Parameters.Add(p1);
OracleDataReader ora = null;
Invalid parameter error Kindly advice
I am trying to run a oracle query using ODP.net. The query is having like
%parameter%. Code is provided below.
string query = @"select col1,col2,col3 from table where name like
'%:cus_name%'";
OracleParameter p1 = new OracleParameter();
p1.OracleDbType = OracleDbType.Char;
p1.Value = name;
p1.ParameterName = "cus_name";
OracleCommand sql = new OracleCommand(query, conn);
sql.Parameters.Add(p1);
OracleDataReader ora = null;
Invalid parameter error Kindly advice
how do i access a public method of a default class outside the package
how do i access a public method of a default class outside the package
I have a class with no modifier(default), which has a public method called
mymeth. I know I could access the method when I am within the package.
However I would like to access the method when I am outside the package.
does anyone has an Idea on how it could be done. theoretically I think it
should be possible since public method means access by the world. here is
the example of my class and method:
class myclass{
public void mymeth(int i,int b){
.....
}
}
I have a class with no modifier(default), which has a public method called
mymeth. I know I could access the method when I am within the package.
However I would like to access the method when I am outside the package.
does anyone has an Idea on how it could be done. theoretically I think it
should be possible since public method means access by the world. here is
the example of my class and method:
class myclass{
public void mymeth(int i,int b){
.....
}
}
Wednesday, 11 September 2013
Wordpress Two Step Login
Wordpress Two Step Login
I would like wp login form to have two steps authentication.
1.) If the username exists, ¹ password field appears.
2.) If the username doesn't exist, the password field is hidden.
¹ visitor must type correct username to proceed to step two.*
Where can I begin my quest to have the login form "detect usernames" in
the DB?
If there is a better way, may you please share your idea?
Thanks for your attention,
I would like wp login form to have two steps authentication.
1.) If the username exists, ¹ password field appears.
2.) If the username doesn't exist, the password field is hidden.
¹ visitor must type correct username to proceed to step two.*
Where can I begin my quest to have the login form "detect usernames" in
the DB?
If there is a better way, may you please share your idea?
Thanks for your attention,
Events are not being triggered when using Template.myTemplate() in Meteor
Events are not being triggered when using Template.myTemplate() in Meteor
I'm trying to catch a click button event inside a google maps InfoWindow.
To do so I have the following
<!-- Html file -->
<template name="infoWindowContent">
<button>Click Me!</button>
</template>
Then I have this on the client.js
//Client js file
//Function that renders the template. Gets called from a user's action
function showInfoWindow(map, marker) {
var infoWindow = new google.maps.InfoWindow();
//This is the line that generates the template's html
var infoWindowHtmlContent = Template.infoWindowContent();
infoWindow.setContent(infoWindowHtmlContent);
infoWindow.open(map, marker);
}
//Template events
Template.infoWindowContent.events = {
'click button': function(event){
console.log('event was triggered', event);
}
}
The infoWindow is shown on the map and it contains the button, but when
the button is clicked no log is displayed in the console. Any clue on
this? How can I catch an event dispatched by some element rendered using
Template.myTemplate()?
I'm trying to catch a click button event inside a google maps InfoWindow.
To do so I have the following
<!-- Html file -->
<template name="infoWindowContent">
<button>Click Me!</button>
</template>
Then I have this on the client.js
//Client js file
//Function that renders the template. Gets called from a user's action
function showInfoWindow(map, marker) {
var infoWindow = new google.maps.InfoWindow();
//This is the line that generates the template's html
var infoWindowHtmlContent = Template.infoWindowContent();
infoWindow.setContent(infoWindowHtmlContent);
infoWindow.open(map, marker);
}
//Template events
Template.infoWindowContent.events = {
'click button': function(event){
console.log('event was triggered', event);
}
}
The infoWindow is shown on the map and it contains the button, but when
the button is clicked no log is displayed in the console. Any clue on
this? How can I catch an event dispatched by some element rendered using
Template.myTemplate()?
Treat mathematical variables like numbers
Treat mathematical variables like numbers
Say I have a variable named x (mathematic variable) I would like to be
able to treat this variable like a number, for example say I would like to
multiply this variable by five: I would like to achieve 5X, however this
is a simple example is there a way to do it for more complicated examples
as well? Or will I have to implement this myself?
Edit: I am not asking for code and cannot provide any as this is just
something that I am curious about to see if there is any way to do this in
c++/c already
Say I have a variable named x (mathematic variable) I would like to be
able to treat this variable like a number, for example say I would like to
multiply this variable by five: I would like to achieve 5X, however this
is a simple example is there a way to do it for more complicated examples
as well? Or will I have to implement this myself?
Edit: I am not asking for code and cannot provide any as this is just
something that I am curious about to see if there is any way to do this in
c++/c already
ExtJs - How to fetch elements from childEls
ExtJs - How to fetch elements from childEls
I'm using the snippet bellow to add some HTML elements to the top of a
FormPanel:
{
xtype: 'component',
itemId: 'form-top',
cls: 'form-top-items',
renderTpl: [
'<div id="{id}-formHelp" class="form-help">',
'<span class="form-help-text">{helpText}</span>',
'</div>'
],
renderData: {
helpText: __("Os campos com * são de preenchimento obrigatório.")
},
childEls: [
{name: 'formHelp', itemId: 'centris-form-help'}
]
}
But once the component is rendered, I can't fetch any child items.
I'm expecting a way to access the formHelp item somehow, but can't find it
anyway bellow the form-top component.
I'm using the snippet bellow to add some HTML elements to the top of a
FormPanel:
{
xtype: 'component',
itemId: 'form-top',
cls: 'form-top-items',
renderTpl: [
'<div id="{id}-formHelp" class="form-help">',
'<span class="form-help-text">{helpText}</span>',
'</div>'
],
renderData: {
helpText: __("Os campos com * são de preenchimento obrigatório.")
},
childEls: [
{name: 'formHelp', itemId: 'centris-form-help'}
]
}
But once the component is rendered, I can't fetch any child items.
I'm expecting a way to access the formHelp item somehow, but can't find it
anyway bellow the form-top component.
Change Working Directory (pwd) to Script Location in Stata 12
Change Working Directory (pwd) to Script Location in Stata 12
I have a lot of scripts (.do files) in different folders, which are
frequently moved around. I would like to have Stata detect where the
script is, and use that as a pwd (working directory). I know people that
have this functionality seemingly by default (the pwd is changed to the
script location when the script is run), but we cannot figure out why I am
not so lucky. It is a bit tedious always having a "cd" line at the top of
my scripts, and having to change this line to reflect the current
directory. I'm using Stata 12 with Windows 7 Professional.
I have a lot of scripts (.do files) in different folders, which are
frequently moved around. I would like to have Stata detect where the
script is, and use that as a pwd (working directory). I know people that
have this functionality seemingly by default (the pwd is changed to the
script location when the script is run), but we cannot figure out why I am
not so lucky. It is a bit tedious always having a "cd" line at the top of
my scripts, and having to change this line to reflect the current
directory. I'm using Stata 12 with Windows 7 Professional.
getting input in java throws exception
getting input in java throws exception
DataInput in = new DataInputStream(System.in);
System.out.println("What is your name");
String name = in.readLine();
The error says "Unhandled IO Exception". What's wrong with this code ?
DataInput in = new DataInputStream(System.in);
System.out.println("What is your name");
String name = in.readLine();
The error says "Unhandled IO Exception". What's wrong with this code ?
Adding dynamic markers on to mapbox map file.
Adding dynamic markers on to mapbox map file.
I am looking for a way to add markers on to a map which I have created in
a web page... Here is the code for the page...
<link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.css'
rel='stylesheet' />
<script src='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.js'></script>
<style>
#map {
width: 100%;
height: 600px;
}
</style>
<div id='map' />
<script type='text/javascript'>
var map = L.mapbox.map('map', '[mapname]')
</script>
This renders the map from mapbox - but I cannot figure out how to write a
web service to provide the markers. This data is stored in a table in a
SQL database.
I understand that I can load a GeoJSON file with the data in - but I am
unsure on how to create this file - and how it differs from regular JSON -
any help would be grateful!
Thanks
I am looking for a way to add markers on to a map which I have created in
a web page... Here is the code for the page...
<link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.css'
rel='stylesheet' />
<script src='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.js'></script>
<style>
#map {
width: 100%;
height: 600px;
}
</style>
<div id='map' />
<script type='text/javascript'>
var map = L.mapbox.map('map', '[mapname]')
</script>
This renders the map from mapbox - but I cannot figure out how to write a
web service to provide the markers. This data is stored in a table in a
SQL database.
I understand that I can load a GeoJSON file with the data in - but I am
unsure on how to create this file - and how it differs from regular JSON -
any help would be grateful!
Thanks
Tab menu not working with AJAX
Tab menu not working with AJAX
Got a tab menu from http://www.menucool.com/tabbed-content, This works
fine on load of the webpage. My issue is when I click on a button, AJAX is
done and content will be loaded (with this tab menu content), but the its
not working as normal.
Here are my screen shots with on page onload and AJAX load,
Normal Page load Works fine
AJAX load
Not working
May be the js file will be loaded only for page load.
How can can make it work for AJAX
My AJAX,
$.ajax({
type: 'GET',
url: destinationUrl,
data: content, // my parameters
dataType: "text",
success: function(data) { // data is tab menu content
$('#successDiv').html(data); // data is populated in successDiv
}
});
Got a tab menu from http://www.menucool.com/tabbed-content, This works
fine on load of the webpage. My issue is when I click on a button, AJAX is
done and content will be loaded (with this tab menu content), but the its
not working as normal.
Here are my screen shots with on page onload and AJAX load,
Normal Page load Works fine
AJAX load
Not working
May be the js file will be loaded only for page load.
How can can make it work for AJAX
My AJAX,
$.ajax({
type: 'GET',
url: destinationUrl,
data: content, // my parameters
dataType: "text",
success: function(data) { // data is tab menu content
$('#successDiv').html(data); // data is populated in successDiv
}
});
Bootstrap 3 Popover: display on hover AND on click, aka. Pin a Popover
Bootstrap 3 Popover: display on hover AND on click, aka. Pin a Popover
Making a popover appear with the hover trigger works fine.
Making a popover appear with the click trigger works fine.
Now, how do I go about making the popover appear when the triggering image
is hovered over, but then if the user clicks on the image, cancel the
hover and initiate a click toggle? In other words, hovering shows the
popover and clicking 'pins' the popover.
The HTML is pretty standard:
<li>User<span class="glyphicon glyphicon-user" rel="popover"
data-trigger="click" data-container="body" data-placement="auto left"
data-content="Body Text" data-original-title="Title Text"></span></li>
And the popover initialization, even more boring:
$(function () {
$("[rel=popover]").popover();
});
From what I have seen so far, it seems likely that the solution is a nice
complex set of popover('show'), popover('hide'), and popover('toggle')
calls, but my javascript / jQuery-foo is not up to the task.
Making a popover appear with the hover trigger works fine.
Making a popover appear with the click trigger works fine.
Now, how do I go about making the popover appear when the triggering image
is hovered over, but then if the user clicks on the image, cancel the
hover and initiate a click toggle? In other words, hovering shows the
popover and clicking 'pins' the popover.
The HTML is pretty standard:
<li>User<span class="glyphicon glyphicon-user" rel="popover"
data-trigger="click" data-container="body" data-placement="auto left"
data-content="Body Text" data-original-title="Title Text"></span></li>
And the popover initialization, even more boring:
$(function () {
$("[rel=popover]").popover();
});
From what I have seen so far, it seems likely that the solution is a nice
complex set of popover('show'), popover('hide'), and popover('toggle')
calls, but my javascript / jQuery-foo is not up to the task.
Tuesday, 10 September 2013
background-size not working properly in chrome
background-size not working properly in chrome
i have a left admin panel which is set in percentage width. the problem is
that i have a repeating background in it and when i use background-size to
tuck-in the background image to the size of percentage-based width, the
image just disappears in chrome. in firefox it works fine. But when i use
ctrl - to zoom-out the display, the image appears. the css of the left
panel is:
.adminmenuback {
width: 30%;
background: url(../images/leftpanel_bg.png) left top repeat-y;
background-size: 100%;
color: #fff;
position: absolute;
top: 0;
bottom: 0;
height: 100%;
}
pls help.
i have a left admin panel which is set in percentage width. the problem is
that i have a repeating background in it and when i use background-size to
tuck-in the background image to the size of percentage-based width, the
image just disappears in chrome. in firefox it works fine. But when i use
ctrl - to zoom-out the display, the image appears. the css of the left
panel is:
.adminmenuback {
width: 30%;
background: url(../images/leftpanel_bg.png) left top repeat-y;
background-size: 100%;
color: #fff;
position: absolute;
top: 0;
bottom: 0;
height: 100%;
}
pls help.
Is there a simpler way exposing Stored Procedures with WCF Data Services?
Is there a simpler way exposing Stored Procedures with WCF Data Services?
There are numerous articles over internet that explain you how to expose a
stored procedure as OData via Wcf Data Services and Entity Framework. Here
is one example article:
http://dotnet.dzone.com/news/exposing-stored-procedure-wcf
The solution is to write something like this:
[WebGet]
public IQueryable<Course> GetCoursesOrderByTitle()
{
return CurrentDataSource
.GetCoursesOrderByTitle()
.AsQueryable();
}
Effectively you need to create a method and enumerate every single stored
procedure parameter in two places: as parameters to the method above and
then as parameters to the method on CurrentDataSource. And you need to
repeat this for every single stored procedure you are exposing. This above
is nothing but plumbing code. Any time a parameter changes or a type on a
parameter changes you need to remember to go here and update, as if
updating it in the EF model is not enough hassle.
I know that I can try and write code gen but I don't know a simple way of
doing this and inserting it in the build cycle.
Does anybody have a working solution to this problem? In my project I have
quite a big number of stored procedures exposed to the api and not a
single but several WCF Data services that expose them and the number of
these keeps growing as the API evolves. How to keep maintenance time for
these low?
There are numerous articles over internet that explain you how to expose a
stored procedure as OData via Wcf Data Services and Entity Framework. Here
is one example article:
http://dotnet.dzone.com/news/exposing-stored-procedure-wcf
The solution is to write something like this:
[WebGet]
public IQueryable<Course> GetCoursesOrderByTitle()
{
return CurrentDataSource
.GetCoursesOrderByTitle()
.AsQueryable();
}
Effectively you need to create a method and enumerate every single stored
procedure parameter in two places: as parameters to the method above and
then as parameters to the method on CurrentDataSource. And you need to
repeat this for every single stored procedure you are exposing. This above
is nothing but plumbing code. Any time a parameter changes or a type on a
parameter changes you need to remember to go here and update, as if
updating it in the EF model is not enough hassle.
I know that I can try and write code gen but I don't know a simple way of
doing this and inserting it in the build cycle.
Does anybody have a working solution to this problem? In my project I have
quite a big number of stored procedures exposed to the api and not a
single but several WCF Data services that expose them and the number of
these keeps growing as the API evolves. How to keep maintenance time for
these low?
MySQL can run select * query but not select column on view
MySQL can run select * query but not select column on view
I've created a view with the following query:
SELECT TableA.ColA as ColA, User.ID as UserID, User.FirstName,
User.LastName, User.Email, TableC.ID as RoleID, TableC.Name as Role FROM
Permission
LEFT JOIN TableB ON TableA.ColA = TableB.ID
LEFT JOIN TableD ON TableD.ID = TableB.OrganizationID
LEFT JOIN User ON User.ID = TableA.UserID
LEFT JOIN TableC ON TableC.ID = TableA.RoleID
WHERE User.Active = 1 AND (TableA.ResourceType = 1
OR (TableA.ResourceType = 5 AND TableD.ID = TableB.OrganizationID))
OR User.Active = 1 AND TableC.ID = 1
ORDER BY ColA, UserID ASC
The view was created successfully and works as intended. I can do a SELECT
* ON view_test on the view without issue. However, if I attempt to select
a specific column from the view, such as SELECT ColA FROM view_test, it
returns with the following error message:
#1356 - View 'database.view_test' references invalid table(s) or column(s)
or function(s) or definer/invoker of view lack rights to use them
The account I'm running this on is root and I've re-granted access to
everything in this database, should something have messed up for some
reason. I've looked at the view in the mysql portion of the database and
it seems fine. I can run it without issue. I can do a SELECT ColA FROM
([view_sql_block_from_above]) as a and it works fine as well. It's only
after having been created as a view that it has these issues.
Any help would be greatly appreciated.
I've created a view with the following query:
SELECT TableA.ColA as ColA, User.ID as UserID, User.FirstName,
User.LastName, User.Email, TableC.ID as RoleID, TableC.Name as Role FROM
Permission
LEFT JOIN TableB ON TableA.ColA = TableB.ID
LEFT JOIN TableD ON TableD.ID = TableB.OrganizationID
LEFT JOIN User ON User.ID = TableA.UserID
LEFT JOIN TableC ON TableC.ID = TableA.RoleID
WHERE User.Active = 1 AND (TableA.ResourceType = 1
OR (TableA.ResourceType = 5 AND TableD.ID = TableB.OrganizationID))
OR User.Active = 1 AND TableC.ID = 1
ORDER BY ColA, UserID ASC
The view was created successfully and works as intended. I can do a SELECT
* ON view_test on the view without issue. However, if I attempt to select
a specific column from the view, such as SELECT ColA FROM view_test, it
returns with the following error message:
#1356 - View 'database.view_test' references invalid table(s) or column(s)
or function(s) or definer/invoker of view lack rights to use them
The account I'm running this on is root and I've re-granted access to
everything in this database, should something have messed up for some
reason. I've looked at the view in the mysql portion of the database and
it seems fine. I can run it without issue. I can do a SELECT ColA FROM
([view_sql_block_from_above]) as a and it works fine as well. It's only
after having been created as a view that it has these issues.
Any help would be greatly appreciated.
Best way to filter a relationship from a twig template
Best way to filter a relationship from a twig template
in my Symfony2 project, I've two entities: Spot and Weather, with a
one-to-many relationship "weatherReports" between the two entities.
Some weather reports are outdated, so I would like do create an
"activeWeatherRecords" method to filter the Weather entities in a Spot
entity.
Unfortunately, I can't see how to do this. The idea is not to fetch
objects from the controller since the Spot objects are favorited, linked
to an User object and accessed directly from a twig template.
So here is the question: What's the best way to filter a relationship
directly from a twig template?
Any idea is welcomed.
Cheers.
Cyril
in my Symfony2 project, I've two entities: Spot and Weather, with a
one-to-many relationship "weatherReports" between the two entities.
Some weather reports are outdated, so I would like do create an
"activeWeatherRecords" method to filter the Weather entities in a Spot
entity.
Unfortunately, I can't see how to do this. The idea is not to fetch
objects from the controller since the Spot objects are favorited, linked
to an User object and accessed directly from a twig template.
So here is the question: What's the best way to filter a relationship
directly from a twig template?
Any idea is welcomed.
Cheers.
Cyril
how to fill different gallons with water? [on hold]
how to fill different gallons with water? [on hold]
I have a problem of algorithm, that is: Write a program to solve the
following problem: You have two jugs: a 4-gallon jug and a 3-gallon jug.
Neither of the jugs have markings on them. There is a pump that can be
used to fill the jugs with water. How can you get exactly two gallons of
water in the 4-gallon jug? I don't know how to solve it. And it has a
generalize version that is: Generalize the problem above so that the
parameters to your solution include the sizes of each jug and the final
amount of water to be left in the larger jug. I don't know how to solve
such a problem, thank you for your help!
I have a problem of algorithm, that is: Write a program to solve the
following problem: You have two jugs: a 4-gallon jug and a 3-gallon jug.
Neither of the jugs have markings on them. There is a pump that can be
used to fill the jugs with water. How can you get exactly two gallons of
water in the 4-gallon jug? I don't know how to solve it. And it has a
generalize version that is: Generalize the problem above so that the
parameters to your solution include the sizes of each jug and the final
amount of water to be left in the larger jug. I don't know how to solve
such a problem, thank you for your help!
Reverse a onClick event
Reverse a onClick event
I've got this:
$(function(){
$('#gallery').click(function(){
$('.overlay').fadeIn(500);
$('#infographic').delay(800).fadeIn(200);
});
});
Now when I click again, I want the above to reverse.
Anyone??
I've got this:
$(function(){
$('#gallery').click(function(){
$('.overlay').fadeIn(500);
$('#infographic').delay(800).fadeIn(200);
});
});
Now when I click again, I want the above to reverse.
Anyone??
accessing volume controls of computer through java
accessing volume controls of computer through java
Is there any API in java to access hardware resources like volume
controls? i want to access volume controls of my laptop using java.i have
tried java media framework to access controls but it is giving only basic
information.
Is there any API in java to access hardware resources like volume
controls? i want to access volume controls of my laptop using java.i have
tried java media framework to access controls but it is giving only basic
information.
Fetch data from data base table in zend framework
Fetch data from data base table in zend framework
I am new to zend frame framework, and in the process of learning. I want
to know that how we can fetch whole data of a table in zend framework and
display it on the screen. I saw lots of tutorials but can't understand the
logic behind this.
If someone can give me small tutorial regarding this that would be very
helpful.
I am using these classes
Model
Application_Model_DbTable_Form extends Zend_Db_Table_Abstract{
protected $_name = 'register';
protected $_primary = 'firstName';
}
class Application_Model_Sign {
private $_dbTable;
public function __construct() {
$this->_dbTable = new Application_Model_DbTable_Form();
}
}
Controller
public function outAction() {
//action body
}
View
<html>
<body>
<table>
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Job Type</th>
</tr>
</table>
</body>
</html>
I am new to zend frame framework, and in the process of learning. I want
to know that how we can fetch whole data of a table in zend framework and
display it on the screen. I saw lots of tutorials but can't understand the
logic behind this.
If someone can give me small tutorial regarding this that would be very
helpful.
I am using these classes
Model
Application_Model_DbTable_Form extends Zend_Db_Table_Abstract{
protected $_name = 'register';
protected $_primary = 'firstName';
}
class Application_Model_Sign {
private $_dbTable;
public function __construct() {
$this->_dbTable = new Application_Model_DbTable_Form();
}
}
Controller
public function outAction() {
//action body
}
View
<html>
<body>
<table>
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Job Type</th>
</tr>
</table>
</body>
</html>
Monday, 9 September 2013
How to make it simpler js with php loop
How to make it simpler js with php loop
function displayResult1(szybkosc)
var n = value = szybkosc;
var u = n.split("|")[1];
document.getElementById('result1').innerText = ' ' + u;
function displayResult2(szybkosc)
var n = value = szybkosc;
var u = n.split("|")[1];
document.getElementById('result2').innerText = ' ' + u;
The js code it works but I'll need to do new function for each result, is
it anyway to make it quicker?
$i = 1;
while ($i
$result = "result" . $i;
$displayResult = "displayResult" . $i;
echo "user number " . $i . "
input type='radio' name='szybkosc'
onclick='$displayResult(this.value)' value='$sp1[id]|1|$row[id]' />
input type='radio' name='szybkosc'
onclick='$displayResult(this.value)' value='$sp1[id]|3|$row[id]' />
input type='radio' name='ss' value='$sp1[id]|1|$row[id]' />
input type='radio' name='ss' onclick='$displayResult(this.value)'
value='$sp1[id]|1|$row[id]' />";
$i++;
}
function displayResult1(szybkosc)
var n = value = szybkosc;
var u = n.split("|")[1];
document.getElementById('result1').innerText = ' ' + u;
function displayResult2(szybkosc)
var n = value = szybkosc;
var u = n.split("|")[1];
document.getElementById('result2').innerText = ' ' + u;
The js code it works but I'll need to do new function for each result, is
it anyway to make it quicker?
$i = 1;
while ($i
$result = "result" . $i;
$displayResult = "displayResult" . $i;
echo "user number " . $i . "
input type='radio' name='szybkosc'
onclick='$displayResult(this.value)' value='$sp1[id]|1|$row[id]' />
input type='radio' name='szybkosc'
onclick='$displayResult(this.value)' value='$sp1[id]|3|$row[id]' />
input type='radio' name='ss' value='$sp1[id]|1|$row[id]' />
input type='radio' name='ss' onclick='$displayResult(this.value)'
value='$sp1[id]|1|$row[id]' />";
$i++;
}
Is there a better way to structure this SQL Query?
Is there a better way to structure this SQL Query?
I have devised an answer to this problem (which I'll post at the end) but
I'm just wondering if there is a 'cleaner' way to structure the query.
The question is as follows:
What is the title and year published of the newest Philip Roth book? You
cannot use the ORDER BY clause. Write a single SQL statement. Use
Sub-queries. Do not assume that you already know the AuthorId for Philip
Roth, the BookId for his latest book or the year the latest book was
released.
The relevant tables from the Database:
Books (BookId, Title, YearPublished)
Authors (AuthorId, FirstName, LastName)
WrittenBy (AuthorId, BookId)
My solution:
SELECT Title, YearPublished
FROM Books NATURAL JOIN Authors NATURAL JOIN WrittenBy
WHERE YearPublished = (SELECT MAX(YearPublished)
FROM Books NATURAL JOIN Authors NATURAL JOIN WrittenBy
WHERE AuthorId = (SELECT AuthorId
FROM Authors
WHERE FirstName = 'Philip'
AND LastName = 'Roth'))
AND FirstName = 'Philip'
AND LastName = 'Roth';
I can't figure out a way to not specify the First and Last names again.
Otherwise it just lists all the books published in the same year as Philip
Roth's latest publication.
This query works perfectly. But, is there a cleaner way to query this?
Thanks :)
(as for which DBMS I am using: These are some review exercises for an
exam. We have to use one created and supplied by the university. It's very
basic SQL. Simpler than Access 2010)
I have devised an answer to this problem (which I'll post at the end) but
I'm just wondering if there is a 'cleaner' way to structure the query.
The question is as follows:
What is the title and year published of the newest Philip Roth book? You
cannot use the ORDER BY clause. Write a single SQL statement. Use
Sub-queries. Do not assume that you already know the AuthorId for Philip
Roth, the BookId for his latest book or the year the latest book was
released.
The relevant tables from the Database:
Books (BookId, Title, YearPublished)
Authors (AuthorId, FirstName, LastName)
WrittenBy (AuthorId, BookId)
My solution:
SELECT Title, YearPublished
FROM Books NATURAL JOIN Authors NATURAL JOIN WrittenBy
WHERE YearPublished = (SELECT MAX(YearPublished)
FROM Books NATURAL JOIN Authors NATURAL JOIN WrittenBy
WHERE AuthorId = (SELECT AuthorId
FROM Authors
WHERE FirstName = 'Philip'
AND LastName = 'Roth'))
AND FirstName = 'Philip'
AND LastName = 'Roth';
I can't figure out a way to not specify the First and Last names again.
Otherwise it just lists all the books published in the same year as Philip
Roth's latest publication.
This query works perfectly. But, is there a cleaner way to query this?
Thanks :)
(as for which DBMS I am using: These are some review exercises for an
exam. We have to use one created and supplied by the university. It's very
basic SQL. Simpler than Access 2010)
Maven compiling with wrong version of android
Maven compiling with wrong version of android
When I run the command mvn clean install on a library project I am using,
I get an error from maven saying that a command could not be run. When I
run the command it gives me a bunch of compiler errors related to the fact
that maven is compiling with android-9 instead of android-17 that is
specified in both the pom.xml and the AndroidManifest.xml
I could really use some direction. Thanks
When I run the command mvn clean install on a library project I am using,
I get an error from maven saying that a command could not be run. When I
run the command it gives me a bunch of compiler errors related to the fact
that maven is compiling with android-9 instead of android-17 that is
specified in both the pom.xml and the AndroidManifest.xml
I could really use some direction. Thanks
CSS: apply formatting to tag contents only
CSS: apply formatting to tag contents only
Normally CSS classes change formatting of tags themselves. For example a
following code
<head>
<style type="text/css">
.r {background-color:green; color:white; font-weight:bold}
</style>
</head>
<body>
<ul>
<li>Item 1</li>
<li class="r">Item 2</li>
<li>Item 3</li>
<li class="r">Item 4</li>
<li>Item 5</li>
</ul>
</body>
makes items with "r" class to appear without a bullet and with
background-color to whole page width.
How to apply formatting not to the tag itself, but to contents only
WITHOUT HAVING TO PUT AN ADDITIONAL TAG INSIDE ?
Normally CSS classes change formatting of tags themselves. For example a
following code
<head>
<style type="text/css">
.r {background-color:green; color:white; font-weight:bold}
</style>
</head>
<body>
<ul>
<li>Item 1</li>
<li class="r">Item 2</li>
<li>Item 3</li>
<li class="r">Item 4</li>
<li>Item 5</li>
</ul>
</body>
makes items with "r" class to appear without a bullet and with
background-color to whole page width.
How to apply formatting not to the tag itself, but to contents only
WITHOUT HAVING TO PUT AN ADDITIONAL TAG INSIDE ?
php script to split download into chunk
php script to split download into chunk
Im writing PHP script for downloading files. I would like to split the
download into chunk lest say 1024 per chunk, can someone give me the code
for that. im storing my files in mysql database.
Here is my download script,
<?php
$company =$_GET['company'];
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
if($id <= 0)
{
die('The ID is invalid!');
}
else
{
$dbLink = new mysqli('localhost', 'sqldata', 'sqldata', 'balhaf');
if(mysqli_connect_errno())
{
die("MySQL connection failed: ". mysqli_connect_error());
}
$query = "SELECT mime, name, size, data FROM $company WHERE id = $id";
$result = $dbLink->query($query);
if($result)
{
if($result->num_rows == 1) {
$row = mysqli_fetch_assoc($result);
$size = $row['size'];
$filename = $row['name'];
$data = $row['data'];
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=".($filename));
header("Content-Length: ".($size));
echo $row['data'];
exit();
}
else
{
echo 'Error! No image exists with that ID.';
}
@mysqli_free_result($result);
}
else
{
echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
}
@mysqli_close($dbLink);
}
}
else
{
echo 'Error! No ID was passed.';
}
?>
Im writing PHP script for downloading files. I would like to split the
download into chunk lest say 1024 per chunk, can someone give me the code
for that. im storing my files in mysql database.
Here is my download script,
<?php
$company =$_GET['company'];
if(isset($_GET['id']))
{
$id = intval($_GET['id']);
if($id <= 0)
{
die('The ID is invalid!');
}
else
{
$dbLink = new mysqli('localhost', 'sqldata', 'sqldata', 'balhaf');
if(mysqli_connect_errno())
{
die("MySQL connection failed: ". mysqli_connect_error());
}
$query = "SELECT mime, name, size, data FROM $company WHERE id = $id";
$result = $dbLink->query($query);
if($result)
{
if($result->num_rows == 1) {
$row = mysqli_fetch_assoc($result);
$size = $row['size'];
$filename = $row['name'];
$data = $row['data'];
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=".($filename));
header("Content-Length: ".($size));
echo $row['data'];
exit();
}
else
{
echo 'Error! No image exists with that ID.';
}
@mysqli_free_result($result);
}
else
{
echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
}
@mysqli_close($dbLink);
}
}
else
{
echo 'Error! No ID was passed.';
}
?>
c# what is the shortest way to verify integer values
c# what is the shortest way to verify integer values
i am reading values from the file and checking the values my code is
while (sr.EndOfStream != null)
{
a= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(a) < 1)
{
Console.WriteLine(a+ " is not a right value");
flag = true;
break;
}
b= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(b) < 1)
{
Console.WriteLine(b+ " is not a right value");
flag = true;
break;
}
....
Is there any other way to make my code look good
i am reading values from the file and checking the values my code is
while (sr.EndOfStream != null)
{
a= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(a) < 1)
{
Console.WriteLine(a+ " is not a right value");
flag = true;
break;
}
b= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(b) < 1)
{
Console.WriteLine(b+ " is not a right value");
flag = true;
break;
}
....
Is there any other way to make my code look good
Database schema creation and AdminServicesTabFieldsSave in WHMCS
Database schema creation and AdminServicesTabFieldsSave in WHMCS
I want to create a WHMCS custom module and need assistance with
template_AdminServicesTabFieldsSave($params) as specified in the sample
code for http://docs.whmcs.com/Creating_Modules.
In my template_AdminServicesTabFields($params) I have the following code:
function template_AdminServicesTabFields($params) {
$fieldsarray = array(
'Debug Mode' => '<input type="checkbox" name="modulefields[0]">',
);
return $fieldsarray;
}
I want to use the template_AdminServicesTabFieldsSave($params) function to
save the status of 'Debug Mode' to a database.
In light of the above function the database save code will look something
like:
function template_AdminServicesTabFieldsSave($params) {
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
}
My problem is I don't know what the schema for mod_customtable should look
like nor how to create a MySQL database field that can store the $_POST
value.
In order to create the database I follow this documentation:
http://docs.whmcs.com/Addon_Module_Developer_Docs (I changed
mod_addonexample to mod_customtable)
function demo_activate() {
# Create Custom DB Table
$query = "CREATE TABLE `mod_customtable` (`id` INT( 1 ) NOT NULL
AUTO_INCREMENT ... ";
$result = mysql_query($query);
...
}
So the specific area of MySQL and WHMCS that I need help with is:
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
What kind of field should I create to store
array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid'])
I need to store:
Value for Debug Mode
The array / params for service ID
I want to create a WHMCS custom module and need assistance with
template_AdminServicesTabFieldsSave($params) as specified in the sample
code for http://docs.whmcs.com/Creating_Modules.
In my template_AdminServicesTabFields($params) I have the following code:
function template_AdminServicesTabFields($params) {
$fieldsarray = array(
'Debug Mode' => '<input type="checkbox" name="modulefields[0]">',
);
return $fieldsarray;
}
I want to use the template_AdminServicesTabFieldsSave($params) function to
save the status of 'Debug Mode' to a database.
In light of the above function the database save code will look something
like:
function template_AdminServicesTabFieldsSave($params) {
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
}
My problem is I don't know what the schema for mod_customtable should look
like nor how to create a MySQL database field that can store the $_POST
value.
In order to create the database I follow this documentation:
http://docs.whmcs.com/Addon_Module_Developer_Docs (I changed
mod_addonexample to mod_customtable)
function demo_activate() {
# Create Custom DB Table
$query = "CREATE TABLE `mod_customtable` (`id` INT( 1 ) NOT NULL
AUTO_INCREMENT ... ";
$result = mysql_query($query);
...
}
So the specific area of MySQL and WHMCS that I need help with is:
update_query("mod_customtable",array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid']));
What kind of field should I create to store
array(
"var1"=>$_POST['modulefields'][0],
),array("serviceid"=>$params['serviceid'])
I need to store:
Value for Debug Mode
The array / params for service ID
Sunday, 8 September 2013
OpenCV: Restore image/frame recorded during fast motion
OpenCV: Restore image/frame recorded during fast motion
Is there any way to restore image which was recorded during fast motion?
By restore I mean to sharpener edges, fix details, etc. I have 10-15sec
long video, so I guess I can use different frames to restore single frame.
Here is an example of such image:
Is there any way to restore image which was recorded during fast motion?
By restore I mean to sharpener edges, fix details, etc. I have 10-15sec
long video, so I guess I can use different frames to restore single frame.
Here is an example of such image:
Not able to insert HTML
Not able to insert HTML
Does anyone see why the $('' line breaks the jQuery below? There's a
jsfiddle here: http://jsfiddle.net/8ZBRP/2/. If you comment out the
$('div') line the code at least compiles and hits the debugger line when
you right-click #box.
$(function() {
$('#box').contextmenu(function(e) {
e.preventDefault();
var document_offset;
debugger;
doc_offset = $(this).offset();
$('<div>').css({width:150px, height:150px});
});
});
Thanks
Does anyone see why the $('' line breaks the jQuery below? There's a
jsfiddle here: http://jsfiddle.net/8ZBRP/2/. If you comment out the
$('div') line the code at least compiles and hits the debugger line when
you right-click #box.
$(function() {
$('#box').contextmenu(function(e) {
e.preventDefault();
var document_offset;
debugger;
doc_offset = $(this).offset();
$('<div>').css({width:150px, height:150px});
});
});
Thanks
Node.js & Express: Serving text files in parts
Node.js & Express: Serving text files in parts
I have a webserver with node.js and express. When I serve a text file that
is big, it takes a lot of time to load into the browser. Imagine a 34 MB
text file being served to the client, he would have to download the 34 MB
only to check for something in the log file.
Is there something I could do about it? Serve it in parts perhaps? Like:
Part 1/10 - Part 10/10
I have a webserver with node.js and express. When I serve a text file that
is big, it takes a lot of time to load into the browser. Imagine a 34 MB
text file being served to the client, he would have to download the 34 MB
only to check for something in the log file.
Is there something I could do about it? Serve it in parts perhaps? Like:
Part 1/10 - Part 10/10
How to fetch assoc array while using mysqli prepare
How to fetch assoc array while using mysqli prepare
To make sure my database is secure I'm using prepare statements. Here is
my code:
//connecting to MySql database
$con=mysqli_connect("host","user","pass","dbname");
// checking database connection
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$stmt = mysqli_prepare($con,"SELECT * FROM `table` WHERE emb=? LIMIT 1");
mysqli_stmt_bind_param($stmt, 's', $emb);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
Now I want to know how can I use ASSOC fetch array
$embInfo = mysqli_fetch_array($stmt, MYSQLI_ASSOC);
I want this so that I can just put something like below to get values
$embInfo['name']
and
$embInfo['email']
To make sure my database is secure I'm using prepare statements. Here is
my code:
//connecting to MySql database
$con=mysqli_connect("host","user","pass","dbname");
// checking database connection
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$stmt = mysqli_prepare($con,"SELECT * FROM `table` WHERE emb=? LIMIT 1");
mysqli_stmt_bind_param($stmt, 's', $emb);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
Now I want to know how can I use ASSOC fetch array
$embInfo = mysqli_fetch_array($stmt, MYSQLI_ASSOC);
I want this so that I can just put something like below to get values
$embInfo['name']
and
$embInfo['email']
How to use cURL to save html files from array?
How to use cURL to save html files from array?
I'm trying save some files using cURL. I have managed to achieve this for
a single url, but when I'm creating an array to keep multiple url's in it,
then it is not working. I'm not getting any errors either even after
turning on error reporting. The files are simply not being saved. My code
in given below. Any help is much appreciated.
<?php
error_reporting(E_ALL);
$var = "http://www.example.com/trailer/";
$urls = array("1423/10_Things_I_Hate_About_You/","1470/10.5__Apocalypse/");
$ch = curl_init();
foreach ($urls as $i => $url) {
$conn[$i]=curl_init($url);
curl_setopt($conn[$i], CURLOPT_URL, $url .$var);
curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($conn[$i], CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$out = curl_exec($conn[$i]);
// close cURL resource, and free up system resources
curl_close($conn[$i]);
$fp = fopen($url . "index.html", 'w');
fwrite($fp, $out);
fclose($fp);
}
I'm trying save some files using cURL. I have managed to achieve this for
a single url, but when I'm creating an array to keep multiple url's in it,
then it is not working. I'm not getting any errors either even after
turning on error reporting. The files are simply not being saved. My code
in given below. Any help is much appreciated.
<?php
error_reporting(E_ALL);
$var = "http://www.example.com/trailer/";
$urls = array("1423/10_Things_I_Hate_About_You/","1470/10.5__Apocalypse/");
$ch = curl_init();
foreach ($urls as $i => $url) {
$conn[$i]=curl_init($url);
curl_setopt($conn[$i], CURLOPT_URL, $url .$var);
curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1);
curl_setopt($conn[$i], CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$out = curl_exec($conn[$i]);
// close cURL resource, and free up system resources
curl_close($conn[$i]);
$fp = fopen($url . "index.html", 'w');
fwrite($fp, $out);
fclose($fp);
}
unclear #define syntax in cpp using `\` sign
unclear #define syntax in cpp using `\` sign
#define is_module_error(_module_,_error_) \
((_module_##_errors<_error_)&&(_error_<_module_##_errors_end))
#define is_general_error(_error_) is_module_error(general,_error_)
#define is_network_error(_error_) is_module_error(network,_error_)
can someone please explain to me what does the first define means?
how is is evaluated?
I don't understand what's the \ sign mean here?
#define is_module_error(_module_,_error_) \
((_module_##_errors<_error_)&&(_error_<_module_##_errors_end))
#define is_general_error(_error_) is_module_error(general,_error_)
#define is_network_error(_error_) is_module_error(network,_error_)
can someone please explain to me what does the first define means?
how is is evaluated?
I don't understand what's the \ sign mean here?
call text box textchanged event automatically in asp.net
call text box textchanged event automatically in asp.net
I have a form from where I am navigating to a form of mine where I have a
text box for quantity. Previously I was entering the quantity. Now, IO
have a work flow that is the reason the other form comes in picture. Now,
I have extensive coding done my text box text changed event. When I do
response.redirect form other form, I flow quantity also and put that
quantity in that text box. Now i dont want to write a new code(function)
for doing the same as updation procedure will also be done. Following is
my code which I am trying to execute and call the text changed event. I am
also using update panel. So, is that the reason why my event is not
getting fired.? Any solution on that,.??
txt_Quantity.TextChanged += new EventHandler(txt_Quantity_TextChanged);
protected void txt_Quantity_TextChanged(object sender, EventArgs e)
{
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlGrid" runat="server" BorderColor="#339933"
Height="400px" BorderStyle="Solid"
BorderWidth="2px" ScrollBars="Auto" Width="100%">
<div style="height: 40px; width: 100%; background-color:
#339933;">
<%-- <img alt="imgrid"
src="Images/grid_icon_green.png" style="padding-left:
10px;" />--%>
<span style="font-size: 20px; font-family: Calibri;
color: White; padding-left: 5px; vertical-align:
top">Asset Distribution</span>
</div>
<AjaxToolKit:TabContainer ID="TabContainer1"
runat="server" Height="400px">
<AjaxToolKit:TabPanel ID="tab1" runat="server"
TabIndex="0" HeaderText="Basic Information">
<ContentTemplate>
<table width="100%">
<tr>
<td class="r1">Last Code:
</td>
<td>
<asp:Label
ID="Lbl_AssetDistriCode"
runat="server"></asp:Label>
</td>
<td width="10%" class="r1">Item Code:
</td>
<td width="23%">
<asp:TextBox ID="txt_ItemCode"
runat="server" Height="95%"
Width="150px" CssClass="txtbxcomp"
AutoPostBack="true"
OnTextChanged="txt_ItemCode_TextChanged"></asp:TextBox>
<%-- <span style="color:
Red;">*</span>--%>
<AjaxToolKit:AutoCompleteExtender
ID="AutoCompleteExtender4"
runat="server"
ServiceMethod="getitem"
ServicePath="WebService.asmx"
TargetControlID="txt_ItemCode"
CompletionInterval="500"
MinimumPrefixLength="1"
EnableCaching="true"
CompletionSetCount="5">
</AjaxToolKit:AutoCompleteExtender>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<tr>
<td class="r1" width="10%">Item Group:
</td>
<td width="23%">
<asp:DropDownList
ID="ddl_Item_Grp" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_Grp_SelectedIndexChanged">
</asp:DropDownList>
<%-- <span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Item Type:
</td>
<td width="23%">
<asp:DropDownList
ID="ddl_Item_typ" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_typ_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="14%">Item Catagory:
</td>
<td width="20%">
<asp:DropDownList
ID="ddl_Item_cat" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"></asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">City:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_city"
runat="server" Height="95%"
Width="150px" CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_city_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Location:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Loc"
runat="server" Height="95%"
Width="150px" CssClass="drp"
>
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Branch:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_Branch"
runat="server" Height="95%"
Width="150px" CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Branch_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">Department:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Dept"
runat="server" Height="95%"
Width="150px" CssClass="txtbx"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Dept_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">User:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_User"
runat="server" Height="95%"
width="150px" CssClass="txtbx"
AutoPostBack="True"></asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<%--<td class="r1" width="15%">Asset
Code:
</td>
<td width="19%">
<asp:DropDownList
ID="ddl_Asset_code" runat="server"
Height="95%" CssClass="txtbx"
AutoPostBack="True"></asp:DropDownList>
<span style="color: Red;">*</span>
</td>--%>
<td class="r1" width="10%">Quantity:
</td>
<td width="23%">
<asp:TextBox ID="txt_Quantity"
runat="server" Height="95%"
Width="150px"
CssClass="txtbxcomp"
AutoPostBack="true"
OnTextChanged="txt_Quantity_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender
ID="FilteredTextBoxExtender3"
runat="server"
TargetControlID="txt_Quantity"
ValidChars="0123456789."
Enabled="True">
</cc1:FilteredTextBoxExtender>
<%-- <span style="color:
Red;">*</span>--%>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<%--<tr>
<td width="15%" class="r1">Mac ID:
</td>
<td width="18%">
<asp:TextBox ID="txt_MacId"
runat="server" Height="95%"
CssClass="txtbx"></asp:TextBox>
<span style="color: Red;">*</span>
</td>
<td width="15%"></td>
<td width="18%"></td>
<td width="15%"></td>
<td width="19%"></td>
</tr>--%>
</table>
</ContentTemplate>
</AjaxToolKit:TabPanel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
<asp:PostBackTrigger ControlID="btnUpdate" />
<asp:PostBackTrigger ControlID="btndelete" />
<asp:PostBackTrigger ControlID="btnClear" />
</Triggers>
</asp:UpdatePanel>
Thanks in advance.
I have a form from where I am navigating to a form of mine where I have a
text box for quantity. Previously I was entering the quantity. Now, IO
have a work flow that is the reason the other form comes in picture. Now,
I have extensive coding done my text box text changed event. When I do
response.redirect form other form, I flow quantity also and put that
quantity in that text box. Now i dont want to write a new code(function)
for doing the same as updation procedure will also be done. Following is
my code which I am trying to execute and call the text changed event. I am
also using update panel. So, is that the reason why my event is not
getting fired.? Any solution on that,.??
txt_Quantity.TextChanged += new EventHandler(txt_Quantity_TextChanged);
protected void txt_Quantity_TextChanged(object sender, EventArgs e)
{
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlGrid" runat="server" BorderColor="#339933"
Height="400px" BorderStyle="Solid"
BorderWidth="2px" ScrollBars="Auto" Width="100%">
<div style="height: 40px; width: 100%; background-color:
#339933;">
<%-- <img alt="imgrid"
src="Images/grid_icon_green.png" style="padding-left:
10px;" />--%>
<span style="font-size: 20px; font-family: Calibri;
color: White; padding-left: 5px; vertical-align:
top">Asset Distribution</span>
</div>
<AjaxToolKit:TabContainer ID="TabContainer1"
runat="server" Height="400px">
<AjaxToolKit:TabPanel ID="tab1" runat="server"
TabIndex="0" HeaderText="Basic Information">
<ContentTemplate>
<table width="100%">
<tr>
<td class="r1">Last Code:
</td>
<td>
<asp:Label
ID="Lbl_AssetDistriCode"
runat="server"></asp:Label>
</td>
<td width="10%" class="r1">Item Code:
</td>
<td width="23%">
<asp:TextBox ID="txt_ItemCode"
runat="server" Height="95%"
Width="150px" CssClass="txtbxcomp"
AutoPostBack="true"
OnTextChanged="txt_ItemCode_TextChanged"></asp:TextBox>
<%-- <span style="color:
Red;">*</span>--%>
<AjaxToolKit:AutoCompleteExtender
ID="AutoCompleteExtender4"
runat="server"
ServiceMethod="getitem"
ServicePath="WebService.asmx"
TargetControlID="txt_ItemCode"
CompletionInterval="500"
MinimumPrefixLength="1"
EnableCaching="true"
CompletionSetCount="5">
</AjaxToolKit:AutoCompleteExtender>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<tr>
<td class="r1" width="10%">Item Group:
</td>
<td width="23%">
<asp:DropDownList
ID="ddl_Item_Grp" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_Grp_SelectedIndexChanged">
</asp:DropDownList>
<%-- <span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Item Type:
</td>
<td width="23%">
<asp:DropDownList
ID="ddl_Item_typ" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_typ_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="14%">Item Catagory:
</td>
<td width="20%">
<asp:DropDownList
ID="ddl_Item_cat" runat="server"
Height="95%" Width="150px"
CssClass="drpComp"></asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">City:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_city"
runat="server" Height="95%"
Width="150px" CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_city_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Location:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Loc"
runat="server" Height="95%"
Width="150px" CssClass="drp"
>
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">Branch:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_Branch"
runat="server" Height="95%"
Width="150px" CssClass="drpComp"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Branch_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">Department:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Dept"
runat="server" Height="95%"
Width="150px" CssClass="txtbx"
AutoPostBack="True"
OnSelectedIndexChanged="ddl_Dept_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<td class="r1" width="10%">User:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_User"
runat="server" Height="95%"
width="150px" CssClass="txtbx"
AutoPostBack="True"></asp:DropDownList>
<%--<span style="color:
Red;">*</span>--%>
</td>
<%--<td class="r1" width="15%">Asset
Code:
</td>
<td width="19%">
<asp:DropDownList
ID="ddl_Asset_code" runat="server"
Height="95%" CssClass="txtbx"
AutoPostBack="True"></asp:DropDownList>
<span style="color: Red;">*</span>
</td>--%>
<td class="r1" width="10%">Quantity:
</td>
<td width="23%">
<asp:TextBox ID="txt_Quantity"
runat="server" Height="95%"
Width="150px"
CssClass="txtbxcomp"
AutoPostBack="true"
OnTextChanged="txt_Quantity_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender
ID="FilteredTextBoxExtender3"
runat="server"
TargetControlID="txt_Quantity"
ValidChars="0123456789."
Enabled="True">
</cc1:FilteredTextBoxExtender>
<%-- <span style="color:
Red;">*</span>--%>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<%--<tr>
<td width="15%" class="r1">Mac ID:
</td>
<td width="18%">
<asp:TextBox ID="txt_MacId"
runat="server" Height="95%"
CssClass="txtbx"></asp:TextBox>
<span style="color: Red;">*</span>
</td>
<td width="15%"></td>
<td width="18%"></td>
<td width="15%"></td>
<td width="19%"></td>
</tr>--%>
</table>
</ContentTemplate>
</AjaxToolKit:TabPanel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
<asp:PostBackTrigger ControlID="btnUpdate" />
<asp:PostBackTrigger ControlID="btndelete" />
<asp:PostBackTrigger ControlID="btnClear" />
</Triggers>
</asp:UpdatePanel>
Thanks in advance.
Subscribe to:
Comments (Atom)