Thursday, 3 October 2013

How to copy only the newest sub directory to a destination linux shell script

How to copy only the newest sub directory to a destination linux shell script

I have a parent folder where every day a new subdirectory is automatically
created. The subdirectory naming format is '2013-10-02T1430+0000'. Later
on today the new subdirectory created will be named
''2013-10-03T1430+0000'.
I need a script which will on a schedule automatically copy only the
contents of the latest subdirectory created to another folder.
I have the cp command down ok but I need to somehow subsitute in the cp
source the latest subdirectory name. After doing some research I found the
following command will return the latest or newest subdirectory. ls -tr
ParentFolder | tail -1. How do I get the result of this command to be
placed into the cp command? Is there an easier way of doing this?
Many thanks to all in advance.

Wednesday, 2 October 2013

ruby refactor redundant code block

ruby refactor redundant code block

I have some pretty straight-forward ruby logic below. I was wondering if
there was any way to make it more DRY, or perhaps if there was a more ruby
way to do this.
if @status == :status1
text.each_slice(3) do |x|
x.flatten!
row = Array.new
row << x[0...num].join(' ')
num.upto(-1) { |i| row << x[i] }
table << row
end
elsif @status == :status2
text.each do |x|
row = Array.new
row << x[0...num].join(' ')
num.upto(-1) { |i| row << x[i] }
table << row
end
end

WiX 3.7: How to add or update a dialog during uninstall?

WiX 3.7: How to add or update a dialog during uninstall?

I need to add a dialog box that would pop up during complete uninstall
(not major upgrade) right after the confirmation ("Are you sure you want
to uninstall this product?") dialog. This dialog would prompt the user to
answer a question and based on the response, set up a property that would
be used in the condition for the RemoveRegistryKey element (i.e. it will
remove a registry key only if the user selects an option to delete the
key).
I have an idea how to add a dialog to the install sequence (I am using a
modified WixUI_InstalLDir sequence to which I added a custom dialog I need
during installation), but I can't find any references that would explain
how to add a custom dialog to an uninstall sequence. It would be even
better if I could modify the uninstall confirmation dialog, so the user
would see one dialog instead of two. An the key thing would be to be able
to set up a property that could be used in the component condition.
Is this possible? Are there any examples how to do this?

Can't modify Site.Master in asp.net

Can't modify Site.Master in asp.net

I am new to .net technology and I have got one project to update some
minor changes.
I just need to add some links to site.Master page and I am not able to
change its code. It seems like I can add a new link if I change the page
to design view but the change does not reflect in source view.
I am using visual studio 2010
Please help and let me know if you need more information

how to virtualize an application (not desktop) in a cloud

how to virtualize an application (not desktop) in a cloud

How can I build a system that runs an application in a cloud so that I see
the application front-end (not the desktop) in a browser?
In other words, I am aware that Vmware or Virtualbox virtualize a complete
SO. But what technology exists to lauch in the virtualized SO an
application, and view the application from a browser? Notice that only the
application must be been in the browser, not the desktop.
(in case this question is more appropiate in another stack site, please
let me know)

Tuesday, 1 October 2013

For transverse maps, $T_x(f^{-1}(Z)=df^{-1}_x(T_{f(x)}(Z))$

For transverse maps, $T_x(f^{-1}(Z)=df^{-1}_x(T_{f(x)}(Z))$

Let $f: X \to Y$ be a map transversal to a submanifold $Z$ in $Y$. Then $W
= f^{-1}(Z)$ is a submanifold of $X$. Prove that $T_x(W)$ is the preimage
of $T_{f(x)}(Z)$ under the linear map $df_x:T_x(X) \to T_{f(x)}(Y)$. the
linear map $df_x:T_x(X)¨T_{f(x)}(Y)$.
My approach to the problem was to create parametrizations, $\phi$ and
$\psi$ of neighborhoods of $f(x)$ and $x$ (choosing all of Euclidean space
as the domain. We then take $y\in T_x(f^{-1}(Z)$ and note that there is
$v$ such that $y=d\psi_x(v)$. Now let $\pi$ as either the submersion or
embedding of the two Euclidean spaces we are mapping from. Then
$df^{-1}_x(d\phi_{f(x)}(d\pi(v))=d\psi_x(v)=y$ by the chain rule so $y\in
df^{-1}_x(T_{f(x)}(Z))$.
I do the other side mutatis mutandis.
Does this actually work, or have I made a critical error? (I'm personally
leaning toward the second)
If anyone could give some tips, I would appreciate it.

iOS 6 Modal Segue as Form Sheet Close Previous Modal

iOS 6 Modal Segue as Form Sheet Close Previous Modal

I'm working on iOS6 with storyboards.
I have a button and on tapping it, there's a Modal Segue (with
Presentation as Form Sheet). The problem I'm facing is the ViewController
where we have the button is also a Modal (again presentation as Form
Sheet). When I dismiss the last Modal the previous one is still being
shown.
I'm attempting to dismiss all using:
[self dismissViewControllerAnimated:YES completion:nil];
which clearly doesn't work. Any advice please.
Thanks.

Exit vim more quickly – unix.stackexchange.com

Exit vim more quickly – unix.stackexchange.com

I use Vim mainly for quick edits rather than long work sessions. In that
sense, I find the keyboard sequence for quitting especially laborious:
Esc, Shift: wq Enter. How to quit Vim (possibly saving …

Issues installing MySQL server on Ubuntu 13.04

Issues installing MySQL server on Ubuntu 13.04

I'm currently trying to install a MySQL server on my Ubuntu 13.04 machine.
The problem is, when I try to install it, I get error messages indicating
that not all packages could be downloaded. When I run sudo apt-get install
mysql-server, and after hanging for a while at reading headers, the
console reads as follows:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client-5.5
mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client-5.5
mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 12 newly installed, 0 to remove and 3 not upgraded.
Need to get 8,077 kB/24.5 MB of archives.
After this operation, 84.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err http://us.archive.ubuntu.com/ubuntu/ raring-updates/main
mysql-client-5.5 i386 5.5.32-0ubuntu0.13.04.1
Connection failed [IP: 91.189.91.13 80]
Err http://security.ubuntu.com/ubuntu/ raring-security/main
mysql-client-5.5 i386 5.5.32-0ubuntu0.13.04.1
Connection failed [IP: 91.189.92.190 80]
Failed to fetch
http://security.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-client-5.5_5.5.32-0ubuntu0.13.04.1_i386.deb
Connection failed [IP: 91.189.92.190 80]
E: Unable to fetch some archives, maybe run apt-get update or try with
--fix-missing?
I've tried the suggested fix or running apt-get update and such, I've made
sure I have no connections blocked, I've restarted, uninstalled,
reinstalled, etc, all to no avail. I've been searching the web all day for
solutions I haven't yet tried, but most people with this issue are running
an older version of Ubuntu. (By the way, I did try the solution here)
Suggestions?

Monday, 30 September 2013

finding number of unique outcomes of round-robin tournament with cycle

finding number of unique outcomes of round-robin tournament with cycle

A round robin tournament is a tournament where each player plays other
player once and there is no draw. If a team wins against all other then it
is called Total Winner. Similarly we define Total Looser as a team which
looses all matches.
EDITED::
Let us define order by win/loss. If $A$ wins $B$ and $B$ wins $C$ then it
is ordered as $\dots >A>B>C>\dots$
Consider $n\ge 3 $ teams, $\frac{n(n-1)}{2}$ games are played and
$2^{\frac{n(n-1)}{2}}$ unique results might be possible. Out of those
$2^{\frac{n(n-1)}{2}}$ possible results, how many unique outcomes are
there such that we can order every player (only once) such that it forms a
cycle. i.e. $$P_1 > P_2 > P_2 > \dots > P_n > P_1$$
Some of my thoughts:: There cannot be cycle if there is Total Winner or
Total Looser. I found (by using Principle of Inclusion Exclusion) out
there exists
$$2^{\frac{n(n-1)}{2}}-(2n)2^{\frac{(n-1)(n-2)}{2}}+n(n-1)2^{\frac{(n-3)(n-2)}{2}}$$
possible results of the tournament where there is no Total Winner or no
Total looser.
ADDED:: I wrote a short script for total matches outcomes and outcomes
with no total winner or looser. But couldn't write more to detect cycles.
For $n=3$ & $n=4$, all matches where there is no total winner or total
looser have some sort of cycles.
ADDED::
Here is updated code. If three players played game, player $(1), (2)$, and
$(3)$ the outcomes are
[(1, 2), (1, 3), (2, 3)] $ \leftarrow (1)$ is total winner so there can't
be cycle.
[(1, 2), (1, 3), (3, 2)]
[(1, 2), (3, 1), (2, 3)]
[(1, 2), (3, 1), (3, 2)]
[(2, 1), (1, 3), (2, 3)]
[(2, 1), (1, 3), (3, 2)]
[(2, 1), (3, 1), (2, 3)]
[(2, 1), (3, 1), (3, 2)]
Here, $(1,2)$ means match was played by $(1)$ and $(2)$ and $(1)$ won the
game.
The following forms a cycle (also it is the only outcome where there are
no total winner and total looser)
[(1, 2), (3, 1), (2, 3)] $ \implies 1>2>3>1$
[(2, 1), (1, 3), (3, 2)] $\implies 1>3>2>1$
Thanks you in advance.

Zabbix: Nagios like hosts/services status list

Zabbix: Nagios like hosts/services status list

How can I have a screen or view in Zabbix where I can see all or all
problematic services/hosts in a status list like the one in Nagios?
Below a screenshot of Nagios problematic services status list for those
who are not familiar with Nagios.
I have looked high and low (manual, google, forums, faqs), but could not
find one. Overview is overwhelming, dashboard widgets gave only summaries,
triggers are not grouped by hosts, and also overwhelming, when there's an
issue.
Performance and graphing is really astonishing in Zabbix, but these status
pages are killer features for me.

php traverse object using varriables for property names

php traverse object using varriables for property names

I have a case where I may recive one of two json objects, in this case
from either the google geocode api, or the places api.
Acccessing values from the geocoding api it will look like this:
$coordinates = $data->results[0]->geometry->location;
$cache_value['lat'] = (string) $coordinates->lat;
$cache_value['lng'] = (string) $coordinates->lng;
and an almost identical structure for places.
$coordinates = $data->result->geometry->location;
$cache_value['lat'] = (string) $coordinates->lat;
$cache_value['lng'] = (string) $coordinates->lng;
In my code I've two functions to handle each case, but they are almost
idential with the exception of the result vs results[0] and I'd like to
combine them. I've tried to passing a varriable but it throws errors:
$result = ($place) ? 'result' : 'results[0];
$coordinates = $data->$result->geometry->location;
Gives the following:
Notice: Undefined property: stdClass::$result[0]
I'd like to know the correct syntax to achive what im after, and any
pointers on nominclature, as Im afraid this question title is a bit
inpercise.

Maintaining position of visitor with js/html?

Maintaining position of visitor with js/html?

I've noticed on a quite few sites, that you have the main content in the
center, and on each side there is a bar with php links. And when you click
on the links, it will not get me to the top of the page again, but it will
remember my position on the site. I wonder how to do that, I heard you can
do that with jquery easily, but I have no idea how. With HTML as far as I
know you can only make an anchor internally, but not externally to other
pages. Thanks a lot.

Sunday, 29 September 2013

Pool Recycling error 2 sprites collides at the same time to a sprite

Pool Recycling error 2 sprites collides at the same time to a sprite

I have a shooting game where, you shoot two bullets at the opposite
direction, so happens that if an enemy gets close to the starting point of
the bullet(enemy is in the area of the bullet starting point) a error
happens,
here is my code:
if((_target.collidesWith(bullet))){
resourcesManager.enemyPool.recyclePoolItem(_target);
targets.remove();
score=score+1;
}
if((_target.collidesWith(bullet2))){
resourcesManager.enemyPool.recyclePoolItem(_target);
targets.remove();
score=score+1;
break;
}
Error Log:
09-30 09:47:23.530: E/AndroidRuntime(1167): in writeCrashedAppName,
pkgName :com.www.tangent
09-30 09:47:23.550: I/Process(1167): Sending signal. PID: 1167 SIG: 9
09-30 09:47:23.550: E/AndroidRuntime(1167): FATAL EXCEPTION: UpdateThread
09-30 09:47:23.550: E/AndroidRuntime(1167): java.lang.IllegalStateException
09-30 09:47:23.550: E/AndroidRuntime(1167): at
java.util.LinkedList$LinkIterator.remove(LinkedList.java:164)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
com.www.scene.WeaponSelectScene$1.onUpdate(WeaponSelectScene.java:318)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.entity.Entity.onManagedUpdate(Entity.java:1395)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.entity.scene.Scene.onManagedUpdate(Scene.java:284)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.entity.Entity.onUpdate(Entity.java:1167)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.entity.scene.Scene.onManagedUpdate(Scene.java:288)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.entity.Entity.onUpdate(Entity.java:1167)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.Engine.onUpdateScene(Engine.java:591)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.Engine.onUpdate(Engine.java:586)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.LimitedFPSEngine.onUpdate(LimitedFPSEngine.java:56)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.Engine.onTickUpdate(Engine.java:548)
09-30 09:47:23.550: E/AndroidRuntime(1167): at
org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)
09-30 09:47:23.570: I/BstWindowOrientationListener(521):
getCurrentRotation(0)
09-30 09:47:23.570: I/ActivityManager(521): Process com.www.tangent (pid
1167) has died.
09-30 09:47:23.570: I/WindowManager(521): WIN DEATH: Window{b4846b48
SurfaceView paused=false}
09-30 09:47:23.590: E/InputDispatcher(521): channel 'b472fa40
com.www.tangent/com.www.tangent.GameActivity (server)' ~ Consumer closed
input channel or an error occurred. events=0x8
09-30 09:47:23.590: E/InputDispatcher(521): channel 'b472fa40
com.www.tangent/com.www.tangent.GameActivity (server)' ~ Channel is
unrecoverably broken and will be disposed!
09-30 09:47:23.590: I/WindowManager(521): WIN DEATH: Window{b472fa40
com.www.tangent/com.www.tangent.GameActivity paused=false}

ASP.NET, what control do I need to achieve this navigation function, thank you

ASP.NET, what control do I need to achieve this navigation function, thank
you

here is what I want to achieve. I am creating a shopping website, and I
have a DataList to show all my products in the content page.
In the administrator page of my website, When I create a new category,
'Nike' and a few pairs of shoes under this 'Nike'. Then I create another
category, 'New Balance' and a few pairs of shorts under this 'New
Balance'. After that I click save then it is saved to my Access database.
Then, I go to my website, I hope the side menu bar which is in the master
page will show 'Nike' and 'New Balance', when I click Nike, those shoes
will be displayed in my DataList, when I click 'New Balance', those shorts
will be displayed in the DataList.
So, what control should I use to achieve this function, to connect the
sidebar with my DataList, please give me some advice or help.
I am new to ASP.NET, still not familiar with it. If I Google it, I dont
even know what I should search.
Thanks a lot

Using a WeakReferenced listener

Using a WeakReferenced listener

Assuming the following:
public interface Listener {
public void onListen();
}
public class ActionClass {
WeakReference<Listener> listener = null;
public void doAction(String action, Listener listener) {
this.listener = new WeakReference<Listener>(listener);
doTheAction(action);
}
public void actionComplete() {
if (listener != null && listener.get() != null)
listener.onListen();
}
}
public class AnotherClass {
ActionClass actioner = new ActionClass();
void init() {
actioner.doAction("something", new Listener() {
onListened() {
Log.d("Tag", "Action complete!");
}
};
}
}
Sorry if there are typos/syntax errors, this was more meant to be pseudo
code.
Anyway, a lot of times by the time the "Action" is complete, the
WeakReference to listener will be GCed, even though the instance of
"AnotherClass" is still alive. Is there a way to avoid this?

Django, gunicorn, upstart Failed to find application

Django, gunicorn, upstart Failed to find application

I'm trying to run Django website with Gunicorn as a service through
Upstart. I have the following init.sh script in my django instance (in the
same dir as manage.py). When I exec the gunicorn get started with all
configured workers and etc. The problem comes when I try to start it
through the upstart.
init.sh
'#!/bin/bash'
set -e
LOGFILE=/var/log/gunicorn/hello.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
# user/group to run as
USER=www-data
GROUP=www-data
cd /opt/defenv/market
source ../bin/activate
test -d $LOGDIR || mkdir -p $LOGDIR
exec ../bin/gunicorn marketsite.wsgi -w $NUM_WORKERS
--user=$USER --group=$GROUP --log-level=debug
--log-file=$LOGFILE 2>>$LOGFILE -n market
/etc/init.d/market.conf
debug = True
loglevel = debug
description "Market Site"
start on runlevel [2345]
stop on runlevel [06]
#respawn
#respawn limit 10 5
exec /opt/defenv/market/init.sh

Saturday, 28 September 2013

Does this php prepare code look ok. Im an trying to update a record in a DataBase and i feel this may be the issue

Does this php prepare code look ok. Im an trying to update a record in a
DataBase and i feel this may be the issue

Here is prepare update statement and I think i Have the Variable types out
of whack, not sure.
// if everything is fine, update the record in the database
if ($stmt =
$mysqli->prepare("UPDATE
`Calibration_and_Inspection_Register`
SET `item_type` = ?,
`location` = ?,
`date_last_test` = ?,
`serial_number` = ?,
`date_next_test` = ?,
`comments` = ?
WHERE `id`=?"))
{
$stmt->bind_param("issdsds",`$id`,
`$item_type`, `$location`,
`$date_last_test`,
`$serial_number`,
`$date_next_test`,
`$comments`);
$stmt->execute();
$stmt->close();
}

ASP.NET Web Forms Routing Ambiguity

ASP.NET Web Forms Routing Ambiguity

I have routing rules in the following order:
routes.MapPageRoute("Corporate", "Shop/{Category}", "~/Shop.aspx");
routes.MapPageRoute("GiftType", "Shop/{Category}", "~/Shop.aspx");
routes.MapPageRoute("Occasion", "Shop/{Category}", "~/Shop.aspx");
routes.MapPageRoute("Discounted", "Shop/{Category}", "~/Shop.aspx");
routes.MapPageRoute("Featured", "Shop/{Featured}", "~/Shop.aspx");
Links I'm using:
<a href="~/Shop/Corporate" title="Corporate Gifts"
runat="server">Corporate</a>
<a href="~/Shop/GiftType" title="Shop by Gift Type" runat="server">Gift
Type</a>
<a href="~/Shop/Occasion" title="Shop by Occasion"
runat="server">Occasion</a>
<a href="~/Shop/Discounted" title="Discounted" runat="server">Discounted</a>
<a href='<%# "~/Shop/"+Eval("Featured") %>' title='<%# Eval("ProductName")
%>'
runat="server">
In the code-behind of the destination page, the following code works and I
don't know why. The switch statement is executing for a case value of
"True" for "Featured"? It's like I'm not differentiating these routes from
each other according to the placeholders?
if (Page.RouteData.Values["Category"] != null)
{
string category = Page.RouteData.Values["Category"].ToString();
switch (category)
{
case ("Corporate"):
Response.Write("Corporate");
break;
case ("GiftType"):
Response.Write("GiftType");
break;
case ("Occasion"):
Response.Write("Occasion");
break;
case ("Discounted"):
Response.Write("Discounted");
break;
// Do not want the following to be picked up here for Category param
case ("True"):
Response.Write("Featured");
break;
}
}
What I want to work code-wise is something like this:
if (Page.RouteData.Values["Category"] != null)
{
string category = Page.RouteData.Values["Category"].ToString();
switch (category)
{
case ("Corporate"):
Response.Write("Corporate");
break;
case ("GiftType"):
Response.Write("GiftType");
break;
case ("Occasion"):
Response.Write("Occasion");
break;
case ("Discounted"):
Response.Write("Discounted");
break;
}
}
else if (Page.RouteData.Values["Featured"].ToString() == "True")
{
Response.Write("Featured");
}

Ignoring style for a concrete tag

Ignoring style for a concrete tag

I have a css file for my entire site. In that css file, for example, I
have the following style defined for all my reference links such as:
a{
color: #333;
padding-right: 3px;
padding-left: 3px;
text-decoration: underline;
outline-width: medium;
outline-style: none;
outline-color: invert;
}
a:link, a:visited, a:active, a:hover{
color: #333;
}
so all my links in my site have above styling, but there are only three
links in my page that I do not want to apply this style, I mean, I want to
ignore it in order to be not applied, so how to ignore style for below
links?
<nav id="NavigationMenu">
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</nav>

how to use wireshark to capture packets from stand input

how to use wireshark to capture packets from stand input

In our program (written in Java, run on Windows), we have packets captured
on our own device, and send to the Java program via a inner callback.
Formerly, we decode these packet by ourselves, but there's some
performance problem. Now we want to use Wireshark instead. I've found that
wireshark can capture packets from stand input, by using the following
command line: "wireshark -k -i -". But I have no idea how to use it in the
cmd prompt in Windows 7. Suppose I have a cap file named test.cap, should
I use "more test.cap | wireshark -k -i -" (just a example, I tried but
failed) or something else? Of course, I also want to ask about the usage
in Java. Does anyone know about it?

Friday, 27 September 2013

Correcting this Word macro to call data from Excel worksheet as suggested

Correcting this Word macro to call data from Excel worksheet as suggested

I'm running this macro in MS Word and it works well but I have a lot more
words to replace. It suggests I can call the data from an Excel worksheet.



Suggested on line 33 of the code below:
"Note: Data arrays are used in this example. In practice the data could
come from a Word table, Excel worksheet or other data source."
arrEng = Split("God H430,heaven H8064,earth H776,waters H4325,good H2896",
",")
arrHeb = Split("Elohim H430,shamayim H8064,aretz H776,mayim H4325,tov
H2896", ",")



How is this done?
What does my .xlsx file need to look like? old words on Column A, new
words on Column B?
How do I tell this macro to go to that file and look for the words to
replace? (my knowledge of VBA is: I started today! :) Thanks :)



Option Explicit
Dim m_oCol1 As Collection
Dim m_oCol2 As Collection
Sub ReplaceWordsAndDefineFootnotes()
Dim clsTL As clsTerms
Dim lngIndex As Long
Set clsTL = New clsTerms
Set clsTL.Items = DefinedTerms
Set m_oCol1 = New Collection
For lngIndex = 1 To clsTL.Count
'Replace each defined English word with it Hebrew equivelent.
ReplaceWords clsTL.Items(lngIndex).EnglishTerm,
clsTL.Items(lngIndex).HebrewTerm
Next lngIndex
Underline_And_DefineFootnote
For lngIndex = 1 To clsTL.Count
'Replace temporary footnote text with with class defined footnote
text.
FixFootnotes clsTL.Items(lngIndex).HebrewTerm,
clsTL.Items(lngIndex).FootnoteText
Next lngIndex
lbl_Exit:
Exit Sub
End Sub
Function DefinedTerms() As Collection
Dim arrEng() As String
Dim arrHeb() As String
Dim lngIndex As Long
Dim oCol As Collection
Dim Term As clsTerm
'Note: Data arrays are used in this example. In practice the data
could come from a Word table, Excel worksheet or other data source.
arrEng = Split("God H430,heaven H8064,earth H776,waters H4325,good
H2896", ",")
arrHeb = Split("Elohim H430,shamayim H8064,aretz H776,mayim H4325,tov
H2896", ",")
Set oCol = New Collection
'Put data in the collection.
For lngIndex = 0 To UBound(arrEng)
Set Term = New clsTerm
Term.EnglishTerm = arrEng(lngIndex)
Term.HebrewTerm = arrHeb(lngIndex)
Term.FootnoteText = arrEng(lngIndex) & ":" & arrHeb(lngIndex)
oCol.Add Term, Term.EnglishTerm
Next lngIndex
Set DefinedTerms = oCol
lbl_Exit:
Exit Function
End Function
Sub ReplaceWords(ByVal strFind As String, ByVal strReplaceWith As String)
Dim oRng As Word.Range
'Add each term processed to a collection.
m_oCol1.Add UCase(strReplaceWith), UCase(strReplaceWith)
Set oRng = ActiveDocument.Range
'Replace each instance of the English word with its Hebrew equivalent.
With oRng.Find
.Text = strFind
.Replacement.Text = strReplaceWith
.MatchWholeWord = True
.MatchCase = False
.Execute Replace:=wdReplaceAll
End With
lbl_Exit:
Exit Sub
End Sub
Sub Underline_And_DefineFootnote()
Dim oRng As Word.Range
Dim lngIndex As Long
Dim oWord As Word.Range
Dim strWord As String
Dim lngCounter As Long
Dim lngPages As Long
With ActiveDocument
Set oRng = .Range
lngPages = .ComputeStatistics(wdStatisticPages)
For lngIndex = 1 To lngPages
Reprocess:
Set m_oCol2 = New Collection
Set oRng = oRng.GoTo(What:=wdGoToPage, Name:=lngIndex)
Set oRng = oRng.GoTo(What:=wdGoToBookmark, Name:="\page")
lngCounter = 1
With oRng
For Each oWord In oRng.Words
'Modify the word range to strip off white space. We
want only the text portion of the word range.
strWord = UCase(Trim(oWord.Text))
oWord.Collapse wdCollapseStart
oWord.MoveEnd wdCharacter, Len(strWord)
If oWord.Characters.Last = Chr(160) Then oWord.MoveEnd
wdCharacter, -1
'We need to know if the text defined by the word range
is a word we want to process.
'We added all of those words to a collection during
the find and replace process.
'If we try to add one of those words to the collection
again then it will error and we will know _
we are dealing with a word we want to process.
On Error Resume Next
m_oCol1.Add strWord, strWord
If Err.Number <> 0 Then
On Error GoTo 0
On Error Resume Next
'We only want to underline and footnote the first
instance of the term on each page.
'So add the term and key to a collection.
m_oCol2.Add strWord, strWord
If Err.Number = 0 Then
'There was no error so underline the term and
footnote it.
oWord.Font.Underline = 1
On Error GoTo 0
ActiveDocument.Footnotes.Add oWord,
CStr(lngCounter), LCase(strWord)
lngCounter = lngCounter + 1
End If
Else
'The word wasn't a word we want to process so
remove it from the collection.
m_oCol1.Remove m_oCol1.Count
End If
Next oWord
End With
'Since processing words will add footnotes, the length of the
document will increase.
'I'm using this method to reenter the processing loop.
lngPages = .ComputeStatistics(wdStatisticPages)
If lngIndex < lngPages Then
lngIndex = lngIndex + 1
GoTo Reprocess
End If
Next lngIndex
End With
Set oRng = Nothing
End Sub
Sub FixFootnotes(ByVal strFind As String, ByVal strReplaceWith As String)
Dim oRng As Word.Range
m_oCol1.Add UCase(strReplaceWith), UCase(strReplaceWith)
Set oRng = ActiveDocument.StoryRanges(wdFootnotesStory)
With oRng.Find
.Text = strFind
.Replacement.Text = strReplaceWith
.MatchWholeWord = True
.MatchCase = False 'True
.Execute Replace:=wdReplaceAll
End With
lbl_Exit:
Exit Sub
End Sub

jquery ui dialog within infoWindow

jquery ui dialog within infoWindow

Is it possible to use ui dialog within an infoWindow or an infoBox ?
This code doesn't work:
google.maps.event.addListener(marker,"click", function()
{
html = "$('#dialog-click').dialog({...})";
ib.setContent(html);
ib.open(map,marker);
}
<div id="dialog-click">
<label for="name">Name:</label>
<input type='text' id='name' />
<label for="firstname">Firstname:</label>
<input type='text' id='firstname' />
</div>

Qt is there a way to send a signal when a serial cable is unplugged?

Qt is there a way to send a signal when a serial cable is unplugged?

working on a project in Qt here. Is there a way to send a signal, or any
way to tell if a USB serial cable gets unplugged?

MySQL limit parameters relative to a row value

MySQL limit parameters relative to a row value

I have a boxes table with a box_size column. I want to fetch a set of
boxes with a total size of 16 how should I do this?
for example fetch 16 row with box_size = 1 , or two rows with box_size = 4
and 4 rows with box_size = 2 etc.

convert snake case (snake_case) to lower camel case (lowerCamelCase) in python

convert snake case (snake_case) to lower camel case (lowerCamelCase) in
python

what would be a good way to convert from snake case (my_string) to lower
camel case (myString) in python 2.7?

iPhone 5 Splash Screen - Can't delete

iPhone 5 Splash Screen - Can't delete

Making a nice mobile site with jQuery.
The splash screen works great except on an iPhone 5 with iOS6 where it
continues to show the old screen from day 1 despite that image not even
being on the server and clearing cache endless time, and certainly
deleting the app storied on the phone desktop.
... so where is that thing stored on the phone? if not in the cache?
Thanks everyone for making S.O. great.
Randy

Thursday, 26 September 2013

Zend Framework 2 CMS file structure

Zend Framework 2 CMS file structure

I'm trying to build a simple content management system based on the Zend
Framework 2. The problem is that I don't know how should the folders
structure be like.
Until now I have to solutions in mind:
A. Building a general "Admin" module that has multiple controllers like
Login Controller, Pages Controller, Posts Controller, each of this
controller with his own actions.
B. Building an module for each component, like: Pages Module that has an
adminController an an frontendController.
I'm sure that none of the above solution is the corect one, but couldn't
find any solid solution or books to provide one. I've taken a look at
gotCMS but noticed that this one i.e, saves all the data like layout views
in the database, and this is not a solution.

Wednesday, 25 September 2013

how to exclude an anchor from "e.stopPropagation()"

how to exclude an anchor from "e.stopPropagation()"

$pageslide.click(function(e) {
e.stopPropagation();
});
That prevents the #pageslide ID or Class from sliding if clicked, how do i
exclude certain elements from being prevented, in this case i want to
exclude <a></a> or <li></li>. Thanks in advance .

Thursday, 19 September 2013

Code for quadratic equation gives incorrect answer

Code for quadratic equation gives incorrect answer

Hello I'm Beginner in C# I make this code for quadratic equation it Run
but not give right answer Help me for solving this code
using System;
using System.Diagnostics;
namespace mynamespace
{
class myclass
{
static void Main(string[] args)
{
float a, b, c, x1, x2;
Console.Write("Enter Value in a");
a=Convert.ToSingle(Console.ReadLine());
Console.WriteLine("Enter Value in b");
b=Convert.ToSingle(Console.ReadLine());
Console.WriteLine("Enter Value in c");
c=Convert.ToSingle(Console.ReadLine());
x1=(-b + Math.Sqrt ( b*b - 4*a*c)/(2*a));
x2=(-b - Math.Sqrt ( b*b - 4*a*c)/(2*a));
Console.WriteLine(x1);
Console.WriteLine(x2);
Console.ReadKey();
}
}
}

Scheduled Console App Crashes with App.config

Scheduled Console App Crashes with App.config

I have a C# console application that reads app settings from its
app.config. The console application is targeted as the action of a Windows
Scheduler Task. It runs once a day.
Since, adding the code to read from the configuration file the app crashes
only when run by the Task Scheduler. When run manually (from command
prompt or by clicking on it in it's folder)), the application runs with no
issues and it works exactly as expected.
Here's the code that reads from the app settings section:
int someValue = 1;
try
{
if (ConfigurationManager.AppSettings["someValue"] != null)
someValue =
int.Parse(ConfigurationManager.AppSettings["someValue"].ToString());
}
catch(Exception exception)
{
// Write to error log
}
This is the exception I'm getting in my error log:
Exception: The type initializer for '<my application name>' threw an
exception.
System.Configuration.ConfigurationErrorsException: An error occurred
loading a configuration file: The parameter 'exePath' is invalid.
Parameter name: exePath ---> System.ArgumentException: The parameter
'exePath' is invalid.
Parameter name: exePath
I have tried allowing the task to run with highest privileges. I have
tried accessing the configuration file in different ways
(Configuration.OpenConfigurationExe(...)), etc... I get the same problem
every time. I have tried putting my .exe in various locations on disk.
This one is in C:\Program Files. I have looked around on S.O. and this
post suggests that it might be a read permissions issue, but if the task
runs under my domain's account and has the highest privileges, is that
still possible? Note that it runs just fine if I run it manually from a
command prompt or by clicking on it.
How can I reliably get a console application to read its app.config if it
has been configured to run under Windows Task Scheduler?

How can make sure my app will run well on GDR3 and 1080p windows phone devices?

How can make sure my app will run well on GDR3 and 1080p windows phone
devices?

We are planning support the next generation of devices with 1080p
capability. However since this is a new aspect ratio, we would like to
make sure that our apps will run well on the new devices.
Moreover, this new resolution will be supported on GDR3 for WP8, so we
also would like to make sure our app will run on it without any issue.
Do you know how can check our windows phone application on GDR3 or 1080p?
Herb

C# XMl Deserialisation with non existing Paths

C# XMl Deserialisation with non existing Paths

I've with xsd.exe created the class for my XML. In the XML (SEPA camt.053)
are multiply nested Nodes that have minOccurs = 0.
I navigate to the node like this:
entry.NtryDtls[0].TxDtls[0].RltdPties.CdtrAcct.Id.Item
In this Path RltdPties, CdtrAcct and Id could be null.
If RltdPties is null I get an Exception, because CdtrAcct doesn't exist.
Is there an easy way without checking each node if it is null to get the
Value of Item? If path doesn't exist it would be enough to get null (or
something else) from the last node that I can check.
My idea is to surround this query with try/catch and if it throws an
Exception I can set the Variable to an empty string or so.
Thanks in advanced

How to compare two Oracle sachems to get delta changes by Altering the table not to drop and recreate it

How to compare two Oracle sachems to get delta changes by Altering the
table not to drop and recreate it

I've already tried out a tool named TOYS i found it free but unfortunately
it didn't work.
then, i tried 'RED-Gate Schema Compare for Oracle' but it uses the
technique to drop and recreate the table mean while i need to just alter
the table with the newly added/dropped columns.
Any help is highly appreciated
Thanks

How to add tool bar( pagination) to custom Viewer Servlet in birt report

How to add tool bar( pagination) to custom Viewer Servlet in birt report

I am a java developer. Working on birt report. I facing problem with that.
I need a report, where resultset will be provided from j2ee application(
as sql query includes dynamic table name according to condition) as well
as display column will be dynamic depending upon choice of user(suppose,
user1 choose col1,col3,col5 and user2 choose col1,col2,col3,col4,col5) in
report generation. My solution 1) Create custom ViewerServlet 2) pass
resultset do the needful. I have implemented first approach but can not
incorporate tool bar(pagination, export etc.).Please give me an idea to
add tool bar in my custom viewer servlet. No solution for 2nd approach. I
got
"techieocean.blogspot.in/2009/06/how-to-pass-resultset-to-birt-report.html"
in web but need in brief to do this. Please help me.

Spring annotation attribute setting with method invocation

Spring annotation attribute setting with method invocation

I've got the spring configuration class:
@Configuration
@EnableJpaRepositories
InfrastructureContextConfiguration
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory()
{...}
I wish to set the entityManagerFactoryRef attribute of the
@EnableJpaRepositories with entityManagerFactory().getObject() invocation.
Can I do that and how if it is allowed?

Wednesday, 18 September 2013

Validation for textbox that shoud not allow greater than a number

Validation for textbox that shoud not allow greater than a number

I have a text box like,
<input type="text" id="hourField" value=""/>
How can we restrict that text box should not allow greater than 12. (i.e
12hr format, this should allow 1 to 12 numbers only. it should not allow
grater than 12.

Error: no known conversion for

Error: no known conversion for

So this is what I currently have, with the Scanner provided by my professor.
#include "Similarity.h"
#include "Scanner.h"
using namespace std;
int Similarity::readData(Scanner inFile){
int similarityInputSize;
vector< vector<int> > containingVector;
bool nextValueFound;
similarityInputSize = inFile.nextInt();
int lineCount = 0;
while(inFile.hasNext()){
containingVector.push_back(vector<int>());
for(int i = 0; i < similarityInputSize; i++){
containingVector[lineCount].push_back(inFile.nextInt());
}
lineCount++;
}
for(int i = 0; i < containingVector.size(); i++){
for(int j = 0; j < similarityInputSize; i++){
cout << containingVector[i][j] << " ";
}
cout << endl;
}
return 0;
}
The Main class is given to us and involves a call by value not by
reference, which my professor got to work.
the errors I receive are:
In file included from /usr/include/c++/4.7/ios:43:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from ../../Utilities/Utils.h:17,
from Main.h:11:
/usr/include/c++/4.7/bits/ios_base.h: In copy constructor
'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)':
/usr/include/c++/4.7/bits/ios_base.h:788:5: error:
'std::ios_base::ios_base(const std::ios_base&)' is private
In file included from /usr/include/c++/4.7/ios:45:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from ../../Utilities/Utils.h:17,
from Main.h:11:
/usr/include/c++/4.7/bits/basic_ios.h:64:11: error: within this context
In file included from ../../Utilities/Utils.h:18:0,
from Main.h:11:
/usr/include/c++/4.7/fstream: In copy constructor
'std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)':
/usr/include/c++/4.7/fstream:420:11: note: synthesized method
'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' first
required here
In file included from /usr/include/c++/4.7/ios:44:0,
from /usr/include/c++/4.7/ostream:40,
from /usr/include/c++/4.7/iostream:40,
from ../../Utilities/Utils.h:17,
from Main.h:11:
/usr/include/c++/4.7/streambuf: In copy constructor
'std::basic_filebuf<char>::basic_filebuf(const
std::basic_filebuf<char>&)':
/usr/include/c++/4.7/streambuf:800:7: error:
'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const
__streambuf_type&) [with _CharT = char; _Traits =
std::char_traits<char>; std::basic_streambuf<_CharT,
_Traits>::__streambuf_type = std::basic_streambuf<char>]' is private
In file included from ../../Utilities/Utils.h:18:0,
from Main.h:11:
/usr/include/c++/4.7/fstream:69:11: error: within this context
/usr/include/c++/4.7/fstream: In copy constructor
'std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)':
/usr/include/c++/4.7/fstream:420:11: note: synthesized method
'std::basic_filebuf<char>::basic_filebuf(const
std::basic_filebuf<char>&)' first required here
In file included from Main.h:12:0:
../../Utilities/Scanner.h: In copy constructor 'Scanner::Scanner(const
Scanner&)':
../../Utilities/Scanner.h:27:7: note: synthesized method
'std::basic_ifstream<char>::basic_ifstream(const
std::basic_ifstream<char>&)' first required here
Main.cpp: In function 'int main(int, char**)':
Main.cpp:58:31: note: synthesized method 'Scanner::Scanner(const
Scanner&)' first required here
In file included from Main.h:14:0:
Similarity.h:23:9: error: initializing argument 1 of 'int
Similarity::readData(Scanner)'
So I don't quite understand what happened. Everywhere I looked said that
the issue would be fixed by a call by reference not by value. However, his
provided code does not include any call by references, which makes me
assume its a more subtle error (or its so big that it's blinding me).
Nevertheless, I changed it anyways and it gave me these errors:
Similarity.cpp:12:5: error: prototype for 'int
Similarity::readData(Scanner&)' does not match any in class 'Similarity'
Similarity.h:23:9: error: candidate is: int Similarity::readData(Scanner)
Main.cpp: In function 'int main(int, char**)':
Main.cpp:58:32: error: no matching function for call to
'Similarity::readData(Scanner*)'
Main.cpp:58:32: note: candidate is:
In file included from Main.h:14:0:
Similarity.h:23:9: note: int Similarity::readData(Scanner)
Similarity.h:23:9: note: no known conversion for argument 1 from
'Scanner*' to 'Scanner'
Anything you can tell me at all will be a help.
Thanks in advance!

IEnumerable property in model, items duplicated in editor template after a few posts

IEnumerable property in model, items duplicated in editor template after a
few posts

I have an upload plugin, users select a file and click on upload button.
the file is uploaded and the controller action takes the file stored name
and populates it into an editor template.
So once the file is successfully uploaded and the view is returned, the
editor templates shows links to the uploaded file. Now sometimes users can
select multiple files and sometimes they can upload one file per post.
The issue arises when they are uploading single files per post. Lets say i
select a file and click upload, the file gets uploaded fine. I select
another file, the file gets uploaded fine but the editor template in
viewsource is overwritten and I have two duplicate items in the list.
So after the second file upload, if I select another file and click
upload, upon post I see two list items which is correct but they are
duplicate. I am pretty sure that when the view is returned upon the second
post, The editor template has distinct items which is correct but I am not
sure what happens in the HTML.
<div class="bodyContent">
<span class="leftContent">Load/Result/Log Files: </span><span
class="rightContent">
<input name="file" id="file" type="file" />
</span>
</div>
<div class="bodyContent">
<span class="leftContent">Uploaded Files</span><span
class="rightContent">
@if (Model.RunFilesDisplay != null)
{
@Html.EditorFor(x => x.RunFilesDisplay)
}
else
{
@Html.Label("N/A");
}
</span>
</div>
@model RunLog.Domain.Entities.RunLogEntryFilesDisplay
<tr>
<td valign="top">
@* @Html.ActionLink(Model.FileName, "Download", new { @file =
Model.FileName })*@
@Html.DisplayFor(x => x.FileName)
@Html.HiddenFor(x => x.FileName)
@Html.HiddenFor(x => x.FileStoredName)
@Html.HiddenFor(x => x.FileExtension)
@Html.CheckBoxFor(x => x.Checked)
</td>
</tr>
[HttpPost]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(RunLogEntry runLogEntry, String
ServiceRequest,
string submit, string submit1, string
submit2, string submit3,
IEnumerable<HttpPostedFileBase> file,
String AssayPerformanceIssues1,
List<string> Replicates)
{
#region LoadList_JSON_FileUpload
//Save LoadList File:
DateTime uploadDate = DateTime.Now;
string destinationPath =
string.Format("{0}\\{1}\\{2}\\{3}\\",
Server.MapPath("~/App_Data/uploads"),
uploadDate.ToString("yyyy"),
uploadDate.ToString("MMM"),
uploadDate.ToString("dd"));
if (!Directory.Exists(destinationPath))
Directory.CreateDirectory(destinationPath);
string storedFileName =
string.Format("{0}{1}.json",
destinationPath,
System.Guid.NewGuid());
List<string> jsonFileList = new
List<string>();
foreach (var f in file)
{
if (f != null)
{
if
(f.FileName.Contains("json")
||
f.FileName.Contains("JSON"))
{
RunLogEntryFilesDisplay
runFile = new
RunLogEntryFilesDisplay();
string storedFileNames =
string.Format("{0}{1}.json",
destinationPath,
System.Guid.NewGuid());
f.SaveAs(storedFileNames);
jsonFileList.Add(storedFileNames);
runLogEntry.LoadListStoredFileName
=
runLogEntry.LoadListStoredFileName
+ storedFileNames;
runFile.FileStoredName =
storedFileNames;
runFile.FileName =
f.FileName;
runFile.FileExtension =
"JSON";
runFile.Checked = false;
runFiles.Add(runFile);
}
}
}
if (runLogEntry.RunFilesDisplay !=
null &&
runLogEntry.RunFilesDisplay.Count() >
0)
{
foreach (RunLogEntryFilesDisplay
fd in runLogEntry.RunFilesDisplay)
{
runFiles.Add(fd);
jsonFileList.Add(fd.FileStoredName);
}
}
var Pair =
FileImport.CyclesCompleted(jsonFileList);
if (Pair.Key == false)
{
ModelState.AddModelError(string.Empty,
"Unable to parse JSON content.");
;
}
else
{
ModelState.Remove("SPTestsRequested");
ModelState.Remove("LoadListFileName");
ModelState.Remove("LoadListStoredFileName");
ModelState.Remove("RunStatusID");
runLogEntry.SPTestsRequested =
Pair.Value;
runLogEntry.RunFilesDisplay =
runFiles;
}

Code signing issue in Xcode 5

Code signing issue in Xcode 5

My project has a sub-project. It's not being code-signed:

Even though I disabled code-signing, I still get this error:
Code Sign error: Multiple matching codesigning identities found: Multiple
codesigning identities (i.e. certificate and private key pairs) matching
"Mac Developer" were found.
When I look in the keychain, there's no duplicate key of "Mac Developer".
I didn't have this issue in Xcode 4.x.
How can I fix this?

I want to change the custom back button in sherlock action bar and remove app icon

I want to change the custom back button in sherlock action bar and remove
app icon

I dont like the default back button that comes with action bars they look
rather to tiny for my liking. I trying to fix a bigger and more
descriptive button like the one used in the WeChat Mobile App. please any
body with an Idea.
I tried this below but did not work
<item name="android:homeAsUpIndicator">@drawable/back</item> //Put in my
style
The the one below in my code
ActionBar actionBar = getSupportActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
// actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
But did not work. the image that I kept in my drawable is not show. My app
icon keeps show on the action bar which I dont want. and the back button
is not working. Please any idea.

JQuery addclass to selected div, remove class if another div is selected

JQuery addclass to selected div, remove class if another div is selected

I'm making a formbuilder, I would like to change the appearance of for
example a heading div. When clicked it should get a border but when
another dynamically generated div is clicked the class should be removed
and the second clicked div has to get the .active class.
How can I do this with generated divs?
Code:
/* Add Class Heading*/
$(document).ready(function() {
$(this.attr('id')).click(function () {
var DivId = $(this).attr('id');
alert(DivId);
$(this).addClass('active');
});
});

How I can add click function in this code

How I can add click function in this code

How I can add click function in this code, so that in addition to open the
submenu also call the filter Links Important?
$('#dl-menu a').ready(function(e) {
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
e.preventDefault();
e.stopPropagation();
});
$('.dl-submenu a').click(function(e) {
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector });
e.preventDefault();
e.stopPropagation();
});

dynamically change attribute id input jquery

dynamically change attribute id input jquery

Here I want to affect a value to dynamically attribute id of input here my
code jquery : for this code i can change to 0 the first value of input as
id=ouseval_0__SousEval_Note but i have many input with dinamic id
<script type="text/javascript">
$("#idselectdiv .tdLabelwidht").change(function () {
var idd = $(this).val();
alert(" selected value@ ="+idd);
if(idd=="-1"){
alert(" Veuillez selectionner un bon choix ");
}
if($(this).find("option:selected").text()!="Conforme"){
$("#souseval_5__SousEval_Note").val(0);
}
alert(" selected option- "+$(this).find("option:selected").text());
});
</script>
in my jsp i have a slect tag and the input who i want edite here value if
user select an option of select tag diferent of conforme:
<s:set name="n" value="0"/>
<s:iterator value="item" status="idStatus" >
<s:select
label="%{Item_Libelle}"
headerValue="---------------- Select ---------------"
headerKey="-1"
list="sousitem"
listKey="SousItem_ID"
listValue="SousItem_Libelle"
cssClass="tdLabelwidht"
id="selectedId"
name="%{'souseval['+#n+'].sousEvalItem.SousItem_ID'}"
/>
<s:textfield name="%{'souseval['+#n+'].SousEval_Note'}"
value="%{ponderation}"
placeholder="entrer Note"
/>
<s:set name="n" value="%{#n+1}"/>
</s:iterator>
equivalent code html :
<tr>
<td class="tdLabel"></td>
<td>
<input id="souseval_5__SousEval_Note" type="text" placeholder="entrer
Note" value="10" name="souseval[5].SousEval_Note">
</td>
</tr>

undefined method for #

undefined method for #

I want show all price for all finds days.
in controller view
def view
@travel = Travel.find(params[:id])
@car = Car.find(:first, :conditions => ["id = ?", @travel.car_id])
@start_day = StartDay.find(:all, :conditions => ["travel_id = ?",
@travel.id])
@import_price = ImportPrice.find(:all,
:conditions => ["begin_date = ? and car_code = ?",
@start_day.day, @car.short_name])
end
When I add value @import_price appears error:
undefined method `day' for #<Array:0x7feb70d56fe8>
How me make the correct selection for all days?
Thanks in advance.
ruby 1.8.7 rails 2.3

Tuesday, 17 September 2013

Click event not triggered after element focusout

Click event not triggered after element focusout

Click event not triggered after focusout event, in textarea. Tabs and
button click is not worked. Fiddle is here.
Steps to produce:
focusin to the textarea and click any tabs or buttons in the popup.

Prerequisites for Creating Chrome/Safari Extensions

Prerequisites for Creating Chrome/Safari Extensions

I have been a programmer for a long time now but have majorly operated in
C and Fortran. I like to believe I am good at scientific/numerical
computing.
Recently, I had an idea for a browser extension. I did some googling and
realized that Javascript is my best option to do so. I have never in my
life looked at HTML or Javascript or CSS. The Safari and Chrome websites
suggest that I should learn HTML, CSS and Javascript.
My question was- how should I proceed with this goal in mind. I don't plan
to make web applications anytime but want to concentrate only on browser
extensions. How much of HTML and CSS do I really need to know? Do I need
to get that out of the way before attempting to study Javascript? How
should I plan this study?
P.S. I looked at a few books on Javascript and it looks eerily close to C
which is a big plus for me. Learning Javascript isn't my concern, learning
HTML/CSS is.

Returning to a page from window.location.href=url

Returning to a page from window.location.href=url

I have a web site builder with a Publish button that puts the constructed
web site out at a designated url. I would then like to perform the
courtesy of transferring the user to the built page. I can use
window.open(url), which opens a new window with the new site and leaves
the editor page in tact. So after seeing the built page the user can just
close it and be back in the editor to make more changes after seeing what
was built. This is the ideal solution, except that it doesn't work with
Safari because it blocks pop ups.
The other possibility is to execute window.location.href=url. This gets
the user to the new page but getting back to the editor and its previous
state is not clean. Hitting the back button from the new site reloads the
editor page without any of the state information the user had built up to
moment of publishing.
Is there a way I can get the user back to editor with the previous state
information displayed, that works for Firefox and Safari?
Thanks.

char pointer allocates random characters

char pointer allocates random characters

I am writing a small C code for class that plays Hangman with an already
input name. One section requires I allow the output of the input phrase
with * in the place of all letters, but not punctuation. Similarly, at the
end of the phrase, the name of the user is put in parentheses and is meant
to be printed as is. The first section of the code works fine, the first
while loop which places the asterisks, but the second while loop seems to
fail every time and seems to store nonsense and random characters
everytime the program is run. Here is the program I have so far.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int guesses = 3;
int limit = 41;
char quote[42] = "I just wrote this game in C! (Josh Masher)";
char strArr[42];
char *quoP;
quoP = &quote[0];
char *strP;
strP = &strArr[0];
while (*quoP != '.' && *quoP != '!' && *quoP != '?') {
if (isalpha(*quoP)) {
*strP = '*';
} else if (*quoP == ' ' || *quoP == ',') {
*strP = *quoP;
}
strP++;
quoP++;
}
while (*quoP != NULL) {
*strP = *quoP;
strP++;
quoP++;
}
}
any ideas?

disabling the parent modal popup when child modal popup is shown

disabling the parent modal popup when child modal popup is shown

I have a web form when the user hits Add contact it shows a modal popup to
collect information there is a grid on the modal popup and they can add
additional information through a child modal popup. Everything works good
except for when the child modal popup is shown I cant seem to get it to
disable the parent modal popup.
<asp:Panel runat="server" ID="ui_pnl_Parent" CssClass="modalPopup"
Style="display: block;" Width="504px">
<asp:ModalPopupExtender ID="ui_pnl_ParentPopupExtender" runat="server"
DynamicServicePath=""
Enabled="True" PopupControlID="ui_pnl_Parent"
TargetControlID="ui_btn_Popup"
BackgroundCssClass="modalBackGround"
RepositionMode="RepositionOnWindowResizeAndScroll">
</asp:ModalPopupExtender>
<asp:Panel runat="server" ID="ui_pnl_Child" CssClass="modalPopupChild"
Style="display: block;" Width="504px">
<asp:ModalPopupExtender ID="ui_pnl_ChildPopupExtender" runat="server"
DynamicServicePath=""
Enabled="True" PopupControlID="ui_pnl_Child"
TargetControlID="ui_btn_Popup2"
BackgroundCssClass="modalBackGroundChild"
RepositionMode="RepositionOnWindowResizeAndScroll">
</asp:ModalPopupExtender>
This I my CSS for the parent and the child
.modalPopup
{
background-color:white;
border-width:1px;
border-style:solid;
border-color:#284775;
padding:3px;
}
.modalBackGround
{
background-color: Silver;
filter:alpha(opacity=55);
opacity:0.7;
}
.modalPopupChild
{
background-color:white;
border-width:1px;
border-style:solid;
border-color:#284775;
padding:3px;
z-index: 110009;
}
.modalBackGroundChild
{
background-color: Silver;
filter:alpha(opacity=55);
opacity:0.7;
z-index: 110008;
}

GKAchievement with partial completion not saving to Game Center (Sandbox)

GKAchievement with partial completion not saving to Game Center (Sandbox)

I'm trying to save partial progress on an achievement and then load it
back when the game starts again. One of my achievements is to do something
1000 times, so I'm submitting a completion number of, say 0.5 for doing it
5 times. But when I quit the game, start it again, and load achievements
from Game Center, the partially completed achievement doesn't come back at
all!
Of note, I have another achievement that works properly, which goes
straight from 0.0 to 100.0 percent complete--and that saved and loaded
back properly the first time I tried it.
Here are my save and load methods:
// _queuedAchievements is a NSMutableSet with GKAchievements in it
- (void) reportQueuedAcheivements
{
NSArray *achievements = [_queuedAchievements allObjects];
if (achievements.count <= 0) {
return;
} else {
NSLog(@"Reporting queued achievements..."); for (GKAchievement *a
in _queuedAchievements) NSLog(@"Achievement: %@, completion:
%.1f", a.identifier, a.percentComplete);
[GKAchievement reportAchievements: achievements
withCompletionHandler:^(NSError *error)
{
if (error != nil)
{
NSLog(@"Error in reporting achievements: %@", error);
} else {
NSLog(@"Successfully reported achievements!");
[_queuedAchievements removeAllObjects];
}
}];
}
}
and...
// _achievementsDictionary is a NSMutableDictionary, as suggesting in
Apple's Game Center guide
- (void) loadAchievements
{
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray
*achievements, NSError *error) {
NSLog(@"loadAchievements completionHandler called!");
if (error != nil)
{
// Handle the error.
NSLog(@"Error loading achievements: %@", error);
}
if (achievements != nil)
{
NSLog(@"Loaded Achievements...");
for (GKAchievement* achievement in achievements) {
[_achievementsDictionary setObject: achievement forKey:
achievement.identifier];
NSLog(@"%@: %.1f", achievement.identifier,
achievement.percentComplete);
}
}
}];
}
Again, setting an achievement straight to 100.0 works fine, but my partial
value never seems to store. The achievement doesn't show up as paritially
complete in the GameCenter app/view controller either (shouldn't it? I'm
not certain).
This is currently in the Sandbox, so it could be something related to
that, but I doubt it. Is it not permitted to report a completion less than
1.0? I haven't actually tried it yet with >= 1.0, but why have a float if
you can't report a fraction?
(Bonus question...it seems Apple's docs recently changed the information
about storing failed submissions--e.g. when the network is down--and
trying again later, i.e. GameKit does that for you now...anyone know when
this changed?)

Sunday, 15 September 2013

Ban Proxy Users Using Thridparty website?

Ban Proxy Users Using Thridparty website?

I use http://www.shroomery.org/ythan/proxycheck.php And Wordpress How I
can Create A plugin To Ban All users that use proxy? I know Code Must be
like this :
<?php
$ipckccc = curl_init();
curl_setopt($ipckccc,CURLOPT_URL,"http://www.shroomery.org/ythan/proxycheck.php?ip=".$_SERVER["HTTP_CF_CONNECTING_IP"]."");
curl_setopt($ipckccc,CURLOPT_RETURNTRANSFER,1);
$ipchecked=curl_exec ($ipckccc);
curl_close ($ipckccc);
?>
and This :
<?php if($ipchecked == 'Y') {
header("HTTP/1.0 404 Not Found");
die();
}else{
echo "hello";
}
?>
But how i can Deny Access Proxy From My Wordpress site?

Working on a code with for-loops and arrays

Working on a code with for-loops and arrays

In the program that I'm writing, I currently have a for-loop that goes
through an array, num[5], and checks to see if there are any 1s in that
array, which looks like:
int counter = 0;
for (int i = 1; i<=5; i++) {
if (num[i] == 1) {
counter++;
This works successfully, but I'm now trying to go through the array and
see what the indices of the 1s in the program are. So, if I have 01001, I
want to make an array that holds the positions of the 1s. The following is
what I've tried so far:
int b[counter];
for (int k = 0; k<= counter; k++) {
for (i = 0; i<=5; i++) {
if (num[i]==1) {
b[k] = i;
}
}
}
but this doesn't produce the desired result. When I type the string in,
say 1001, I get 444. Can someone tell me what I'm doing incorrectly?

How could I calculate several means using one set of user inputs?

How could I calculate several means using one set of user inputs?

I am trying to calculate an arithmetic, geometric, and harmonic mean as
well as a standard deviation, after prompting a user to input 5 integers.
I have the arithmetic mean working well. Its the others after it that are
troublesome.. I am almost positive it is because of my structuring, but I
just am not sure what to change after researching online and in my
textbook... and any help is appreciated with this!
Here is the code:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
float a_mean;
float g_mean;
float h_mean;
float st_dev;
sum1 = 0; sum2 = 0; sum3 = 0;
float data[100];
n = 5;
int i;
int main()
{
printf("Please Enter Five Integers:\n"); /* Prompts user input */
for ( i = 0; i < n; ++i)
{
scanf("%f", &data[i]);
sum1 = sum1 + data[i];
}
a_mean = sum1 / n;
{
sum2 = sum2 * data[i];
}
g_mean = pow(sum2, 1 / n);
{
sum3 = sum3 + ( 1 / data[i] );
}
h_mean = n / sum3;
printf("Arithmetic mean: %0.2f\n", a_mean);
printf("Geometric mean: %0.2f\n", g_mean);
printf("Harmonic mean: %0.2f\n", h_mean);
return 0;
}
I know its probably something basic with my for-structuring, but I simply
don't know a lot about this stuff yet, so thanks in advance

RUN CRON every day once an hour between 8am and 5pm

RUN CRON every day once an hour between 8am and 5pm

Hello I need to run a cron job every day once an hour between 8am and 5pm.
I am new to cronjobs. Thanks.

Save Related Data using Entity data

Save Related Data using Entity data

i HAVE AREAs in my project like
Areas Student Controllers StudentController
Views
Shared
ViewProfile
My Route configured is
context.MapRoute( "Student_default", "Student/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
I am calling views as RedirectToAction("ViewProfile", "Student",new { Area
= "",id = WebSecurity.CurrentUserId});
But Url shows ~/Student/Student/ViewProfile/4
I want url to be ~/Student/ViewProfile/4
can you guide me how can i achive that

how do I compile a whole Frege source tree

how do I compile a whole Frege source tree

Following the answeres to how to use multiple inline assertions in Frege I
learned how to compile two Frege modules A and B where B depends on A: you
have to compile B. If given the -make option, the compiler will figure out
that B depends on A, will find A on the sourcepath (-sp flag), and will
compile A first and then B.
However, I cannot just give all files I care about to the compiler. Giving
both A and B to the compiler failed with a "cyclic dependency" error for
me. And I also found no way to give a directory to the compiler (it just
did nothing).
This looks like I had to know the root of the dependency graph to do a
proper compilation of all need-to-be-compiled files. But
I may not know the root.
There may be many of them.
It's very difficult to do a proper build automation that way.
Is there a combination of compiler options where I can just let the
compiler compile all files in a source tree?

twitter bootstrap remove newline

twitter bootstrap remove newline

As the title states, using twitter bootstrap, if I have two paragraphs as
follows
<p> Line 1</p> <p> Line2 </p>
bootstrap automatically inserts a newline rendering it like:
Line1
Line2
How do I override bootstrap CSS so that it does not insert the newline so
I can get the html to render like this:
Line1 Line2
Thanks all for the help!

Saturday, 14 September 2013

My if statement needs work

My if statement needs work

How do I make an alert / prompt message if the record is not found?
$("#recordInput").on("keypress", function(enter2){
var record = $('input[name="record"]').val();
if (enter2.keyCode == 13){
$("#drinks li:contains('" + record + "')").appendTo("#hugs");
$('form').trigger("reset");
}
});

DateDiff SQL Error

DateDiff SQL Error

I have a problem with my SQL syntax. But I can not determine what is wrong
with the syntax. The syntax is:
SELECT * FROM Inmuebles WHERE DATEDIFF(day, FechaIngreso, getdate()) <= 30
The reason why I put three parameters in the DATEDIFF function is because
that I have read on here: DATEDIFF
The execution of this query has returned the following error:
#1582 - Incorrect parameter count in the call to native function 'DATEDIFF'
Then Google the mistake, and I came across the following post:
Error in calculating age in MySQL?
Having read this post, I decided to leave the query in this way:
SELECT * FROM Inmuebles WHERE DATEDIFF(FechaIngreso, getdate()) <= 30
But unfortunately tripped me with this error:
#1547 - Column count of mysql.proc is wrong. Expected 20, found 16. The
table is probably corrupted
Thanks for taking the time to read, please I hope you can forgive my
horrible way to write English and can help with this problem. Greetings!

upload image to azure blob and display in src tag

upload image to azure blob and display in src tag

I'm trying to create a simple rest api for images
I'm posting from the client using js formdata and jquery ajax
to an asp.net ApiController
that is uploading to azure blob storage
whenever I try to retrieve one of the images that I uploaded, I get one of
those 'no image' icons
you can see it here:
http://listr.blob.core.windows.net/images/42zrkyxd.k3y.jpg
I also try to use it in a src tag to no avail
I uploaded an image through visual studio and that is getting retrieved
properly so I think it has to be the upload code.
The blobs look the same when looking at them on the azure portal as far as
blob properties go.
api and client code below:
help! and thanks in advance
[System.Web.Http.HttpPost]
[ActionName("Images")]
public HttpResponseMessage Images(int id)
{
if (!Request.Content.IsMimeMultipartContent("form-data"))
{
throw new
HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("CloudStorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container =
blobClient.GetContainerReference("images");
container.CreateIfNotExists();
var permissions = container.GetPermissions();
if (permissions.PublicAccess == BlobContainerPublicAccessType.Off)
{
permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
container.SetPermissions(permissions);
}
var task = Request.Content.ReadAsStreamAsync();
task.Wait();
Stream stream = task.Result;
string randomBlobName = string.Format(Path.GetRandomFileName() +
".jpg");
CloudBlockBlob blob =
container.GetBlockBlobReference(randomBlobName);
blob.Properties.ContentType = "image/jpeg";
blob.UploadFromStream(stream);
return new HttpResponseMessage(HttpStatusCode.Created);
}
Client code here
<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
<script>
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
// Loop through the FileList and render image files as
thumbnails.
for (var i = 0, f; f = files[i]; i++) {
// Only process image files.
if (!f.type.match('image.*')) {
continue;
}
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function (theFile) {
return function (e) {
// Render thumbnail.
var span = document.createElement('span');
span.innerHTML = ['<img class="thumb" src="',
e.target.result,
'" title="',
escape(theFile.name),
'"/>'].join('');
document.getElementById('list').insertBefore(span,
null);
var data = new FormData();
data.append('image', e.target.result);
if (FormData) {
$.ajax({
url: "api/posts/3/images",
type: "POST",
data: data,
processData: false,
contentType: false,
success: function (res) {
console.dir(res);
}
});
}
};
})(f);
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
}
document.getElementById('files').addEventListener('change',
handleFileSelect, false);
</script>
thanks

The best way of eliminating semi-duplicate! records in Oracle

The best way of eliminating semi-duplicate! records in Oracle

I have some records like
a,b
b,a
a,c
c,a
b,d
d,b
b,f
f,b
...
in my query result. (They are emails) What is the best way to have:
a,b
a,c
b,d
b,f
and eliminate b,a and c,a, d,b, f,b?
I tried
SELECT *
FROM ...
WHERE MOD(ROWNUM/2)=0
But it just returns the first row

How to add extensions list to qq uploder

How to add extensions list to qq uploder

I am using the Valums Ajax Uploader to upload files.
How to add extensions list to qq uploader ? in (java script file)
qq uploader on github

iOS holding UIView references in a MutableArray with ARC

iOS holding UIView references in a MutableArray with ARC

I try to manage several views and keep those references in a mutable
array. If I both add a view reference in a mutable array and also added
into a view, as a subview. And then the reference count seems not correct.
Will cause the bad access error.
So my question is that is there a good way to manage those views. For
example, if I need to reuse the views. Keeping them in a mutable array
when no used and reuse them later.

Simple tree to store hierarchical company employees in C++

Simple tree to store hierarchical company employees in C++

We want to maintain the list of employees in a company. We will be
concerned with two quantities associated with each employee in the company
-- name of the employee (you can assume no two employees in the company
have the same name), and the level of the employee. The level denotes
where the person stands in the hierarchy. Level 1 denotes the highest post
in the company (say the CEO), level 2 comes below level 1 and so on. There
is only 1 person at level 1, but there can be several employees at level i
> 1. Each level i employee works under a level i-1 employee, which is
his/her immediate boss. Given an employee A, we can form a sequence of
employees A',A'', A''', ... where A works under A', A' works under A'',
and so on. We say that each employee in A',A'', A''',... is a boss of A. i
would like to implement a suitable tree data-structure so that we can
implement the operations like adding, deletions, printing etc.
the program should be able to read data from a file. The file contains
some integers and some words. The first entry is guaranteed to be an
integer. Depending on the value of the integer your program should do the
following: 1 Read the name of the CEO. Keep this person at level 1. 2 Read
the names in pairs. For each pair (A,B) add the employee A in the tree so
that he reports to immediate boss B. Note that automatically level of A
will be one more than that of B. 3 Read the name. If the name is "top"
,print the company structure by printing the level number and names of
employees at that level in each line, starting with level 1. If another
name is given then print the subtree starting with the node containing
that name. 4 Read the name K. Print K and within curly braces print the
names of all the employees who happen to be boss of K, starting with the
immediate boss.
5 Read the name pair (C D). Remove C from the tree and rearrange the
employee records such that all persons working under C will now work under
D. If no one is reporting to C then simply remove C. 6 Read the name pair
(G F). Print names G and F within curly braces. Print the name of the
employee who is common boss of G and F at the lowest hierarchy in the
company. There will be many bosses of G and F but this boss will be at the
highest level amongst all the bosses. 7 print a line of character "-". 8
Print your name and entry number and exit the program.
Sample input: 1 singh 2 sen singh rao singh pal sen jain sen de rao 3 top
7 4 jain 7 6 dev pal
2 bal rao negi de dev sen 5 sen rao 7 3 rao 7 4 negi
Sample output: 1 singh 2 sen rao 3 pal jain de



jain { sen singh }



{ dev pal }sen



2 rao 3 de bal pal jain dev 4 negi



negi { de rao singh }
I would be happy to have a proper code because i have trouble programming
in c++

Error when use do_upload

Error when use do_upload

I have a problem when i use do_upload its always error with The upload
path does not appear to be valid.
function save_blog(){
$config['upload_path'] =
'ftp://username:password@hostname:port/public_html/img/blog/';
//$config['upload_path'] = 'img/blog/';
$config['allowed_types'] = 'gif|jpg|png';
get_instance()->load->library('upload', $this->config);
echo $config['upload_path'];
if($this->upload->do_upload('myDoc'))
{
echo "file upload success";
}
else
{
echo $this->upload->display_errors();
}
}
On my server there are path /public_html/img/blog/
PS* i can use do_upload when i used a simple code like
http://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html
but on my project I have to upload 2 files in one click so I try to use
$this->upload->do_upload('myDoc') for one of my input first but it still
error.

Friday, 13 September 2013

Java Eclipse Programming Need Support

Java Eclipse Programming Need Support

I am having problems with my programming (Im a novice) of this java class
file it does go with other class files. I would appreciate it if someone
can help with this. I'm getting stressed over trying to figure out my
problem.
this is what i was trying to learn it off of
Part 1: http://www.youtube.com/watch?v=x4QaOmDV9eE
Part 2: http://www.youtube.com/watch?v=x4QaOmDV9eE
Part 3: http://www.youtube.com/watch?v=TY9bDWuAaVg
If You want the file it is: http://www.mediafire.com/?s1mmlrr9arfrwis
I'm having problems with these in the class
* public class GameCanvas extends Canvas implements Runnable{
* long beginTime = System.currentTimeMillis();
* t.sleep(sleepTime);



Here is my code:
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
public class GameCanvas extends Canvas implements Runnable{
int FWidth = 800;
int FHeight = 600;
public long period = 10;
public BufferStrategy Buffer;
public Graphics graphics;
private Thread t;
public GameCanvas(){
this.setIgnoreRepaint(true);
this.setBounds (0, 0, FWidth, FHeight);
this.setBackground(Color.white);
this.setVisible(true);
}
public void addNotify(){
super.addNotify();
this.createBufferStrategy(2);
this.Buffer = this.getBufferStrategy();
startGame();
}
public void startGame(){
if(t == null){
t = new Thread(this);
t.start();
}
}
public void run(){
while(true){
long beginTime = System.currentTimeMillis();
Update();
Render();
Draw();
long timeTaken = System.currentTimeMillis();
long sleepTime = period - timeTaken;
try{
t.sleep(sleepTime);
}
catch(Exception e) {
}
}
}
public void Update(){
}
public void Render(){
graphics = Buffer.getDrawGraphics();
graphics.setColor(Color.white);
graphics.fillRect(0, 0, FWidth, FHeight);
//Paint :D
}
public void Draw(){
if(!Buffer.contentsLost()){
Buffer.show();
if(graphics != null){
graphics.dispose();
}
}
}
}

Building a string that starts with a number and the second part of the string is to have a common indent

Building a string that starts with a number and the second part of the
string is to have a common indent

I'm building a value to display in a dropdown Select box. This value
consists of a currency value, then a username. What I would like is that
the usernames all start with the same indent.
Ex (what I have currently):
$1,000 UserA
$100 UserB
$10 UserC
What I would like:
$1,000 UserA
$100 UserB
$10 UserC
or even better:
$1,000 UserA
$100 UserB
$10 UserC
As I see the third list as the most readable.
Is there an easy way to do this without writing a function where I examine
the max length, and then format it manually or a "cheat" to accomplish
this?

Update parent from iframe using jquery

Update parent from iframe using jquery

I have this minimal test case
a.html
<!DOCTYPE html>
<html>
<body>
<input type="text" id="myinput">
<iframe id="frame" src="b.html" style="width:100%;height:100%"
frameBorder="0"></iframe>
</body>
</html>
b.html
<!DOCTYPE html>
<html>
<body>
<script>
function update_parent(value) {
window.parent.document.getElementById('myinput').value=value;
}
</script>
<a class="tag" name="something" href="javascript:void(0)"
onclick="update_parent(something)"/>Bla Bla</a>
</body>
</html>
The purpose here is to update the input box in parent window, when a
button is clicked on the iframe. I tried to do it using plain javascript
as you can see above, but it doesn't work either. I want to do this using
jquery if possible.

Using a web service in asp.net C#

Using a web service in asp.net C#

I am making a Web application in asp.net with C# 3.0 .NET framework. I
want to know how to find and integrate a web service with my project such
that it gives me fresh airlines rates which i can use in the C# logic to
make decisions

Jquery resize image with a heart beat effect

Jquery resize image with a heart beat effect

Hello want to make a image with a heartbeat effect. It has to resize a
bit, let's say maximum 20 pixel bigger, and then goes to original size. It
will be like a heartbeat, 2 beats - original, 2 beats - original.
So far I found only this effect:
(function pulse(back) {
$('#seventyfive').animate(
{
'font-size': (back) ? '100px' : '140px',
opacity: (back) ? 1 : 0.5
}, 700, function(){pulse(!back)});
})(false);
Or you can check it out here: JSFiddle

How to record the running information of functions in your program?

How to record the running information of functions in your program?

guys! Recently,i attend a coding interview.And I was asked a question
which i don't know. After searching the answer on the internet for a few
day, I come here call for help. The question is described as followed: You
should propose a approach to record the running information of function in
your program,for example,the times of a function called,and so on. By the
way, you are not allowed to modify these functions.Maybe you want to
define a global variant in these function to record the running
function,but that is not allowed.
Ok! That's all about the question i met in a coding interview.

Thursday, 12 September 2013

Google removed app from playstore

Google removed app from playstore

One of our apps has been removed from Playstore by Google.
//Sent by Google Play Team
REASON FOR REMOVAL: Violation of section 4.3 of the Developer Distribution
Agreement. We classify a user's contacts as private and confidential
information. Apps which upload a user's contacts to a service without
making this clear to the user and obtaining the user's explicit consent
are regarded as being in violation of section 4.3 of the DDA.
We are getting contact information from users phone and sending the list
of contacts to our server through an HTTP API. However at the server we
are not storing any of those information and using only for some complex
operations.
4.3 DDA agreement says we should have a separate user-agreement and opt
user to agree to those Terms & Conditions.
Can we solve this problem by have a separate EULA and prompt user to agree
upon those ? Please let me know the right solution because I don't want to
risk my client's developer account getting deleted.

Creating a checkable context menu from a list of enum values

Creating a checkable context menu from a list of enum values

I see lots of people asking questions similar to mine, but so far I
haven't been able to put the pieces together to solve my problem.
I have a certain enum type (let's call it MyCustomEnum) which I'd like to
use to create the list of choices in a ContextMenu. I'd like the menu
items to be checkable, and have the checked MenuItem bound to a static
setting the application uses (a property we'll call MyCustomEnumSetting on
the settings class MyCustomSettingsClass).
So far, I'm able to generate the ContextMenu and check the correct
MenuItem, based on the setting value. I did this using a MultiBinding to
compare the enum value in the DataContext of the MenuItem to the value of
the settings class enum and see if their values equal. However, the
binding is only one way: clicking on an unchecked MenuItem doesn't update
the binding. I have a feeling I'm missing something, but this part of WPF
is a bit more fuzzy to me.
Here's what I have so far:
<UserControl>
<UserControl.Resources>
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type
system:Enum}" x:Key="MyCustomEnumProvider">
<ObjectDataProvider.MethodParameters>
<x:Type Type="local:MyCustomEnum" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<local:EnumEqualsConverter x:Key="EnumEqualsConverter" />
</FrameworkElement.Resources>
<FrameworkElement.ContextMenu>
<ContextMenu ItemsSource="{Binding Source={StaticResource
MyCustomEnumProvider}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter
Property="IsChecked">
<Setter.Value>
<MultiBinding Converter="{StaticResource
EnumEqualsConverter}">
<MultiBinding.Bindings>
<Binding Source="{x:Static
local:MyCustomSettingsClass.Default}"
Path="MyCustomEnumSetting" />
<Binding
RelativeSource="{RelativeSource Self}"
Path="DataContext" Mode="OneWay" />
</MultiBinding.Bindings>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</FrameworkElement.ContextMenu>
</FrameworkElement>
In this example, EnumEqualsConverter simply checks whether the input
values are equal. Any suggestions for a different direction I could go to
get the results I'm looking for?