MySQL group by affecting other group
I've got a SUM(value) which calculates the votes for each idea, but this
gets affected by the amount of tags each idea can have.
For example,
SELECT
id,
title,
description,
COALESCE(SUM(case when value > 0 then value end),0) votes_up,
COALESCE(SUM(case when value < 0 then value end),0) votes_down,
GROUP_CONCAT(DISTINCT tags.name) AS 'tags',
FROM ideas
LEFT JOIN votes ON ideas.id = votes.idea_id
LEFT JOIN tags_rel ON ideas.id = tags_rel.idea_id
LEFT JOIN tags ON tags_rel.tag_id = tags.id
GROUP BY ideas.id
So if there are more than one tags.name, then the SUM() get multiplied by
the number of tags.name
How can I fix this?
Saturday, 31 August 2013
how to design the database for the follwing scenario?
how to design the database for the follwing scenario?
I'm working on a regression test project. Let's say the model is like: R =
f(C). C is the collection of test cases with the size is about 2000, and R
is the result of all test cases. It will produce about 2000000 records to
insert into the db on every daily run. We'll keep a baseline for the R,
and baseline is initialized as the R of the first daily run. After each
daily run, we'll compare the result with the baseline(we call the
difference between the daily run result with the baseline as Regression
Issue). If there are differences, we'll investigate it and update some
records of the baseline or file a bug if necessary. baselinetable:
(casename, resultid) is primary key. buildnumber casename resultid result
1 case1 0 abc 1 case1 1 def 1 case2 0 ijk resulttable's schema is the same
as baselinetable except: (buildnumber, casename, resultid) is the primary
key. buildnumber casename resultid result 1 case1 0 abc 1 case1 1 def 1
case2 0 ijk 2 case1 0 abc 2 case1 1 fff 2 case2 0 ijk The problem is that:
the db grows too fast (2000000 records per day). So I tried the following
2 solution: solution A: Only keep those records which are different with
current baseline. resulttable: (buildnumber, casename, resultid) is the
primary key. buildnumber casename resultid result baseline_buildnumber 1
case1 0 abc 1 1 case1 1 def 1 1 case2 0 ijk 1 2 case1 1 fff 1 Because the
baseline could be updated, so I add column 'baseline_buildnumber' to mark
which baseline is based on. And accordingly, we need keep multiple version
of baseline be add the buildnumber as primary key: baselinetable:
(buildnumber, casename, resultid) is primary key. buildnumber casename
resultid result 1 case1 0 abc 1 case1 1 def 2 case1 1 fff 1 case2 0 ijk
This solution can remarkably reduce the size of db. But it's complicate:
First, when insert the daily run results, we need to compare the result
with the latest baseline(eg. the 1st,3rd,4th row of the baselinetable
above). Second, if we don't investigate and update the baseline before the
next daily run. It will comes into the following situation: The latest
baseline build is Num1, and the result of build Num2 and build Num3 both
are based on baseline Num1. It's simple to get the Regression Issue of
build Num2. Because the diff result is based on baseline Num1 and Num1 is
also the latest baseline build, so all the diff results of build Num2 are
Regression Issue. But if we update the baseline to build Num2, then we
want to get the Regression Issue of build Num3. We need to compare the
diff result of build Num3 with the baseline Num2, and also need to fetch
the diff between baseline Num1 and baseline Num2, because the
baseline_buildnumber is Num1(which is not the latest baseline build) when
we insert the diff result of build Num3.
Do you guys have any better idea? Thanks very much!
I'm working on a regression test project. Let's say the model is like: R =
f(C). C is the collection of test cases with the size is about 2000, and R
is the result of all test cases. It will produce about 2000000 records to
insert into the db on every daily run. We'll keep a baseline for the R,
and baseline is initialized as the R of the first daily run. After each
daily run, we'll compare the result with the baseline(we call the
difference between the daily run result with the baseline as Regression
Issue). If there are differences, we'll investigate it and update some
records of the baseline or file a bug if necessary. baselinetable:
(casename, resultid) is primary key. buildnumber casename resultid result
1 case1 0 abc 1 case1 1 def 1 case2 0 ijk resulttable's schema is the same
as baselinetable except: (buildnumber, casename, resultid) is the primary
key. buildnumber casename resultid result 1 case1 0 abc 1 case1 1 def 1
case2 0 ijk 2 case1 0 abc 2 case1 1 fff 2 case2 0 ijk The problem is that:
the db grows too fast (2000000 records per day). So I tried the following
2 solution: solution A: Only keep those records which are different with
current baseline. resulttable: (buildnumber, casename, resultid) is the
primary key. buildnumber casename resultid result baseline_buildnumber 1
case1 0 abc 1 1 case1 1 def 1 1 case2 0 ijk 1 2 case1 1 fff 1 Because the
baseline could be updated, so I add column 'baseline_buildnumber' to mark
which baseline is based on. And accordingly, we need keep multiple version
of baseline be add the buildnumber as primary key: baselinetable:
(buildnumber, casename, resultid) is primary key. buildnumber casename
resultid result 1 case1 0 abc 1 case1 1 def 2 case1 1 fff 1 case2 0 ijk
This solution can remarkably reduce the size of db. But it's complicate:
First, when insert the daily run results, we need to compare the result
with the latest baseline(eg. the 1st,3rd,4th row of the baselinetable
above). Second, if we don't investigate and update the baseline before the
next daily run. It will comes into the following situation: The latest
baseline build is Num1, and the result of build Num2 and build Num3 both
are based on baseline Num1. It's simple to get the Regression Issue of
build Num2. Because the diff result is based on baseline Num1 and Num1 is
also the latest baseline build, so all the diff results of build Num2 are
Regression Issue. But if we update the baseline to build Num2, then we
want to get the Regression Issue of build Num3. We need to compare the
diff result of build Num3 with the baseline Num2, and also need to fetch
the diff between baseline Num1 and baseline Num2, because the
baseline_buildnumber is Num1(which is not the latest baseline build) when
we insert the diff result of build Num3.
Do you guys have any better idea? Thanks very much!
Convert word into specific Part Of Speech (POS) format?
Convert word into specific Part Of Speech (POS) format?
Given a word, is it possible, using NLTK, to convert that word into a
specific Part Of Speech (POS) form? For example, given the word "run", can
I ask NLTK to convert it to any of the following:
VBZ: runs, as in "George runs to the store."
VBD: ran, as in "George ran to the store."
VB: run, as in "George wants to run."
Etc. If yes, same for nouns? e.g.:
NN: run, as in "George wants to run."
NNS: runs, as in "George went for two runs."
NNP: Run, as in "George had dinner at Run."
Given a word, is it possible, using NLTK, to convert that word into a
specific Part Of Speech (POS) form? For example, given the word "run", can
I ask NLTK to convert it to any of the following:
VBZ: runs, as in "George runs to the store."
VBD: ran, as in "George ran to the store."
VB: run, as in "George wants to run."
Etc. If yes, same for nouns? e.g.:
NN: run, as in "George wants to run."
NNS: runs, as in "George went for two runs."
NNP: Run, as in "George had dinner at Run."
Android R file not building when declare-styleable of type enum is added
Android R file not building when declare-styleable of type enum is added
Recently my Android workspace isn't compiling correctly anymore (the R
file isn't created). After trying the usual like cleaning i started
searching deeper. I discovered that when i comment out the items int my
attrs.xml file of the type declare-styleable with the format="enum" the R
file is build but not when they are present (not commented out). Is there
a recent change or something with the way you have the declare enums or
something? Here a piece of the project
working
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<!-- <attr name="swipeMode" format="enum"> -->
<!-- <enum name="none" value="0" /> -->
<!-- <enum name="both" value="1" /> -->
<!-- <enum name="right" value="2" /> -->
<!-- <enum name="left" value="3" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionLeft" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionRight" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeDrawableChecked" format="reference" /> -->
<!-- <attr name="swipeDrawableUnchecked" format="reference" /> -->
</declare-styleable>
</resources>
not working
<?xml version="1.0" encoding="utf-8"?>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<attr name="swipeMode" format="enum">
<enum name="none" value="0" />
<enum name="both" value="1" />
<enum name="right" value="2" />
<enum name="left" value="3" />
</attr>
<attr name="swipeActionLeft" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeActionRight" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeDrawableChecked" format="reference" />
<attr name="swipeDrawableUnchecked" format="reference" />
</declare-styleable>
Recently my Android workspace isn't compiling correctly anymore (the R
file isn't created). After trying the usual like cleaning i started
searching deeper. I discovered that when i comment out the items int my
attrs.xml file of the type declare-styleable with the format="enum" the R
file is build but not when they are present (not commented out). Is there
a recent change or something with the way you have the declare enums or
something? Here a piece of the project
working
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<!-- <attr name="swipeMode" format="enum"> -->
<!-- <enum name="none" value="0" /> -->
<!-- <enum name="both" value="1" /> -->
<!-- <enum name="right" value="2" /> -->
<!-- <enum name="left" value="3" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionLeft" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeActionRight" format="enum"> -->
<!-- <enum name="reveal" value="0" /> -->
<!-- <enum name="dismiss" value="1" /> -->
<!-- <enum name="choice" value="2" /> -->
<!-- </attr> -->
<!-- <attr name="swipeDrawableChecked" format="reference" /> -->
<!-- <attr name="swipeDrawableUnchecked" format="reference" /> -->
</declare-styleable>
</resources>
not working
<?xml version="1.0" encoding="utf-8"?>
<declare-styleable name="SwipeListView">
<attr name="swipeOpenOnLongPress" format="boolean" />
<attr name="swipeAnimationTime" format="integer" />
<attr name="swipeOffsetLeft" format="dimension" />
<attr name="swipeOffsetRight" format="dimension" />
<attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
<attr name="swipeFrontView" format="reference" />
<attr name="swipeBackView" format="reference" />
<attr name="swipeMode" format="enum">
<enum name="none" value="0" />
<enum name="both" value="1" />
<enum name="right" value="2" />
<enum name="left" value="3" />
</attr>
<attr name="swipeActionLeft" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeActionRight" format="enum">
<enum name="reveal" value="0" />
<enum name="dismiss" value="1" />
<enum name="choice" value="2" />
</attr>
<attr name="swipeDrawableChecked" format="reference" />
<attr name="swipeDrawableUnchecked" format="reference" />
</declare-styleable>
echo back array variables to html form when submitting
echo back array variables to html form when submitting
After alot of digging around some very informative posts and info to try
and find out how to solve this issue I thought I would ask around to see
if anyone has any pointers. I have an html form with various inputs
(checkboxes, text boxes etc...). Each input section has its own submit or
'Upload' button. On Upload a php script is called and various bits of
processing is done before data is sent over a pipe to a Python script for
further stuff. I am currently echoing back input variables to the form on
submission so that the html page does not refresh (or should I say the
inputted data is not lost to the users view) on an Upload event, however,
I now have to do the same for a bunch of checkboxes and text boxes the
values of which are stored in an array. The code I have written so far is
as follows (I am new to both php and html so please excuse the
inefficiency that I'm sure is obvious)
html/php
<margin>CH1</margin><input type="checkbox"name="ANout[]"value="AN1_OUT"
<?php if(in_array('AN1_OUT',$_POST['ANout']))echo'checked';?>>
Voltage<input type="text"size="5"name="ANout[]"
value="<?php $ANout[$i]=$_POST['ANout'];
if(!empty($ANout[$i]))echo"$ANout[$i]";?>">
<br>
The code above works fine for the checkboxes which happily remain after an
Upload button is pressed but not for the array. When the Upload event
occurs I simply get 'Array' written in the text box. I have tried existing
code I have written to echo back other text input in the form (see below)
and which works but these are for sole entries, not arrays. I have tried
various configurations of syntax but I always seem to get the same result.
Working Code:
<margin>Duty Cyle</margin><input type="text"name="PWM1DC"size="3"
value="<?php $PWM1DC = $_POST['PWM1DC'];
if(!empty($PWM1DC))echo "PWM1DC";?>">
<br>
Any clues would be appreciated.
After alot of digging around some very informative posts and info to try
and find out how to solve this issue I thought I would ask around to see
if anyone has any pointers. I have an html form with various inputs
(checkboxes, text boxes etc...). Each input section has its own submit or
'Upload' button. On Upload a php script is called and various bits of
processing is done before data is sent over a pipe to a Python script for
further stuff. I am currently echoing back input variables to the form on
submission so that the html page does not refresh (or should I say the
inputted data is not lost to the users view) on an Upload event, however,
I now have to do the same for a bunch of checkboxes and text boxes the
values of which are stored in an array. The code I have written so far is
as follows (I am new to both php and html so please excuse the
inefficiency that I'm sure is obvious)
html/php
<margin>CH1</margin><input type="checkbox"name="ANout[]"value="AN1_OUT"
<?php if(in_array('AN1_OUT',$_POST['ANout']))echo'checked';?>>
Voltage<input type="text"size="5"name="ANout[]"
value="<?php $ANout[$i]=$_POST['ANout'];
if(!empty($ANout[$i]))echo"$ANout[$i]";?>">
<br>
The code above works fine for the checkboxes which happily remain after an
Upload button is pressed but not for the array. When the Upload event
occurs I simply get 'Array' written in the text box. I have tried existing
code I have written to echo back other text input in the form (see below)
and which works but these are for sole entries, not arrays. I have tried
various configurations of syntax but I always seem to get the same result.
Working Code:
<margin>Duty Cyle</margin><input type="text"name="PWM1DC"size="3"
value="<?php $PWM1DC = $_POST['PWM1DC'];
if(!empty($PWM1DC))echo "PWM1DC";?>">
<br>
Any clues would be appreciated.
Splash screen android phonegap timming
Splash screen android phonegap timming
I found in this answer this code:
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);
And it works, but like this, result is:
Splash screen for 5 seconds
Black screen untill the app is ready
index.html when app is ready
So I was wondering if there is any chance of running this
super.loadUrl("file:///android_asset/www/index.html");
As a callback of some ready function, is there a way?
I found in this answer this code:
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);
And it works, but like this, result is:
Splash screen for 5 seconds
Black screen untill the app is ready
index.html when app is ready
So I was wondering if there is any chance of running this
super.loadUrl("file:///android_asset/www/index.html");
As a callback of some ready function, is there a way?
Friday, 30 August 2013
PHP Javabridge: Call to undefined function java_import() when import a class
PHP Javabridge: Call to undefined function java_import() when import a class
help me please.
success to execute
include 'Java.inc';
echo java("java.lang.System")->getProperties();
but, get error when trying import a class:
include 'Java.inc';
var_dump(java_import("java.lang.Integer", NULL, FALSE));
Fatal error: Call to undefined function java_import() in
D:\www\test\javabridge\test_import_class.php on line 3
help me please.
success to execute
include 'Java.inc';
echo java("java.lang.System")->getProperties();
but, get error when trying import a class:
include 'Java.inc';
var_dump(java_import("java.lang.Integer", NULL, FALSE));
Fatal error: Call to undefined function java_import() in
D:\www\test\javabridge\test_import_class.php on line 3
Thursday, 29 August 2013
Encrypting a document with multiple keys
Encrypting a document with multiple keys
Hypothetical here. Let's say you are Manning and have the goods. You
publish the "security file" on Bittorrent and send the keys to a few
trusted journalists in case you get shot, while you work on the redacted
version. Since the journalists know that there are others, and because
journalists are people who can be influenced... you want to avoid a
situation where one journalist releases the key and blames it on you or
another journalist.
So, is it possible to have multiple keys able to decrypt a file, and if a
key is published, be able to attribute that key to a specific person?
Hypothetical here. Let's say you are Manning and have the goods. You
publish the "security file" on Bittorrent and send the keys to a few
trusted journalists in case you get shot, while you work on the redacted
version. Since the journalists know that there are others, and because
journalists are people who can be influenced... you want to avoid a
situation where one journalist releases the key and blames it on you or
another journalist.
So, is it possible to have multiple keys able to decrypt a file, and if a
key is published, be able to attribute that key to a specific person?
Coding events from Qt Creator
Coding events from Qt Creator
I've just started working with Qt Creator and have a question. How do I
code up an event? For example, I have a for called myprogramui.ui which I
used pyuic4 to generate myprogramui.py. In my myprogramui.ui file I have a
menu item that, when clicked, I would like to load another form called
mysettingsui.ui. But I can't figure out WHERE to put the code! Can anyone
clue me in?
Thanks!
I've just started working with Qt Creator and have a question. How do I
code up an event? For example, I have a for called myprogramui.ui which I
used pyuic4 to generate myprogramui.py. In my myprogramui.ui file I have a
menu item that, when clicked, I would like to load another form called
mysettingsui.ui. But I can't figure out WHERE to put the code! Can anyone
clue me in?
Thanks!
Extract links from mysql and make it clickable?
Extract links from mysql and make it clickable?
I have a database table that stores URL.What I need is grab those URL's
from table and make it click-able with the URL's title as anchor.
This is what I have tried:
while($row4 = mysql_fetch_assoc($result4))
{
echo "<a href =\"$row4[Url1]\">".$row4['Title1']. "</a>";
}
It displays for example my tilte1 that is youtube and Url1 is
www.youtube.com.
But when I click on it it is going to localhost/mysite/www.youtube.com
How can I fix this?
I have a database table that stores URL.What I need is grab those URL's
from table and make it click-able with the URL's title as anchor.
This is what I have tried:
while($row4 = mysql_fetch_assoc($result4))
{
echo "<a href =\"$row4[Url1]\">".$row4['Title1']. "</a>";
}
It displays for example my tilte1 that is youtube and Url1 is
www.youtube.com.
But when I click on it it is going to localhost/mysite/www.youtube.com
How can I fix this?
Wednesday, 28 August 2013
Inheritance and nested views in AngularJS
Inheritance and nested views in AngularJS
I'm trying to set up some nested views in angularjs. I've been using the
ui-router library to do this which works great for the most part. The
problem is that there is a separate controller for each view with no real
inheritance going on between them. If I want to modify something in a
parent controller from a child controller I have to use $scope.$parent .
This is a bit of a pain and it can become worse if there are multiple
levels of inheritance and you have to remember which level the variable
you are accessing is on. Also if you forget to use $parent in your child
controller and you try to modify one of the parent's variables, Angular
will create a new instance of the variable which could lead to some hard
to track down bugs.
Ideally I would just be able to use prototype inheritance. This would also
map nicely into classes in Typescript or Coffeescript. One way I thought
of to do this would be to get rid of all the parent controllers and just
have the child controllers which would inherit any common functionality
from prototypes (super classes). Then you would just have to throw the
controller up on the $rootScope so that the parent views could access it.
Can anyone think of any issues with this solution or better solutions?
Would I be better off just using $parent and letting Angular handel the
"inheritance".
Thanks
I'm trying to set up some nested views in angularjs. I've been using the
ui-router library to do this which works great for the most part. The
problem is that there is a separate controller for each view with no real
inheritance going on between them. If I want to modify something in a
parent controller from a child controller I have to use $scope.$parent .
This is a bit of a pain and it can become worse if there are multiple
levels of inheritance and you have to remember which level the variable
you are accessing is on. Also if you forget to use $parent in your child
controller and you try to modify one of the parent's variables, Angular
will create a new instance of the variable which could lead to some hard
to track down bugs.
Ideally I would just be able to use prototype inheritance. This would also
map nicely into classes in Typescript or Coffeescript. One way I thought
of to do this would be to get rid of all the parent controllers and just
have the child controllers which would inherit any common functionality
from prototypes (super classes). Then you would just have to throw the
controller up on the $rootScope so that the parent views could access it.
Can anyone think of any issues with this solution or better solutions?
Would I be better off just using $parent and letting Angular handel the
"inheritance".
Thanks
How to control microphone volume in Sony Wireless Stereo Headset?
How to control microphone volume in Sony Wireless Stereo Headset?
I have a Sony Wireless Stereo Headset.
There isn't any option to lower the microphone volume in Windows controls.
And in Skype I can't change the microphone volume
Is there some software I have to install, or configure something?
How can I control my microphone volume?
I have a Sony Wireless Stereo Headset.
There isn't any option to lower the microphone volume in Windows controls.
And in Skype I can't change the microphone volume
Is there some software I have to install, or configure something?
How can I control my microphone volume?
media query and not
media query and not
I have the following less code:
@mobile: ~'screen and (max-width: 480px)';
Then I use it as follows:
@media @mobile {
// some code
}
It works fine but I would like to also use "not" like:
@media not @mobile {
// some code
}
But I get the error "ParseError: Unrecognised input" in the "not" part.
Is it possible to solve this?
Thank You, Miguel
I have the following less code:
@mobile: ~'screen and (max-width: 480px)';
Then I use it as follows:
@media @mobile {
// some code
}
It works fine but I would like to also use "not" like:
@media not @mobile {
// some code
}
But I get the error "ParseError: Unrecognised input" in the "not" part.
Is it possible to solve this?
Thank You, Miguel
iOS (Objective C) I need these three stock options to be class level variables, so they are only declared and initialised once
iOS (Objective C) I need these three stock options to be class level
variables, so they are only declared and initialised once
I need the three stock options below to be declared and initialise only
once. I have got some pseudo code for it but unsure on how to make it
work.
This is declared in the M file of the iOS app and nothing is in the H file .
pseudo code for the below...
// _msftStockPrice _googStockPrice _applStockPrice need to be
class level
if(_msftStrockPrice == nil)
_googStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if(_appleStrockPrice == nil)
_msftStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if(_msftStrockPrice == nil)
_msftStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if ([plot.identifier isEqual:CPDTickerSymbolAAPL] == YES) {
return [_appleStockPrice objectAtIndex:index];
} else if ([plot.identifier isEqual:CPDTickerSymbolGOOG] == YES) {
return [[_googStockPrice objectAtIndex:index];
} else if ([plot.identifier isEqual:CPDTickerSymbolMSFT] == YES) {
return [_msftStockPrice objectAtIndex:index];
*/
variables, so they are only declared and initialised once
I need the three stock options below to be declared and initialise only
once. I have got some pseudo code for it but unsure on how to make it
work.
This is declared in the M file of the iOS app and nothing is in the H file .
pseudo code for the below...
// _msftStockPrice _googStockPrice _applStockPrice need to be
class level
if(_msftStrockPrice == nil)
_googStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if(_appleStrockPrice == nil)
_msftStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if(_msftStrockPrice == nil)
_msftStockPrice = [[[CPDStockPriceStore sharedInstance]
monthlyPrices:CPDTickerSymbolMSFT]
if ([plot.identifier isEqual:CPDTickerSymbolAAPL] == YES) {
return [_appleStockPrice objectAtIndex:index];
} else if ([plot.identifier isEqual:CPDTickerSymbolGOOG] == YES) {
return [[_googStockPrice objectAtIndex:index];
} else if ([plot.identifier isEqual:CPDTickerSymbolMSFT] == YES) {
return [_msftStockPrice objectAtIndex:index];
*/
Python code/function layout
Python code/function layout
I am learning Python and am trying to figure out the best way to structure
my code.
Lets say I have a long function, and want to break it up into smaller
functions. In C, I would make it a 'static' function at the top level
(since that is the only level of functions). I would also probably forward
declare it and place it after the now-shortened function that uses it.
Now for Python. In Python, I have the option to create a nested function.
Since this new "inner" function is really only a piece of the larger
function broken off for readability purposes, and only used by it, it
sounds like it should be a nested function, but having this function
inside the parent function causes the whole function to still be very
long, since no code was actually moved out of it! And especially since the
functions have to be fully coded before they are called, it means the
actual short function is all the way down at the end of this pseudo-long
function, making readability terrible!
What is considered good practice for situations like this?
I am learning Python and am trying to figure out the best way to structure
my code.
Lets say I have a long function, and want to break it up into smaller
functions. In C, I would make it a 'static' function at the top level
(since that is the only level of functions). I would also probably forward
declare it and place it after the now-shortened function that uses it.
Now for Python. In Python, I have the option to create a nested function.
Since this new "inner" function is really only a piece of the larger
function broken off for readability purposes, and only used by it, it
sounds like it should be a nested function, but having this function
inside the parent function causes the whole function to still be very
long, since no code was actually moved out of it! And especially since the
functions have to be fully coded before they are called, it means the
actual short function is all the way down at the end of this pseudo-long
function, making readability terrible!
What is considered good practice for situations like this?
Tuesday, 27 August 2013
jQueryUI - tabs usage
jQueryUI - tabs usage
I'm pretty new on programming trying to create web application which can
change the content without loading the menu all over again.
Then i decided to use vertical jqeury-ui tabs as a navigator. Using this code
<div id="tabs">
<ul>
<li><center>Market Data</center></li>
<li><a href="t1.htm">For Test 1</a></li>
<li><a href="t2.htm">For Test 2</a></li>
<li><a href="t3.htm">For Test 3</a></li>
</ul>
</div>
The question is this "tabs" of jquery-ui using what mechanic for
displaying another htm file inside it AJAX, iframe or what?
Is this a good approach?
And can it handle a complex htm file that involve submit the form, receive
a data from web service?
Thank you in advance !
I'm pretty new on programming trying to create web application which can
change the content without loading the menu all over again.
Then i decided to use vertical jqeury-ui tabs as a navigator. Using this code
<div id="tabs">
<ul>
<li><center>Market Data</center></li>
<li><a href="t1.htm">For Test 1</a></li>
<li><a href="t2.htm">For Test 2</a></li>
<li><a href="t3.htm">For Test 3</a></li>
</ul>
</div>
The question is this "tabs" of jquery-ui using what mechanic for
displaying another htm file inside it AJAX, iframe or what?
Is this a good approach?
And can it handle a complex htm file that involve submit the form, receive
a data from web service?
Thank you in advance !
Using scrapy to scrap an ASP.Net with AJAX requests
Using scrapy to scrap an ASP.Net with AJAX requests
I'm fairly new to python and I've been using scrapy to scrap an ASP.Net
with AJAX requests. I tried to follow this tutorial as a sort of guideline
to what I am willing to achieve. The main difference between this page and
the one I'm trying to scrap is the page navigation link. On the tutorial,
we have: Next >> and therefore it tells us to pass the name of the anchor
to __EVENTTARGET. The page I want to scrap do not call the javascript
function __doPostBack explicitly. Instead it does the following:
Since the call is different, I don't know what values should be passed to
__EVENTTARGET and __EVENTARGUMENT to navigate between pages and also, how
to pass them correctly.
Here's my code:
for i in range(10):
html = response.read()
print "Page %d :" % i
br.select_form("aspnetForm")
print br.form
br.set_all_readonly(False)
mnext = re.search("""<input type="button" class="next" name="next"
onclick="return false;">""", html)
if not mnext:
print "button not found, breaking\n\n"
break
br["__EVENTTARGET"] = mnext.group(0) #this was changed. It's probably
wrong...
br["__EVENTARGUMENT"] = ""
#br.find_control("btnSearch").disabled = True #commented
response = br.submit()
I'm fairly new to python and I've been using scrapy to scrap an ASP.Net
with AJAX requests. I tried to follow this tutorial as a sort of guideline
to what I am willing to achieve. The main difference between this page and
the one I'm trying to scrap is the page navigation link. On the tutorial,
we have: Next >> and therefore it tells us to pass the name of the anchor
to __EVENTTARGET. The page I want to scrap do not call the javascript
function __doPostBack explicitly. Instead it does the following:
Since the call is different, I don't know what values should be passed to
__EVENTTARGET and __EVENTARGUMENT to navigate between pages and also, how
to pass them correctly.
Here's my code:
for i in range(10):
html = response.read()
print "Page %d :" % i
br.select_form("aspnetForm")
print br.form
br.set_all_readonly(False)
mnext = re.search("""<input type="button" class="next" name="next"
onclick="return false;">""", html)
if not mnext:
print "button not found, breaking\n\n"
break
br["__EVENTTARGET"] = mnext.group(0) #this was changed. It's probably
wrong...
br["__EVENTARGUMENT"] = ""
#br.find_control("btnSearch").disabled = True #commented
response = br.submit()
Target sensitive variables in make
Target sensitive variables in make
What is the best way to have some make variables be target sensitive in make?
I have a set of c files and depending the overall make target sometimes
they need to be build with g++ for other targets at other times they will
need to be built with gcc. In both cases the individual object file target
has the same name (thing.o)
The invocations of make are recursive with the appropriate $CC variable
being passed down...
I have a solution but it feels ugly and not the right way do to it so I'm
looking for something better
Thanks in advance
My "solution" stripped down:
# analyze the environment to choose a cc for c targets and another for
gtest targets
TARGET_ARCH_OVR32 = m32
TARGET_ARCH_OVR64 = m64
TARGET_ARCH_OVRRD = none
CC_prod_on64 = /usr/bin/gcc
CC_prod_on32 = gcc4
CC_gtest_on64 = /usr/bin/g++
CC_gtest_on32 = g++
PROC = $(shell uname -p)
TARGET_MACHN_ARCH := $(if $(findstring
64,$(PROC)),PLATFORM_64BIT,PLATFORM_32BIT)
CC_xrpc := $(if $(findstring
64,$(PROC)),$(CC_prod_on64),$(CC_prod_on32))
CC_gtest := $(if $(findstring
64,$(PROC)),$(CC_gtest_on64),$(CC_gtest_on32))
# this is the list of directores containing c files for the g++ build
# it is a superset of the PRODDIRS
TESTSUBDIRS = $(CHIPROOT)/open_source/google_test \
general general/testing \
$(CHIPROOT)/drv $(CHIPROOT)/drv/testing \
..
..
$ this is the list of directories containing C files for the gcc build
PRODDIRS = general \
$(CHIPROOT)/drv \
$(CHIPROOT)/dev \
..
..
CCx := $(if $(filter gtest,$(MAKECMDGOALS)),$(CC_gtest),$(CC_xrpc))
BUILDDIRx := $(if $(filter gtest,\
$(MAKECMDGOALS)),$(GTESTRESULTDIR),$(PRODTARGETDIR)/$(OSTYPE))
DIRSx := $(if $(filter gtest,$(MAKECMDGOALS)),$(TESTSUBDIRS),$(PRODDIRS))
TEST_MODE := $(if $(filter gtest,$(MAKECMDGOALS)),GTEST,NOUNIT_TEST)
DIRS = $(DIRSx)
BUILDDIR = $(BUILDDIRx)
CC = $(CCx)
objdir: $(CSPLATFORMDIR)/makebuilddir
$(CSPLATFORMDIR)/makebuilddir $(BUILDDIR)
# this is the target that actaully goes and compiles all the c files
$(DIRS): objdir
$(MAKE) CC=$(CCx) BUILDDIR=$(BUILDDIRx) -e -C $@
# this is one of the overall targets (it needs g++)
gtest: $(CSPLATFORMDIR)/makebuilddir $(DIRS) $(CHIPROOT)/irq
$(CHIPROOT)/irq/testing
$(CSPLATFORMDIR)/makebuilddir $(GTESTRESULTDIR)
g++ $(OBJS) -lpthread $(GTESTLIBDIR)/libgtest_main.a
$(GTESTLIBDIR)/libgtest.a -o\
$(GTESTRESULTDIR)/gtest
cp $(GTESTRESULTDIR)/gtest .
# this is another overall target (it needs gcc)
prod.a: $(CSPLATFORMDIR)/makebuilddir $(DIRS)
$(CSPLATFORMDIR)/makebuilddir $(BUILDDIR)
$(AR) -r $(TARGET) $(OBJS)
ls -l $(TARGET)
What is the best way to have some make variables be target sensitive in make?
I have a set of c files and depending the overall make target sometimes
they need to be build with g++ for other targets at other times they will
need to be built with gcc. In both cases the individual object file target
has the same name (thing.o)
The invocations of make are recursive with the appropriate $CC variable
being passed down...
I have a solution but it feels ugly and not the right way do to it so I'm
looking for something better
Thanks in advance
My "solution" stripped down:
# analyze the environment to choose a cc for c targets and another for
gtest targets
TARGET_ARCH_OVR32 = m32
TARGET_ARCH_OVR64 = m64
TARGET_ARCH_OVRRD = none
CC_prod_on64 = /usr/bin/gcc
CC_prod_on32 = gcc4
CC_gtest_on64 = /usr/bin/g++
CC_gtest_on32 = g++
PROC = $(shell uname -p)
TARGET_MACHN_ARCH := $(if $(findstring
64,$(PROC)),PLATFORM_64BIT,PLATFORM_32BIT)
CC_xrpc := $(if $(findstring
64,$(PROC)),$(CC_prod_on64),$(CC_prod_on32))
CC_gtest := $(if $(findstring
64,$(PROC)),$(CC_gtest_on64),$(CC_gtest_on32))
# this is the list of directores containing c files for the g++ build
# it is a superset of the PRODDIRS
TESTSUBDIRS = $(CHIPROOT)/open_source/google_test \
general general/testing \
$(CHIPROOT)/drv $(CHIPROOT)/drv/testing \
..
..
$ this is the list of directories containing C files for the gcc build
PRODDIRS = general \
$(CHIPROOT)/drv \
$(CHIPROOT)/dev \
..
..
CCx := $(if $(filter gtest,$(MAKECMDGOALS)),$(CC_gtest),$(CC_xrpc))
BUILDDIRx := $(if $(filter gtest,\
$(MAKECMDGOALS)),$(GTESTRESULTDIR),$(PRODTARGETDIR)/$(OSTYPE))
DIRSx := $(if $(filter gtest,$(MAKECMDGOALS)),$(TESTSUBDIRS),$(PRODDIRS))
TEST_MODE := $(if $(filter gtest,$(MAKECMDGOALS)),GTEST,NOUNIT_TEST)
DIRS = $(DIRSx)
BUILDDIR = $(BUILDDIRx)
CC = $(CCx)
objdir: $(CSPLATFORMDIR)/makebuilddir
$(CSPLATFORMDIR)/makebuilddir $(BUILDDIR)
# this is the target that actaully goes and compiles all the c files
$(DIRS): objdir
$(MAKE) CC=$(CCx) BUILDDIR=$(BUILDDIRx) -e -C $@
# this is one of the overall targets (it needs g++)
gtest: $(CSPLATFORMDIR)/makebuilddir $(DIRS) $(CHIPROOT)/irq
$(CHIPROOT)/irq/testing
$(CSPLATFORMDIR)/makebuilddir $(GTESTRESULTDIR)
g++ $(OBJS) -lpthread $(GTESTLIBDIR)/libgtest_main.a
$(GTESTLIBDIR)/libgtest.a -o\
$(GTESTRESULTDIR)/gtest
cp $(GTESTRESULTDIR)/gtest .
# this is another overall target (it needs gcc)
prod.a: $(CSPLATFORMDIR)/makebuilddir $(DIRS)
$(CSPLATFORMDIR)/makebuilddir $(BUILDDIR)
$(AR) -r $(TARGET) $(OBJS)
ls -l $(TARGET)
Why there are many guest accounts?
Why there are many guest accounts?
After I saw this answer, I realized that there are many guest accounts on
my system:
cat /etc/passwd | grep guest
guest-jzXeRx:x:117:127:Guest,,,:/tmp/guest-jzXeRx:/bin/false
guest-l5dAPU:x:118:128:Guest,,,:/tmp/guest-l5dAPU:/bin/false
guest-FdSAkw:x:119:129:Guest,,,:/tmp/guest-FdSAkw:/bin/false
guest-eBU0cU:x:121:131:Guest,,,:/tmp/guest-eBU0cU:/bin/false
Moreover, in this moment there is nobody logged as guest, but if somebody
will login as guest, a new guest account is created - why, since there are
already other guest accounts?
After the new guest will log out, his account will be deleted. But why the
other guest accounts remain? For what use/purpose?
After I saw this answer, I realized that there are many guest accounts on
my system:
cat /etc/passwd | grep guest
guest-jzXeRx:x:117:127:Guest,,,:/tmp/guest-jzXeRx:/bin/false
guest-l5dAPU:x:118:128:Guest,,,:/tmp/guest-l5dAPU:/bin/false
guest-FdSAkw:x:119:129:Guest,,,:/tmp/guest-FdSAkw:/bin/false
guest-eBU0cU:x:121:131:Guest,,,:/tmp/guest-eBU0cU:/bin/false
Moreover, in this moment there is nobody logged as guest, but if somebody
will login as guest, a new guest account is created - why, since there are
already other guest accounts?
After the new guest will log out, his account will be deleted. But why the
other guest accounts remain? For what use/purpose?
How to get list of functions in an array in php
How to get list of functions in an array in php
<?php
function funct_one(){
//do something
}
function funct_two(){
//do something
}
function funct_three(){
//do something
}
function funct_four(){
//do something
}
$func_list=array();
?>
thats an example code
i want a list of all functions, something like this,
$func_list=array('funct_one','funct_two','funct_three','funct_four');
i want this array to generated itself on load .
<?php
function funct_one(){
//do something
}
function funct_two(){
//do something
}
function funct_three(){
//do something
}
function funct_four(){
//do something
}
$func_list=array();
?>
thats an example code
i want a list of all functions, something like this,
$func_list=array('funct_one','funct_two','funct_three','funct_four');
i want this array to generated itself on load .
Getting a val from an option tag inside a form. CodeIgniter
Getting a val from an option tag inside a form. CodeIgniter
The similar questions out there didnt really help me because they were too
specific.
I have a form with a select input. I need the val that accompies the
option tags.
When I var_dump the post data, I can see that the data being transferred
is not the val of the option, but the name of the option.
i.e:
<select name="selector">
<option val="1">Option 1</option>
<option val="2">Option </option>
</select>
And my post data will say something like ["selector"]=> string(8) "Option 1"
I'm using CodeIgniter and I'm not sure how to get it to play along.
I want to avoid doing something convoluted with JavaScript and getting the
.val() and assigning it to something else. That would be lame.
The similar questions out there didnt really help me because they were too
specific.
I have a form with a select input. I need the val that accompies the
option tags.
When I var_dump the post data, I can see that the data being transferred
is not the val of the option, but the name of the option.
i.e:
<select name="selector">
<option val="1">Option 1</option>
<option val="2">Option </option>
</select>
And my post data will say something like ["selector"]=> string(8) "Option 1"
I'm using CodeIgniter and I'm not sure how to get it to play along.
I want to avoid doing something convoluted with JavaScript and getting the
.val() and assigning it to something else. That would be lame.
Monday, 26 August 2013
Cannot Create InboxRule on one individual mailbox
Cannot Create InboxRule on one individual mailbox
This one user when trying to create a rule through outlook throws the
generic "One or more rules cannot be uploaded to Microsoft Exchange and
have been deactivated. This could be because some of the parameters are
not supported, or there is insufficient space to store all of your rules"
This user does not have any other rules set, i've adjusted the rule quota
to the max value.
When I try to create a rule using the powershell cmdlet New-InboxRule, I
get the following error (The command works for multiple other mailboxes on
the same database, as well for other users) :
There was an error saving the rules.
+ CategoryInfo : NotSpecified: (0:Int32) [New-InboxRule],
StoragePermanentException
+ FullyQualifiedErrorId :
569675E6,Microsoft.Exchange.Management.RecipientTasks.NewInboxRule
This one user when trying to create a rule through outlook throws the
generic "One or more rules cannot be uploaded to Microsoft Exchange and
have been deactivated. This could be because some of the parameters are
not supported, or there is insufficient space to store all of your rules"
This user does not have any other rules set, i've adjusted the rule quota
to the max value.
When I try to create a rule using the powershell cmdlet New-InboxRule, I
get the following error (The command works for multiple other mailboxes on
the same database, as well for other users) :
There was an error saving the rules.
+ CategoryInfo : NotSpecified: (0:Int32) [New-InboxRule],
StoragePermanentException
+ FullyQualifiedErrorId :
569675E6,Microsoft.Exchange.Management.RecipientTasks.NewInboxRule
How does notify work in Java threads?
How does notify work in Java threads?
I am new to using threads in java . I have a simple reader writer problem
where that when a writer comes in on a thread, a reader will wait for the
writer to complete.
However, when I run my program, I find that my thread doesn't get
notified? Why is this?
My code is below:
public class ReaderWriter {
Object o = new Object();
volatile boolean writing;
Thread readerThread = new Thread( "reader") {
public void run() {
while(true) {
System.out.println("reader starts");
if(writing) {
synchronized (o) {
try {
o.wait();
System.out.println("Awaked from wait");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
System.out.println( "reader thread working "+o.hashCode());
}
}
};
Thread writerThread = new Thread("writer" ) {
public void run() {
System.out.println( " writer thread");
try {
synchronized (o) {
writing = true;
System.out.println("writer is working .. ");
Thread.sleep(10000);
writing = false;
o.notify();
System.out.println("reader is notified");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
public static void main(String[] args) {
ReaderWriter rw=new ReaderWriter();
rw.readerThread.start();
rw.writerThread.start();
}
}
I am new to using threads in java . I have a simple reader writer problem
where that when a writer comes in on a thread, a reader will wait for the
writer to complete.
However, when I run my program, I find that my thread doesn't get
notified? Why is this?
My code is below:
public class ReaderWriter {
Object o = new Object();
volatile boolean writing;
Thread readerThread = new Thread( "reader") {
public void run() {
while(true) {
System.out.println("reader starts");
if(writing) {
synchronized (o) {
try {
o.wait();
System.out.println("Awaked from wait");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
System.out.println( "reader thread working "+o.hashCode());
}
}
};
Thread writerThread = new Thread("writer" ) {
public void run() {
System.out.println( " writer thread");
try {
synchronized (o) {
writing = true;
System.out.println("writer is working .. ");
Thread.sleep(10000);
writing = false;
o.notify();
System.out.println("reader is notified");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
public static void main(String[] args) {
ReaderWriter rw=new ReaderWriter();
rw.readerThread.start();
rw.writerThread.start();
}
}
how can I link to a PlugIn admin-sub-menu page after processing a formular
how can I link to a PlugIn admin-sub-menu page after processing a formular
I have a Plugin with 3 submenu_pages. In one page is a formular (in one
some text and in one a list of items). when I submit the form, there will
be done some processing. after that I don't want to get back to the
form-page, but WP shell redirect me to one of the other submenu_pages (in
this case a list).
how can I achive this?
add_menu_page( 'page1 main page', '0', 'manage_options', 'mg-pi',
'mg_backend');
add_submenu_page( 'mg-pi', 'list smthing', '0', 'manage_options',
'mg-pi-sub-list', 'mg_list');
add_submenu_page( 'mg-pi', 'create', '0', 'manage_options',
'mg-pi-sub-create', 'mg_new_item');
so in mg_new_item() is the processing and then it shell redirect to
mg_list(). but if I do the php call to mg_list() the url is still the one
of mg_new_item().
I know I could do some header("Location: the-hardcoded-list-url"); but I
am looking for the WordPress common way of doing it, with generic Url
generation.
I have a Plugin with 3 submenu_pages. In one page is a formular (in one
some text and in one a list of items). when I submit the form, there will
be done some processing. after that I don't want to get back to the
form-page, but WP shell redirect me to one of the other submenu_pages (in
this case a list).
how can I achive this?
add_menu_page( 'page1 main page', '0', 'manage_options', 'mg-pi',
'mg_backend');
add_submenu_page( 'mg-pi', 'list smthing', '0', 'manage_options',
'mg-pi-sub-list', 'mg_list');
add_submenu_page( 'mg-pi', 'create', '0', 'manage_options',
'mg-pi-sub-create', 'mg_new_item');
so in mg_new_item() is the processing and then it shell redirect to
mg_list(). but if I do the php call to mg_list() the url is still the one
of mg_new_item().
I know I could do some header("Location: the-hardcoded-list-url"); but I
am looking for the WordPress common way of doing it, with generic Url
generation.
TeXstudio: Finalize placeholder, red frame, red box
TeXstudio: Finalize placeholder, red frame, red box
When TeXstudio completes a command like \label{key} that requires an
argument a placeholder is positioned between curly brackets. The
placeholder is surrounded by a red frame. When jumping forward through the
document using CTRL+Leftarrow or CTRL+Rightarrow jumping to the
placeholder takes precedence over jumping to next/last words and even
takes you across multiple lines.
While I want this behaviour I also want to be able to jump single words in
the direction of the last placeholder after it is set to the wanted
content. To do this I need to somehow finalize the placeholder indicated
by the removal of the red frame. I can do this by a number of combinations
of moving the cursor into the red frame, pressing Enter and then undoing
the Enter press.
However, that doesn't feel like a forward way to composing a document and
I suspect there is a right way to make a placeholder lose its jump point
property. So, what is the correct way to finalize a placeholder?
When TeXstudio completes a command like \label{key} that requires an
argument a placeholder is positioned between curly brackets. The
placeholder is surrounded by a red frame. When jumping forward through the
document using CTRL+Leftarrow or CTRL+Rightarrow jumping to the
placeholder takes precedence over jumping to next/last words and even
takes you across multiple lines.
While I want this behaviour I also want to be able to jump single words in
the direction of the last placeholder after it is set to the wanted
content. To do this I need to somehow finalize the placeholder indicated
by the removal of the red frame. I can do this by a number of combinations
of moving the cursor into the red frame, pressing Enter and then undoing
the Enter press.
However, that doesn't feel like a forward way to composing a document and
I suspect there is a right way to make a placeholder lose its jump point
property. So, what is the correct way to finalize a placeholder?
Sunday, 25 August 2013
VB.Net string contains exact match
VB.Net string contains exact match
I'm wondering if there is a way to search for an exact text match in a
text box
for example
using "if textbox1.text.contains("Hello") then" works
however i only want it to search for text "Hello" and if i have 2 words
like this
HelloFriend Hello Friend
I only want it to find the word matching so the second statement Hello
Friend and not HelloFriend as this doesn't match the keyword.
Is this possible?
I'm wondering if there is a way to search for an exact text match in a
text box
for example
using "if textbox1.text.contains("Hello") then" works
however i only want it to search for text "Hello" and if i have 2 words
like this
HelloFriend Hello Friend
I only want it to find the word matching so the second statement Hello
Friend and not HelloFriend as this doesn't match the keyword.
Is this possible?
Java - JPA - (Un)instantiated List causes changes to one of its objects to be reverted
Java - JPA - (Un)instantiated List causes changes to one of its objects to
be reverted
Why does opening an uninstantiated List of (entity) objects revert changes
already made to any one of said objects within the same transaction?
Scenario:
A, B and C are all Entities
A holds a reference to a particular instance of B, retrievable with a.getB();
C has a list of B objects, retrievable with c.getListOfB()
The following is true: c.getListOfB().contains(a.getB())
If I do the following within a transaction:
B b = a.getB();
b.setOk(true); // <-- Changed from false to true
and then follow with:
c.getListOfB().isEmpty() // <-- Any function will do, I just used
.isEmpty() to test it
Then b IMMEDIATELY has OK value set to false again :/
This happens within the same Transaction, before committing to DB.
Can someone please be so kind as to explain to me why EntityManager isn't
aware of the changes already made to the above entity within the
Transaction, and how to I can make sure it keeps them? This led me on a
long bug hunt and I'm literally at loss of words on how to find any
helpful results online.
be reverted
Why does opening an uninstantiated List of (entity) objects revert changes
already made to any one of said objects within the same transaction?
Scenario:
A, B and C are all Entities
A holds a reference to a particular instance of B, retrievable with a.getB();
C has a list of B objects, retrievable with c.getListOfB()
The following is true: c.getListOfB().contains(a.getB())
If I do the following within a transaction:
B b = a.getB();
b.setOk(true); // <-- Changed from false to true
and then follow with:
c.getListOfB().isEmpty() // <-- Any function will do, I just used
.isEmpty() to test it
Then b IMMEDIATELY has OK value set to false again :/
This happens within the same Transaction, before committing to DB.
Can someone please be so kind as to explain to me why EntityManager isn't
aware of the changes already made to the above entity within the
Transaction, and how to I can make sure it keeps them? This led me on a
long bug hunt and I'm literally at loss of words on how to find any
helpful results online.
I need a more comfortable workspace, what does everyone do? [on hold]
I need a more comfortable workspace, what does everyone do? [on hold]
I get too uncomfotable in office chairs or any standard chair, sitting
forward on sofa with laptop etc. I need to be able to sit back in a well
padded chair and have easy access to a keyboard and mouse connected to a
laptop. I've seen laptop trays on ebay but they would only really be
suitable for sitting up on a sofa or lying in bed. Does no one else have
the issue? I find I can't be productive without comfortable access to
keyboard and mouse with relaxed posture. It's a lot better in the office
in work, but at home I just can't seem to find a way. I haven't got room
for a full desk station etc.
I suppose what I am asking is if there is any sort of dentist shaped chair
anyone uses with build in laptop and mouse holder. Or how are the rest of
you coping?!
I get too uncomfotable in office chairs or any standard chair, sitting
forward on sofa with laptop etc. I need to be able to sit back in a well
padded chair and have easy access to a keyboard and mouse connected to a
laptop. I've seen laptop trays on ebay but they would only really be
suitable for sitting up on a sofa or lying in bed. Does no one else have
the issue? I find I can't be productive without comfortable access to
keyboard and mouse with relaxed posture. It's a lot better in the office
in work, but at home I just can't seem to find a way. I haven't got room
for a full desk station etc.
I suppose what I am asking is if there is any sort of dentist shaped chair
anyone uses with build in laptop and mouse holder. Or how are the rest of
you coping?!
Replace line with multiple trailing patterns
Replace line with multiple trailing patterns
I have 2 files called myfile.txt & responsefile.txt as below.
myfile.txt
user=myname
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
responsefile.txt
'#'Please fill the user id details.
'#'Here is example user=urname.
user=
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=
Now, using above two files want to have the following end result after
replacing the matching patterns. The responsefile.txt content should be
intact just the matched pattern should be prefixed with details provided
in myfile.txt or only replace the whole matching line as 1st pattern are
same in both the files and would be more than 100 patterns. SO, please
suggest with a simple solution.
responsefile.txt (new file replaced/substituted with patterns)
'#'Please fill the user id details.
'#'Here is example user=urname.
user=myname
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
Patterns would be same in both the files for example "user=" or
"Was_WAS_AdminId=" in both the files.
Thanks
I have 2 files called myfile.txt & responsefile.txt as below.
myfile.txt
user=myname
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
responsefile.txt
'#'Please fill the user id details.
'#'Here is example user=urname.
user=
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=
Now, using above two files want to have the following end result after
replacing the matching patterns. The responsefile.txt content should be
intact just the matched pattern should be prefixed with details provided
in myfile.txt or only replace the whole matching line as 1st pattern are
same in both the files and would be more than 100 patterns. SO, please
suggest with a simple solution.
responsefile.txt (new file replaced/substituted with patterns)
'#'Please fill the user id details.
'#'Here is example user=urname.
user=myname
'#'Please fill the details.
'#'Here is example Was_WAS_AdminId=CN=wsadmin-xxxx.
Was_WAS_AdminId=CN=wsadmin,OU=service,OU=WAS_Secure,OU=tb,ou=dcdc,ou=sysadm,dc=info,dc=prd,dc=dcdc
Patterns would be same in both the files for example "user=" or
"Was_WAS_AdminId=" in both the files.
Thanks
C - printing a floating number, not precise?
C - printing a floating number, not precise?
I'm creating a floating variable with the number 123.56789. Then I
directly print that var, but it isn't returning the correct value. How
come? Did I do something wrong? After a look here on the questions, it
seems that I'm not the only one, but the main difference with me and
others is that I directly print the value in the variable and don't do any
operations with it.
#include <stdio.h>
#include <stdlib.h>
int main(void){
float num = 123.56789;
printf("Number is %f", num);
// I expect to print '123.56789'
// But it prints '123.567889' with an extra '8'
//Why?
}
I'm creating a floating variable with the number 123.56789. Then I
directly print that var, but it isn't returning the correct value. How
come? Did I do something wrong? After a look here on the questions, it
seems that I'm not the only one, but the main difference with me and
others is that I directly print the value in the variable and don't do any
operations with it.
#include <stdio.h>
#include <stdlib.h>
int main(void){
float num = 123.56789;
printf("Number is %f", num);
// I expect to print '123.56789'
// But it prints '123.567889' with an extra '8'
//Why?
}
Convert DataTable to Generic List
Convert DataTable to Generic List
I have a below method in dataService layer:
public DataTable retTable ()
{
DataTable dt = new DataTable();
adap.Fill(dt);
return dt;
}
because I should add (using Data) name space in business layer. I wanna
change it to:
public List<DataTable> retTable()
{
DataTable dt = new DataTable();
adap.Fill(dt);
List<DataTable> lst = new List<DataTable>();
lst.AddRange(dt);
return lst ;
}
but I have error in
lst.AddRange(dt);
how can i solve it?
I have a below method in dataService layer:
public DataTable retTable ()
{
DataTable dt = new DataTable();
adap.Fill(dt);
return dt;
}
because I should add (using Data) name space in business layer. I wanna
change it to:
public List<DataTable> retTable()
{
DataTable dt = new DataTable();
adap.Fill(dt);
List<DataTable> lst = new List<DataTable>();
lst.AddRange(dt);
return lst ;
}
but I have error in
lst.AddRange(dt);
how can i solve it?
Saturday, 24 August 2013
Generating function for $\sum_{k\geq 1} H^{(k)}_n x^ k $
Generating function for $\sum_{k\geq 1} H^{(k)}_n x^ k $
Is there a generating function for
$$\tag{1}\sum_{k\geq 1} H^{(k)}_n x^ k $$
I know that
$$\tag{2}\sum_{k\geq 1} H^{(k)}_n x^n= \frac{\operatorname{Li}_k(x)}{1-x} $$
But notice in (1) the fixed $n$.
Is there a generating function for
$$\tag{1}\sum_{k\geq 1} H^{(k)}_n x^ k $$
I know that
$$\tag{2}\sum_{k\geq 1} H^{(k)}_n x^n= \frac{\operatorname{Li}_k(x)}{1-x} $$
But notice in (1) the fixed $n$.
How to add an image to Ubuntu Server 12.04 LTS?
How to add an image to Ubuntu Server 12.04 LTS?
With Ubuntu Server being a completely text only OS, how do you add an
image file? I have a webpage set up and would like to add an image or two.
Open SSH is running on the server and connected to my laptop running
Windows 7 (over PuTTY). Is there a way to somehow "drag-and-drop" an image
file to the server from my laptop over Open SSH?
Thanks in advance, Chandler
Yes, I may be a n00b but I am 13, and completely new to Linux and HTML in
general. :)
With Ubuntu Server being a completely text only OS, how do you add an
image file? I have a webpage set up and would like to add an image or two.
Open SSH is running on the server and connected to my laptop running
Windows 7 (over PuTTY). Is there a way to somehow "drag-and-drop" an image
file to the server from my laptop over Open SSH?
Thanks in advance, Chandler
Yes, I may be a n00b but I am 13, and completely new to Linux and HTML in
general. :)
Learning UNIX Bash/Shell scripting on a windows enviornment
Learning UNIX Bash/Shell scripting on a windows enviornment
I was just curious if there are any tools out there that would allow me to
practice shell scripting without dual booting my computer to half windows
and half UNIX. I've heard of Cygwin but is that truly UNIX ?
I was just curious if there are any tools out there that would allow me to
practice shell scripting without dual booting my computer to half windows
and half UNIX. I've heard of Cygwin but is that truly UNIX ?
Gw2 empowering might radius
Gw2 empowering might radius
So I spec my guardian to precision damage and toughness. I noticed that
some of my team mates are not getting might during the usage of Empowering
Might on my guardian honor spec maybe it's because of the stacking rule
where you can only get 5 allied targets. Also another question is "what is
the cooldown on it's effect?" because I don't think it would make any
sense when a guardian just aoes a mob with 50% critical chance and the
team would get a 25 might stack for 5 seconds
So I spec my guardian to precision damage and toughness. I noticed that
some of my team mates are not getting might during the usage of Empowering
Might on my guardian honor spec maybe it's because of the stacking rule
where you can only get 5 allied targets. Also another question is "what is
the cooldown on it's effect?" because I don't think it would make any
sense when a guardian just aoes a mob with 50% critical chance and the
team would get a 25 might stack for 5 seconds
Dynamically remove select option value using href - jquery
Dynamically remove select option value using href - jquery
I am having a list of users with delete hyperlink assume
<a href="#" onclick="delete(id)">Delete</a>
And i have a combo box at the top to filter specific user using user id.
The delete action will performed with ajax and it reloads the content. The
content gets reloaded but the combo box contains the deleted id. Is there
any way to clear it using jquery.
I am having a list of users with delete hyperlink assume
<a href="#" onclick="delete(id)">Delete</a>
And i have a combo box at the top to filter specific user using user id.
The delete action will performed with ajax and it reloads the content. The
content gets reloaded but the combo box contains the deleted id. Is there
any way to clear it using jquery.
Is it possible to conquer Japan and Manchuria in Korea's scenario "Samurai Invasion"?
Is it possible to conquer Japan and Manchuria in Korea's scenario "Samurai
Invasion"?
The original victory condition is to regain all the Korean city at some
time after 1600 but within 100 turns. But instead can one win by capturing
Kyoto and Fe Ala, under a not-too-easy level?
Invasion"?
The original victory condition is to regain all the Korean city at some
time after 1600 but within 100 turns. But instead can one win by capturing
Kyoto and Fe Ala, under a not-too-easy level?
Friday, 23 August 2013
OSX FSEventStreamEventFlags not working correctly
OSX FSEventStreamEventFlags not working correctly
I am watching a directory for file system events. Everything seems to work
fine with one exception. When I create a file the first time, it spits out
that it was created. Then I can remove it and it says it was removed. When
I go to create the same file again, I get both a created and removed flag
at the same time. I obviously am misunderstanding how the flags are being
set when the callback is being called. What is happening here?
//
// main.c
// GoFSEvents
//
// Created by Kyle Cook on 8/22/13.
// Copyright (c) 2013 Kyle Cook. All rights reserved.
//
#include <CoreServices/CoreServices.h>
#include <stdio.h>
#include <string.h>
void eventCallback(FSEventStreamRef stream, void* callbackInfo, size_t
numEvents, void* paths, const FSEventStreamEventFlags eventFlags[], const
FSEventStreamEventId eventIds[]) {
char **pathsList = paths;
for(int i = 0; i<numEvents; i++) {
uint32 flag = eventFlags[i];
uint32 created = kFSEventStreamEventFlagItemCreated;
uint32 removed = kFSEventStreamEventFlagItemRemoved;
if(flag & removed) {
printf("Item Removed: %s\n", pathsList[i]);
}
else if(flag & created) {
printf("Item Created: %s\n", pathsList[i]);
}
}
}
int main(int argc, const char * argv[])
{
CFStringRef mypath = CFSTR("/path/to/dir");
CFArrayRef paths = CFArrayCreate(NULL, (const void **)&mypath, 1, NULL);
CFRunLoopRef loop = CFRunLoopGetMain();
FSEventStreamRef stream = FSEventStreamCreate(NULL,
(FSEventStreamCallback)eventCallback, NULL, paths,
kFSEventStreamEventIdSinceNow, 1.0, kFSEventStreamCreateFlagFileEvents
| kFSEventStreamCreateFlagNoDefer);
FSEventStreamScheduleWithRunLoop(stream, loop, kCFRunLoopDefaultMode);
FSEventStreamStart(stream);
CFRunLoopRun();
FSEventStreamStop(stream);
FSEventStreamInvalidate(stream);
FSEventStreamRelease(stream);
return 0;
}
I am watching a directory for file system events. Everything seems to work
fine with one exception. When I create a file the first time, it spits out
that it was created. Then I can remove it and it says it was removed. When
I go to create the same file again, I get both a created and removed flag
at the same time. I obviously am misunderstanding how the flags are being
set when the callback is being called. What is happening here?
//
// main.c
// GoFSEvents
//
// Created by Kyle Cook on 8/22/13.
// Copyright (c) 2013 Kyle Cook. All rights reserved.
//
#include <CoreServices/CoreServices.h>
#include <stdio.h>
#include <string.h>
void eventCallback(FSEventStreamRef stream, void* callbackInfo, size_t
numEvents, void* paths, const FSEventStreamEventFlags eventFlags[], const
FSEventStreamEventId eventIds[]) {
char **pathsList = paths;
for(int i = 0; i<numEvents; i++) {
uint32 flag = eventFlags[i];
uint32 created = kFSEventStreamEventFlagItemCreated;
uint32 removed = kFSEventStreamEventFlagItemRemoved;
if(flag & removed) {
printf("Item Removed: %s\n", pathsList[i]);
}
else if(flag & created) {
printf("Item Created: %s\n", pathsList[i]);
}
}
}
int main(int argc, const char * argv[])
{
CFStringRef mypath = CFSTR("/path/to/dir");
CFArrayRef paths = CFArrayCreate(NULL, (const void **)&mypath, 1, NULL);
CFRunLoopRef loop = CFRunLoopGetMain();
FSEventStreamRef stream = FSEventStreamCreate(NULL,
(FSEventStreamCallback)eventCallback, NULL, paths,
kFSEventStreamEventIdSinceNow, 1.0, kFSEventStreamCreateFlagFileEvents
| kFSEventStreamCreateFlagNoDefer);
FSEventStreamScheduleWithRunLoop(stream, loop, kCFRunLoopDefaultMode);
FSEventStreamStart(stream);
CFRunLoopRun();
FSEventStreamStop(stream);
FSEventStreamInvalidate(stream);
FSEventStreamRelease(stream);
return 0;
}
${pageContext.request.contextPath} does not working
${pageContext.request.contextPath} does not working
I'm using tomcat 7.0. Now I am facing an issue that could not load the css
and js file. trying to add ${pageContext.request.contextPath} but does not
work, also tried c:url tag, but getting syntax error in eclipse.
The structure of these files is:
WebContent
-content/css/lab3.css
html and js folder are under content folder as well
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>lab3</display-name>
<welcome-file-list>
<welcome-file>/content/html/lab3.html</welcome-file>
</welcome-file-list>
</web-app>
Here is the html head:
<link rel="stylesheet" type= "text/css" href=
"${pageContext.request.contextPath}/css/lab3.css" media="screen,
projection">
I'm using tomcat 7.0. Now I am facing an issue that could not load the css
and js file. trying to add ${pageContext.request.contextPath} but does not
work, also tried c:url tag, but getting syntax error in eclipse.
The structure of these files is:
WebContent
-content/css/lab3.css
html and js folder are under content folder as well
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"
version="3.0">
<display-name>lab3</display-name>
<welcome-file-list>
<welcome-file>/content/html/lab3.html</welcome-file>
</welcome-file-list>
</web-app>
Here is the html head:
<link rel="stylesheet" type= "text/css" href=
"${pageContext.request.contextPath}/css/lab3.css" media="screen,
projection">
Tab and pre wrapped around JSON output in Chrome
Tab and pre wrapped around JSON output in Chrome
I am using this simple code to print an array as a JSON structure.
header('Content-Type: application/json');
echo json_encode($this->data, JSON_PRETTY_PRINT);
I'm using Chrome Version 28.0.1500.95 m. For some odd reason the output is
wrapped in a pre tag with a tab character (/t) at the beginning.
The tab seems to cause jQuery.isEmptyObject to not work as intended. How
could this be fixed ?
How
<pre style="word-wrap: break-word; white-space: pre-wrap;"> {
"title": "Node",
"items": [
{
"label": "Do stuff",
"icon": "..\/ui\/images\/icons\/16x16\/icon.png",
"action": "dostuff"
}
]
}</pre>
I am using this simple code to print an array as a JSON structure.
header('Content-Type: application/json');
echo json_encode($this->data, JSON_PRETTY_PRINT);
I'm using Chrome Version 28.0.1500.95 m. For some odd reason the output is
wrapped in a pre tag with a tab character (/t) at the beginning.
The tab seems to cause jQuery.isEmptyObject to not work as intended. How
could this be fixed ?
How
<pre style="word-wrap: break-word; white-space: pre-wrap;"> {
"title": "Node",
"items": [
{
"label": "Do stuff",
"icon": "..\/ui\/images\/icons\/16x16\/icon.png",
"action": "dostuff"
}
]
}</pre>
Back Two Steps Activity Android
Back Two Steps Activity Android
Hi i m using Twitter4j and theres an issue of back stack because when i
loged in it open browser for verification and then create new activity and
then we press back button it opens browser again.i want to remove that
browser activity from stack just that one and its mystery for me how to do
that.
Hi i m using Twitter4j and theres an issue of back stack because when i
loged in it open browser for verification and then create new activity and
then we press back button it opens browser again.i want to remove that
browser activity from stack just that one and its mystery for me how to do
that.
Want a method that how to get payment online through credit cards direct to by bank account
Want a method that how to get payment online through credit cards direct
to by bank account
I want a method that how to get payment online through credit cards direct
to my bank account.
Like i want people to click on button in my website and they directly get
transfer to a page where they insert their credit card details and pay me
direct to my bank account don't want to use a payment gateway..of if there
is any way still by using payment gateway and money direct go to my bank
account without going to payment gateway and then withdrawing and getting
in my bank account. Any Suggestion?
to by bank account
I want a method that how to get payment online through credit cards direct
to my bank account.
Like i want people to click on button in my website and they directly get
transfer to a page where they insert their credit card details and pay me
direct to my bank account don't want to use a payment gateway..of if there
is any way still by using payment gateway and money direct go to my bank
account without going to payment gateway and then withdrawing and getting
in my bank account. Any Suggestion?
Format string with spaces
Format string with spaces
pI'm trying to make an elegant logging system in C++. I'm currently using
codeprintf()/code, although codecout/code can also be an option./p pWhat I
want to achieve is something like this/p precodeconsole_log( ClassName,
funcName, Message. ); /code/pre pMy current code for this is simply:/p
precodestatic void console_log( const std::string amp; className, const
std::string amp; funcName, const std::string amp; message ) { printf( %s :
%s : %s\n, className.c_str(), funcName.c_str(), message.c_str() ); }
/code/pre pIt prints nicely, like this/p precode// For example:
console_log( MenuPanel, selectedThisButton, Something happened. );
console_log( MenuPanel, selectedAnotherButton, Another thing happened. );
// Output: MenuPanel : selectedThisButton : Something happened. MenuPanel
: selectedAnotherButton : Another thing happened. /code/pre pHowever, I
want it to be printed in a table-like manner, where all columns are
aligned properly. For example:/p precodeMenuPanel : selectedThisButton :
Something happened. MenuPanel : selectedAnotherButton : Another thing
happened. /code/pre pHow do I make it so that the first and second columns
have the exact same width/number of characters, with additional spaces if
necessary? It doesn't need to be dynamic. Something like setting a column
to 16 characters will do./p pI don't wish to use any third-party libs for
something as simple as this, though. And if possible, no codeboost/code./p
pI'm trying to make an elegant logging system in C++. I'm currently using
codeprintf()/code, although codecout/code can also be an option./p pWhat I
want to achieve is something like this/p precodeconsole_log( ClassName,
funcName, Message. ); /code/pre pMy current code for this is simply:/p
precodestatic void console_log( const std::string amp; className, const
std::string amp; funcName, const std::string amp; message ) { printf( %s :
%s : %s\n, className.c_str(), funcName.c_str(), message.c_str() ); }
/code/pre pIt prints nicely, like this/p precode// For example:
console_log( MenuPanel, selectedThisButton, Something happened. );
console_log( MenuPanel, selectedAnotherButton, Another thing happened. );
// Output: MenuPanel : selectedThisButton : Something happened. MenuPanel
: selectedAnotherButton : Another thing happened. /code/pre pHowever, I
want it to be printed in a table-like manner, where all columns are
aligned properly. For example:/p precodeMenuPanel : selectedThisButton :
Something happened. MenuPanel : selectedAnotherButton : Another thing
happened. /code/pre pHow do I make it so that the first and second columns
have the exact same width/number of characters, with additional spaces if
necessary? It doesn't need to be dynamic. Something like setting a column
to 16 characters will do./p pI don't wish to use any third-party libs for
something as simple as this, though. And if possible, no codeboost/code./p
Thursday, 22 August 2013
imageEdgeInsets for Image but what about for backgroundImage?
imageEdgeInsets for Image but what about for backgroundImage?
UIButton's method "imageEdgeInsets" is for Image but what if I want to do
insets for backgroundImage?
How do we give inset for backgroundImage?
UIButton's method "imageEdgeInsets" is for Image but what if I want to do
insets for backgroundImage?
How do we give inset for backgroundImage?
How to change the context path of a Spring MVC application deployed in TOMCAT 6.0
How to change the context path of a Spring MVC application deployed in
TOMCAT 6.0
I have a application by the name (say ) SR.DEV.1.001.war . The builds will
change as might have thought already to SR.DEV.1.001 ..004 and so on .
However, the jsp's inside have links like DS/admin or DS/user .
I have checked online for a few resources so as to help me , like here ,
here and here
After trying them out, Im still having the same issue . I tried in
context.xml in META-INF
01) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/SR.DEV.1.001.war" path=""
reloadable="true" />
02) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/SR.DEV.1.001.war" path="/"
reloadable="true" />
03) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/" path="/DS" reloadable="true" />
04) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="" path="/DS" reloadable="true" />
Please help me fix the issue , as without which , its difficult for me to
manage the versions of the war , without affecting the context .
Thanks in advance .
TOMCAT 6.0
I have a application by the name (say ) SR.DEV.1.001.war . The builds will
change as might have thought already to SR.DEV.1.001 ..004 and so on .
However, the jsp's inside have links like DS/admin or DS/user .
I have checked online for a few resources so as to help me , like here ,
here and here
After trying them out, Im still having the same issue . I tried in
context.xml in META-INF
01) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/SR.DEV.1.001.war" path=""
reloadable="true" />
02) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/SR.DEV.1.001.war" path="/"
reloadable="true" />
03) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/" path="/DS" reloadable="true" />
04) <?xml version="1.0" encoding="UTF-8"?>
<Context docBase="" path="/DS" reloadable="true" />
Please help me fix the issue , as without which , its difficult for me to
manage the versions of the war , without affecting the context .
Thanks in advance .
Is there a tool for the conversion of duplicate literals into final Strings/magic numbers in Java?
Is there a tool for the conversion of duplicate literals into final
Strings/magic numbers in Java?
I have some Java files that use the same String values up to 20 times
each, and I want a tool that replaces those Strings with a private static
final String STRING_TO_CAPS_AS_CONSTANT or something along those lines. If
it can also convert numbers into magic numbers, that would be great. I'm
using Eclipse but if it's a standalone tool I can still make use of it.
Strings/magic numbers in Java?
I have some Java files that use the same String values up to 20 times
each, and I want a tool that replaces those Strings with a private static
final String STRING_TO_CAPS_AS_CONSTANT or something along those lines. If
it can also convert numbers into magic numbers, that would be great. I'm
using Eclipse but if it's a standalone tool I can still make use of it.
Layout issues with Winforms present when built in Release mode, not in Debug mode or in the Designer
Layout issues with Winforms present when built in Release mode, not in
Debug mode or in the Designer
I've run across a few layout issues over the years where when making GUIs
with Winforms in C# where everything looks totally fine in Debug mode, but
then I check it in and test our installed copy, and little things like
labels not being positioned quite right (like the edge encroaches onto a
nearby control) or other controls are misplaced by a few pixels. However,
in the designer (both modes) and when running in Debug mode everything
looks fine. Rather than having to build our entire solution in Release
mode to make sure my layouts look fine, is there a reason that designer
generated code is being built incorrectly between modes, and is there
anything I can do to combat this?
We build against .NET 4.0, however, these issues have occurred when
building for both .NET 2.0 and .NET 3.5 SP1.
Debug mode or in the Designer
I've run across a few layout issues over the years where when making GUIs
with Winforms in C# where everything looks totally fine in Debug mode, but
then I check it in and test our installed copy, and little things like
labels not being positioned quite right (like the edge encroaches onto a
nearby control) or other controls are misplaced by a few pixels. However,
in the designer (both modes) and when running in Debug mode everything
looks fine. Rather than having to build our entire solution in Release
mode to make sure my layouts look fine, is there a reason that designer
generated code is being built incorrectly between modes, and is there
anything I can do to combat this?
We build against .NET 4.0, however, these issues have occurred when
building for both .NET 2.0 and .NET 3.5 SP1.
ListView item set error Android
ListView item set error Android
I have a listview that have 5 item in it if am trying to set error on the
4 th and 5th item .Then it is throwing a null pointer exception. Exception
08-22 13:34:49.523: E/AndroidRuntime(16952): FATAL EXCEPTION: main
08-22 13:34:49.523: E/AndroidRuntime(16952): java.lang.NullPointerException
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.example.iweenflightbookingpage.MainActivity$1.onClick(MainActivity.java:116)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.view.View.performClick(View.java:4091)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.view.View$PerformClick.run(View.java:17072)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Handler.handleCallback(Handler.java:615)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Looper.loop(Looper.java:153)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
java.lang.reflect.Method.invokeNative(Native Method)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
java.lang.reflect.Method.invoke(Method.java:511)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
dalvik.system.NativeStart.main(Native Method)
Code To set Error
allValues = myAdapter.getAllValues();
Log.d("this is my array", "arr: " + Arrays.toString(allValues));
for(int i=0;i<allValues.length;i++){
if(allValues[i] == passengerList[i]){
Log.d("Lop Count", ""+allValues[i]+"="+i);
View v = listView.getChildAt(4);
TextView tv=(TextView)v.findViewById(android.R.id.text1); //This
Line is 116
tv.setError("Please change the data");
}
}
BaseAdapter Class
class data extends BaseAdapter {
String[] Title;
Activity activity;
public data (MainActivity mainActivity, String[] text) {
Title = text;
activity = mainActivity;
}
public String[] getAllValues() {
return Title;
}
public int getCount() {
// TODO Auto-generated method stub
return Title.length;
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
View row ;
row = inflater.inflate(android.R.layout.simple_list_item_1,
parent, false);
TextView title;
title = (TextView) row.findViewById(android.R.id.text1);
title.setText(Title[position]);
return (row);
}
This exception is occuring in case of 4 and 5 will be the value of i.
Please help me to resolve the issue
I have a listview that have 5 item in it if am trying to set error on the
4 th and 5th item .Then it is throwing a null pointer exception. Exception
08-22 13:34:49.523: E/AndroidRuntime(16952): FATAL EXCEPTION: main
08-22 13:34:49.523: E/AndroidRuntime(16952): java.lang.NullPointerException
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.example.iweenflightbookingpage.MainActivity$1.onClick(MainActivity.java:116)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.view.View.performClick(View.java:4091)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.view.View$PerformClick.run(View.java:17072)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Handler.handleCallback(Handler.java:615)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Handler.dispatchMessage(Handler.java:92)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.os.Looper.loop(Looper.java:153)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
android.app.ActivityThread.main(ActivityThread.java:4987)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
java.lang.reflect.Method.invokeNative(Native Method)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
java.lang.reflect.Method.invoke(Method.java:511)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
08-22 13:34:49.523: E/AndroidRuntime(16952): at
dalvik.system.NativeStart.main(Native Method)
Code To set Error
allValues = myAdapter.getAllValues();
Log.d("this is my array", "arr: " + Arrays.toString(allValues));
for(int i=0;i<allValues.length;i++){
if(allValues[i] == passengerList[i]){
Log.d("Lop Count", ""+allValues[i]+"="+i);
View v = listView.getChildAt(4);
TextView tv=(TextView)v.findViewById(android.R.id.text1); //This
Line is 116
tv.setError("Please change the data");
}
}
BaseAdapter Class
class data extends BaseAdapter {
String[] Title;
Activity activity;
public data (MainActivity mainActivity, String[] text) {
Title = text;
activity = mainActivity;
}
public String[] getAllValues() {
return Title;
}
public int getCount() {
// TODO Auto-generated method stub
return Title.length;
}
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = activity.getLayoutInflater();
View row ;
row = inflater.inflate(android.R.layout.simple_list_item_1,
parent, false);
TextView title;
title = (TextView) row.findViewById(android.R.id.text1);
title.setText(Title[position]);
return (row);
}
This exception is occuring in case of 4 and 5 will be the value of i.
Please help me to resolve the issue
Wednesday, 21 August 2013
Minimize the listview row into a single line
Minimize the listview row into a single line
I'm using listview to show the messages from the database..when i add a
message it takes all the string and showing on the listview..here is my
xml file and java.. I need to get the message in a singline per rows with
'...'. I researched for this question and i found,type
android:singleLine="true" in textview,but i don't know what they mean 'in
textview'.becauz i'm using listview.please help.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/wave" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/SearchMessageExit"
android:focusableInTouchMode="true"
>
</ListView>
</LinearLayout>
message.java
public void detailsOfMessage(){
try{
Database_message info = new Database_message(this);
String data = info.getData();
info.close();
if(data.equals(""))
{
Toast.makeText(getApplicationContext(), "Empty Message",
Toast.LENGTH_LONG).show();
}
StringTokenizer token = new StringTokenizer(data,"\t");
int rows = token.countTokens();
classes = new String[rows];
int i=0;
while (token.hasMoreTokens())
{
classes[i]=token.nextToken();
i++;
}
listView = (ListView) findViewById(R.id.list);
listView.setOnItemClickListener(this);
listView.setOnLongClickListener(this);
inAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,0);
listView.setAdapter(inAdapter);
for (int r = 0; r < classes.length; r++) {
inAdapter.add(classes[r]);
}
}catch(Exception e){
Toast.makeText(getApplicationContext(), "Empty Message",
Toast.LENGTH_LONG).show();
}
}
I'm using listview to show the messages from the database..when i add a
message it takes all the string and showing on the listview..here is my
xml file and java.. I need to get the message in a singline per rows with
'...'. I researched for this question and i found,type
android:singleLine="true" in textview,but i don't know what they mean 'in
textview'.becauz i'm using listview.please help.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/wave" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/SearchMessageExit"
android:focusableInTouchMode="true"
>
</ListView>
</LinearLayout>
message.java
public void detailsOfMessage(){
try{
Database_message info = new Database_message(this);
String data = info.getData();
info.close();
if(data.equals(""))
{
Toast.makeText(getApplicationContext(), "Empty Message",
Toast.LENGTH_LONG).show();
}
StringTokenizer token = new StringTokenizer(data,"\t");
int rows = token.countTokens();
classes = new String[rows];
int i=0;
while (token.hasMoreTokens())
{
classes[i]=token.nextToken();
i++;
}
listView = (ListView) findViewById(R.id.list);
listView.setOnItemClickListener(this);
listView.setOnLongClickListener(this);
inAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,0);
listView.setAdapter(inAdapter);
for (int r = 0; r < classes.length; r++) {
inAdapter.add(classes[r]);
}
}catch(Exception e){
Toast.makeText(getApplicationContext(), "Empty Message",
Toast.LENGTH_LONG).show();
}
}
What is the syntax/signature of a Objective-C method that returns a block without typedef?
What is the syntax/signature of a Objective-C method that returns a block
without typedef?
I defined a block that takes an NSString and returns a NSURL for that string:
id (^)(id obj)
I've used typedef to make it a block with a name:
typedef id (^URLTransformer)(id);
And the following method does not work:
+ (URLTransformer)transformerToUrlWithString:(NSString *)urlStr
{
return Block_copy(^(id obj){
if ([obj isKindOfClass:NSString.class])
{
NSString *urlStr = obj;
return [NSURL URLWithString:[urlStr
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
return nil; // **THIS LINE FAILS**
});
}
Error:
Return type 'void *' must match previous return type 'id' when block
literal has unspecified explicit return type
My question is: 1. how to correctly implement the method 2. how to
implement the method without typedef URLTransformer?
Thanks
without typedef?
I defined a block that takes an NSString and returns a NSURL for that string:
id (^)(id obj)
I've used typedef to make it a block with a name:
typedef id (^URLTransformer)(id);
And the following method does not work:
+ (URLTransformer)transformerToUrlWithString:(NSString *)urlStr
{
return Block_copy(^(id obj){
if ([obj isKindOfClass:NSString.class])
{
NSString *urlStr = obj;
return [NSURL URLWithString:[urlStr
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
return nil; // **THIS LINE FAILS**
});
}
Error:
Return type 'void *' must match previous return type 'id' when block
literal has unspecified explicit return type
My question is: 1. how to correctly implement the method 2. how to
implement the method without typedef URLTransformer?
Thanks
The possibility of a `while` function for Haskell list-like monads
The possibility of a `while` function for Haskell list-like monads
In Clojure, I can write something like this:
(for [x [1 2 3] :when (not= x 2)]
x)
and get back the vector [1 3]. Haskell has an equivalent using the guard
function:
do x <- [1, 2, 3]
guard $ x /= 2
return x
But Clojure also has a :while qualifier in its for macro, allowing me to
do this:
(for [x [1 2 3] :while (not= x 2)]
x)
and get back [1].
My question is: can you write a monad in Haskell with an analogous while
function? I.e., something that would let me write:
do x <- fromList [1, 2, 3]
while $ x /= 2
return x
and get back a value corresponding to the list [1]? If so, how? If not,
why not?
Note that I realize that you could directly call takeWhile on the list,
itself:
do x <- takeWhile (/= 2) [1, 2, 3]
return x
but I'm looking for something that acts more like guard.
In Clojure, I can write something like this:
(for [x [1 2 3] :when (not= x 2)]
x)
and get back the vector [1 3]. Haskell has an equivalent using the guard
function:
do x <- [1, 2, 3]
guard $ x /= 2
return x
But Clojure also has a :while qualifier in its for macro, allowing me to
do this:
(for [x [1 2 3] :while (not= x 2)]
x)
and get back [1].
My question is: can you write a monad in Haskell with an analogous while
function? I.e., something that would let me write:
do x <- fromList [1, 2, 3]
while $ x /= 2
return x
and get back a value corresponding to the list [1]? If so, how? If not,
why not?
Note that I realize that you could directly call takeWhile on the list,
itself:
do x <- takeWhile (/= 2) [1, 2, 3]
return x
but I'm looking for something that acts more like guard.
Finding a base for a submodule
Finding a base for a submodule
I. Find a base for the submodule of $\mathbb Z^{(3)}$ generated by
$f_1=(1,0,-1)$, $f_2=(2,-3,1)$, $f_3=(0,3,1)$, $f_4=(3,1,5)$.
My question here: Is it enough to find the Smith normal form of the matrix
$A$ consisting of the elements of $f_i$'s or one must find the form
$A'=QAP^{-1}$? If it is the last case, how I can find this form?
II. Find a base for the $\mathbb Z$-submodule of $\mathbb Z^{(3)}$
consisting of all $(x_1,x_2,x_3)$ satisfying the conditions
$x_1+2x_2+3x_3=0$, $x_1+4x_2+9x_3=0$.
How to handle this question?
I. Find a base for the submodule of $\mathbb Z^{(3)}$ generated by
$f_1=(1,0,-1)$, $f_2=(2,-3,1)$, $f_3=(0,3,1)$, $f_4=(3,1,5)$.
My question here: Is it enough to find the Smith normal form of the matrix
$A$ consisting of the elements of $f_i$'s or one must find the form
$A'=QAP^{-1}$? If it is the last case, how I can find this form?
II. Find a base for the $\mathbb Z$-submodule of $\mathbb Z^{(3)}$
consisting of all $(x_1,x_2,x_3)$ satisfying the conditions
$x_1+2x_2+3x_3=0$, $x_1+4x_2+9x_3=0$.
How to handle this question?
mySQL Query Caching symfony
mySQL Query Caching symfony
How can i Cache MySQL Query 24 Hours in Text Files when using symfony ?
I dont want to Cache the Rest just MySQL , because of whitelabeling.
Is there any warpet Or Similar ?
I already Researched the Results on google but did Not find result.
How can i Cache MySQL Query 24 Hours in Text Files when using symfony ?
I dont want to Cache the Rest just MySQL , because of whitelabeling.
Is there any warpet Or Similar ?
I already Researched the Results on google but did Not find result.
Get value from url on post method mvc3
Get value from url on post method mvc3
I needed to get a data from the url on my post method. I have this routing
on my asax:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Then on my Home Controller, under Get:
[HttpGet]
public ActionResult Index()
{
var id = ControllerContext.RouteData.GetRequiredString("id");
}
And on Post:
[HttpPost]
public ActionResult SomeNewNameHere(HomeModel homeModel)
{
var id = ControllerContext.RouteData.GetRequiredString("id");
}
My problem here is I need that id from the url on my post method. By
debugging, I noticed that it gets the id on the get method, but when i
post it, it returns me a null resulting to an error. Anything I missed
here? Thanks!
Sample url:
http://localhost:1000/Controller/Action/12312121212
I needed to get a data from the url on my post method. I have this routing
on my asax:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Then on my Home Controller, under Get:
[HttpGet]
public ActionResult Index()
{
var id = ControllerContext.RouteData.GetRequiredString("id");
}
And on Post:
[HttpPost]
public ActionResult SomeNewNameHere(HomeModel homeModel)
{
var id = ControllerContext.RouteData.GetRequiredString("id");
}
My problem here is I need that id from the url on my post method. By
debugging, I noticed that it gets the id on the get method, but when i
post it, it returns me a null resulting to an error. Anything I missed
here? Thanks!
Sample url:
http://localhost:1000/Controller/Action/12312121212
Create a database for webapplication. keep primary key for tables mysql
Create a database for webapplication. keep primary key for tables mysql
I am developing a webapplication but I am pretty new to this. Basic idea:
user logs in and can input data through many different forms. Each form
should be connected to a user and catalogued by year and month.
Right now my db structure is:
core_user: id_user,username, password core_year: id_year, year core_month:
id_month, month ch: id_ch, many variables...
I would like to have columns in core_year, core_month and ch that register
id_user so that I can retrieve and store data for the user and by month
and year.
I've tryed with foreign keys but had no success. What I'd like to have:
task--> user registered--> unique primary key=id_user task--> year
registered--> unique primary key=id_year with with the id_user of the
session that is going on.
and so on..
Any suggestion?
Thank you so much for the help!
I am developing a webapplication but I am pretty new to this. Basic idea:
user logs in and can input data through many different forms. Each form
should be connected to a user and catalogued by year and month.
Right now my db structure is:
core_user: id_user,username, password core_year: id_year, year core_month:
id_month, month ch: id_ch, many variables...
I would like to have columns in core_year, core_month and ch that register
id_user so that I can retrieve and store data for the user and by month
and year.
I've tryed with foreign keys but had no success. What I'd like to have:
task--> user registered--> unique primary key=id_user task--> year
registered--> unique primary key=id_year with with the id_user of the
session that is going on.
and so on..
Any suggestion?
Thank you so much for the help!
Tuesday, 20 August 2013
Sitecore Reload the Content Editor
Sitecore Reload the Content Editor
In Sitecore, I am opening up a item in content editor using code and after
user has done some changes I want to reload the content editor. I am
trying to do this in Sitecore Item:Locked event handler and I am wondering
whether I can raise a Sitecore event so the content editor would reload.
In Sitecore, I am opening up a item in content editor using code and after
user has done some changes I want to reload the content editor. I am
trying to do this in Sitecore Item:Locked event handler and I am wondering
whether I can raise a Sitecore event so the content editor would reload.
Can typename be omitted in the type-specifier of an out of line member definition?
Can typename be omitted in the type-specifier of an out of line member
definition?
I ran into this strange behaviour when testing whether or not typename is
required by clang. Both clang and gcc accept this code while msvc rejects
it.
template<class T1>
struct A
{
template<class T2>
struct B
{
static B f;
static typename A<T2>::template B<T1> g;
};
};
template<class T1>
template<class T2>
typename A<T2>::template B<T1> // ok, typename/template required
A<T1>::B<T2>::g;
template<class T1>
template<class T2>
A<T1>::B<T2> // clang/gcc accept, msvc rejects missing typename
A<T1>::B<T2>::f;
In general, a qualified-id C<T>::M<U> (where C<T> is a dependent name)
should be written typename C<T>::template M<U>. Is the behaviour of
gcc/clang incorrect, or is there an exception to the general rule (quoted
below) in this particular case?
It could be argued that C<T> is not a dependent name, or that M<U> refers
to a member of the current instantiation. However, at the point of parsing
the type-specifier it's not possible to know that the current
instantiation is C<T>. It seems unfair to require the implementation to
guess that C<T> is the current instantiation.
14.6 Name resolution [temp.res]
A name used in a template declaration or definition and that is dependent
on a template-parameter is assumed not to name a type unless the
applicable name lookup finds a type name or the name is qualified by the
keyword typename.
14.2 Names of template specializations [temp.names]
When the name of a member template specialization appears after . or -> in
a postfix-expression or after a nested-name-specifier in a qualified-id,
and the object or pointer expression of the postfix-expression or the
nested-name-specifier in the qualified-id depends on a template parameter
(14.6.2) but does not refer to a member of the current instantiation
(14.6.2.1), the member template name must be prefixed by the keyword
template. Otherwise the name is assumed to name a non-template.
To further investigate what clang is doing here, I also tried this:
template<class T1>
struct C
{
template<class T2>
struct D
{
static typename A<T1>::template B<T2> f;
static typename A<T1>::template B<T2> g;
};
};
template<class T1>
template<class T2>
typename A<T1>::template B<T2> // ok, typename/template required
C<T1>::D<T2>::f;
template<class T1>
template<class T2>
A<T1>::B<T2> // clang rejects with incorrect error
C<T1>::D<T2>::g;
Clang gives error: redefinition of 'g' with a different type, but the type
of g actually matches the declaration.
I would instead expect to see a diagnostic suggesting the use of typename
or template.
This gives credit to the hypothesis that clang's behaviour in the first
example is unintended.
definition?
I ran into this strange behaviour when testing whether or not typename is
required by clang. Both clang and gcc accept this code while msvc rejects
it.
template<class T1>
struct A
{
template<class T2>
struct B
{
static B f;
static typename A<T2>::template B<T1> g;
};
};
template<class T1>
template<class T2>
typename A<T2>::template B<T1> // ok, typename/template required
A<T1>::B<T2>::g;
template<class T1>
template<class T2>
A<T1>::B<T2> // clang/gcc accept, msvc rejects missing typename
A<T1>::B<T2>::f;
In general, a qualified-id C<T>::M<U> (where C<T> is a dependent name)
should be written typename C<T>::template M<U>. Is the behaviour of
gcc/clang incorrect, or is there an exception to the general rule (quoted
below) in this particular case?
It could be argued that C<T> is not a dependent name, or that M<U> refers
to a member of the current instantiation. However, at the point of parsing
the type-specifier it's not possible to know that the current
instantiation is C<T>. It seems unfair to require the implementation to
guess that C<T> is the current instantiation.
14.6 Name resolution [temp.res]
A name used in a template declaration or definition and that is dependent
on a template-parameter is assumed not to name a type unless the
applicable name lookup finds a type name or the name is qualified by the
keyword typename.
14.2 Names of template specializations [temp.names]
When the name of a member template specialization appears after . or -> in
a postfix-expression or after a nested-name-specifier in a qualified-id,
and the object or pointer expression of the postfix-expression or the
nested-name-specifier in the qualified-id depends on a template parameter
(14.6.2) but does not refer to a member of the current instantiation
(14.6.2.1), the member template name must be prefixed by the keyword
template. Otherwise the name is assumed to name a non-template.
To further investigate what clang is doing here, I also tried this:
template<class T1>
struct C
{
template<class T2>
struct D
{
static typename A<T1>::template B<T2> f;
static typename A<T1>::template B<T2> g;
};
};
template<class T1>
template<class T2>
typename A<T1>::template B<T2> // ok, typename/template required
C<T1>::D<T2>::f;
template<class T1>
template<class T2>
A<T1>::B<T2> // clang rejects with incorrect error
C<T1>::D<T2>::g;
Clang gives error: redefinition of 'g' with a different type, but the type
of g actually matches the declaration.
I would instead expect to see a diagnostic suggesting the use of typename
or template.
This gives credit to the hypothesis that clang's behaviour in the first
example is unintended.
portfolio optimization sorting efficient solutions C#
portfolio optimization sorting efficient solutions C#
I have the following problem to solve:
Let H be a set of portfolios. For each portfolio i in H let (ri,vi) be the
(return,risk) values for this solution.
For each i in H if there exists j in H (j is different from i) such that
rj>=ri and vj<=vi then delete i from H. because i is dominated by j (it
has better return for less risk).
At the end H will be the set of undominated efficient solutions.
I tried to solve the above problem using linq:
H.RemoveAll(x => H.Any(y => x.CalculateReturn() <= y.CalculateReturn() &&
x.CalculateRisk() >= y.CalculateRisk() && x != y));
But I wonder if there exist a more efficient way, because if H.Count() is
of the order of ten thousands, then it takes a lot of time to remove the
dominated portfolios.
Thanks in advance for any help !
Christos
I have the following problem to solve:
Let H be a set of portfolios. For each portfolio i in H let (ri,vi) be the
(return,risk) values for this solution.
For each i in H if there exists j in H (j is different from i) such that
rj>=ri and vj<=vi then delete i from H. because i is dominated by j (it
has better return for less risk).
At the end H will be the set of undominated efficient solutions.
I tried to solve the above problem using linq:
H.RemoveAll(x => H.Any(y => x.CalculateReturn() <= y.CalculateReturn() &&
x.CalculateRisk() >= y.CalculateRisk() && x != y));
But I wonder if there exist a more efficient way, because if H.Count() is
of the order of ten thousands, then it takes a lot of time to remove the
dominated portfolios.
Thanks in advance for any help !
Christos
GitHub for Windows: Login Failed
GitHub for Windows: Login Failed
I was using the git-scm client for a long time now, and saw a GitHub for
Windows client. "Why not give it a try?"
I deleted git-scm with CCleaner and then installed this client. On the
login phase, it says: "Login failed. Unable to retreive your user info
from the server. A proxy server might be interfering with the request."
I don't use any proxy. What can be wrong?
Cheers, PathDevel
ADD: Oh, I forgot to say, I'm using Windows 8 x64
I was using the git-scm client for a long time now, and saw a GitHub for
Windows client. "Why not give it a try?"
I deleted git-scm with CCleaner and then installed this client. On the
login phase, it says: "Login failed. Unable to retreive your user info
from the server. A proxy server might be interfering with the request."
I don't use any proxy. What can be wrong?
Cheers, PathDevel
ADD: Oh, I forgot to say, I'm using Windows 8 x64
Should I use in-app purchases in this case?
Should I use in-app purchases in this case?
I want to develop application for some mobile network operators, that
allow to set music for ringback tone. In details, I download available
melodies list from operator, then when user selects necessary tune I call
operator API to set it for RBT. Pretty simple.
But I'm worried about one thing - user should be charged for this service.
Off course I'll notify user about it and clearly describe amount of
charge. Operator already has billing for this service so I can use it.
As I read in IAP guides, In-app purchases should be used only for digital
goods that will be used inside application ("Items can only be used in the
app where the purchase is made"). So here is my question, does it mean
that in my case I can use operator billing and I will not have problems
with application review?
I want to develop application for some mobile network operators, that
allow to set music for ringback tone. In details, I download available
melodies list from operator, then when user selects necessary tune I call
operator API to set it for RBT. Pretty simple.
But I'm worried about one thing - user should be charged for this service.
Off course I'll notify user about it and clearly describe amount of
charge. Operator already has billing for this service so I can use it.
As I read in IAP guides, In-app purchases should be used only for digital
goods that will be used inside application ("Items can only be used in the
app where the purchase is made"). So here is my question, does it mean
that in my case I can use operator billing and I will not have problems
with application review?
Monday, 19 August 2013
Is the case where the zeros of $f$ or $g$ are isolated possible?
Is the case where the zeros of $f$ or $g$ are isolated possible?
Let us consider the following equation in $\mathbb{C}$
$$f(s)g(s)=0$$
Assume that $f,g:\mathbb{C}¨\mathbb{R}$, then they are not analytic, but
they are probably continuous in some subdomains of $\mathbb{C}$.
My question is: Is the case where the zeros of $f$ or $g$ are isolated
possible?
If yes, then there is a contradiction since both functions are continuous
and one of these functions has a continuum of zeros.
Let us consider the following equation in $\mathbb{C}$
$$f(s)g(s)=0$$
Assume that $f,g:\mathbb{C}¨\mathbb{R}$, then they are not analytic, but
they are probably continuous in some subdomains of $\mathbb{C}$.
My question is: Is the case where the zeros of $f$ or $g$ are isolated
possible?
If yes, then there is a contradiction since both functions are continuous
and one of these functions has a continuum of zeros.
Tracing network RJ45 / RJ11 cable from user desk to patch panel backend
Tracing network RJ45 / RJ11 cable from user desk to patch panel backend
I am new to these kind of work and I don't have much experience in network
tracing. I have receive a new task which I was told to trace all patch
cable of RJ45/RJ11 from the phone panel @ user desk to patch panel
backend. Then I was told to produce a new updated layout of the patch
panel.
There's a lot of phones in that office from ground floor to 2nd floor. May
I hear your advice on how to do trace this patch cable?
thanks.
I am new to these kind of work and I don't have much experience in network
tracing. I have receive a new task which I was told to trace all patch
cable of RJ45/RJ11 from the phone panel @ user desk to patch panel
backend. Then I was told to produce a new updated layout of the patch
panel.
There's a lot of phones in that office from ground floor to 2nd floor. May
I hear your advice on how to do trace this patch cable?
thanks.
Cubic spline interpolant with not-a-knot end condition Algorithm
Cubic spline interpolant with not-a-knot end condition Algorithm
I'm trying to code an implemention of a Cubic spline interpolant with
not-a-knot end condition in C++.Does anyone have any recommendations on
sources for the algorithm? thank you
I'm trying to code an implemention of a Cubic spline interpolant with
not-a-knot end condition in C++.Does anyone have any recommendations on
sources for the algorithm? thank you
call javascript object properties
call javascript object properties
This is probably a very easy question but let's say I have a php
json_encoded javascript object of this form:
var js_objet = {
"1": {
"Users": {
"id": "14",
"name": "Peter"
},
"Children": [
{
id: 17,
name: "Paul"
},
{
id: 18,
name: "Mathew"
}
]
}
}
What is the synthax to get the name of the child with id 18 (Mathew) for
example from that Object?
Thank you
This is probably a very easy question but let's say I have a php
json_encoded javascript object of this form:
var js_objet = {
"1": {
"Users": {
"id": "14",
"name": "Peter"
},
"Children": [
{
id: 17,
name: "Paul"
},
{
id: 18,
name: "Mathew"
}
]
}
}
What is the synthax to get the name of the child with id 18 (Mathew) for
example from that Object?
Thank you
Widget Windows - consume Web Service REST with JSON response
Widget Windows - consume Web Service REST with JSON response
I implement a gadget windows and I can call a REST Web Service. I have
search on many topic in google and in stackoverflow, but I haven't fund
the solution of my problem.
I want to use an ajax call, but it doesn't work, the "$" isn't defined.
My code :
function callWebService(){
$.ajax({
type:"GET",
url:"url",
data:'arguments',
dataType:"json",
success : function(msg){
loadJSON(msg);
},
error: function(msg){
alert("Error : " + msg);
}
});
}
Thank you in advance
I implement a gadget windows and I can call a REST Web Service. I have
search on many topic in google and in stackoverflow, but I haven't fund
the solution of my problem.
I want to use an ajax call, but it doesn't work, the "$" isn't defined.
My code :
function callWebService(){
$.ajax({
type:"GET",
url:"url",
data:'arguments',
dataType:"json",
success : function(msg){
loadJSON(msg);
},
error: function(msg){
alert("Error : " + msg);
}
});
}
Thank you in advance
Sunday, 18 August 2013
Fade out multiple Bootstrap alerts
Fade out multiple Bootstrap alerts
I came across a question asking how to fade out Bootstrap alerts after 5
seconds, and the answer was the following code. The issue is, it only
works once, however as I have multiple alerts that are generated after an
AJAX call this is no good. How do I make the following code run every time
an alert is triggered?
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 5000);
I came across a question asking how to fade out Bootstrap alerts after 5
seconds, and the answer was the following code. The issue is, it only
works once, however as I have multiple alerts that are generated after an
AJAX call this is no good. How do I make the following code run every time
an alert is triggered?
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 5000);
Does it hurt to leave rot laying around?
Does it hurt to leave rot laying around?
In Don't Starve, does it hurt to let food rot on the ground? The wikia
says that pigs will eat it, does it hurt them? Are there any actual
negatives?
In Don't Starve, does it hurt to let food rot on the ground? The wikia
says that pigs will eat it, does it hurt them? Are there any actual
negatives?
Bash heredoc not working
Bash heredoc not working
I guess this is going to have a simple solution, which is why I'm not
seeing it.
My heredoc syntax is correct, so why does this...
echo<<HH
Usage:
procss [COMMAND]
Commands:
partial - Creates new partial in the working directory
dir - Creates new directory with required partials
HH
...only spit out a newline and leave?
[sage@ed procss]$ _procss_help
[sage@ed procss]$
I even backed out of the script and did it line by line.
[sage@ed procss]$ echo <<END
> Usage:
> procss [COMMAND]
>
> Commands:
> partial - Creates new partial in the working directory
> dir - Creates new directory with required partials
> END
[sage@ed procss]$
Not even this works.
[sage@ed procss]$ echo <<END
> Hello
> World
> END
[sage@ed procss]$
After double checking and triple checking the manual and SO, I'm sure I'm
not being tripped up by common whitespace related mistakes. There is no
trailing whitespace after the opening heredoc line, and no leading
whitespace before the ending line.
What's wrong?
I guess this is going to have a simple solution, which is why I'm not
seeing it.
My heredoc syntax is correct, so why does this...
echo<<HH
Usage:
procss [COMMAND]
Commands:
partial - Creates new partial in the working directory
dir - Creates new directory with required partials
HH
...only spit out a newline and leave?
[sage@ed procss]$ _procss_help
[sage@ed procss]$
I even backed out of the script and did it line by line.
[sage@ed procss]$ echo <<END
> Usage:
> procss [COMMAND]
>
> Commands:
> partial - Creates new partial in the working directory
> dir - Creates new directory with required partials
> END
[sage@ed procss]$
Not even this works.
[sage@ed procss]$ echo <<END
> Hello
> World
> END
[sage@ed procss]$
After double checking and triple checking the manual and SO, I'm sure I'm
not being tripped up by common whitespace related mistakes. There is no
trailing whitespace after the opening heredoc line, and no leading
whitespace before the ending line.
What's wrong?
What is the advantage of regular expression?
What is the advantage of regular expression?
The regular Expression of code
String inputOne = "cat cat cat cattie cat";
String findStr = "cat";
Pattern p = Pattern.compile("cat");
Matcher m = p.matcher(inputOne);
int countOne = 0;
while (m.find()) {
countOne++;
}
System.out.println("Match number " + countOne);
String comparison of code
String inpuTwo = "cat cat cat cattie cat";
int lastIndex = 0;
int count = 0;
while (lastIndex != -1) {
lastIndex = inpuTwo.indexOf("cat", lastIndex);
if (lastIndex != -1) {
count++;
lastIndex += findStr.length();
}
}
System.out.println("Match number " + countOne);
In both will do find the occurrences of substring "cat" in a input string
"cat cat cat cattie cat".
My questions is what is the difference between them?
What is the advantage in regular expression over string comparison.
Which one i should use for applications. regular expression or string
comparison?.
Thanks.
The regular Expression of code
String inputOne = "cat cat cat cattie cat";
String findStr = "cat";
Pattern p = Pattern.compile("cat");
Matcher m = p.matcher(inputOne);
int countOne = 0;
while (m.find()) {
countOne++;
}
System.out.println("Match number " + countOne);
String comparison of code
String inpuTwo = "cat cat cat cattie cat";
int lastIndex = 0;
int count = 0;
while (lastIndex != -1) {
lastIndex = inpuTwo.indexOf("cat", lastIndex);
if (lastIndex != -1) {
count++;
lastIndex += findStr.length();
}
}
System.out.println("Match number " + countOne);
In both will do find the occurrences of substring "cat" in a input string
"cat cat cat cattie cat".
My questions is what is the difference between them?
What is the advantage in regular expression over string comparison.
Which one i should use for applications. regular expression or string
comparison?.
Thanks.
How can I send a data field to a javascript function?
How can I send a data field to a javascript function?
I'm using kendo-ui grid.
My grid fill with ajax method.
No I have to pass primary key field value to a method as parameter.
I used a code same as this :
columns.Template(@<text></text>).ClientTemplate("#= renderNumber(data, <#=
UserId #>)#");
but my javascript methode doesnt fire.
But if I use this :
columns.Template(@<text></text>).ClientTemplate("#= renderNumber(data)#");
It will run. Actually without input parameter.
any idea ?
I'm using kendo-ui grid.
My grid fill with ajax method.
No I have to pass primary key field value to a method as parameter.
I used a code same as this :
columns.Template(@<text></text>).ClientTemplate("#= renderNumber(data, <#=
UserId #>)#");
but my javascript methode doesnt fire.
But if I use this :
columns.Template(@<text></text>).ClientTemplate("#= renderNumber(data)#");
It will run. Actually without input parameter.
any idea ?
How do you find out which packages installed has `apache2` as its dependency?
How do you find out which packages installed has `apache2` as its dependency?
When installing softwares like nginx on an Ubuntu 12.04 server, apache2
appears to be installed as one of the dependency which is not what we
need.
Question: How do you find out which packages installed has apache2 as its
dependency?
When installing softwares like nginx on an Ubuntu 12.04 server, apache2
appears to be installed as one of the dependency which is not what we
need.
Question: How do you find out which packages installed has apache2 as its
dependency?
Saturday, 17 August 2013
Java Generic Class
Java Generic Class
public interface EXPeekableQueue<E extends Comparable<E>>>{
public void enqueue(E e);
}
public interface EXammutableQueue<E>{
public EXammutableQueue<E> enqueue(E e);
public E peek();
}
What exactly do this Syntax means ? I am having trouble understanding Java
Generic class. Can someone send me a link to a good tutorial or pdf file ?
Thankyou!!
public interface EXPeekableQueue<E extends Comparable<E>>>{
public void enqueue(E e);
}
public interface EXammutableQueue<E>{
public EXammutableQueue<E> enqueue(E e);
public E peek();
}
What exactly do this Syntax means ? I am having trouble understanding Java
Generic class. Can someone send me a link to a good tutorial or pdf file ?
Thankyou!!
Images not uploading or being saved to database
Images not uploading or being saved to database
Summary: There are NO error messages, just no images are being uploaded,
and no values are being stored in post_image, post_image2, or post_image3.
So I have a site where members can post topics like a forum, I have added
the feature to upload image attachments with topics that display in the
view topic page as well as storing the image on the server as
"uploads/images/(username/".
I am trying to incorporate this into the posts section so users can post
images as responses, for for some reason I it is not storing or uploading
the images, here is the section of the page that makes replies.
<form method="post" action="add_reply.php" enctype="multipart/form-data">
<textarea name="post_content" cols="45" rows="3"
id="post_content"></textarea><br>
<input type="file" name="post_image" value="Browse"
accept="image/*">
<div id="toggleText" style="display: none">
<input type="file" name="post_image2" size="15px"
accept="image/*">
<br>
<input type="file" name="post_image3" size="15px"
accept="image/*">
</div>
<div id="more-less-images"><a id="displayText"
href="javascript:toggle();">More
images</a></div>
And here is the "add_reply.php" which processes it.
// get values that sent from form
$post_image = null;
//Get Timestamp to add in image name.
$date = new DateTime();
$timestamp = $date->getTimestamp();
//Check upload folder is created
if (!file_exists('uploads')) {
mkdir('uploads', 0777, true);
}
//Check user directory is created or not.
$user = $user_data['username'];
$uid = $_SESSION['user_id'];
if (!file_exists('uploads/images/' . $user)) {
mkdir('uploads/images/' . $user, 0777, true);
}
//Below Code will copy all three images to the Upload directory
and add path to the three variables.
$imageFile = null;
$imageFile2 = null;
$imagefile3 = null;
if (isset($_FILES['post_image']) && $_FILES['post_image']['size']
> 0) {
$info = pathinfo($_FILES['post_image']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."1." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image']['tmp_name'], $target);
$imageFile = $target;
}
if (isset($_FILES['post_image2']) &&
$_FILES['post_image2']['size'] > 0) {
$info = pathinfo($_FILES['post_image2']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."2." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image2']['tmp_name'], $target);
$imageFile2 = $target;
}
if (isset($_FILES['post_image3']) &&
$_FILES['post_image3']['size'] > 0) {
$info = pathinfo($_FILES['post_image3']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."3." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image3']['tmp_name'], $target);
$imageFile3 = $target;
}
$post_content = htmlspecialchars($_POST['post_content']);
$post_by = $_SESSION['user_id'];
$invisipost = isset($_POST['invisipost']) ? $_POST['invisipost'] : 0 ;
// Insert answer
$sql2="INSERT INTO `posts`(post_topic, post_content, post_image,
post_image2, post_image3, post_date, post_by, invisipost)VALUES('$id',
'$post_content',
'$imageFile','$imageFile2','$imageFile3',date_add(now(),INTERVAL 2 HOUR),
'$post_by', '$invisipost')";
$result2=mysql_query($sql2);
if($result2){
header("Location: view_topic.php?topic_id=$id");
Before anyone comments I am getting the whole site working first then
converting to MySQLi, Thanks for any advice.
This is my "add_topic.php" file, which successfully adds the images on
topics, just posts isn't working..
<?php
include 'core/init.php';
include 'includes/overall/header.php';
$tags = isset($_POST['tags']) ? $_POST['tags'] : null;
$topic_data = htmlentities($_POST['topic_data']);
if ($topic_data != "") {
if (mysql_num_rows(mysql_query("SELECT * FROM `topics` WHERE
`topic_data`='{$topic_data}'")) == 0) {
if (is_array($tags)) {
$image_attach = null;
//Get Timestamp to add in image name.
$date = new DateTime();
$timestamp = $date->getTimestamp();
//Check upload folder is created
if (!file_exists('uploads')) {
mkdir('uploads', 0777, true);
}
//Check user directory is created or not.
$user = $user_data['username'];
$uid = $_SESSION['user_id'];
if (!file_exists('uploads/images/' . $user)) {
mkdir('uploads/images/' . $user, 0777, true);
}
//Below Code will copy all three images to the Upload directory
and add path to the three variables.
$imageFile = null;
$imageFile2 = null;
$imagefile3 = null;
if (isset($_FILES['image_attach']) &&
$_FILES['image_attach']['size'] > 0) {
$info = pathinfo($_FILES['image_attach']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."1." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach']['tmp_name'], $target);
$imageFile = $target;
}
if (isset($_FILES['image_attach2']) &&
$_FILES['image_attach2']['size'] > 0) {
$info = pathinfo($_FILES['image_attach2']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."2." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach2']['tmp_name'],
$target);
$imageFile2 = $target;
}
if (isset($_FILES['image_attach3']) &&
$_FILES['image_attach3']['size'] > 0) {
$info = pathinfo($_FILES['image_attach3']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."3." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach3']['tmp_name'],
$target);
$imageFile3 = $target;
}
//insert the topic first
$topic_data = htmlentities($_POST['topic_data']);
$posted_by = $_SESSION['user_id'];
$invisipost = isset($_POST['invisipost']) ? $_POST['invisipost'] : 0;
mysql_query("INSERT INTO topics(topic_data, image_attach,
image_attach2, image_attach3, posted_by, posted, view, reply,
invisipost)VALUES('{$topic_data}', '$imageFile', '$imageFile2',
'$imageFile3', '{$posted_by}', date_add(now(),INTERVAL 2 HOUR),
'0', '0', '{$invisipost}')");
$inserted_topic_id = mysql_insert_id();
foreach ($tags as $t) {
if ($t != '') {
if (mysql_num_rows(mysql_query("SELECT * FROM `tags` WHERE
`tags`='{$t}'")) == 0) {
$sql = "INSERT INTO tags (tags) VALUES('$t')";
mysql_query($sql);
$inserted_tag_id = mysql_insert_id();
$sqla = "INSERT INTO topic_tags (topic_id, tag_id)
VALUES('$inserted_topic_id', '$inserted_tag_id')";
mysql_query($sqla);
} else {
$queryData = mysql_fetch_array(mysql_query("SELECT *
FROM tags WHERE tags='$t'"));
$tag_id = $queryData['tag_id'];
$sqlb = "INSERT INTO topic_tags (topic_id, tag_id)
VALUES('$inserted_topic_id', '$tag_id')";
mysql_query($sqlb);
}
}
}
header("Location: topics.php?tags={$t}");
} else {
echo 'Invalid tag';
}
} else {
echo "<h2>Opps...</h2><p>Topic already existing.</p>";
}
} else {
echo "<h2>Opps...</h2><p>You did not fill out all the required
fields.</p>";
}
mysql_close();
include 'includes/overall/footer.php';
?>
Summary: There are NO error messages, just no images are being uploaded,
and no values are being stored in post_image, post_image2, or post_image3.
So I have a site where members can post topics like a forum, I have added
the feature to upload image attachments with topics that display in the
view topic page as well as storing the image on the server as
"uploads/images/(username/".
I am trying to incorporate this into the posts section so users can post
images as responses, for for some reason I it is not storing or uploading
the images, here is the section of the page that makes replies.
<form method="post" action="add_reply.php" enctype="multipart/form-data">
<textarea name="post_content" cols="45" rows="3"
id="post_content"></textarea><br>
<input type="file" name="post_image" value="Browse"
accept="image/*">
<div id="toggleText" style="display: none">
<input type="file" name="post_image2" size="15px"
accept="image/*">
<br>
<input type="file" name="post_image3" size="15px"
accept="image/*">
</div>
<div id="more-less-images"><a id="displayText"
href="javascript:toggle();">More
images</a></div>
And here is the "add_reply.php" which processes it.
// get values that sent from form
$post_image = null;
//Get Timestamp to add in image name.
$date = new DateTime();
$timestamp = $date->getTimestamp();
//Check upload folder is created
if (!file_exists('uploads')) {
mkdir('uploads', 0777, true);
}
//Check user directory is created or not.
$user = $user_data['username'];
$uid = $_SESSION['user_id'];
if (!file_exists('uploads/images/' . $user)) {
mkdir('uploads/images/' . $user, 0777, true);
}
//Below Code will copy all three images to the Upload directory
and add path to the three variables.
$imageFile = null;
$imageFile2 = null;
$imagefile3 = null;
if (isset($_FILES['post_image']) && $_FILES['post_image']['size']
> 0) {
$info = pathinfo($_FILES['post_image']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."1." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image']['tmp_name'], $target);
$imageFile = $target;
}
if (isset($_FILES['post_image2']) &&
$_FILES['post_image2']['size'] > 0) {
$info = pathinfo($_FILES['post_image2']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."2." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image2']['tmp_name'], $target);
$imageFile2 = $target;
}
if (isset($_FILES['post_image3']) &&
$_FILES['post_image3']['size'] > 0) {
$info = pathinfo($_FILES['post_image3']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."3." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['post_image3']['tmp_name'], $target);
$imageFile3 = $target;
}
$post_content = htmlspecialchars($_POST['post_content']);
$post_by = $_SESSION['user_id'];
$invisipost = isset($_POST['invisipost']) ? $_POST['invisipost'] : 0 ;
// Insert answer
$sql2="INSERT INTO `posts`(post_topic, post_content, post_image,
post_image2, post_image3, post_date, post_by, invisipost)VALUES('$id',
'$post_content',
'$imageFile','$imageFile2','$imageFile3',date_add(now(),INTERVAL 2 HOUR),
'$post_by', '$invisipost')";
$result2=mysql_query($sql2);
if($result2){
header("Location: view_topic.php?topic_id=$id");
Before anyone comments I am getting the whole site working first then
converting to MySQLi, Thanks for any advice.
This is my "add_topic.php" file, which successfully adds the images on
topics, just posts isn't working..
<?php
include 'core/init.php';
include 'includes/overall/header.php';
$tags = isset($_POST['tags']) ? $_POST['tags'] : null;
$topic_data = htmlentities($_POST['topic_data']);
if ($topic_data != "") {
if (mysql_num_rows(mysql_query("SELECT * FROM `topics` WHERE
`topic_data`='{$topic_data}'")) == 0) {
if (is_array($tags)) {
$image_attach = null;
//Get Timestamp to add in image name.
$date = new DateTime();
$timestamp = $date->getTimestamp();
//Check upload folder is created
if (!file_exists('uploads')) {
mkdir('uploads', 0777, true);
}
//Check user directory is created or not.
$user = $user_data['username'];
$uid = $_SESSION['user_id'];
if (!file_exists('uploads/images/' . $user)) {
mkdir('uploads/images/' . $user, 0777, true);
}
//Below Code will copy all three images to the Upload directory
and add path to the three variables.
$imageFile = null;
$imageFile2 = null;
$imagefile3 = null;
if (isset($_FILES['image_attach']) &&
$_FILES['image_attach']['size'] > 0) {
$info = pathinfo($_FILES['image_attach']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."1." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach']['tmp_name'], $target);
$imageFile = $target;
}
if (isset($_FILES['image_attach2']) &&
$_FILES['image_attach2']['size'] > 0) {
$info = pathinfo($_FILES['image_attach2']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."2." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach2']['tmp_name'],
$target);
$imageFile2 = $target;
}
if (isset($_FILES['image_attach3']) &&
$_FILES['image_attach3']['size'] > 0) {
$info = pathinfo($_FILES['image_attach3']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $uid. $timestamp ."3." . $ext;
$target = 'uploads/images/' . $user . "/" . $newname;
move_uploaded_file($_FILES['image_attach3']['tmp_name'],
$target);
$imageFile3 = $target;
}
//insert the topic first
$topic_data = htmlentities($_POST['topic_data']);
$posted_by = $_SESSION['user_id'];
$invisipost = isset($_POST['invisipost']) ? $_POST['invisipost'] : 0;
mysql_query("INSERT INTO topics(topic_data, image_attach,
image_attach2, image_attach3, posted_by, posted, view, reply,
invisipost)VALUES('{$topic_data}', '$imageFile', '$imageFile2',
'$imageFile3', '{$posted_by}', date_add(now(),INTERVAL 2 HOUR),
'0', '0', '{$invisipost}')");
$inserted_topic_id = mysql_insert_id();
foreach ($tags as $t) {
if ($t != '') {
if (mysql_num_rows(mysql_query("SELECT * FROM `tags` WHERE
`tags`='{$t}'")) == 0) {
$sql = "INSERT INTO tags (tags) VALUES('$t')";
mysql_query($sql);
$inserted_tag_id = mysql_insert_id();
$sqla = "INSERT INTO topic_tags (topic_id, tag_id)
VALUES('$inserted_topic_id', '$inserted_tag_id')";
mysql_query($sqla);
} else {
$queryData = mysql_fetch_array(mysql_query("SELECT *
FROM tags WHERE tags='$t'"));
$tag_id = $queryData['tag_id'];
$sqlb = "INSERT INTO topic_tags (topic_id, tag_id)
VALUES('$inserted_topic_id', '$tag_id')";
mysql_query($sqlb);
}
}
}
header("Location: topics.php?tags={$t}");
} else {
echo 'Invalid tag';
}
} else {
echo "<h2>Opps...</h2><p>Topic already existing.</p>";
}
} else {
echo "<h2>Opps...</h2><p>You did not fill out all the required
fields.</p>";
}
mysql_close();
include 'includes/overall/footer.php';
?>
when LiVe Titans vs Bengals Live Stream Football Preseason Week 2
when LiVe Titans vs Bengals Live Stream Football Preseason Week 2
Viewers Welcome....! Welcome to watch Live Stream NFL Online Today. Enjoy
to watch live stream online National Football League. Stream coverage NFL
online tv,
[CLICK HERE TO WATCH NFL LIVE ONLINE][1]
Viewers Welcome....! Welcome to watch Live Stream NFL Online Today. Enjoy
to watch live stream online National Football League. Stream coverage NFL
online tv,
[CLICK HERE TO WATCH NFL LIVE ONLINE][1]
A phone call you ask your friend to make to you in middle of a date
A phone call you ask your friend to make to you in middle of a date
Is there a dedicated expression for a pre-arranged phone call you receive
to give you an opportunity to politely get out of a situation (e.g. a
dinner date)?
Is there a dedicated expression for a pre-arranged phone call you receive
to give you an opportunity to politely get out of a situation (e.g. a
dinner date)?
Use Handlebars to generate CSS?
Use Handlebars to generate CSS?
I'm wondering if Handlebars can be used like Liquid, to precompile and
generate dynamic CSS based on variables. I have tried the following code,
and it correctly outputs CSS, but as Handlebars is mainly targetted, is
there any drawbacks for this?
var template = Handlebars.compile("p + p { border-color: {{ borderColor }}
}");
var context = {borderColor: "#ffffff"};
var html = template(context);
Thanks
I'm wondering if Handlebars can be used like Liquid, to precompile and
generate dynamic CSS based on variables. I have tried the following code,
and it correctly outputs CSS, but as Handlebars is mainly targetted, is
there any drawbacks for this?
var template = Handlebars.compile("p + p { border-color: {{ borderColor }}
}");
var context = {borderColor: "#ffffff"};
var html = template(context);
Thanks
Android negative margin does not work
Android negative margin does not work
I have encountered a problem where i try to give a negative left margin to
LinearLayout. The negative margin does not appear. here is my code
HorizontalScrollView hview = new HorizontalScrollView(context); //
HorizontalScrollView is the outer view
RelativeLayout.LayoutParams hs_lot_params = new
RelativeLayout.LayoutParams(164, 164);
hs_lot_params.setMargins(100, 100, 0, 0); // set the positions
ImageView image = new ImageView(context);
image.setBackgroundResource(R.drawable.leder);
LinearLayout.LayoutParams img_lot_params = new
LinearLayout.LayoutParams(164, 164);
img_lot_params.setMargins(0, 0, 0, 0);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(164, 164);
layoutParams.setMargins(-132, 0, 0, 0);
ll.addView(image, img_lot_params);
hview.addView(ll, layoutParams);
Note: my plan is to scroll the image from left to right. First, the left
part of the image is hidden and can scroll to right to see full image
I have encountered a problem where i try to give a negative left margin to
LinearLayout. The negative margin does not appear. here is my code
HorizontalScrollView hview = new HorizontalScrollView(context); //
HorizontalScrollView is the outer view
RelativeLayout.LayoutParams hs_lot_params = new
RelativeLayout.LayoutParams(164, 164);
hs_lot_params.setMargins(100, 100, 0, 0); // set the positions
ImageView image = new ImageView(context);
image.setBackgroundResource(R.drawable.leder);
LinearLayout.LayoutParams img_lot_params = new
LinearLayout.LayoutParams(164, 164);
img_lot_params.setMargins(0, 0, 0, 0);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams layoutParams = new
LinearLayout.LayoutParams(164, 164);
layoutParams.setMargins(-132, 0, 0, 0);
ll.addView(image, img_lot_params);
hview.addView(ll, layoutParams);
Note: my plan is to scroll the image from left to right. First, the left
part of the image is hidden and can scroll to right to see full image
How do I backup a windows azure virtual machine?
How do I backup a windows azure virtual machine?
How do I backup a windows azure virtual machine? I would like to schedule
daily backups of system state that could be restored if needed. Data can
be backed via Azure Backup, but not system it seems.
How do I backup a windows azure virtual machine? I would like to schedule
daily backups of system state that could be restored if needed. Data can
be backed via Azure Backup, but not system it seems.
Friday, 16 August 2013
Dirac Delta Measure
Dirac Delta Measure
I have a question about the Dirac delta measure. Does the "sifting"
property hold at the limits of integration? That is, does
$\int_{[a,b]}f(x)\delta_b(dx)=f(b)$?
Thanks...
I have a question about the Dirac delta measure. Does the "sifting"
property hold at the limits of integration? That is, does
$\int_{[a,b]}f(x)\delta_b(dx)=f(b)$?
Thanks...
Saturday, 10 August 2013
IndexOutOfBoundsException not making sense to me
IndexOutOfBoundsException not making sense to me
I have an IndexOutOfBoundsException, but I am protecting the call with
finish() which should exit the Activity in Android! Should I be using an
else statement?
if (mIndex >= mQidList.size()) {
closeDB();
finish();
}
mQidList.get(mIndex);
I have an IndexOutOfBoundsException, but I am protecting the call with
finish() which should exit the Activity in Android! Should I be using an
else statement?
if (mIndex >= mQidList.size()) {
closeDB();
finish();
}
mQidList.get(mIndex);
Select environment in Laravel 4 using .htaccess
Select environment in Laravel 4 using .htaccess
I have a site that is in the testing phase, so it connects not to the real
data but to a local copy of a database.
My customer needs now a fast link to retrieve some urgent and important
pdf reports, so I need to set up another version of the site that links to
the "real data".
I can create two environments ("local" and "real") with different database
connections, and I would like to give the opportunity to select the
environment via the URL (I know it's not pretty from a security point of
view, but let's take this for granted).
So I would like to use:
my.ip.address/mysite to use the test db
my.ip.address/mysite/real to usew the real db, redirecting to the URLs
without the "real folders".
F.ex.: /mysite/real/admin shoud redirect to /mysite/admin but selecting
the "real" environment on Laravel 4.
1) is it possible to pattern-match also folders in Laravel 4 or is it
possible only for domains? In other words, does this work?
$env = $app->detectEnvironment(array(
'test' => array('*/mysite/*'),
'real' => array('*/mysite/real/*'),
));
2) if so, I just can't figure out how to write the .htaccess rule, I've tried
RewriteRule ^/real(.*)$ $1
but it won't work.
I have a site that is in the testing phase, so it connects not to the real
data but to a local copy of a database.
My customer needs now a fast link to retrieve some urgent and important
pdf reports, so I need to set up another version of the site that links to
the "real data".
I can create two environments ("local" and "real") with different database
connections, and I would like to give the opportunity to select the
environment via the URL (I know it's not pretty from a security point of
view, but let's take this for granted).
So I would like to use:
my.ip.address/mysite to use the test db
my.ip.address/mysite/real to usew the real db, redirecting to the URLs
without the "real folders".
F.ex.: /mysite/real/admin shoud redirect to /mysite/admin but selecting
the "real" environment on Laravel 4.
1) is it possible to pattern-match also folders in Laravel 4 or is it
possible only for domains? In other words, does this work?
$env = $app->detectEnvironment(array(
'test' => array('*/mysite/*'),
'real' => array('*/mysite/real/*'),
));
2) if so, I just can't figure out how to write the .htaccess rule, I've tried
RewriteRule ^/real(.*)$ $1
but it won't work.
Are we supposed to change strings.xml on java for android?
Are we supposed to change strings.xml on java for android?
I was just wondering if I was right when modifying strings.xml ? Thanks
I was just wondering if I was right when modifying strings.xml ? Thanks
Friday, 9 August 2013
CSS Styles to only One Class
CSS Styles to only One Class
Using Zurb's Foundation, I'm attempting to add my own styles to the
navbar, which is working great. Unfortunately, Zurb's responsive navbar
changes its look when the viewing container becomes smaller. When it does
this, it adds a second class to the nav element.
Before responsive change:
<nav class="top-bar">
After responsive change:
<nav class="top-bar expanded">
My custom styles look terrible for this expanded navbar, and I was
wondering if there was a way to only apply styles when an element
contained solely 1 class and not multiple. I know it's very easy to only
apply styles when an element has two or more classes, but can you exclude
one?
Thanks!
Using Zurb's Foundation, I'm attempting to add my own styles to the
navbar, which is working great. Unfortunately, Zurb's responsive navbar
changes its look when the viewing container becomes smaller. When it does
this, it adds a second class to the nav element.
Before responsive change:
<nav class="top-bar">
After responsive change:
<nav class="top-bar expanded">
My custom styles look terrible for this expanded navbar, and I was
wondering if there was a way to only apply styles when an element
contained solely 1 class and not multiple. I know it's very easy to only
apply styles when an element has two or more classes, but can you exclude
one?
Thanks!
Delivery reporting for RabbitMQ STOMP producer?
Delivery reporting for RabbitMQ STOMP producer?
I am trying to find out if it is possible for a STOMP producer to receive
"delivered to Consumer" delivery reports for messages sent to queues?
I know the producer can receive receipts from the broker by indicating
persistence:true in the SEND frame as shown on rabbitmq website:
"Receipts for SEND frames with persistent:true are not sent until a
confirm is received from the broker." -
https://www.rabbitmq.com/stomp.html
At the consumer end it is possible to indicate to the broker that a
message is successfully delivered to the consumer only on receipt of an
ACK by adding "ack: 'client'" to the SEND frame.
However, I've not found a method for end to end delivery receipts or
perhaps I've misunderstood the references? Grateful for any pointers. :)
I am trying to find out if it is possible for a STOMP producer to receive
"delivered to Consumer" delivery reports for messages sent to queues?
I know the producer can receive receipts from the broker by indicating
persistence:true in the SEND frame as shown on rabbitmq website:
"Receipts for SEND frames with persistent:true are not sent until a
confirm is received from the broker." -
https://www.rabbitmq.com/stomp.html
At the consumer end it is possible to indicate to the broker that a
message is successfully delivered to the consumer only on receipt of an
ACK by adding "ack: 'client'" to the SEND frame.
However, I've not found a method for end to end delivery receipts or
perhaps I've misunderstood the references? Grateful for any pointers. :)
Why doesn't boot-repair delete bios_grub partition after installing grub-efi?
Why doesn't boot-repair delete bios_grub partition after installing grub-efi?
Have been working on building a multi boot system using EFI. This EFI
capable system can not boot Ubuntu or any other installation media using
EFI with the only exception being Windows installation media. Most distros
appear to be using grub for their boot manager and boot loader so trying
different distros and tools such as Parted Magic and Boot Repair give same
results when trying to boot EFI mode in order for an EFI install to be
done.
What happens when trying to boot media EFI mode is if EFI grub manager
loads (black screen) and if any choice is selected (Try Ubuntu, Install
Ubuntu or Verify) get error can not read disk and the kernel needs to be
loaded first). There appears to be no explanation online (that i have
found so far) that goes anywhere near describing how and why this happens.
The accepted way of installing Ubuntu to an EFI system is apparently
switch off EFI and install in legacy mode which involves creating a
bios-grub partition before commencing or let boot-repair to do the fix
after installing Ubuntu in legacy mode. Boot Repair detects EFI system and
creates the bios_grub partition and installs grub-efi.
So after getting Ubuntu and Windows booting using EFI i noticed the
grub_bios partition was still in existence so i removed it with gdisk and
still have Windows and Ubuntu booting.
Why doesn't boot-repair delete bios_grub partition after installing grub-efi?
Have been working on building a multi boot system using EFI. This EFI
capable system can not boot Ubuntu or any other installation media using
EFI with the only exception being Windows installation media. Most distros
appear to be using grub for their boot manager and boot loader so trying
different distros and tools such as Parted Magic and Boot Repair give same
results when trying to boot EFI mode in order for an EFI install to be
done.
What happens when trying to boot media EFI mode is if EFI grub manager
loads (black screen) and if any choice is selected (Try Ubuntu, Install
Ubuntu or Verify) get error can not read disk and the kernel needs to be
loaded first). There appears to be no explanation online (that i have
found so far) that goes anywhere near describing how and why this happens.
The accepted way of installing Ubuntu to an EFI system is apparently
switch off EFI and install in legacy mode which involves creating a
bios-grub partition before commencing or let boot-repair to do the fix
after installing Ubuntu in legacy mode. Boot Repair detects EFI system and
creates the bios_grub partition and installs grub-efi.
So after getting Ubuntu and Windows booting using EFI i noticed the
grub_bios partition was still in existence so i removed it with gdisk and
still have Windows and Ubuntu booting.
Why doesn't boot-repair delete bios_grub partition after installing grub-efi?
limits that are set in an unmodified environment
limits that are set in an unmodified environment
If /etc/security/limits.conf has not been edited or changed, there are
nothing but comments. However 'cat /proc/self/limits' shows there are some
limits in effect. Are these compiled into the kernel? If no where does the
system get the initial default limits in an unmodified environment?
[~]$ cat /proc/self/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 10485760 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 1024 60413 processes
Max open files 1024 4096 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 60413 60413 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
If /etc/security/limits.conf has not been edited or changed, there are
nothing but comments. However 'cat /proc/self/limits' shows there are some
limits in effect. Are these compiled into the kernel? If no where does the
system get the initial default limits in an unmodified environment?
[~]$ cat /proc/self/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 10485760 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 1024 60413 processes
Max open files 1024 4096 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 60413 60413 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
How to perform the reverse of `xargs`?
How to perform the reverse of `xargs`?
I have a list of numbers that I want to reverse.
They are already sorted.
35 53 102 342
I want this:
342 102 53 35
So I thought of this:
echo $NUMBERS | ??? | tac | xargs
What's the ???
It should turn a space separated list into a line separated list.
I'd like to avoid having to set IFS.
Maybe I can use bash arrays, but I was hoping there's a command whose
purpose in life is to do the opposite of xargs (maybe xargs is more than a
one trick pony as well!!)
I have a list of numbers that I want to reverse.
They are already sorted.
35 53 102 342
I want this:
342 102 53 35
So I thought of this:
echo $NUMBERS | ??? | tac | xargs
What's the ???
It should turn a space separated list into a line separated list.
I'd like to avoid having to set IFS.
Maybe I can use bash arrays, but I was hoping there's a command whose
purpose in life is to do the opposite of xargs (maybe xargs is more than a
one trick pony as well!!)
possSuperiors - why does AD have it, but not openldap
possSuperiors - why does AD have it, but not openldap
Having used openldap and now getting to know MS active directory (AD), I
realize that in AD there is an attribute called "possSuperios", which
defines which objects are allowed as parent objects. Afaik this is not
present in openldap. (How is decided which objects are allowed as parents
in openldap?)
Can anyone shed some light on this design decision? Does having
possSuperios make AD more rubobst? Or more flexible? I am just curious
about why one would choose to do it this or the other way.
Having used openldap and now getting to know MS active directory (AD), I
realize that in AD there is an attribute called "possSuperios", which
defines which objects are allowed as parent objects. Afaik this is not
present in openldap. (How is decided which objects are allowed as parents
in openldap?)
Can anyone shed some light on this design decision? Does having
possSuperios make AD more rubobst? Or more flexible? I am just curious
about why one would choose to do it this or the other way.
jQuery change text on toggle
jQuery change text on toggle
Below I'm trying to use jQuery to open and close a pane, but I'd also like
to use jQuery to toggle the text too. Could someone assist in helping me
rename .chatstatus to either open or close when its toggled?
$('.chatstatus').click(function(){
$('.mChatBodyFix').slideToggle(500);
$.cookie('chatPane', $.cookie('chatPane')=='open'?"closed":"open",
{expires:1});
var chatstatustext = $('.chatstatus').text();
$('.chatstatus').html() == chatstatustext?"close":"open";
});
Below I'm trying to use jQuery to open and close a pane, but I'd also like
to use jQuery to toggle the text too. Could someone assist in helping me
rename .chatstatus to either open or close when its toggled?
$('.chatstatus').click(function(){
$('.mChatBodyFix').slideToggle(500);
$.cookie('chatPane', $.cookie('chatPane')=='open'?"closed":"open",
{expires:1});
var chatstatustext = $('.chatstatus').text();
$('.chatstatus').html() == chatstatustext?"close":"open";
});
Java Reference Assigned
Java Reference Assigned
class ClassA {}
class ClassB extends ClassA {}
class ClassC extends ClassA {}
and
ClassA p0 = new ClassA();
ClassB p1 = new ClassB();
ClassC p2 = new ClassC();
ClassA p3 = new ClassB();
ClassA p4 = new ClassC();
p0 = p1 works
But, p1 = p2 fails compilation....
Could not figure out why is this behavior when the hierarchy is same in
both the statements? A --> B --> C
class ClassA {}
class ClassB extends ClassA {}
class ClassC extends ClassA {}
and
ClassA p0 = new ClassA();
ClassB p1 = new ClassB();
ClassC p2 = new ClassC();
ClassA p3 = new ClassB();
ClassA p4 = new ClassC();
p0 = p1 works
But, p1 = p2 fails compilation....
Could not figure out why is this behavior when the hierarchy is same in
both the statements? A --> B --> C
Thursday, 8 August 2013
To document.getElementById('x').style.height+14
To document.getElementById('x').style.height+14
css
#x{height:100px;}
js
document.getElementById('x').onkeydown=function(){ if(event.keyCode ==
13){ var h = Number(this.style.height);this.style.height = h+14+'px'; }};
document.getElementById('x').style.height+14 ¢¸ What should I do?
help me
css
#x{height:100px;}
js
document.getElementById('x').onkeydown=function(){ if(event.keyCode ==
13){ var h = Number(this.style.height);this.style.height = h+14+'px'; }};
document.getElementById('x').style.height+14 ¢¸ What should I do?
help me
Media Events Not Working in Safari/Chrome
Media Events Not Working in Safari/Chrome
I've got an alert that pops up when the video on said page plays and
finishes. Any reason why this is no longer working in Safari/Chrome? It
was working as recently as about 2 months ago.
$(document).ready( function() {
var v = document.getElementsByTagName("video")[0];
v.addEventListener("playing", function() {
alert("Video has started");
});
v.addEventListener("ended", function() {
alert("Video has ended");
});
});
Still works perfectly fine in Firefox.
Any help is appreciated. Thanks in advance.
I've got an alert that pops up when the video on said page plays and
finishes. Any reason why this is no longer working in Safari/Chrome? It
was working as recently as about 2 months ago.
$(document).ready( function() {
var v = document.getElementsByTagName("video")[0];
v.addEventListener("playing", function() {
alert("Video has started");
});
v.addEventListener("ended", function() {
alert("Video has ended");
});
});
Still works perfectly fine in Firefox.
Any help is appreciated. Thanks in advance.
php if file exists include file if not include another file
php if file exists include file if not include another file
I am trying to include a file if it exists, if the file doesn't exist i
would like it to include another file instead.
I have the following code which seems to work correctly, The only problem
with my code is if the file does exist then it displays them both.
I would like to only include
include/article.php
if
include/'.$future.'.php
doesn't exist.
if
include/'.$future.'.php
exists i don't want to include
include/article.php
<?php
$page = $_GET['include'];
if (file_exists('include/'.$future.'.php')){
include('include/'.$future.'.php');
}
else{
include('include/article.php');
}
?>
I am trying to include a file if it exists, if the file doesn't exist i
would like it to include another file instead.
I have the following code which seems to work correctly, The only problem
with my code is if the file does exist then it displays them both.
I would like to only include
include/article.php
if
include/'.$future.'.php
doesn't exist.
if
include/'.$future.'.php
exists i don't want to include
include/article.php
<?php
$page = $_GET['include'];
if (file_exists('include/'.$future.'.php')){
include('include/'.$future.'.php');
}
else{
include('include/article.php');
}
?>
Subscribe to:
Comments (Atom)