Javascript return enclosing function
I have a simple scenario in which I check if something exists before
adding it, if it does, I return the function (hence exiting). I use this
pattern many times and I would like to decouple it in another simple
function.
function onEvent(e){
if( this.has(e) )
return
this.add(e);
// More logic different on an event-basis
}
I would like to decouple it like so:
function safeAdd(e){
if( this.has(e) )
return
this.add(e);
}
function onEvent(e){
safeAdd(e);
// More logic
}
But obviously doing so just returns safeAdd and doesn't exit from onEvent,
and the rest of the logic gets executed anyways.
I know I could do something like:
function safeAdd(e){
if( this.has(e) )
return false
this.add(e);
return true
}
function onEvent(e){
if( !safeAdd(e) )
return
// More logic
}
But, since I repeat this a lot, I would like to be as concise as possible.
Saturday, 31 August 2013
Two keys pressed simultaneously in autohotkey
Two keys pressed simultaneously in autohotkey
I'm wiring innards of a keyboard to make a board of buttons to use as
macros for photoshop among other applications. The insert key and a letter
key is wired to a single tactile switch. This is done with each letter
switch.
I can use Ins & a:: but because I can't predict which will be "read"
first, I have to have the reverse as well. The problem is that when I use
a & Ins:: the 'a' key doesn't work properly.
Is there a way to use the 'up' and 'down' function with a letter key?
Maybe that will work? Otherwise if there is a way to determine if two keys
were pressed within a certain time between each other, I believe that
would work.
I'm wiring innards of a keyboard to make a board of buttons to use as
macros for photoshop among other applications. The insert key and a letter
key is wired to a single tactile switch. This is done with each letter
switch.
I can use Ins & a:: but because I can't predict which will be "read"
first, I have to have the reverse as well. The problem is that when I use
a & Ins:: the 'a' key doesn't work properly.
Is there a way to use the 'up' and 'down' function with a letter key?
Maybe that will work? Otherwise if there is a way to determine if two keys
were pressed within a certain time between each other, I believe that
would work.
Get Twitter Bootstrap navbar to load different pages, not just reference to divs on same page
Get Twitter Bootstrap navbar to load different pages, not just reference
to divs on same page
I am very new to web development and I don't know all the terms. But
basically I want to implement my website like getbootstrap.com --- i.e.
when you click on Getting started, the webpage brings you to a different
page (and resource I believe). My current website's navbar just has
references to different divs on the same page. Can someone direct me to
some resources to learn about how "pages" work?
to divs on same page
I am very new to web development and I don't know all the terms. But
basically I want to implement my website like getbootstrap.com --- i.e.
when you click on Getting started, the webpage brings you to a different
page (and resource I believe). My current website's navbar just has
references to different divs on the same page. Can someone direct me to
some resources to learn about how "pages" work?
Finding minimal cover in functional dependencies
Finding minimal cover in functional dependencies
I just took a quiz in my introduction to databases courses which went over
minimal cover. I couldn't get this question right, and I still don't
understand the instructor's lecture on how he got to the answer. I am
having trouble understanding what to do after the first step of breaking
down the dependencies. What I have done so far is based off a previous
post, which is to break it first into individual dependencies. Any help
understanding how to find minimal cover would be greatly appreciated.
This is the problem I haven't been able to figure out-
Consider a relation R(A,B,C,D,E,F,G,H) with the following functional
dependencies:
AB->CD
H->B
G->DA
C->BG
CD->EF
A->HJ
J->G
What I have done so far is this, to try to simplify it:
H -> B
G -> D
G -> A
C -> B
C -> G
CD -> E
D -> F
A -> H
A -> J
J -> G
I just took a quiz in my introduction to databases courses which went over
minimal cover. I couldn't get this question right, and I still don't
understand the instructor's lecture on how he got to the answer. I am
having trouble understanding what to do after the first step of breaking
down the dependencies. What I have done so far is based off a previous
post, which is to break it first into individual dependencies. Any help
understanding how to find minimal cover would be greatly appreciated.
This is the problem I haven't been able to figure out-
Consider a relation R(A,B,C,D,E,F,G,H) with the following functional
dependencies:
AB->CD
H->B
G->DA
C->BG
CD->EF
A->HJ
J->G
What I have done so far is this, to try to simplify it:
H -> B
G -> D
G -> A
C -> B
C -> G
CD -> E
D -> F
A -> H
A -> J
J -> G
how can I handle events for a created control
how can I handle events for a created control
In VB Express 2010, I have created a bunch of controls on the main form.
Now, I want to process the information when it's entered.
How can I create a subroutine to handle changes to controls that do not
even exist when to program compiles?
In VB Express 2010, I have created a bunch of controls on the main form.
Now, I want to process the information when it's entered.
How can I create a subroutine to handle changes to controls that do not
even exist when to program compiles?
Over Query limit
Over Query limit
Here I have a code to show me google places objects when search in boxes.
So:
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
types: ["museum"]
};
// alert(request.bounds);
service.nearbySearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert("Request["+searchIndex+"] failed: "+status);
return;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML +=
"bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
but if box is empty I get error: Request[i].failed ZERO_RESULT My first
question is How to JUMP over this, so how go to next box and this just
jump becouse there is no results
Also some time I get OVER_QUERY_LIMIT - How I can solve this problem?
Here I have a code to show me google places objects when search in boxes.
So:
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
types: ["museum"]
};
// alert(request.bounds);
service.nearbySearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert("Request["+searchIndex+"] failed: "+status);
return;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML +=
"bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
but if box is empty I get error: Request[i].failed ZERO_RESULT My first
question is How to JUMP over this, so how go to next box and this just
jump becouse there is no results
Also some time I get OVER_QUERY_LIMIT - How I can solve this problem?
Friday, 30 August 2013
No longer able to view Database in Visual Studio 2013
No longer able to view Database in Visual Studio 2013
In VS 2012 and 2013 I was able to view SDF Databases, and also edit/manage
them. But I can't anymore. I haven't changed anything either. It just
won't open the database, it just says that it's unable to open this kind
of database. I've tried creating several new ones and opening different
ones but no luck.
Is there something I need to download?
In VS 2012 and 2013 I was able to view SDF Databases, and also edit/manage
them. But I can't anymore. I haven't changed anything either. It just
won't open the database, it just says that it's unable to open this kind
of database. I've tried creating several new ones and opening different
ones but no luck.
Is there something I need to download?
In Linux, can folders be arranged based on which folder was LAST ACCESSED?
In Linux, can folders be arranged based on which folder was LAST ACCESSED?
I suppose this is not just a linux desktop question
but a linux question in a generic way.
Is it possible to list folders and files based on
which one was last ACCESSED
not based on which one was last modified. but
accessed.
is this possible, if so, how can it be done ?
i do not believe i'd find any answers on google for this.
I suppose this is not just a linux desktop question
but a linux question in a generic way.
Is it possible to list folders and files based on
which one was last ACCESSED
not based on which one was last modified. but
accessed.
is this possible, if so, how can it be done ?
i do not believe i'd find any answers on google for this.
Thursday, 29 August 2013
Authenticating Curl HTTP Post
Authenticating Curl HTTP Post
Hi I am trying to send POST request through CURL but its throwing an error
which says
"Failed connect to qaservices.carrental.com:443; No error".
The username and password is already included in the soap header in an xml
file
<?php
$filename = 'c:/v.xml';
$data = file_get_contents($filename);
$url = 'https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071';
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_HEADER, 0 );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
if ( curl_errno($soap_do) )
{
$result = 'ERROR -> ' . curl_errno($soap_do) . ': ' .
curl_error($soap_do);
}
else
{
$returnCode = (int)curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
switch($returnCode)
{
case 200:
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
curl_close($ch);
echo $result;
?>
When i try to send HttpWebRequest in vb.net this works. the copy of code
in vb.net is
doc.Load("c:/v.xml")
Dim content As String = doc.InnerXml
Dim urlEncoded As String = content
Dim encodedRequest As Byte() = New
ASCIIEncoding().GetBytes(urlEncoded)
Dim request As HttpWebRequest =
DirectCast(WebRequest.Create("https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071"),
HttpWebRequest)
request.Method = "POST"
request.Accept = "*/*"
request.ContentType = "application/x-www-form-urlencoded"
' request.UserAgent = "Custom REST client v1.0"
request.ContentLength = encodedRequest.Length
request.Proxy.Credentials =
CredentialCache.DefaultCredentials
Dim reqStream As Stream = request.GetRequestStream()
reqStream.Write(encodedRequest, 0, encodedRequest.Length)
reqStream.Flush()
reqStream.Close()
Dim response As HttpWebResponse = (request.GetResponse())
Dim responseStream As Stream = response.GetResponseStream()
Dim streamReader As New StreamReader(responseStream)
Dim responseContent As String = streamReader.ReadToEnd
I think it has to do something in setting up proxy credential Can anyone
please guide me in correct path
Hi I am trying to send POST request through CURL but its throwing an error
which says
"Failed connect to qaservices.carrental.com:443; No error".
The username and password is already included in the soap header in an xml
file
<?php
$filename = 'c:/v.xml';
$data = file_get_contents($filename);
$url = 'https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071';
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url );
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_HEADER, 0 );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($soap_do);
$err = curl_error($soap_do);
if ( curl_errno($soap_do) )
{
$result = 'ERROR -> ' . curl_errno($soap_do) . ': ' .
curl_error($soap_do);
}
else
{
$returnCode = (int)curl_getinfo($soap_do, CURLINFO_HTTP_CODE);
switch($returnCode)
{
case 200:
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
curl_close($ch);
echo $result;
?>
When i try to send HttpWebRequest in vb.net this works. the copy of code
in vb.net is
doc.Load("c:/v.xml")
Dim content As String = doc.InnerXml
Dim urlEncoded As String = content
Dim encodedRequest As Byte() = New
ASCIIEncoding().GetBytes(urlEncoded)
Dim request As HttpWebRequest =
DirectCast(WebRequest.Create("https://qaservices.carrental.com/wsbang/HTTPSOAPRouter/ws9071"),
HttpWebRequest)
request.Method = "POST"
request.Accept = "*/*"
request.ContentType = "application/x-www-form-urlencoded"
' request.UserAgent = "Custom REST client v1.0"
request.ContentLength = encodedRequest.Length
request.Proxy.Credentials =
CredentialCache.DefaultCredentials
Dim reqStream As Stream = request.GetRequestStream()
reqStream.Write(encodedRequest, 0, encodedRequest.Length)
reqStream.Flush()
reqStream.Close()
Dim response As HttpWebResponse = (request.GetResponse())
Dim responseStream As Stream = response.GetResponseStream()
Dim streamReader As New StreamReader(responseStream)
Dim responseContent As String = streamReader.ReadToEnd
I think it has to do something in setting up proxy credential Can anyone
please guide me in correct path
Book Review Required for Drupal for Education and E-Learning - Second Edition
Book Review Required for Drupal for Education and E-Learning - Second Edition
Packt is looking for people interested in reviewing the book Drupal for
Education and E-Learning - Second Edition Drupal for Education and
E-Learning - Second Edition on their blog/ amazon The book is written by
James G. Robertson and Bill Fitzgerald
If interested, please let me know at – sabyasachir@packtpub.com or leave a
comment below with your email ID, I will provide you with the e-copy of
the book. Note : Limited copies available. Thanks and regards
Packt is looking for people interested in reviewing the book Drupal for
Education and E-Learning - Second Edition Drupal for Education and
E-Learning - Second Edition on their blog/ amazon The book is written by
James G. Robertson and Bill Fitzgerald
If interested, please let me know at – sabyasachir@packtpub.com or leave a
comment below with your email ID, I will provide you with the e-copy of
the book. Note : Limited copies available. Thanks and regards
Wednesday, 28 August 2013
Maven failed to start Liberty Profile on Windows
Maven failed to start Liberty Profile on Windows
I was trying to configure Maven to launch WebSphere Liberty Profile from
Eclipse. Anyhow I find it working on Linux but doesn't work on Windows.
Below is the setup on pom.xml. (Please note only relevant code will be
post here)
<pluginRepositories>
<pluginRepository>
<id>WASdev</id>
<name>WASdev Repository</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
...
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.ibm.websphere.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<serverHome>D:\tool\wlp</serverHome>
<serverName>LP1</serverName>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<serverHome>D:\tool\wlp</serverHome>
<serverName>LP1</serverName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
I have my Liberty Profile install at D:\tool\wlp and have a server created
named LP1. When I launch the server with this goal: liberty:start-server,
I will hit this error:
[ERROR] Failed to execute goal
com.ibm.websphere.wlp.maven.plugins:liberty-maven-plugin:1.0:start-server
(default-cli) on project SpringSecurity4: CWWKM2002E: Failed to invoke
[D:\tool\wlp\bin\server.bat, start, LP1, --clean]. RC= 22 but expected=0.
I wasn't sure what 22 means? Forget about that mystery number, only IBM
guy may decode that number. When I try this on cmd > mvn start LP1, I have
this output:
The filename, directory name, or volume label syntax is incorrect.
Starting server LP1. Server LP1 start failed. Check server logs for
details.
The content of the log was shown below, but still I'm not able to decode
the message behind the scene. Hope you guys could help.
arg0=LP1 arg1=--status:start exit=22
Command: "C:\Documents and
Settings\kok.hoe.loh\Tool\jdk1.6.0_30\jre\bin\java"
-XX:MaxPermSize=256m "-javaagent:D:\tool\wlp\bin\tools\ws-javaagent.jar"
-jar "D:\tool\wlp\bin\tools\ws-server.jar" --batch-file start LP1 --clean
Java home: C:\Documents and
Settings\kok.hoe.loh\Tool\jdk1.6.0_30\jre
Install root: D:/tool/wlp/
System libraries: D:/tool/wlp/lib/
User root: D:/tool/wlp/usr/
Server config: D:/tool/wlp/usr/servers/LP1/
Server output: D:/tool/wlp/usr/servers/LP1/
I was trying to configure Maven to launch WebSphere Liberty Profile from
Eclipse. Anyhow I find it working on Linux but doesn't work on Windows.
Below is the setup on pom.xml. (Please note only relevant code will be
post here)
<pluginRepositories>
<pluginRepository>
<id>WASdev</id>
<name>WASdev Repository</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
...
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.ibm.websphere.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<serverHome>D:\tool\wlp</serverHome>
<serverName>LP1</serverName>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<serverHome>D:\tool\wlp</serverHome>
<serverName>LP1</serverName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
I have my Liberty Profile install at D:\tool\wlp and have a server created
named LP1. When I launch the server with this goal: liberty:start-server,
I will hit this error:
[ERROR] Failed to execute goal
com.ibm.websphere.wlp.maven.plugins:liberty-maven-plugin:1.0:start-server
(default-cli) on project SpringSecurity4: CWWKM2002E: Failed to invoke
[D:\tool\wlp\bin\server.bat, start, LP1, --clean]. RC= 22 but expected=0.
I wasn't sure what 22 means? Forget about that mystery number, only IBM
guy may decode that number. When I try this on cmd > mvn start LP1, I have
this output:
The filename, directory name, or volume label syntax is incorrect.
Starting server LP1. Server LP1 start failed. Check server logs for
details.
The content of the log was shown below, but still I'm not able to decode
the message behind the scene. Hope you guys could help.
arg0=LP1 arg1=--status:start exit=22
Command: "C:\Documents and
Settings\kok.hoe.loh\Tool\jdk1.6.0_30\jre\bin\java"
-XX:MaxPermSize=256m "-javaagent:D:\tool\wlp\bin\tools\ws-javaagent.jar"
-jar "D:\tool\wlp\bin\tools\ws-server.jar" --batch-file start LP1 --clean
Java home: C:\Documents and
Settings\kok.hoe.loh\Tool\jdk1.6.0_30\jre
Install root: D:/tool/wlp/
System libraries: D:/tool/wlp/lib/
User root: D:/tool/wlp/usr/
Server config: D:/tool/wlp/usr/servers/LP1/
Server output: D:/tool/wlp/usr/servers/LP1/
Cookie not being created and stored websphere
Cookie not being created and stored websphere
pI've a WEB project deployed in WAS 6.1 server which creates and stores a
cookie for session management. I've upgraded WAS to v7.0.0.27 and now the
cookie is not being stored nor created. I'm using jdk1.6_19, WEB Module
2.5 and EJB 3.0./p pThis is the way I create the cookie:/p precode Cookie
cookie = new Cookie(user, divison); cookie.setMaxAge(Integer.MAX_VALUE);
cookie.setPath(/); res.addCookie( cookie ); /code/pre pI've spent 2 weeks
on this but nothing seems to be working. I've patch my RSA to have
7.5.5.5.001 Fix, I've gone thru Websphere console for setting cookies,
I've deployed the same application in Tomcat and the cookie is getting
created but in WAS Websphere v7.0.0.27 I can't make it./p pAny idea or
solution for this issue will be appreciated/p
pI've a WEB project deployed in WAS 6.1 server which creates and stores a
cookie for session management. I've upgraded WAS to v7.0.0.27 and now the
cookie is not being stored nor created. I'm using jdk1.6_19, WEB Module
2.5 and EJB 3.0./p pThis is the way I create the cookie:/p precode Cookie
cookie = new Cookie(user, divison); cookie.setMaxAge(Integer.MAX_VALUE);
cookie.setPath(/); res.addCookie( cookie ); /code/pre pI've spent 2 weeks
on this but nothing seems to be working. I've patch my RSA to have
7.5.5.5.001 Fix, I've gone thru Websphere console for setting cookies,
I've deployed the same application in Tomcat and the cookie is getting
created but in WAS Websphere v7.0.0.27 I can't make it./p pAny idea or
solution for this issue will be appreciated/p
What does the '?' means in C++?
What does the '?' means in C++?
I´m developing in C++ and I've downloaded a source code from a web, but
analyzing it I've found and structure that I can´t understand...
This is the code:
CvSeq* objects = cvHaarDetectObjects( img, cascade, storage, 1.1, 4, 0,
cvSize( 40, 50 ));
CvRect* r;
// Loop through objects and draw boxes
for( int i = 0; i < (objects ? objects->total : 0 ); i++ ){
r = ( CvRect* )cvGetSeqElem( objects, i );
cvRectangle( img, cvPoint( r->x, r->y ), cvPoint( r->x + r->width,
r->y + r->height ),
colors[i%8]);
}
Inside the 'for' loop it has an structure as delimiter that I can´t
understand, I don´t know how '?' works :(...
Any idea? Thanks for all :)!
I´m developing in C++ and I've downloaded a source code from a web, but
analyzing it I've found and structure that I can´t understand...
This is the code:
CvSeq* objects = cvHaarDetectObjects( img, cascade, storage, 1.1, 4, 0,
cvSize( 40, 50 ));
CvRect* r;
// Loop through objects and draw boxes
for( int i = 0; i < (objects ? objects->total : 0 ); i++ ){
r = ( CvRect* )cvGetSeqElem( objects, i );
cvRectangle( img, cvPoint( r->x, r->y ), cvPoint( r->x + r->width,
r->y + r->height ),
colors[i%8]);
}
Inside the 'for' loop it has an structure as delimiter that I can´t
understand, I don´t know how '?' works :(...
Any idea? Thanks for all :)!
Moved Exchange 2010 to a VM, can't decomission original (physical server)
Moved Exchange 2010 to a VM, can't decomission original (physical server)
We created an exchange VM to replace a physical server, moved the
mailboxes after pointing internal and external DNS to it.
Everything works fine, except when I turn off the original machine, about
half my users lose connection.
A right click on outlook systray for connection status shows Server
'EXCHANGE01 still in the list for those failing... The same list on
failing machines also shows Server exch (the new VM).
Working users only show connection to Server EXCH in the list.
All desktops are identical Dell optiplex's running win7 (same image).
I can't quite figure out what's still pointing them to exchange. Their DNS
is right, a ping to 'mail' shows the right IP for the exch server... so it
must be something in outlook, or some odd config in the server. The fact
that it's roughly half the users is what's throwing me off. All mailboxes
are on the new VM.
I have had SOME users succeed by closing outlook and opening it while ONLY
the exch server was on, but others doggedly stick to waiting for
exchange01.
Stumped
We created an exchange VM to replace a physical server, moved the
mailboxes after pointing internal and external DNS to it.
Everything works fine, except when I turn off the original machine, about
half my users lose connection.
A right click on outlook systray for connection status shows Server
'EXCHANGE01 still in the list for those failing... The same list on
failing machines also shows Server exch (the new VM).
Working users only show connection to Server EXCH in the list.
All desktops are identical Dell optiplex's running win7 (same image).
I can't quite figure out what's still pointing them to exchange. Their DNS
is right, a ping to 'mail' shows the right IP for the exch server... so it
must be something in outlook, or some odd config in the server. The fact
that it's roughly half the users is what's throwing me off. All mailboxes
are on the new VM.
I have had SOME users succeed by closing outlook and opening it while ONLY
the exch server was on, but others doggedly stick to waiting for
exchange01.
Stumped
Mysql select record that should have today and tomorrow date
Mysql select record that should have today and tomorrow date
I want to select record that must have two or more entries but should have
today and tomorrow date in table. I am saving date in table in date
format.
SELECT `availibility`.*
FROM (`availibility`)
WHERE `property_id`= 8818
AND (availibility.unavailibility_date between CURDATE()
AND DATE_ADD(CURDATE(),INTERVAL 1 DAY))
I am using above query but this will true even one date (today or
tomorrow) exists. I want to get such record that should have both dates
for example
ID property_id Date
369516 8818 2013-01-19
369517 8818 2013-01-18
369518 8818 2013-01-17
418021 8818 2013-08-27
418022 8818 2013-08-28
418022 8818 2013-08-29
418022 2001 2013-07-29
418022 2001 2013-07-30
8818 property should come in record set because both date exists here
I want to select record that must have two or more entries but should have
today and tomorrow date in table. I am saving date in table in date
format.
SELECT `availibility`.*
FROM (`availibility`)
WHERE `property_id`= 8818
AND (availibility.unavailibility_date between CURDATE()
AND DATE_ADD(CURDATE(),INTERVAL 1 DAY))
I am using above query but this will true even one date (today or
tomorrow) exists. I want to get such record that should have both dates
for example
ID property_id Date
369516 8818 2013-01-19
369517 8818 2013-01-18
369518 8818 2013-01-17
418021 8818 2013-08-27
418022 8818 2013-08-28
418022 8818 2013-08-29
418022 2001 2013-07-29
418022 2001 2013-07-30
8818 property should come in record set because both date exists here
How to get the executable given only the hex code?
How to get the executable given only the hex code?
I am learning windows assembly language with masm as my assembler and link
as my linker. I took the following assembly code and obtained the exe
.386
.model flat, stdcall
option casemap :none
extrn MessageBoxA@16 : PROC
extrn ExitProcess@4 : PROC
.code
start:
mov eax, 0
push eax
jmp msg
pgm: pop ebx
push ebx
push ebx
push eax
call MessageBoxA@16
push eax
call ExitProcess@4
msg: call pgm
db "KingKong",0
end start
C:\Arena>ml /c /coff a.asm
Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: a.asm
C:\Arena>link /subsystem:windows /defaultlib:kernel32 /defaultlib:user32
a.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
The program works fine and displays the message box, Now I ran a objdump
-d a.exe and obtain the shellcode and inserted it back to obtain the
executable as
.386
.model flat, stdcall
option casemap :none
extrn MessageBoxA@16 : PROC
extrn ExitProcess@4 : PROC
.code
start:
db
0xb8,0x00,0x00,0x00,0x00,0x50,0xeb,0x0f,0x5b,0x53,0x53,0x50,0xe8,0x1b,0x00,0x00,0x00,0x50,0xe8,0x0f,0x00,0x00,0x00,0xe8,0xec,0xff,0xff,0xff,0x4b,0x69,0x6e,0x67,0x4b,0x6f,0x6e,0x67,0x00,0xcc,0xff,0x25,0x00,0x20,0x40,0x00,0xff,0x25,0x08,0x20,0x40,0x00
end start
but when I try to assemble it I get
C:\Arena>ml /c /coff b.asm
Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: b.asm
b.asm(10) : error A2042:statement too complex
I was able to get back the executable with the hexdump on linux and that
thread is here. I need to get back the executable using only the hexdump I
obtained on windows now. How do I do it ?
I am learning windows assembly language with masm as my assembler and link
as my linker. I took the following assembly code and obtained the exe
.386
.model flat, stdcall
option casemap :none
extrn MessageBoxA@16 : PROC
extrn ExitProcess@4 : PROC
.code
start:
mov eax, 0
push eax
jmp msg
pgm: pop ebx
push ebx
push ebx
push eax
call MessageBoxA@16
push eax
call ExitProcess@4
msg: call pgm
db "KingKong",0
end start
C:\Arena>ml /c /coff a.asm
Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: a.asm
C:\Arena>link /subsystem:windows /defaultlib:kernel32 /defaultlib:user32
a.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
The program works fine and displays the message box, Now I ran a objdump
-d a.exe and obtain the shellcode and inserted it back to obtain the
executable as
.386
.model flat, stdcall
option casemap :none
extrn MessageBoxA@16 : PROC
extrn ExitProcess@4 : PROC
.code
start:
db
0xb8,0x00,0x00,0x00,0x00,0x50,0xeb,0x0f,0x5b,0x53,0x53,0x50,0xe8,0x1b,0x00,0x00,0x00,0x50,0xe8,0x0f,0x00,0x00,0x00,0xe8,0xec,0xff,0xff,0xff,0x4b,0x69,0x6e,0x67,0x4b,0x6f,0x6e,0x67,0x00,0xcc,0xff,0x25,0x00,0x20,0x40,0x00,0xff,0x25,0x08,0x20,0x40,0x00
end start
but when I try to assemble it I get
C:\Arena>ml /c /coff b.asm
Microsoft (R) Macro Assembler Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: b.asm
b.asm(10) : error A2042:statement too complex
I was able to get back the executable with the hexdump on linux and that
thread is here. I need to get back the executable using only the hexdump I
obtained on windows now. How do I do it ?
Tuesday, 27 August 2013
Fancybox Iframe - Show only the inner content?
Fancybox Iframe - Show only the inner content?
When I use fancybox to load an external url, It is showing inside another
div with border and background as white. I want to display only the
content, which is in the URL. No need to show the outer box, including
drop shadow and close button. How can I make it like this ? Any help will
be greatly appreciated
When I use fancybox to load an external url, It is showing inside another
div with border and background as white. I want to display only the
content, which is in the URL. No need to show the outer box, including
drop shadow and close button. How can I make it like this ? Any help will
be greatly appreciated
Parse data in excel -- space delimited -- right to left
Parse data in excel -- space delimited -- right to left
1 Exxon Mobil 452,926.0 41,060.0 2 Wal-Mart Stores 446,950.0 15,699.0 3
Chevron 245,621.0 26,895.0 4 ConocoPhillips 237,272.0 12,436.0 5 General
Motors 150,276.0 9,190.0 6 General Electric 147,616.0 14,151.0 7 Berkshire
Hathaway 143,688.0 10,254.0
How do I take the above data and create four columns of data in excel?
Rank# Company Name #data1 #data2
Split Text into Columns Function in Excel
this solutions comes close ...
Where is the "read line from right to left" and use the first two spaces
to delimit text function?
Chers, Mw
1 Exxon Mobil 452,926.0 41,060.0 2 Wal-Mart Stores 446,950.0 15,699.0 3
Chevron 245,621.0 26,895.0 4 ConocoPhillips 237,272.0 12,436.0 5 General
Motors 150,276.0 9,190.0 6 General Electric 147,616.0 14,151.0 7 Berkshire
Hathaway 143,688.0 10,254.0
How do I take the above data and create four columns of data in excel?
Rank# Company Name #data1 #data2
Split Text into Columns Function in Excel
this solutions comes close ...
Where is the "read line from right to left" and use the first two spaces
to delimit text function?
Chers, Mw
What kind of modification should I apply to make this loop forever?
What kind of modification should I apply to make this loop forever?
I want to demonstrate to my self the visibility thread-safety problem when
accessing to a variable from more than one thread without using any kind
of synchronisation.
I'm running this example from Java Concurrency in Practice:
public class NoVisibility {
private static boolean ready;
private static int number;
private static class ReaderThread extends Thread {
@Override
public void run() {
while (!ready) {
Thread.yield();
}
System.out.println(number);
}
}
public static void main(String[] args) throws InterruptedException {
new ReaderThread().start();
number = 42;
ready = true;
}
}
How to make it loop forever instead of printing 42 every time I run
(looping for ever means that the modification of the variable ready =
true; in the ReaderThread thread is not visisble to the main thread).
I want to demonstrate to my self the visibility thread-safety problem when
accessing to a variable from more than one thread without using any kind
of synchronisation.
I'm running this example from Java Concurrency in Practice:
public class NoVisibility {
private static boolean ready;
private static int number;
private static class ReaderThread extends Thread {
@Override
public void run() {
while (!ready) {
Thread.yield();
}
System.out.println(number);
}
}
public static void main(String[] args) throws InterruptedException {
new ReaderThread().start();
number = 42;
ready = true;
}
}
How to make it loop forever instead of printing 42 every time I run
(looping for ever means that the modification of the variable ready =
true; in the ReaderThread thread is not visisble to the main thread).
Install / Update SQLite on centOS 6.4
Install / Update SQLite on centOS 6.4
I need sqlite 3.7+ installed on server for installing subversion 1.8.
Unfortunately the version of sqlite installed on server is 3.6. When i
tried to remove sqlite using yum remove sqlite, i got the following error
Error: Trying to remove "yum", which is protected
You could try using --skip-broken to work around the problem
So how can i update / reinstall sqlite to latest version? Any help and
suggestions are highly appreciable. Thanks.
I need sqlite 3.7+ installed on server for installing subversion 1.8.
Unfortunately the version of sqlite installed on server is 3.6. When i
tried to remove sqlite using yum remove sqlite, i got the following error
Error: Trying to remove "yum", which is protected
You could try using --skip-broken to work around the problem
So how can i update / reinstall sqlite to latest version? Any help and
suggestions are highly appreciable. Thanks.
How to get value from string template in Java
How to get value from string template in Java
I have a String template like this:
"Thanks, this is your value : [value]. And this is your account number :
[accountNumber]"
And i have inputs like this:
input 1 : "Thanks, this is your value : 100. And this is your account
number : 219AD098"
input 2 : "Thanks, this is your value : 150. And this is your account
number : 90582374"
input 3 : "Thanks, this is your value : 200. And this is your account
number : 18A47"
I want output like this:
output 1 : "[value] = 100 | [accountNumber] = 219AD098"
output 2 : "[value] = 150 | [accountNumber] = 90582374"
output 3 : "[value] = 200 | [accountNumber] = 18A47"
How to do that? Maybe using Regex?
I have a String template like this:
"Thanks, this is your value : [value]. And this is your account number :
[accountNumber]"
And i have inputs like this:
input 1 : "Thanks, this is your value : 100. And this is your account
number : 219AD098"
input 2 : "Thanks, this is your value : 150. And this is your account
number : 90582374"
input 3 : "Thanks, this is your value : 200. And this is your account
number : 18A47"
I want output like this:
output 1 : "[value] = 100 | [accountNumber] = 219AD098"
output 2 : "[value] = 150 | [accountNumber] = 90582374"
output 3 : "[value] = 200 | [accountNumber] = 18A47"
How to do that? Maybe using Regex?
Monday, 26 August 2013
Some general Twitter4J questions
Some general Twitter4J questions
I'm trying to do a write up of Twitter4J for part of a uni project, but
I'm getting hung up on a few things. From the Twitter4J api:
void sample()
Starts listening on random sample of all public statuses. The default
access level provides a small proportion of the Firehose. The "Gardenhose"
access level provides a proportion more suitable for data mining and
research applications that desire a larger proportion to be statistically
significant sample.
This implies that by default, a "default access" is provided to the
stream, but another type of access, "Gardenhose access" is available. Is
this correct? And if so, how do you access the higher Gardenhose access?
I'm asking as I've seen some answers on SO suggest that there is only one
level of access - the Gardenhose, and I'm trying to clear this up once and
for all.
In addition to this, I would like a reference (if possible) to the number
of tweets the sample stream allows access to. I've read lots of people
cite 1% for "default access" and 10% for "gardenhose access" - but I can't
find this anywhere in the API.
So to sum up, two questions:
Does the sample stream have a "default access" and a "gardenhose access",
or just one of those?
How much of the Twitter firehose stream can these levels of access gain?
If replying, please have links to reference-able API where possible.
I'm trying to do a write up of Twitter4J for part of a uni project, but
I'm getting hung up on a few things. From the Twitter4J api:
void sample()
Starts listening on random sample of all public statuses. The default
access level provides a small proportion of the Firehose. The "Gardenhose"
access level provides a proportion more suitable for data mining and
research applications that desire a larger proportion to be statistically
significant sample.
This implies that by default, a "default access" is provided to the
stream, but another type of access, "Gardenhose access" is available. Is
this correct? And if so, how do you access the higher Gardenhose access?
I'm asking as I've seen some answers on SO suggest that there is only one
level of access - the Gardenhose, and I'm trying to clear this up once and
for all.
In addition to this, I would like a reference (if possible) to the number
of tweets the sample stream allows access to. I've read lots of people
cite 1% for "default access" and 10% for "gardenhose access" - but I can't
find this anywhere in the API.
So to sum up, two questions:
Does the sample stream have a "default access" and a "gardenhose access",
or just one of those?
How much of the Twitter firehose stream can these levels of access gain?
If replying, please have links to reference-able API where possible.
Extract embedded DTD using SAX2 in Java
Extract embedded DTD using SAX2 in Java
I need extract the DOCTYPE content of the follow XML into a String. Then I
want get the HTTP content of the external DTD, and also put it in other
String.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ONIXMessage SYSTEM
"http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
..........
</ONIXMessage>
The string must have the content of
"http://www.editeur.org/onix/2.1/reference/onix-international.dtd"
My java code is:
public class OnixImporter extends DefaultHandler {
public OnixImporter(){super();}
public static void main (String args[]) throws Exception {
XMLReader xr = XMLReaderFactory.createXMLReader();
OnixImporter handler = new OnixImporter();
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
//HOW GET the DTD????
FileReader r = new FileReader("c:\\file.xml");
xr.parse(new InputSource(r));
}
public void startDocument () {....}
public void endDocument () {....}
public void startElement (String uri, String name, String qName,
Attributes atts) {....}
public void endElement (String uri, String name, String qName) {....}
public void characters (char ch[], int start, int length) {....}
}
Thanks in advance.
I need extract the DOCTYPE content of the follow XML into a String. Then I
want get the HTTP content of the external DTD, and also put it in other
String.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ONIXMessage SYSTEM
"http://www.editeur.org/onix/2.1/reference/onix-international.dtd">
<ONIXMessage>
..........
</ONIXMessage>
The string must have the content of
"http://www.editeur.org/onix/2.1/reference/onix-international.dtd"
My java code is:
public class OnixImporter extends DefaultHandler {
public OnixImporter(){super();}
public static void main (String args[]) throws Exception {
XMLReader xr = XMLReaderFactory.createXMLReader();
OnixImporter handler = new OnixImporter();
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
//HOW GET the DTD????
FileReader r = new FileReader("c:\\file.xml");
xr.parse(new InputSource(r));
}
public void startDocument () {....}
public void endDocument () {....}
public void startElement (String uri, String name, String qName,
Attributes atts) {....}
public void endElement (String uri, String name, String qName) {....}
public void characters (char ch[], int start, int length) {....}
}
Thanks in advance.
jQuery Ajax - downloading incomplete (binary) file
jQuery Ajax - downloading incomplete (binary) file
This is what I have:
jquery/1.10.2
$.ajax({
url: "http://samplepdf.com/sample.pdf",
dataType: "text",
data: "",
success: function(data) {
alert(data.length);
},
error: function(a, b, c) {}
});
When I run that locally (in Safari 6.0.5 on OS X), I get 211300. However,
the actual file appears to be 218882 bytes. With something fully ASCII
(such as http://www.angio.net/pi/digits/pi1000000.txt), it seems to work
correctly.
I don't need to download the file, but rather, work with its content.
Is there any way to make ajax work with binary files (either client side
or server side) without resorting to using base64?
This is what I have:
jquery/1.10.2
$.ajax({
url: "http://samplepdf.com/sample.pdf",
dataType: "text",
data: "",
success: function(data) {
alert(data.length);
},
error: function(a, b, c) {}
});
When I run that locally (in Safari 6.0.5 on OS X), I get 211300. However,
the actual file appears to be 218882 bytes. With something fully ASCII
(such as http://www.angio.net/pi/digits/pi1000000.txt), it seems to work
correctly.
I don't need to download the file, but rather, work with its content.
Is there any way to make ajax work with binary files (either client side
or server side) without resorting to using base64?
Playing games from windows
Playing games from windows
I need to ask you a question . First of all sorry for my poor english ,
please try to understand me and if you post an answer please don't use
"rare words" .
I use Ubuntu 12.04 . Before that I used Windows 7 . I have changed nothing
from the hardware since I upgraded to Ubuntu . The games that I could play
before , can I play them now ? I only care about singleplayer mode so
anything like "Steam" or "garena" or any other service like this , it is
useless FOR ME
for example : I used to play AC3 . Can I play it again through wine ?
Sorry again for the poor english , and thanks :D
I need to ask you a question . First of all sorry for my poor english ,
please try to understand me and if you post an answer please don't use
"rare words" .
I use Ubuntu 12.04 . Before that I used Windows 7 . I have changed nothing
from the hardware since I upgraded to Ubuntu . The games that I could play
before , can I play them now ? I only care about singleplayer mode so
anything like "Steam" or "garena" or any other service like this , it is
useless FOR ME
for example : I used to play AC3 . Can I play it again through wine ?
Sorry again for the poor english , and thanks :D
How not to ask for publish permission everytime?
How not to ask for publish permission everytime?
I did this in facebook
[self vSuspendAndHaltThisThreadTillUnsuspendedWhileDoing:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.ACAstore requestAccessToAccountsWithType:self.ACAccounts
options:[self dicPostOptions] completion:^(BOOL granted, NSError
*error) {
self.bPermissionToAccessStoreGranted=granted;
[self vContinue];
}];
}];
}];
Basically I am asking for publish permission. What I want to do is to
check whether such publish permission has been granted or not before
asking again.
How to do so?
I did this in facebook
[self vSuspendAndHaltThisThreadTillUnsuspendedWhileDoing:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.ACAstore requestAccessToAccountsWithType:self.ACAccounts
options:[self dicPostOptions] completion:^(BOOL granted, NSError
*error) {
self.bPermissionToAccessStoreGranted=granted;
[self vContinue];
}];
}];
}];
Basically I am asking for publish permission. What I want to do is to
check whether such publish permission has been granted or not before
asking again.
How to do so?
Sunday, 25 August 2013
Show that $A$ is similar to a diagonal matrix iff $b=?iso-8859-1?Q?=3Dc=3Dd=3De=3Df=3Dg=3D0$_=96_math.stackexchange.com?=
Show that $A$ is similar to a diagonal matrix iff $b=c=d=e=f=g=0$ –
math.stackexchange.com
Show that $A$ is similar to a diagonal matrix iff $$b=c=d=e=f=g=0$$ $$A=
\left(\begin{array}{cccc}a & b & c & d \\ 0 & a & e & f\\ 0 & 0 & a & g\\
0 & 0 & …
math.stackexchange.com
Show that $A$ is similar to a diagonal matrix iff $$b=c=d=e=f=g=0$$ $$A=
\left(\begin{array}{cccc}a & b & c & d \\ 0 & a & e & f\\ 0 & 0 & a & g\\
0 & 0 & …
Remove z-axis ticks (only) from R's persp
Remove z-axis ticks (only) from R's persp
I need a 3D perspective plot with tickmarks and labels on the x and y axes
only, but not the z axis. Is this possible with persp? If not, is there
another R library that can do this?
Here is some working code, used only to illustrate what I'm looking for:
x <- seq(-10, 10, length= 30)
y <- x
f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
persp(x, y, z, theta = 30, phi = 30, ticktype = "detailed")
Finally, this is the desired plot output, which I've edited to erase the z
axis tick marks and labels.
I need a 3D perspective plot with tickmarks and labels on the x and y axes
only, but not the z axis. Is this possible with persp? If not, is there
another R library that can do this?
Here is some working code, used only to illustrate what I'm looking for:
x <- seq(-10, 10, length= 30)
y <- x
f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
persp(x, y, z, theta = 30, phi = 30, ticktype = "detailed")
Finally, this is the desired plot output, which I've edited to erase the z
axis tick marks and labels.
i18n vs qsTr (what is the difference)
i18n vs qsTr (what is the difference)
In this tutorial
http://developer.ubuntu.com/resources/tutorials/getting-started/currency-converter-phone-app/
you can see i18n.tr was used for the internationalisation of text in the
Qml file. Today I checked this tutorial:
http://qt-project.org/doc/qt-5.0/qtquick/qtquick-internationalization.html
where they use another technique (qsTr).
What is the difference between the two? What makes one better than the
other in some situations?
In this tutorial
http://developer.ubuntu.com/resources/tutorials/getting-started/currency-converter-phone-app/
you can see i18n.tr was used for the internationalisation of text in the
Qml file. Today I checked this tutorial:
http://qt-project.org/doc/qt-5.0/qtquick/qtquick-internationalization.html
where they use another technique (qsTr).
What is the difference between the two? What makes one better than the
other in some situations?
[ Military ] Open Question : Do you know any apps like this for andriod phone ? military related?
[ Military ] Open Question : Do you know any apps like this for andriod
phone ? military related?
i think it is military related. only combat men could answercit. an app
could show you the cover age map of eatable wild plants and animals
activity zone on screen. it looks like the radar scope on the screen. i
know an app could show the coverage map of WIFI and 4G signal . just
similar to that. you are the center point of GPS. because once you got in
a strange and dangers area without any supplement. that app can show you
the save place and a place you can find eatable plants without posion.
thanks.
phone ? military related?
i think it is military related. only combat men could answercit. an app
could show you the cover age map of eatable wild plants and animals
activity zone on screen. it looks like the radar scope on the screen. i
know an app could show the coverage map of WIFI and 4G signal . just
similar to that. you are the center point of GPS. because once you got in
a strange and dangers area without any supplement. that app can show you
the save place and a place you can find eatable plants without posion.
thanks.
Master View Application : How to send a predefined text based on selecting a tableview to detailview
Master View Application : How to send a predefined text based on selecting
a tableview to detailview
Currently, when I click on an item in the tableview, I am redirected to
detailview. But I do not know how to retrieve and send messge
With this, I get the selection of tableview and I created a message.
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
LoanModel* loan = _feed.users[indexPath.row];
NSString* message = [NSString stringWithFormat:@"%@ from %@ needs a loan %@",
loan.name, loan.username, loan.email
];
}
But how can i send this message to detailview and display it ?
Here is my detailview h
// ssDetailViewController.h
#import <UIKit/UIKit.h>
@interface ssDetailViewController : UIViewController
@property (strong, nonatomic) id detailItem;
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
@end
Here is my detailview m
// ssDetailViewController.m
#import "ssDetailViewController.h"
@interface ssDetailViewController ()
- (void)configureView;
@end
@implementation ssDetailViewController
#pragma mark - Managing the detail item
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
self.detailDescriptionLabel.text = [self.detailItem description];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
a tableview to detailview
Currently, when I click on an item in the tableview, I am redirected to
detailview. But I do not know how to retrieve and send messge
With this, I get the selection of tableview and I created a message.
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
LoanModel* loan = _feed.users[indexPath.row];
NSString* message = [NSString stringWithFormat:@"%@ from %@ needs a loan %@",
loan.name, loan.username, loan.email
];
}
But how can i send this message to detailview and display it ?
Here is my detailview h
// ssDetailViewController.h
#import <UIKit/UIKit.h>
@interface ssDetailViewController : UIViewController
@property (strong, nonatomic) id detailItem;
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
@end
Here is my detailview m
// ssDetailViewController.m
#import "ssDetailViewController.h"
@interface ssDetailViewController ()
- (void)configureView;
@end
@implementation ssDetailViewController
#pragma mark - Managing the detail item
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
self.detailDescriptionLabel.text = [self.detailItem description];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Saturday, 24 August 2013
cartodb: query for the points within a radio from another point - postgis
cartodb: query for the points within a radio from another point - postgis
I've georreferenced a couple of points in a CartoDb table, so now I have a
the_geom column of type point
I'd like to get all the points that are x meters away from a certain x,y
point.
So far now, following this article
http://unserializableone.blogspot.com.ar/2007/02/using-postgis-to-find-points-of.html,
I tried the following:
SELECT * FROM my_contacts
WHERE
distance(
transform(PointFromText('POINT(-34.6043183 -58.380924)', 4269),32661),
the_geom
) < 1000
(in this case my x,y point would be -34.6043183 -58.380924 and I'm looking
for locations within 1000 meters from it)
and I get this error: ERROR: Operation on two GEOMETRIES with different SRIDs
I tried without the transform, and I get the same error
How can I find out the SRIDs of the points in my db?
And how can I translate a lat, lon google map point to that desired SRID?
update:
with this query I found out the SRID of my points
SELECT ST_SRID(the_geom) FROM my_contacts
they are all 4326, so I tried with
and this seems to work rather ok:
SELECT *
FROM my_contacts
where
distance(
transform(PointFromText(
'POINT(-34.6675645 -58.3712721)', 4326),4326),
the_geom
) < 33.62
order by distance
but I just got thiw 33.62 by trial and error, I don't know how to
translate it to meters, and the results when trying with a different point
don't seem to be very consistent...
thanks a lot
I've georreferenced a couple of points in a CartoDb table, so now I have a
the_geom column of type point
I'd like to get all the points that are x meters away from a certain x,y
point.
So far now, following this article
http://unserializableone.blogspot.com.ar/2007/02/using-postgis-to-find-points-of.html,
I tried the following:
SELECT * FROM my_contacts
WHERE
distance(
transform(PointFromText('POINT(-34.6043183 -58.380924)', 4269),32661),
the_geom
) < 1000
(in this case my x,y point would be -34.6043183 -58.380924 and I'm looking
for locations within 1000 meters from it)
and I get this error: ERROR: Operation on two GEOMETRIES with different SRIDs
I tried without the transform, and I get the same error
How can I find out the SRIDs of the points in my db?
And how can I translate a lat, lon google map point to that desired SRID?
update:
with this query I found out the SRID of my points
SELECT ST_SRID(the_geom) FROM my_contacts
they are all 4326, so I tried with
and this seems to work rather ok:
SELECT *
FROM my_contacts
where
distance(
transform(PointFromText(
'POINT(-34.6675645 -58.3712721)', 4326),4326),
the_geom
) < 33.62
order by distance
but I just got thiw 33.62 by trial and error, I don't know how to
translate it to meters, and the results when trying with a different point
don't seem to be very consistent...
thanks a lot
Alaram Manager in android
Alaram Manager in android
I'm having code which is to be run daily, for this I'm trying to use Alarm
manager. This is my code for triggering alarm.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this, AlarmReciever.class);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.cancel(pi); // cancel any existing alarms
am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAY,
AlarmManager.INTERVAL_DAY, pi);
}
This part of code is calling AlarmReciever class as expected, but I want
the code in AaramReciever class to be executed once daily. But its being
called multiple times. How do I restrict it?
I'm having code which is to be run daily, for this I'm trying to use Alarm
manager. This is my code for triggering alarm.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = new Intent(this, AlarmReciever.class);
PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.cancel(pi); // cancel any existing alarms
am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAY,
AlarmManager.INTERVAL_DAY, pi);
}
This part of code is calling AlarmReciever class as expected, but I want
the code in AaramReciever class to be executed once daily. But its being
called multiple times. How do I restrict it?
What is the meaning of ps process names printed in [] such as [cgroup]?
What is the meaning of ps process names printed in [] such as [cgroup]?
when I do a command such as ps -aux on CentOS 6 I get a bunch of processes
whos command is listed in [] as shown below. What is the meaning of the []
in the name? I am assuming that these are special processes of some kind,
what makes a process name show up with a [] around it?
[root@centos6 src]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 18:48 ? 00:00:01 /sbin/init
root 2 0 0 18:48 ? 00:00:00 [kthreadd]
root 3 2 0 18:48 ? 00:00:00 [migration/0]
root 4 2 0 18:48 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 18:48 ? 00:00:00 [migration/0]
root 6 2 0 18:48 ? 00:00:00 [watchdog/0]
root 7 2 0 18:48 ? 00:00:02 [events/0]
when I do a command such as ps -aux on CentOS 6 I get a bunch of processes
whos command is listed in [] as shown below. What is the meaning of the []
in the name? I am assuming that these are special processes of some kind,
what makes a process name show up with a [] around it?
[root@centos6 src]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 18:48 ? 00:00:01 /sbin/init
root 2 0 0 18:48 ? 00:00:00 [kthreadd]
root 3 2 0 18:48 ? 00:00:00 [migration/0]
root 4 2 0 18:48 ? 00:00:00 [ksoftirqd/0]
root 5 2 0 18:48 ? 00:00:00 [migration/0]
root 6 2 0 18:48 ? 00:00:00 [watchdog/0]
root 7 2 0 18:48 ? 00:00:02 [events/0]
Setting initial state of PrintPreviewDialog controls
Setting initial state of PrintPreviewDialog controls
I'm working with PrintPreviewDialog and want to tweak its initial
presentation from the default. So far, I've done this:
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.WindowState = FormWindowState.Maximized;
dlg.PrintPreviewControl.Zoom = 1.0;
...which gives me the presentation I want, but when the dialog is opened,
the zoom control has the "Auto" choice selected, not 100% as would
correspond to the zoom value of 1.0. How can I get at the zoom control to
show 100% as the currently selected zoom setting so as not to confuse the
user?
I'm working with PrintPreviewDialog and want to tweak its initial
presentation from the default. So far, I've done this:
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.WindowState = FormWindowState.Maximized;
dlg.PrintPreviewControl.Zoom = 1.0;
...which gives me the presentation I want, but when the dialog is opened,
the zoom control has the "Auto" choice selected, not 100% as would
correspond to the zoom value of 1.0. How can I get at the zoom control to
show 100% as the currently selected zoom setting so as not to confuse the
user?
Ebean inheritance "Abstract class with no readMethod" exception
Ebean inheritance "Abstract class with no readMethod" exception
I try to use inheritance with Ebean in Play! Framework 2.1.0. The
inheritance strategy is "single table", as it is the only one supported by
Ebean. I closely follow example from JPA Wikibook
@Entity
@Inheritance
@DiscriminatorColumn(name="price_type")
@Table(name="prices")
public abstract class Price {
@Id
public long id;
// Price value
@Column(precision=2, scale=18)
public BigDecimal value;
}
@Entity
@DiscriminatorValue("F")
public class FixedPrice extends Price {
// NO id field here
...
}
@Entity
@DiscriminatorValue("V")
public class VariablePrice extends Price {
// NO id field here
...
}
This code passes compilation, but I get
RuntimeException: Abstract class with no readMethod for models.Price.id
com.avaje.ebeaninternal.server.deploy.ReflectGetter.create(ReflectGetter.java:33)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1353)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1142)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1058)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252)
com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:124)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:59)
play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:79)
Google search brings only one relevant link which is source code of
ReflectGetter.java. The comment there says
For abstract classes that hold the id property we need to use reflection
to get the id values some times.
This provides the BeanReflectGetter objects to do that.
If I drop abstract keyword from superclass declaration, exception
disappears. I would really prefer not to make superclass concrete though.
I try to use inheritance with Ebean in Play! Framework 2.1.0. The
inheritance strategy is "single table", as it is the only one supported by
Ebean. I closely follow example from JPA Wikibook
@Entity
@Inheritance
@DiscriminatorColumn(name="price_type")
@Table(name="prices")
public abstract class Price {
@Id
public long id;
// Price value
@Column(precision=2, scale=18)
public BigDecimal value;
}
@Entity
@DiscriminatorValue("F")
public class FixedPrice extends Price {
// NO id field here
...
}
@Entity
@DiscriminatorValue("V")
public class VariablePrice extends Price {
// NO id field here
...
}
This code passes compilation, but I get
RuntimeException: Abstract class with no readMethod for models.Price.id
com.avaje.ebeaninternal.server.deploy.ReflectGetter.create(ReflectGetter.java:33)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1353)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1142)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1058)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565)
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252)
com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:124)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210)
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:59)
play.db.ebean.EbeanPlugin.onStart(EbeanPlugin.java:79)
Google search brings only one relevant link which is source code of
ReflectGetter.java. The comment there says
For abstract classes that hold the id property we need to use reflection
to get the id values some times.
This provides the BeanReflectGetter objects to do that.
If I drop abstract keyword from superclass declaration, exception
disappears. I would really prefer not to make superclass concrete though.
How do I fix input lag on my new HDTV
How do I fix input lag on my new HDTV
I recently purchased a new 55 inch LED HDTV, I hooked my ps3 up to it
(HDMI) and now I experiance about a half a second delay when I press a
button and the action is preformed on the TV. This never happened on my
old TV, I've looked around and can't find any solutions help! I'm using a
Kogan KALED55XXXWA and as far as I know there isn't a game mode.
I recently purchased a new 55 inch LED HDTV, I hooked my ps3 up to it
(HDMI) and now I experiance about a half a second delay when I press a
button and the action is preformed on the TV. This never happened on my
old TV, I've looked around and can't find any solutions help! I'm using a
Kogan KALED55XXXWA and as far as I know there isn't a game mode.
Friday, 23 August 2013
A theorem on restriction of a metric
A theorem on restriction of a metric
Consider $(X,d)$ be a metric space. Let $Y\subseteq X$ be a metric on
itself and $E\subseteq Y$. Then there is a theorem which says that $E$ is
open in $Y$ iff $E=Y\cap G$ for some open subset $G$ of the original space
$G$. The intuition behind behind this condition is not clear. Why is that
intersection is so special? I understand that $E$ being a subset of some
open set of $X$ is not enough because a subset of a open set need not be
an open set ?
Consider $(X,d)$ be a metric space. Let $Y\subseteq X$ be a metric on
itself and $E\subseteq Y$. Then there is a theorem which says that $E$ is
open in $Y$ iff $E=Y\cap G$ for some open subset $G$ of the original space
$G$. The intuition behind behind this condition is not clear. Why is that
intersection is so special? I understand that $E$ being a subset of some
open set of $X$ is not enough because a subset of a open set need not be
an open set ?
Dynamically creating triangle with max-width/fit inside div
Dynamically creating triangle with max-width/fit inside div
I have a web page that accepts three inputs. I am dynamically creating a
triangle from these three inputs (by setting border-widths). I want the
triangle to fit inside the div on the page. For example, if the inputs
were 500, 500, 300 I want to reduce these to fit inside the div on the
page while retaining the aspect ratio of the inputs.
HTML:
<div id="triangle"></div>
CSS:
#triangle {
max-width: 200px;
width: 0;
height: 0;
margin: 0 auto;
}
jQuery:
$("#triangle").css({
"border-left": length1 + "px solid transparent",
"border-right": length2 + "px solid transparent",
"border-bottom": length3 + "px solid #2383ea"
});
I have a web page that accepts three inputs. I am dynamically creating a
triangle from these three inputs (by setting border-widths). I want the
triangle to fit inside the div on the page. For example, if the inputs
were 500, 500, 300 I want to reduce these to fit inside the div on the
page while retaining the aspect ratio of the inputs.
HTML:
<div id="triangle"></div>
CSS:
#triangle {
max-width: 200px;
width: 0;
height: 0;
margin: 0 auto;
}
jQuery:
$("#triangle").css({
"border-left": length1 + "px solid transparent",
"border-right": length2 + "px solid transparent",
"border-bottom": length3 + "px solid #2383ea"
});
How to create ~/.bash_profile and ~/.profile
How to create ~/.bash_profile and ~/.profile
So, I don't have .bash_profile neither .profile in my home folder. How do
I create them? After that, what should I do so every time I open the
terminal these files get read?
So, I don't have .bash_profile neither .profile in my home folder. How do
I create them? After that, what should I do so every time I open the
terminal these files get read?
The Most Basic principles of Python
The Most Basic principles of Python
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
4: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a csv file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a csv file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
##########################################################################
###################################
You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
4: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..
will provide you with the top 1 million web sites in the world.
updated daily in a csv file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.
always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.
google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a csv file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
##########################################################################
###################################
Absolute session timeout with Lift / Jetty
Absolute session timeout with Lift / Jetty
What is a good way to implement an absolute session timeout in a Lift
application running under Jetty?
I already have an idle timeout, but I want sessions to eventually time out
even if the user is never idle.
What is a good way to implement an absolute session timeout in a Lift
application running under Jetty?
I already have an idle timeout, but I want sessions to eventually time out
even if the user is never idle.
eerror message in php in codeigniter
eerror message in php in codeigniter
hi all in model i gave in function as follows
$query = $this->db->get();
$result = $query->result();
$data[] = $result;
but am getting error as A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: models/survey_model.php
Line Number: 845
null
what was the for this. can someone help me please
hi all in model i gave in function as follows
$query = $this->db->get();
$result = $query->result();
$data[] = $result;
but am getting error as A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: models/survey_model.php
Line Number: 845
null
what was the for this. can someone help me please
Thursday, 22 August 2013
How to compile libxml2 and libcurl to 32-bit under 64-bit machine?
How to compile libxml2 and libcurl to 32-bit under 64-bit machine?
I download the packages libxml2-2.9.1.tar.gz and curl-7.31.0.tar.gz from
thw web. If I compile these two under 32-bit machine, it'll be ok. But
formal environment is 64-bit machine, after I compiled thest two, libxml2
and libcurl became 64-bit. When I ran the application program, it reported
an error. Now, how can I compile these two packages into 32-bit, under a
64-bit machine? I found on the 64-bit machine, there is an old package
libxml2.so.2.6.26 in /usr/local/lib, it is 64-bit file; but in /usr/lib,
there also has a file libxml2.so.2.6.16, it is 32-bit. It really confuses
me a lot.
I just hope the application program can run ok, Someone help. Thanks a lot.
I download the packages libxml2-2.9.1.tar.gz and curl-7.31.0.tar.gz from
thw web. If I compile these two under 32-bit machine, it'll be ok. But
formal environment is 64-bit machine, after I compiled thest two, libxml2
and libcurl became 64-bit. When I ran the application program, it reported
an error. Now, how can I compile these two packages into 32-bit, under a
64-bit machine? I found on the 64-bit machine, there is an old package
libxml2.so.2.6.26 in /usr/local/lib, it is 64-bit file; but in /usr/lib,
there also has a file libxml2.so.2.6.16, it is 32-bit. It really confuses
me a lot.
I just hope the application program can run ok, Someone help. Thanks a lot.
finding Intra-Air Building, 659 High Road Leytonstone, Wanstead London, E11 1HL
finding Intra-Air Building, 659 High Road Leytonstone, Wanstead London,
E11 1HL
I can't locate this address Intra-Air Building, 659 High Road Leytonstone,
Wanstead London, E11 1HL, please show me a link in google maps.
E11 1HL
I can't locate this address Intra-Air Building, 659 High Road Leytonstone,
Wanstead London, E11 1HL, please show me a link in google maps.
Calling a method from one class in another.
Calling a method from one class in another.
I have a parent page that has a RadTabStrip on it. On the TabClick event I
want to call a function from one of the tabs(child page). On the child
page I will be setting a control to visible=false; I will let the child
page handle the control handling I just need to call it in my parent page
because both tabs are being rendered at once so when I switch from tab to
tab it doesn't see that its on a page load so it wont try to make the
panel visible=false;
This is the Parent Page.
public void Page_Load(object sender, EventArgs e)
{
// call controls_confgMangrEvntNotif_confgMngrTab1.Test();
}
This is the child page and the meth I wish to call.
public partial class controls_confgMangrEvntNotif_confgMngrTab1 :
System.Web.UI.UserControl
{
public static void Test()
{
Debug.WriteLine("test");
}
I believe my current problem is do to access modifiers. If I do the name
of the class . it will give me a hashtable I made public static but no
other functions or variables.
I have a parent page that has a RadTabStrip on it. On the TabClick event I
want to call a function from one of the tabs(child page). On the child
page I will be setting a control to visible=false; I will let the child
page handle the control handling I just need to call it in my parent page
because both tabs are being rendered at once so when I switch from tab to
tab it doesn't see that its on a page load so it wont try to make the
panel visible=false;
This is the Parent Page.
public void Page_Load(object sender, EventArgs e)
{
// call controls_confgMangrEvntNotif_confgMngrTab1.Test();
}
This is the child page and the meth I wish to call.
public partial class controls_confgMangrEvntNotif_confgMngrTab1 :
System.Web.UI.UserControl
{
public static void Test()
{
Debug.WriteLine("test");
}
I believe my current problem is do to access modifiers. If I do the name
of the class . it will give me a hashtable I made public static but no
other functions or variables.
VB display cell value offset active cell
VB display cell value offset active cell
I'm trying to display the value of a cell according to my ActiveCell or
Target Cell using a Fonction. The cell I'm trying to display is in the
same spreadsheet.
My objectif is to create a Header in the spreadsheet that would display
information according to the position of the Active cell.
I've tried this code and typed the fonction =VendorName5() in the cell
were I want the value to be displayed but seems to be missing something.
Can you help ?:
Function VendorName5() As String
Name = ActiveCell.Offset(0, -4)
VendorName5 = Name
End Function
I'm trying to display the value of a cell according to my ActiveCell or
Target Cell using a Fonction. The cell I'm trying to display is in the
same spreadsheet.
My objectif is to create a Header in the spreadsheet that would display
information according to the position of the Active cell.
I've tried this code and typed the fonction =VendorName5() in the cell
were I want the value to be displayed but seems to be missing something.
Can you help ?:
Function VendorName5() As String
Name = ActiveCell.Offset(0, -4)
VendorName5 = Name
End Function
Getting my Python variables onto a webpage
Getting my Python variables onto a webpage
I like to think of myself as a decent programmer, but I'm definitely no IT
guy. I typically work on embedded stuff; networking and the Internet may
as well be magic for all I understand of it. I've got a Python program
that I'd like to add some remote monitoring capability to. I want to be
able to print some of my program variables to a webpage that I can access
from within my LAN -- if possible, have it autoupdate so I don't have to
mash refresh. How do I go about doing this? My google fu is mostly turning
up ways how to use python to scrape data off other websites which is not
what I want. My first impression is to write my HTML file from Python that
gets read by Apache but this sounds like it'll cause read/write
contentions and lots of unnecessary I/O if I'm constantly rewriting the
file.
I'd appreciate any help pointing me in the right direction.
(I realize I can just use ssh + print to console to but this is really ugly)
I like to think of myself as a decent programmer, but I'm definitely no IT
guy. I typically work on embedded stuff; networking and the Internet may
as well be magic for all I understand of it. I've got a Python program
that I'd like to add some remote monitoring capability to. I want to be
able to print some of my program variables to a webpage that I can access
from within my LAN -- if possible, have it autoupdate so I don't have to
mash refresh. How do I go about doing this? My google fu is mostly turning
up ways how to use python to scrape data off other websites which is not
what I want. My first impression is to write my HTML file from Python that
gets read by Apache but this sounds like it'll cause read/write
contentions and lots of unnecessary I/O if I'm constantly rewriting the
file.
I'd appreciate any help pointing me in the right direction.
(I realize I can just use ssh + print to console to but this is really ugly)
Minecraft PE on iPad Mobile Hotspot?
Minecraft PE on iPad Mobile Hotspot?
I have several iOS devices, one of which is an iPad 3 w/3G. If I enable
tethering, and the other iDevices connect to it, will it be possible to
play Minecraft PE between all the devices?
I have several iOS devices, one of which is an iPad 3 w/3G. If I enable
tethering, and the other iDevices connect to it, will it be possible to
play Minecraft PE between all the devices?
Get label for input field
Get label for input field
I'm doing a validation with Jquery and need to get the $label from each
element with their own label. Now the alert() gives med [object object].
The best thing for me here is to get an alert() with all fields lined up
that is not filled out. And not an alert() for each.
Here is a fiddle: http://jsfiddle.net/s7pYX/
How is this accomplished?
HTML:
<div>
<label for="txtName">Name</label>
<input type="text" id="txtName" class="form-control" name="txtName">
</div>
<div>
<label for="txtEmail">E-mail</label>
<input type="text" id="txtEmail" class="form-control" name="txtEmail">
</div>
Jquery:
$('input').each(function(){
if ($(this).val() == '') {
$element = $(this)
var $label = $("label[for='"+$element.attr('id')+"']")
alert($label)
}
});
In the alert() I expect like this "You need to fill out: Name, E-mail"
I'm doing a validation with Jquery and need to get the $label from each
element with their own label. Now the alert() gives med [object object].
The best thing for me here is to get an alert() with all fields lined up
that is not filled out. And not an alert() for each.
Here is a fiddle: http://jsfiddle.net/s7pYX/
How is this accomplished?
HTML:
<div>
<label for="txtName">Name</label>
<input type="text" id="txtName" class="form-control" name="txtName">
</div>
<div>
<label for="txtEmail">E-mail</label>
<input type="text" id="txtEmail" class="form-control" name="txtEmail">
</div>
Jquery:
$('input').each(function(){
if ($(this).val() == '') {
$element = $(this)
var $label = $("label[for='"+$element.attr('id')+"']")
alert($label)
}
});
In the alert() I expect like this "You need to fill out: Name, E-mail"
Wednesday, 21 August 2013
AsyncTask in fragments not updating UI
AsyncTask in fragments not updating UI
I am using FragmentPagerAdapter to swipe Fragment and using AsyncTask to
update gridview but its not updating the UI.
Its not updating the UI and also not throwing any error I tried to check
the flow and its running GalleryTab fragment twice...and unable to
understand the problem .
My code:-
public class GalleryTab extends Fragment {
GridView gridview;
ProgressDialog mProgressDialog;
GridViewAdapter adapter;
public List<GalleryList> phonearraylist = null;
View view;
private WeakReference<RemoteDataTask> asyncTaskWeakRef;
public static Fragment newInstance(Context context) {
GalleryTab f = new GalleryTab();
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.activity_gallery_tab, null);
setRetainInstance(true);
startNewAsyncTask();
//new RemoteDataTask(this).execute();
return inflater.inflate(R.layout.activity_gallery_tab,
container, false);
}
// RemoteDataTask AsyncTask
private class RemoteDataTask extends AsyncTask<Void, Void,
Void> {
private WeakReference<GalleryTab> fragmentWeakRef;
private RemoteDataTask (GalleryTab gallerytab) {
this.fragmentWeakRef = new
WeakReference<GalleryTab>(gallerytab);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
// Create the array
phonearraylist = new ArrayList<GalleryList>();
try {
for (int i = 0; i <= 6; i++) {
GalleryList map = new GalleryList();
map.setGallery("http://oi39.tinypic.com/21oydxs.jpg");
System.out.println("PRINT!!!!-- "+ i);
phonearraylist.add(map);
}
} catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// if (this.fragmentWeakRef.get() != null) {
adapter = new GridViewAdapter(getActivity(),
phonearraylist);
System.out.println("PRINT SIZE -- "+
phonearraylist.size());
gridview = (GridView)view.findViewById(R.id.gridview);
gridview.setAdapter(adapter);
// mProgressDialog.dismiss();
// }
}
}
private void startNewAsyncTask() {
RemoteDataTask asyncTask = new RemoteDataTask(this);
this.asyncTaskWeakRef = new WeakReference<RemoteDataTask
>(asyncTask );
asyncTask.execute();
}
}
I am using FragmentPagerAdapter to swipe Fragment and using AsyncTask to
update gridview but its not updating the UI.
Its not updating the UI and also not throwing any error I tried to check
the flow and its running GalleryTab fragment twice...and unable to
understand the problem .
My code:-
public class GalleryTab extends Fragment {
GridView gridview;
ProgressDialog mProgressDialog;
GridViewAdapter adapter;
public List<GalleryList> phonearraylist = null;
View view;
private WeakReference<RemoteDataTask> asyncTaskWeakRef;
public static Fragment newInstance(Context context) {
GalleryTab f = new GalleryTab();
return f;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.activity_gallery_tab, null);
setRetainInstance(true);
startNewAsyncTask();
//new RemoteDataTask(this).execute();
return inflater.inflate(R.layout.activity_gallery_tab,
container, false);
}
// RemoteDataTask AsyncTask
private class RemoteDataTask extends AsyncTask<Void, Void,
Void> {
private WeakReference<GalleryTab> fragmentWeakRef;
private RemoteDataTask (GalleryTab gallerytab) {
this.fragmentWeakRef = new
WeakReference<GalleryTab>(gallerytab);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
// Create the array
phonearraylist = new ArrayList<GalleryList>();
try {
for (int i = 0; i <= 6; i++) {
GalleryList map = new GalleryList();
map.setGallery("http://oi39.tinypic.com/21oydxs.jpg");
System.out.println("PRINT!!!!-- "+ i);
phonearraylist.add(map);
}
} catch (ParseException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// if (this.fragmentWeakRef.get() != null) {
adapter = new GridViewAdapter(getActivity(),
phonearraylist);
System.out.println("PRINT SIZE -- "+
phonearraylist.size());
gridview = (GridView)view.findViewById(R.id.gridview);
gridview.setAdapter(adapter);
// mProgressDialog.dismiss();
// }
}
}
private void startNewAsyncTask() {
RemoteDataTask asyncTask = new RemoteDataTask(this);
this.asyncTaskWeakRef = new WeakReference<RemoteDataTask
>(asyncTask );
asyncTask.execute();
}
}
how do i use find and each to get href from li
how do i use find and each to get href from li
I have an navigation menu and want to get the href attribute from each li
a *here is what i have*
$('#navbar ul li').each(function(){
console.log($('a').attr('href'));
});
here is my menu
<div id="navbar">
<ul class="sf-menu sf-js-enabled" id="navmain">
<li><a href="/index.php">HOME</a></li>
<li><a href="/shop/sales/">SALES</a></li>
<li><a href="/shop/clothing/">CLOTHING</a></li>
<li><a href="/shop/accessories/">ACCESSORIES</a></li>
<li><a href="/cart.php">CART</a></li>
<li><a href="/wishlist.php">WISHLIST</a></li>
<li><a href="/contactus.php">CONTACT US</a></li>
<li><a href="/aboutus.php">ABOUT US</a></li>
</ul>
</div>
I have an navigation menu and want to get the href attribute from each li
a *here is what i have*
$('#navbar ul li').each(function(){
console.log($('a').attr('href'));
});
here is my menu
<div id="navbar">
<ul class="sf-menu sf-js-enabled" id="navmain">
<li><a href="/index.php">HOME</a></li>
<li><a href="/shop/sales/">SALES</a></li>
<li><a href="/shop/clothing/">CLOTHING</a></li>
<li><a href="/shop/accessories/">ACCESSORIES</a></li>
<li><a href="/cart.php">CART</a></li>
<li><a href="/wishlist.php">WISHLIST</a></li>
<li><a href="/contactus.php">CONTACT US</a></li>
<li><a href="/aboutus.php">ABOUT US</a></li>
</ul>
</div>
Table columns, setting both min and max width with css
Table columns, setting both min and max width with css
I would like to have a table which in the columns can stretch but I'm
having a little trouble with min and max width in css.
It also seems that theres some conflicting answers around how this works:
min/max width should work: table td width under control
min/max width are unsupported: Min-width and max-height for table atrributes
I would like to have the following
table{
width:100%;
}
.a, .b, .c
{
background-color: red;
}
.a
{
min-width 10px;
max-width: 20px;
}
.b
{
min-width 40px;
max-width: 45px;
}
.c
{
}
<table>
<tr>
<td class="a">A</td>
<td class="b">B</td>
<td class="c">C</td>
</tr>
</table>
Is there a way of achieving this without javascript (ie constrained
stretching of columns with a table)?
I only need this to work with CSS3 + HTML5
a jsfiddle with stuff not expanding:http://jsfiddle.net/4b3RZ/6/
if I set only min-width on the columns i get a proportional
stretch:http://jsfiddle.net/4b3RZ/8/
below is a table of what actually gets rendered for some different css
setups:
I would like to have a table which in the columns can stretch but I'm
having a little trouble with min and max width in css.
It also seems that theres some conflicting answers around how this works:
min/max width should work: table td width under control
min/max width are unsupported: Min-width and max-height for table atrributes
I would like to have the following
table{
width:100%;
}
.a, .b, .c
{
background-color: red;
}
.a
{
min-width 10px;
max-width: 20px;
}
.b
{
min-width 40px;
max-width: 45px;
}
.c
{
}
<table>
<tr>
<td class="a">A</td>
<td class="b">B</td>
<td class="c">C</td>
</tr>
</table>
Is there a way of achieving this without javascript (ie constrained
stretching of columns with a table)?
I only need this to work with CSS3 + HTML5
a jsfiddle with stuff not expanding:http://jsfiddle.net/4b3RZ/6/
if I set only min-width on the columns i get a proportional
stretch:http://jsfiddle.net/4b3RZ/8/
below is a table of what actually gets rendered for some different css
setups:
Match LaTeX reserved characters with regex
Match LaTeX reserved characters with regex
I have an HTML to LaTeX parser tailored to what it's supposed to do
(convert snippets of HTML into snippets of LaTeX), but there is a little
issue with filling in variables. The issue is that variables should be
allowed to contain the LaTeX reserved characters (namely # $ % ^ & _ { } ~
\). These need to be escaped so that they won't kill our LaTeX renderer.
The program that handles the conversion and everything is written in
Python, so I tried to find a nice solution. My first idea was to simply do
a .replace(), but replace doesn't allow you to match only if the first is
not a \. My second attempt was a regex, but I failed miserably at that.
The regex I came up with is ([^\][#\$%\^&_\{\}~\\]). I hoped that this
would match any of the reserved characters, but only if it didn't have a \
in front. Unfortunately, this matches ever single character in my input
text. I've also tried different variations on this regex, but I can't get
it to work. The variations mainly consisted of removing/adding slashes in
the second part of the regex.
Can anyone help with this regex?
I have an HTML to LaTeX parser tailored to what it's supposed to do
(convert snippets of HTML into snippets of LaTeX), but there is a little
issue with filling in variables. The issue is that variables should be
allowed to contain the LaTeX reserved characters (namely # $ % ^ & _ { } ~
\). These need to be escaped so that they won't kill our LaTeX renderer.
The program that handles the conversion and everything is written in
Python, so I tried to find a nice solution. My first idea was to simply do
a .replace(), but replace doesn't allow you to match only if the first is
not a \. My second attempt was a regex, but I failed miserably at that.
The regex I came up with is ([^\][#\$%\^&_\{\}~\\]). I hoped that this
would match any of the reserved characters, but only if it didn't have a \
in front. Unfortunately, this matches ever single character in my input
text. I've also tried different variations on this regex, but I can't get
it to work. The variations mainly consisted of removing/adding slashes in
the second part of the regex.
Can anyone help with this regex?
Enter passwords on webpages programmatically in c#?
Enter passwords on webpages programmatically in c#?
Everybody
I want to create an application which logins in my Modem Configuration.
My modem in TP-Link.The username and password are admin.
How can i enter passwords programmatically in c# web browser.
Thanks.
Everybody
I want to create an application which logins in my Modem Configuration.
My modem in TP-Link.The username and password are admin.
How can i enter passwords programmatically in c# web browser.
Thanks.
SQL Query (Display Positive and Negative value with two columns)
SQL Query (Display Positive and Negative value with two columns)
I have one column table with negative and positive values and want to
display positive and negative values in different columns using SQL Query.
Column
-10000
-17000
16000
25000
output should be like
A B
-----------------
-10000
16000
-17000
25000
I have one column table with negative and positive values and want to
display positive and negative values in different columns using SQL Query.
Column
-10000
-17000
16000
25000
output should be like
A B
-----------------
-10000
16000
-17000
25000
Tuesday, 20 August 2013
Browser back button doesn't work when content is loaded into an iframe
Browser back button doesn't work when content is loaded into an iframe
I have a javascript funtion using which I display some content when the
user clicks on a link.
function showContent(filename){
var oldcontent = $('#content').html();
var srcUrl = getSourceUrl(filename);
$('#content').html(oldcontent + '<iframe
style="width:100%;height=100%;display:block;" src="'+srcUrl+'" />');
}
Since the content is loaded into an IFrame, the URL doesn't get changed
and I can not go back to the previous page where the link was using
browser's back button. I am a newbie and I tried to do something(silly
experiment) like this. i.e. appending a '#page2' to the url but then when
user clicks on the back button, nothing happens.
var oldcontent = $('#content').html();
var srcUrl = getSourceUrl(filename);
location.href = location.href + '#page2';
$('#content').html(oldcontent + '<iframe
style="width:100%;height=100%;display:block;" src="'+srcUrl+'" />');
Can anyone please tell me what's wrong with this and how to enable the
back button functionality?
Thanks
I have a javascript funtion using which I display some content when the
user clicks on a link.
function showContent(filename){
var oldcontent = $('#content').html();
var srcUrl = getSourceUrl(filename);
$('#content').html(oldcontent + '<iframe
style="width:100%;height=100%;display:block;" src="'+srcUrl+'" />');
}
Since the content is loaded into an IFrame, the URL doesn't get changed
and I can not go back to the previous page where the link was using
browser's back button. I am a newbie and I tried to do something(silly
experiment) like this. i.e. appending a '#page2' to the url but then when
user clicks on the back button, nothing happens.
var oldcontent = $('#content').html();
var srcUrl = getSourceUrl(filename);
location.href = location.href + '#page2';
$('#content').html(oldcontent + '<iframe
style="width:100%;height=100%;display:block;" src="'+srcUrl+'" />');
Can anyone please tell me what's wrong with this and how to enable the
back button functionality?
Thanks
Lucene configure command (and PHP scripts) generating embedded BOMs in the output config.inc file
Lucene configure command (and PHP scripts) generating embedded BOMs in the
output config.inc file
Previously we had great success installing and using Lucene on our
mediawiki system. We are now moving to a new server with a newer PHP and
newer OS.
Running Lucene's "configure" creates the needed output files but they
contain embedded BOMs
VI shows this:
dbname=<feff>wikidb
wgScriptPath=<feff>
hostname=eng-sea-wiki01.west.isilon.com
indexes=/usr/local/lucene-search-2.1.3/indexes
mediawiki=/usr/local/www/wiki
base=/usr/local/lucene-search-2.1.3
wgServer=<feff>https://newwiki.west.isilon.com
Look to be that some php calls are returning string containing prepended
BOMS. I verified this by running a mediawiki script
maintenance/dumpBackup.php which dumped XML with a prepended BOM.
QUESTION: How do I get my Php (Version 5.5.1) to NOT output BOMs?
output config.inc file
Previously we had great success installing and using Lucene on our
mediawiki system. We are now moving to a new server with a newer PHP and
newer OS.
Running Lucene's "configure" creates the needed output files but they
contain embedded BOMs
VI shows this:
dbname=<feff>wikidb
wgScriptPath=<feff>
hostname=eng-sea-wiki01.west.isilon.com
indexes=/usr/local/lucene-search-2.1.3/indexes
mediawiki=/usr/local/www/wiki
base=/usr/local/lucene-search-2.1.3
wgServer=<feff>https://newwiki.west.isilon.com
Look to be that some php calls are returning string containing prepended
BOMS. I verified this by running a mediawiki script
maintenance/dumpBackup.php which dumped XML with a prepended BOM.
QUESTION: How do I get my Php (Version 5.5.1) to NOT output BOMs?
Using lock statement with ThreadPool in C#
Using lock statement with ThreadPool in C#
I have a multi-threaded program (C#) where I have to share global static
variables between threads that may take some time to execute (sending data
request to another system using WCF). The problem is that using the lock
statement does not seem to guarantee mutual exclusion when it's declared
outside of the ThreadPool.
static void Main(string[] args)
{
public static int globalVar = 0;
public object locker;
System.Timers.Timer timer1 = new System.Timers.Timer(1000);
timer1.Elapsed += new ElapsedEventHandler(onTimer1ElapsedEvent);
timer1.Interval = 1000;
timer1.Enabled = true;
System.Timers.Timer timer2 = new System.Timers.Timer(500);
timer2.Elapsed += new ElapsedEventHandler(onTimer2ElapsedEvent);
timer2.Interval = 500;
timer2.Enabled = true;
}
public void onTimer1ElapsedEvent(object source, ElapsedEventArgs e)
{
lock (locker) {
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
globalVar = 1;
Console.WriteLine("Timer1 var = {0}", globalVar);
}));
}
}
public void onTimer2ElapsedEvent(object source, ElapsedEventArgs e)
{
lock (locker) {
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
globalVar = 2;
Thread.Sleep(2000); // simulates a WCF request that may take
time
Console.WriteLine("Timer2 var = {0}", globalVar);
}));
}
}
So the lock does not work and the program can prints: Timer2 var = 1
Putting the the lock statement inside the ThreadPool seems to resolve the
problem.
public void onTimer1ElapsedEvent(object source, ElapsedEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
lock (locker) {
globalVar = 1;
Console.WriteLine("Timer1 var = {0}", globalVar);
}
}));
}
public void onTimer2ElapsedEvent(object source, ElapsedEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
lock (locker) {
globalVar = 2;
Thread.Sleep(2000); // simulates a WCF request that may take
time
Console.WriteLine("Timer2 var = {0}", globalVar);
}
}));
}
However, I don't uderstand the difference between the two approaches and
why it does not produce the same behaviour.
Also, the 2nd approach resolves the mutual exclusion problem but the
timer1 thread will always have to wait for the timer2 to finish his lock
statement (which takes time), so the multi-threading concept does not work
anymore in my program. I want to know what's the best solution of having
multi threading doing their job in parallel with using shared variables ?
I have a multi-threaded program (C#) where I have to share global static
variables between threads that may take some time to execute (sending data
request to another system using WCF). The problem is that using the lock
statement does not seem to guarantee mutual exclusion when it's declared
outside of the ThreadPool.
static void Main(string[] args)
{
public static int globalVar = 0;
public object locker;
System.Timers.Timer timer1 = new System.Timers.Timer(1000);
timer1.Elapsed += new ElapsedEventHandler(onTimer1ElapsedEvent);
timer1.Interval = 1000;
timer1.Enabled = true;
System.Timers.Timer timer2 = new System.Timers.Timer(500);
timer2.Elapsed += new ElapsedEventHandler(onTimer2ElapsedEvent);
timer2.Interval = 500;
timer2.Enabled = true;
}
public void onTimer1ElapsedEvent(object source, ElapsedEventArgs e)
{
lock (locker) {
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
globalVar = 1;
Console.WriteLine("Timer1 var = {0}", globalVar);
}));
}
}
public void onTimer2ElapsedEvent(object source, ElapsedEventArgs e)
{
lock (locker) {
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
globalVar = 2;
Thread.Sleep(2000); // simulates a WCF request that may take
time
Console.WriteLine("Timer2 var = {0}", globalVar);
}));
}
}
So the lock does not work and the program can prints: Timer2 var = 1
Putting the the lock statement inside the ThreadPool seems to resolve the
problem.
public void onTimer1ElapsedEvent(object source, ElapsedEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
lock (locker) {
globalVar = 1;
Console.WriteLine("Timer1 var = {0}", globalVar);
}
}));
}
public void onTimer2ElapsedEvent(object source, ElapsedEventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(state =>
{
lock (locker) {
globalVar = 2;
Thread.Sleep(2000); // simulates a WCF request that may take
time
Console.WriteLine("Timer2 var = {0}", globalVar);
}
}));
}
However, I don't uderstand the difference between the two approaches and
why it does not produce the same behaviour.
Also, the 2nd approach resolves the mutual exclusion problem but the
timer1 thread will always have to wait for the timer2 to finish his lock
statement (which takes time), so the multi-threading concept does not work
anymore in my program. I want to know what's the best solution of having
multi threading doing their job in parallel with using shared variables ?
Text Underline Showing Underline
Text Underline Showing Underline
I seem to be having a problem with Underline. I have a box that is linkable:
<div class="single_box">
<a href="servicesweprovide.asp"><img
src="images/law_enforcement_accreditation.jpg" alt="" />
<p>Law Enforcement<br />Accreditation</p></a>
</div>
Here is the CSS:
.single_box {
width:253px;
min-height:170px;
float:left;
margin:0px 15px 0 0;
padding:0px;
text-decoration:none;
}
.single_box p{
background:url(../images/arrow.png) 92% 50% #0b2e84 no-repeat;
font:bold 16px/18px Arial, Helvetica, sans-serif; color:#fff;
padding:6px 14px;
word-spacing:normal;
letter-spacing:normal;
font-stretch:normal;
cursor:pointer;
text-decoration:none;
}
.single_box p:hover {
background-color:#ffc210;
text-decoration:none;
}
I set it up on JFiddle here: http://jsfiddle.net/2EHkp/
I have a feeling it has to do with me targeting the <p> Paragraph and not
the href. But I can't figure out how to target the href instead of the
<p>. Can someone please tell me what I am doing wrong?
I seem to be having a problem with Underline. I have a box that is linkable:
<div class="single_box">
<a href="servicesweprovide.asp"><img
src="images/law_enforcement_accreditation.jpg" alt="" />
<p>Law Enforcement<br />Accreditation</p></a>
</div>
Here is the CSS:
.single_box {
width:253px;
min-height:170px;
float:left;
margin:0px 15px 0 0;
padding:0px;
text-decoration:none;
}
.single_box p{
background:url(../images/arrow.png) 92% 50% #0b2e84 no-repeat;
font:bold 16px/18px Arial, Helvetica, sans-serif; color:#fff;
padding:6px 14px;
word-spacing:normal;
letter-spacing:normal;
font-stretch:normal;
cursor:pointer;
text-decoration:none;
}
.single_box p:hover {
background-color:#ffc210;
text-decoration:none;
}
I set it up on JFiddle here: http://jsfiddle.net/2EHkp/
I have a feeling it has to do with me targeting the <p> Paragraph and not
the href. But I can't figure out how to target the href instead of the
<p>. Can someone please tell me what I am doing wrong?
Adding a Dollar Sign to a Text Field Input using JavaScript
Adding a Dollar Sign to a Text Field Input using JavaScript
Using JavaScript, I'm looking to automatically put a dollar sign in front
of the entered amount in an input field within a form. I'm using the below
code, but am not sure what I'm missing:
<!DOCTYPE html>
<head>
<title>Example</title>
<script>
var test = document.getElementById("name");
document.write("$"+test.value);
</script>
</head>
<body>
<form action="" method="get">
<input type="text" id="name"/>
</form>
</body>
</html>
Any help is appreciated. Thanks!
Using JavaScript, I'm looking to automatically put a dollar sign in front
of the entered amount in an input field within a form. I'm using the below
code, but am not sure what I'm missing:
<!DOCTYPE html>
<head>
<title>Example</title>
<script>
var test = document.getElementById("name");
document.write("$"+test.value);
</script>
</head>
<body>
<form action="" method="get">
<input type="text" id="name"/>
</form>
</body>
</html>
Any help is appreciated. Thanks!
Covert a JS to a Lua file
Covert a JS to a Lua file
Can someone please help me out to finish converting a javascript module
into a Lua executable code?
The JS file: http://praytimes.org/code/v2/js/PrayTimes.js
I'm not a Lua expert but this is as far as I can go and I'm sure I have
made something wrong here and there: http://pastebin.com/6BpC0ZPB
Note: the Lua file is not yet tested
Can someone please help me out to finish converting a javascript module
into a Lua executable code?
The JS file: http://praytimes.org/code/v2/js/PrayTimes.js
I'm not a Lua expert but this is as far as I can go and I'm sure I have
made something wrong here and there: http://pastebin.com/6BpC0ZPB
Note: the Lua file is not yet tested
Why is my UINavigation controller off by 79 pixels
Why is my UINavigation controller off by 79 pixels
In the iphone everything works great.
However when I look at my navigationbar frame it is -44? Iphone the y
origin is 0.
Is it supposed to be this? Now everything seems to be shifted up by 79
pixels.
Any idea how to fix?
When I rotate everything sizes ok it is just the initial landscape size
that is wrong.
adding to the view this code fixes it but is obviously not what I want to
do: navigationController.view.superview.frame = CGRectMake(-79, 0,
size.width, size.height);
StarTravelAppDelegate *appDelegate = (StarTravelAppDelegate *)
[[UIApplication sharedApplication] delegate];
FirstMenuView *firstMenuView = [[[FirstMenuView alloc] init]
autorelease];
// bac123ViewController *bac123 = [[bac123ViewController alloc]
autorelease];
// UINavigationController *navigationController;
// appDelegate.navController = [[[UINavigationController alloc]
initWithRootViewController:firstMenuView] autorelease];
MyNavigationController *navigationController = appDelegate.navController;
[navigationController pushViewController:firstMenuView animated:true];
CGSize size = [[CCDirector sharedDirector] winSize];
navigationController.view.superview.frame = CGRectMake(-79, 0,
size.width, size.height);
// UIView *view = [[CCDirector sharedDirector] view];
// [view addSubview:bac123.view];
// [view addSubview:navigationController.view];
navigationController.navigationBarHidden = true;
The app delegate:
@implementation MyNavigationController
// The available orientations should be defined in the Info.plist file.
// And in iOS 6+ only, you can override it in the Root View controller in
the "supportedInterfaceOrientations" method.
// Only valid for iOS 6+. NOT VALID for iOS 4 / 5.
-(NSUInteger)supportedInterfaceOrientations {
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationMaskLandscape;
// iPad only
return UIInterfaceOrientationMaskLandscape;
}
// Supported orientations. Customize it for your own needs
// Only valid on iOS 4 / 5. NOT VALID for iOS 6.
-
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
// iPad only
// iPhone only
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
// This is needed for iOS4 and iOS5 in order to ensure
// that the 1st scene has the correct dimensions
// This is not needed on iOS6 and could be added to the
application:didFinish...
-(void) directorDidReshapeProjection:(CCDirector*)director
{
if(director.runningScene == nil) {
// Add the first scene to the stack. The director will draw it
immediately into the framebuffer. (Animation is started
automatically when the view is displayed.)
// and add the scene to the stack. The director will run it when
it automatically when the view is displayed.
[director runWithScene: [SpaceScene scene]];
}
}
@end
@implementation StarTravelAppDelegate
@synthesize window=window_, navController=navController_, director=director_;
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create the main window
window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]];
// CCGLView creation
// viewWithFrame: size of the OpenGL view. For full screen use
[_window bounds]
// - Possible values: any CGRect
// pixelFormat: Format of the render buffer. Use RGBA8 for better
color precision (eg: gradients). But it takes more memory and it is
slower
// - Possible values: kEAGLColorFormatRGBA8, kEAGLColorFormatRGB565
// depthFormat: Use stencil if you plan to use CCClippingNode. Use
Depth if you plan to use 3D effects, like CCCamera or CCNode#vertexZ
// - Possible values: 0, GL_DEPTH_COMPONENT24_OES,
GL_DEPTH24_STENCIL8_OES
// sharegroup: OpenGL sharegroup. Useful if you want to share the same
OpenGL context between different threads
// - Possible values: nil, or any valid EAGLSharegroup group
// multiSampling: Whether or not to enable multisampling
// - Possible values: YES, NO
// numberOfSamples: Only valid if multisampling is enabled
// - Possible values: 0 to glGetIntegerv(GL_MAX_SAMPLES_APPLE)
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:0
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
director_.wantsFullScreenLayout = YES;
// Display FSP and SPF
[director_ setDisplayStats:YES];
// set FPS at 60
[director_ setAnimationInterval:1.0/60];
// attach the openglView to the director
[director_ setView:glView];
// 2D projection
[director_ setProjection:kCCDirectorProjection2D];
// [director setProjection:kCCDirectorProjection3D];
// Enables High Res mode (Retina Display) on iPhone 4 and maintains
low res on all other devices
if( ! [director_ enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change this setting at any time.
[CCTexture2D
setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// If the 1st suffix is not found and if fallback is enabled then
fallback suffixes are going to searched. If none is found, it will try
with the name without suffix.
// On iPad HD : "-ipadhd", "-ipad", "-hd"
// On iPad : "-ipad", "-hd"
// On iPhone HD: "-hd"
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
[sharedFileUtils setEnableFallbackSuffixes:NO]; //
Default: NO. No fallback suffixes are going to be used
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default
on iPhone RetinaDisplay is "-hd"
[sharedFileUtils setiPadSuffix:@"-ipad"]; // Default
on iPad is "ipad"
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default
on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
// Create a Navigation Controller with the Director
navController_ = [[MyNavigationController alloc]
initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
// for rotation and other messages
[director_ setDelegate:navController_];
// set the Navigation Controller as the root view controller
[window_ setRootViewController:navController_];
//[window_ addSubview: navController_.view];
// make main window visible
[window_ makeKeyAndVisible];
return YES;
}
// getting a call, pause the game
-(void) applicationWillResignActive:(UIApplication *)application
{
if( [navController_ visibleViewController] == director_ )
[director_ pause];
}
// call got rejected
-(void) applicationDidBecomeActive:(UIApplication *)application
{
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
if( [navController_ visibleViewController] == director_ )
[director_ resume];
}
-(void) applicationDidEnterBackground:(UIApplication*)application
{
if( [navController_ visibleViewController] == director_ )
[director_ stopAnimation];
}
-(void) applicationWillEnterForeground:(UIApplication*)application
{
if( [navController_ visibleViewController] == director_ )
[director_ startAnimation];
}
// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
CC_DIRECTOR_END();
}
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
[[CCDirector sharedDirector] purgeCachedData];
}
// next delta time will be zero
-(void) applicationSignificantTimeChange:(UIApplication *)application
{
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}
- (void) dealloc
{
[window_ release];
[navController_ release];
[super dealloc];
}
@end
In the iphone everything works great.
However when I look at my navigationbar frame it is -44? Iphone the y
origin is 0.
Is it supposed to be this? Now everything seems to be shifted up by 79
pixels.
Any idea how to fix?
When I rotate everything sizes ok it is just the initial landscape size
that is wrong.
adding to the view this code fixes it but is obviously not what I want to
do: navigationController.view.superview.frame = CGRectMake(-79, 0,
size.width, size.height);
StarTravelAppDelegate *appDelegate = (StarTravelAppDelegate *)
[[UIApplication sharedApplication] delegate];
FirstMenuView *firstMenuView = [[[FirstMenuView alloc] init]
autorelease];
// bac123ViewController *bac123 = [[bac123ViewController alloc]
autorelease];
// UINavigationController *navigationController;
// appDelegate.navController = [[[UINavigationController alloc]
initWithRootViewController:firstMenuView] autorelease];
MyNavigationController *navigationController = appDelegate.navController;
[navigationController pushViewController:firstMenuView animated:true];
CGSize size = [[CCDirector sharedDirector] winSize];
navigationController.view.superview.frame = CGRectMake(-79, 0,
size.width, size.height);
// UIView *view = [[CCDirector sharedDirector] view];
// [view addSubview:bac123.view];
// [view addSubview:navigationController.view];
navigationController.navigationBarHidden = true;
The app delegate:
@implementation MyNavigationController
// The available orientations should be defined in the Info.plist file.
// And in iOS 6+ only, you can override it in the Root View controller in
the "supportedInterfaceOrientations" method.
// Only valid for iOS 6+. NOT VALID for iOS 4 / 5.
-(NSUInteger)supportedInterfaceOrientations {
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationMaskLandscape;
// iPad only
return UIInterfaceOrientationMaskLandscape;
}
// Supported orientations. Customize it for your own needs
// Only valid on iOS 4 / 5. NOT VALID for iOS 6.
-
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// iPhone only
if( [[UIDevice currentDevice] userInterfaceIdiom] ==
UIUserInterfaceIdiomPhone )
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
// iPad only
// iPhone only
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
// This is needed for iOS4 and iOS5 in order to ensure
// that the 1st scene has the correct dimensions
// This is not needed on iOS6 and could be added to the
application:didFinish...
-(void) directorDidReshapeProjection:(CCDirector*)director
{
if(director.runningScene == nil) {
// Add the first scene to the stack. The director will draw it
immediately into the framebuffer. (Animation is started
automatically when the view is displayed.)
// and add the scene to the stack. The director will run it when
it automatically when the view is displayed.
[director runWithScene: [SpaceScene scene]];
}
}
@end
@implementation StarTravelAppDelegate
@synthesize window=window_, navController=navController_, director=director_;
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create the main window
window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]];
// CCGLView creation
// viewWithFrame: size of the OpenGL view. For full screen use
[_window bounds]
// - Possible values: any CGRect
// pixelFormat: Format of the render buffer. Use RGBA8 for better
color precision (eg: gradients). But it takes more memory and it is
slower
// - Possible values: kEAGLColorFormatRGBA8, kEAGLColorFormatRGB565
// depthFormat: Use stencil if you plan to use CCClippingNode. Use
Depth if you plan to use 3D effects, like CCCamera or CCNode#vertexZ
// - Possible values: 0, GL_DEPTH_COMPONENT24_OES,
GL_DEPTH24_STENCIL8_OES
// sharegroup: OpenGL sharegroup. Useful if you want to share the same
OpenGL context between different threads
// - Possible values: nil, or any valid EAGLSharegroup group
// multiSampling: Whether or not to enable multisampling
// - Possible values: YES, NO
// numberOfSamples: Only valid if multisampling is enabled
// - Possible values: 0 to glGetIntegerv(GL_MAX_SAMPLES_APPLE)
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:0
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
director_.wantsFullScreenLayout = YES;
// Display FSP and SPF
[director_ setDisplayStats:YES];
// set FPS at 60
[director_ setAnimationInterval:1.0/60];
// attach the openglView to the director
[director_ setView:glView];
// 2D projection
[director_ setProjection:kCCDirectorProjection2D];
// [director setProjection:kCCDirectorProjection3D];
// Enables High Res mode (Retina Display) on iPhone 4 and maintains
low res on all other devices
if( ! [director_ enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change this setting at any time.
[CCTexture2D
setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// If the 1st suffix is not found and if fallback is enabled then
fallback suffixes are going to searched. If none is found, it will try
with the name without suffix.
// On iPad HD : "-ipadhd", "-ipad", "-hd"
// On iPad : "-ipad", "-hd"
// On iPhone HD: "-hd"
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
[sharedFileUtils setEnableFallbackSuffixes:NO]; //
Default: NO. No fallback suffixes are going to be used
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default
on iPhone RetinaDisplay is "-hd"
[sharedFileUtils setiPadSuffix:@"-ipad"]; // Default
on iPad is "ipad"
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default
on iPad RetinaDisplay is "-ipadhd"
// Assume that PVR images have premultiplied alpha
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
// Create a Navigation Controller with the Director
navController_ = [[MyNavigationController alloc]
initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
// for rotation and other messages
[director_ setDelegate:navController_];
// set the Navigation Controller as the root view controller
[window_ setRootViewController:navController_];
//[window_ addSubview: navController_.view];
// make main window visible
[window_ makeKeyAndVisible];
return YES;
}
// getting a call, pause the game
-(void) applicationWillResignActive:(UIApplication *)application
{
if( [navController_ visibleViewController] == director_ )
[director_ pause];
}
// call got rejected
-(void) applicationDidBecomeActive:(UIApplication *)application
{
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
if( [navController_ visibleViewController] == director_ )
[director_ resume];
}
-(void) applicationDidEnterBackground:(UIApplication*)application
{
if( [navController_ visibleViewController] == director_ )
[director_ stopAnimation];
}
-(void) applicationWillEnterForeground:(UIApplication*)application
{
if( [navController_ visibleViewController] == director_ )
[director_ startAnimation];
}
// application will be killed
- (void)applicationWillTerminate:(UIApplication *)application
{
CC_DIRECTOR_END();
}
// purge memory
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
[[CCDirector sharedDirector] purgeCachedData];
}
// next delta time will be zero
-(void) applicationSignificantTimeChange:(UIApplication *)application
{
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}
- (void) dealloc
{
[window_ release];
[navController_ release];
[super dealloc];
}
@end
Monday, 19 August 2013
Program Flow using Events
Program Flow using Events
I'm trying to write a program where Step 1 -> Kick off Step 2 -> kick off
step 3. Variables are passed in between each step.
Can I use events this way in C#? What might be the best way to write a
program that does this?
public class ProgramFlow // the listener program
{
EventArgs args = null;
public delegate void EventHandler(string str, EventArgs e);
public static event EventHandler Step1Reached;
public static event EventHandler Step2Reached;
public ProgramFlow()
{
Step1 step1 = new Step1();
// Print string and kick off Step2
Step2 step2 =new Step2();
// Print String kick off next step
}
}
public class Step1
{
string charRead;
public Step1()
{
Console.Write("Input something for Step1: ");
charRead = Console.ReadLine();
Console.WriteLine();
ProgramFlow.Step1Reached += ProgramFlow_Step1Reached;
}
void ProgramFlow_Step2Reached(string str, EventArgs e)
{
Console.WriteLine(charRead);
}
}
public class Step2
{
string charRead;
public Step2()
{
Console.Write("Input something for Step2: ");
charRead = Console.ReadLine();
Console.WriteLine();
ProgramFlow.Step2Reached += ProgramFlow_Step2Reached;
}
void ProgramFlow_Step2Reached(string str, EventArgs e)
{
Console.WriteLine(charRead);
}
}
class Program
{
static void Main(string[] args)
{
ProgramFlow programFlow = new ProgramFlow();
Console.ReadKey();
}
}
I'm trying to write a program where Step 1 -> Kick off Step 2 -> kick off
step 3. Variables are passed in between each step.
Can I use events this way in C#? What might be the best way to write a
program that does this?
public class ProgramFlow // the listener program
{
EventArgs args = null;
public delegate void EventHandler(string str, EventArgs e);
public static event EventHandler Step1Reached;
public static event EventHandler Step2Reached;
public ProgramFlow()
{
Step1 step1 = new Step1();
// Print string and kick off Step2
Step2 step2 =new Step2();
// Print String kick off next step
}
}
public class Step1
{
string charRead;
public Step1()
{
Console.Write("Input something for Step1: ");
charRead = Console.ReadLine();
Console.WriteLine();
ProgramFlow.Step1Reached += ProgramFlow_Step1Reached;
}
void ProgramFlow_Step2Reached(string str, EventArgs e)
{
Console.WriteLine(charRead);
}
}
public class Step2
{
string charRead;
public Step2()
{
Console.Write("Input something for Step2: ");
charRead = Console.ReadLine();
Console.WriteLine();
ProgramFlow.Step2Reached += ProgramFlow_Step2Reached;
}
void ProgramFlow_Step2Reached(string str, EventArgs e)
{
Console.WriteLine(charRead);
}
}
class Program
{
static void Main(string[] args)
{
ProgramFlow programFlow = new ProgramFlow();
Console.ReadKey();
}
}
Ubuntu install libgdiplus failed with automake
Ubuntu install libgdiplus failed with automake
this is how i get the libgdiplus git clone
git://github.com/mono/libgdiplus.git but can't install,why?
root@ubuntu:/opt/mono-3.0/libgdiplus# ./autogen.sh --prefix=/usr
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: You should add the contents of the following files to
`aclocal.m4':
libtoolize: `/usr/share/aclocal/libtool.m4'
libtoolize: `/usr/share/aclocal/ltoptions.m4'
libtoolize: `/usr/share/aclocal/ltversion.m4'
libtoolize: `/usr/share/aclocal/ltsugar.m4'
libtoolize: `/usr/share/aclocal/lt~obsolete.m4'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to
configure.in and
libtoolize: rerunning libtoolize, to keep the correct libtool macros
in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Running aclocal ...
aclocal: warning: autoconf input should be named 'configure.ac', not
'configure.in'
configure.in:11: warning: macro 'AM_PROG_LIBTOOL' not found in library
Running autoheader...
Running automake --gnu ...
automake: warning: autoconf input should be named 'configure.ac', not
'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not
'configure.in'
src/Makefile.am:122: warning: 'INCLUDES' is the old name for
'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
src/Makefile.am:1: The usual way to define 'LIBTOOL' is to add
'LT_INIT'
src/Makefile.am:1: to 'configure.in' and run 'aclocal' and
'autoconf' again.
src/Makefile.am:1: If 'LT_INIT' is in 'configure.in', make sure
src/Makefile.am:1: its definition is in aclocal's search path.
tests/Makefile.am:5: warning: 'INCLUDES' is the old name for
'AM_CPPFLAGS' (or '*_CPPFLAGS')
**Error**: automake failed.
root@ubuntu:/opt/mono-3.0/libgdiplus#
what problem with my automake?
Acutally i m trying to Install with this way
http://forums.ext.net/showthread.php?22030-Installation-procedure-for-Mono-3-0-1-on-Ubuntu-12-04-and-Debian-%28correcting-Combobox-Base-Class-Error%29
..
this is how i get the libgdiplus git clone
git://github.com/mono/libgdiplus.git but can't install,why?
root@ubuntu:/opt/mono-3.0/libgdiplus# ./autogen.sh --prefix=/usr
Running libtoolize...
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: You should add the contents of the following files to
`aclocal.m4':
libtoolize: `/usr/share/aclocal/libtool.m4'
libtoolize: `/usr/share/aclocal/ltoptions.m4'
libtoolize: `/usr/share/aclocal/ltversion.m4'
libtoolize: `/usr/share/aclocal/ltsugar.m4'
libtoolize: `/usr/share/aclocal/lt~obsolete.m4'
libtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to
configure.in and
libtoolize: rerunning libtoolize, to keep the correct libtool macros
in-tree.
libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
Running aclocal ...
aclocal: warning: autoconf input should be named 'configure.ac', not
'configure.in'
configure.in:11: warning: macro 'AM_PROG_LIBTOOL' not found in library
Running autoheader...
Running automake --gnu ...
automake: warning: autoconf input should be named 'configure.ac', not
'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not
'configure.in'
src/Makefile.am:122: warning: 'INCLUDES' is the old name for
'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am:1: error: Libtool library used but 'LIBTOOL' is undefined
src/Makefile.am:1: The usual way to define 'LIBTOOL' is to add
'LT_INIT'
src/Makefile.am:1: to 'configure.in' and run 'aclocal' and
'autoconf' again.
src/Makefile.am:1: If 'LT_INIT' is in 'configure.in', make sure
src/Makefile.am:1: its definition is in aclocal's search path.
tests/Makefile.am:5: warning: 'INCLUDES' is the old name for
'AM_CPPFLAGS' (or '*_CPPFLAGS')
**Error**: automake failed.
root@ubuntu:/opt/mono-3.0/libgdiplus#
what problem with my automake?
Acutally i m trying to Install with this way
http://forums.ext.net/showthread.php?22030-Installation-procedure-for-Mono-3-0-1-on-Ubuntu-12-04-and-Debian-%28correcting-Combobox-Base-Class-Error%29
..
Using Regex (or anything) to do an advanced find and replace
Using Regex (or anything) to do an advanced find and replace
I'm trying to find all things inside double quotes and replace it with a
link using it. I have over 500 lines of questions, so I don't want to do
it by hand.
Original php doc snippet:
$q2 = array ("What does Mars look like from Earth?",
"What is Mars's position relative to Earth?");
$q3 = array ("What does Mars's surface look like?",
"Show me a view of the surface of Mars.",
"Show me a picture of the surface of Mars.");
Formatting I want:
$q2 = array ("<a
href="answer.php?query=What+does+Mars+look+like+from+Earth%3F">What does
Mars look like from Earth?</a>",
<a
href="answer.php?query=What+is+Mars's+position+relative+to+Earth%3F">"What
is Mars's position relative to Earth?");
I tried using Regex, but without any previous experience with it, I was
unsuccessful. Using RegExr (my example) I came up with a find of:
"[A-Za-z0-9\s.\?']*" and a replace of: < a href=answer.php?query=$&>$&"
This just gave results like
$q2 = array (<a href=answer.php?query="What does Mars look like from
Earth?">"What does Mars look like from Earth?"</a>",
This is close, but not what I need. Hopefully someone knows what replace I
should use, or a better program to try. Any help would be appreciated.
I'm trying to find all things inside double quotes and replace it with a
link using it. I have over 500 lines of questions, so I don't want to do
it by hand.
Original php doc snippet:
$q2 = array ("What does Mars look like from Earth?",
"What is Mars's position relative to Earth?");
$q3 = array ("What does Mars's surface look like?",
"Show me a view of the surface of Mars.",
"Show me a picture of the surface of Mars.");
Formatting I want:
$q2 = array ("<a
href="answer.php?query=What+does+Mars+look+like+from+Earth%3F">What does
Mars look like from Earth?</a>",
<a
href="answer.php?query=What+is+Mars's+position+relative+to+Earth%3F">"What
is Mars's position relative to Earth?");
I tried using Regex, but without any previous experience with it, I was
unsuccessful. Using RegExr (my example) I came up with a find of:
"[A-Za-z0-9\s.\?']*" and a replace of: < a href=answer.php?query=$&>$&"
This just gave results like
$q2 = array (<a href=answer.php?query="What does Mars look like from
Earth?">"What does Mars look like from Earth?"</a>",
This is close, but not what I need. Hopefully someone knows what replace I
should use, or a better program to try. Any help would be appreciated.
Collection was modified; enumeration operation may not execute , even when i create a copy of the current object
Collection was modified; enumeration operation may not execute , even when
i create a copy of the current object
I have the following repository method :-
public void DeleteVM(int id, string username)
{
var VM = tms.TMSVirtualMachines.SingleOrDefault(a =>
a.TMSVirtualMachineID == id);
var auditinfo =
IntiateTechnologyAudit(tms.AuditActions.SingleOrDefault(a =>
a.Name.ToUpper() == "DELETE").ID,
VM.Technology.TechnologyType.AssetTypeID,
username, VM.TMSVirtualMachineID);
var technology = tms.Technologies.SingleOrDefault(a =>
a.TechnologyID == id);
technology.IsDeleted = true;
tms.Entry(technology).State = EntityState.Modified;
var vm2 = VM;
foreach(var ip in vm2.Technology.TechnologyIPs)
{
tms.TechnologyIPs.Remove(ip);
}
tms.TMSVirtualMachines.Remove(VM);
InsertOrUpdateTechnologyAudit(auditinfo);
}
But i am getting the following exception :-
System.InvalidOperationException was caught HResult=-2146233079
Message=Collection was modified; enumeration operation may not execute.
Source=System.Core StackTrace: at
System.Collections.Generic.HashSet`1.Enumerator.MoveNext()
although i have created a copy of the VM and i perform the foreach over it..
i create a copy of the current object
I have the following repository method :-
public void DeleteVM(int id, string username)
{
var VM = tms.TMSVirtualMachines.SingleOrDefault(a =>
a.TMSVirtualMachineID == id);
var auditinfo =
IntiateTechnologyAudit(tms.AuditActions.SingleOrDefault(a =>
a.Name.ToUpper() == "DELETE").ID,
VM.Technology.TechnologyType.AssetTypeID,
username, VM.TMSVirtualMachineID);
var technology = tms.Technologies.SingleOrDefault(a =>
a.TechnologyID == id);
technology.IsDeleted = true;
tms.Entry(technology).State = EntityState.Modified;
var vm2 = VM;
foreach(var ip in vm2.Technology.TechnologyIPs)
{
tms.TechnologyIPs.Remove(ip);
}
tms.TMSVirtualMachines.Remove(VM);
InsertOrUpdateTechnologyAudit(auditinfo);
}
But i am getting the following exception :-
System.InvalidOperationException was caught HResult=-2146233079
Message=Collection was modified; enumeration operation may not execute.
Source=System.Core StackTrace: at
System.Collections.Generic.HashSet`1.Enumerator.MoveNext()
although i have created a copy of the VM and i perform the foreach over it..
Sunday, 18 August 2013
How to get audio decibel (dB) from mp3 file every second in Android?
How to get audio decibel (dB) from mp3 file every second in Android?
I want to create a music player application that can show decibel value
every second when music player played a song. And when I increase a volume
of my Android device, it makes decibel value get bigger. Otherwise,when I
decrease, that value get smaller. I'm really stuck where I must start for
creating it.
I've ever read from another articles, this related with FFT, buffering,
volume, etc.. But I don't know how to put that compenent in my source
code.
Is there any idea for its source code example ??? Please, help me !!! I'm
really...really.. so depressed to find out that way..
Sorry for my poor English.. Thanks alot for your helping, I appreaciate.. :)
I want to create a music player application that can show decibel value
every second when music player played a song. And when I increase a volume
of my Android device, it makes decibel value get bigger. Otherwise,when I
decrease, that value get smaller. I'm really stuck where I must start for
creating it.
I've ever read from another articles, this related with FFT, buffering,
volume, etc.. But I don't know how to put that compenent in my source
code.
Is there any idea for its source code example ??? Please, help me !!! I'm
really...really.. so depressed to find out that way..
Sorry for my poor English.. Thanks alot for your helping, I appreaciate.. :)
php opendir symbolic link on localhost apache
php opendir symbolic link on localhost apache
I am running a localhost server on my mac under /Users/myusername/Sites
I have a symbolic link to an external directory in my Sites folder. If I
try to run opendir and load images in the directory that is a symbolic
link I get
Warning: opendir(dir/symlinkDir/) [function.opendir]: failed to open dir:
Permission denied
symlinkDir is a symbolic link to a dir containing images. This works fine
it symlinkDir is not a soft link but instead an actual dir.
I have tried changing permissions on the directory, 755, 777, +x. I've
also tried changing the /etc/apache2/users/myusername.conf to
<Directory "/Users/myusername/Sites/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I am running a localhost server on my mac under /Users/myusername/Sites
I have a symbolic link to an external directory in my Sites folder. If I
try to run opendir and load images in the directory that is a symbolic
link I get
Warning: opendir(dir/symlinkDir/) [function.opendir]: failed to open dir:
Permission denied
symlinkDir is a symbolic link to a dir containing images. This works fine
it symlinkDir is not a soft link but instead an actual dir.
I have tried changing permissions on the directory, 755, 777, +x. I've
also tried changing the /etc/apache2/users/myusername.conf to
<Directory "/Users/myusername/Sites/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
How to remove elements/nodes from angular.js array
How to remove elements/nodes from angular.js array
I am trying to remove elements from the array $scope.items so that items
are removed in the view ng-repeat="item in items"
Just for demonstrative purposes here is some code:
for(i=0;i<$scope.items.length;i++){
if($scope.items[i].name == 'ted'){
$scope.items.shift();
}
}
I want to remove the 1st element from the view if there is the name ted
right? It works fine, but the view reloads all the elements. Because all
the array keys have shifted. This is creating unnecessary lag in the
mobile app I am creating..
Anyone have an ideas to this solution please?
Thanks,
Nick
I am trying to remove elements from the array $scope.items so that items
are removed in the view ng-repeat="item in items"
Just for demonstrative purposes here is some code:
for(i=0;i<$scope.items.length;i++){
if($scope.items[i].name == 'ted'){
$scope.items.shift();
}
}
I want to remove the 1st element from the view if there is the name ted
right? It works fine, but the view reloads all the elements. Because all
the array keys have shifted. This is creating unnecessary lag in the
mobile app I am creating..
Anyone have an ideas to this solution please?
Thanks,
Nick
Durandal looses knockout binding
Durandal looses knockout binding
Guru Guys)
I've faced strange(for me) trouble.
In my SPA I have such route structure:
shell - some navigational logic is here.
designs - designs list with filtering, sorting and searching. if user
clicks on list item, he is redirected to it's details page.
designs/details/:id - detailed view of separate design from list.
Shell has main menu and composition binding for specific menus: for
designs list i have strip with filtering, sorting and searching buttons.
For design details i switch it to strip with download button and 'come
back' button, which returns user to design list.
So, the problem is: when i open design list, everything is ok. But, when i
go to details of some item. and after that come back to list, all bindings
in composed view are broken. In console i have ""Unable to parse
bindings.↵Message: ReferenceError: categories is not
defined;↵Bindings value: foreach: categories"".
I suspect, that something is wrong with my promises objects. because i'm
newbee in promises) Can You, please, give me some advices? Here is my
markup and code:
shell.js(shortened)
define(['durandal/plugins/router', 'fw/service'], function (router,
service, userDataModel) {
var o = function () {
var self = this;
/*Current view and viewmodel for composed menu*/
self.currentNavView = ko.observable('views/shellnav');
self.currentNavModel = ko.observable('viewmodels/shell');
/*Router*/
self.router = router;
/*Route activation*/
self.activate = function(args){
/*navigate to designs list*/
router.activate('designs');
}
return self;
}
return new o();});
designs.js
here is the possible problem - when visiting this page first time,
self.categories is filled with data. when coming back to this page from
details - self.categories are empty. categories are the datasource for one
of my filters. they are bound in designsnav.html, and, when coming back
from details, knockout throws an error, that they are not defined.
define(['datamodels/designsdatamodel', 'datamodels/categoryDataModel',
'durandal/app', 'viewmodels/shell', 'durandal/plugins/router',
'viewmodels/designDetails', "fw/service"], function (designModel,
categoryModel, app, shell, router, designsDetails, service) {
var o = function () {
var self = this,
self.designs = ko.observableArray([]),
self.categories = ko.observableArray([]);
self.activate = function (args) {
shell.currentNavView('views/designsnav');
shell.currentNavModel('viewmodels/designs');
var ret = $.when(designModel.getItems(), categoryModel.getItems());
ret.done(function (designsData, categoryData) {
designs(designsData);
categories(categoryData);
});
return ret;
}
/*Displaying design details*/
self.detailClick = function (design) {
router.navigateTo("#/designs/details/" + design.id());
};
return self;
};
return new o();});
designsDataModel.js - here i retrieve data from server and return promices
for list and separate design.
define(['fw/service'], function (service) {
var o = function () {
var self = this;
self.designs = null;
self.getDesign = function (id) {
var dur = $.Deferred();
$.when(service.getDesignDetail(id)).done(function (data) {
dur.resolve(new self.DesignsModel(data))
});
return dur.promise();
};
self.getItems = function () {
var dur = $.Deferred();
$.when(service.getDesigns(opts)).done(function (data) {
var newItems = $.map(data.Items, function (item) { return new
self.DesignsModel(item) });
dur.resolve(newItems);
});
return dur.promise();
};
self.DesignsModel = function (data) {
var self = this;
/*other fields are removed for less displaying*/
};
return self;
}
return new o();
});
categoryDataModel.js - here i receive categories list from server.
define(['fw/service'], function (service) {
var o = function () {
var self = this;
self.getItems = function () {
var dur = $.Deferred();
$.when(service.getCategories()).done(function (data) {
var categories = $.map(data.Items, function (item) { return
new self.CategoryModel(item) });
dur.resolve(categories);
});
return dur.promise();
};
self.CategoryModel = function (data) {
this.id = ko.observable(data.Id);
this.title = ko.observable(data.Title);
this.count = ko.observable(data.Count);
this.selected = ko.observable(false);
}
return self;
}
return new o();});
designDetails.js - when coming back from this to design list, all bindings
from composed view are broken.
define(['viewmodels/shell', 'datamodels/designsdatamodel',
'durandal/plugins/router', 'viewmodels/designs'], function (shell,
designsDM, router, designs) {
var self = this;
self.design = ko.observable();
self.backClick = function () {
shell.currentNavView('views/designsnav');
shell.currentNavModel('viewmodels/designs');
router.navigateTo("#/designs");
};
self.zoomImage = function () {
var $cont = $('.top-container-left');
if ($cont.is(".zoomed")) {
$cont.removeClass("zoomed");
} else {
$cont.addClass("zoomed");
}
};
self.activate = function (args) {
var dur = $.when(designsDM.getDesign(args.id));
shell.currentNavView('views/designDetailsNav');
dur.done(function (data) {
if (data.viewed() === false)
{
data.views(parseInt(data.views()) + 1);
data.viewed(true);
}
self.design(data);
});
return dur;
};
return self;});
I understand, that i've posted a lot of code, but, maybe, somebody will
see rude mistake somewhere - in code or in logic. I will be very grateful
for all constructive coments. Thanks in advance!
Guru Guys)
I've faced strange(for me) trouble.
In my SPA I have such route structure:
shell - some navigational logic is here.
designs - designs list with filtering, sorting and searching. if user
clicks on list item, he is redirected to it's details page.
designs/details/:id - detailed view of separate design from list.
Shell has main menu and composition binding for specific menus: for
designs list i have strip with filtering, sorting and searching buttons.
For design details i switch it to strip with download button and 'come
back' button, which returns user to design list.
So, the problem is: when i open design list, everything is ok. But, when i
go to details of some item. and after that come back to list, all bindings
in composed view are broken. In console i have ""Unable to parse
bindings.↵Message: ReferenceError: categories is not
defined;↵Bindings value: foreach: categories"".
I suspect, that something is wrong with my promises objects. because i'm
newbee in promises) Can You, please, give me some advices? Here is my
markup and code:
shell.js(shortened)
define(['durandal/plugins/router', 'fw/service'], function (router,
service, userDataModel) {
var o = function () {
var self = this;
/*Current view and viewmodel for composed menu*/
self.currentNavView = ko.observable('views/shellnav');
self.currentNavModel = ko.observable('viewmodels/shell');
/*Router*/
self.router = router;
/*Route activation*/
self.activate = function(args){
/*navigate to designs list*/
router.activate('designs');
}
return self;
}
return new o();});
designs.js
here is the possible problem - when visiting this page first time,
self.categories is filled with data. when coming back to this page from
details - self.categories are empty. categories are the datasource for one
of my filters. they are bound in designsnav.html, and, when coming back
from details, knockout throws an error, that they are not defined.
define(['datamodels/designsdatamodel', 'datamodels/categoryDataModel',
'durandal/app', 'viewmodels/shell', 'durandal/plugins/router',
'viewmodels/designDetails', "fw/service"], function (designModel,
categoryModel, app, shell, router, designsDetails, service) {
var o = function () {
var self = this,
self.designs = ko.observableArray([]),
self.categories = ko.observableArray([]);
self.activate = function (args) {
shell.currentNavView('views/designsnav');
shell.currentNavModel('viewmodels/designs');
var ret = $.when(designModel.getItems(), categoryModel.getItems());
ret.done(function (designsData, categoryData) {
designs(designsData);
categories(categoryData);
});
return ret;
}
/*Displaying design details*/
self.detailClick = function (design) {
router.navigateTo("#/designs/details/" + design.id());
};
return self;
};
return new o();});
designsDataModel.js - here i retrieve data from server and return promices
for list and separate design.
define(['fw/service'], function (service) {
var o = function () {
var self = this;
self.designs = null;
self.getDesign = function (id) {
var dur = $.Deferred();
$.when(service.getDesignDetail(id)).done(function (data) {
dur.resolve(new self.DesignsModel(data))
});
return dur.promise();
};
self.getItems = function () {
var dur = $.Deferred();
$.when(service.getDesigns(opts)).done(function (data) {
var newItems = $.map(data.Items, function (item) { return new
self.DesignsModel(item) });
dur.resolve(newItems);
});
return dur.promise();
};
self.DesignsModel = function (data) {
var self = this;
/*other fields are removed for less displaying*/
};
return self;
}
return new o();
});
categoryDataModel.js - here i receive categories list from server.
define(['fw/service'], function (service) {
var o = function () {
var self = this;
self.getItems = function () {
var dur = $.Deferred();
$.when(service.getCategories()).done(function (data) {
var categories = $.map(data.Items, function (item) { return
new self.CategoryModel(item) });
dur.resolve(categories);
});
return dur.promise();
};
self.CategoryModel = function (data) {
this.id = ko.observable(data.Id);
this.title = ko.observable(data.Title);
this.count = ko.observable(data.Count);
this.selected = ko.observable(false);
}
return self;
}
return new o();});
designDetails.js - when coming back from this to design list, all bindings
from composed view are broken.
define(['viewmodels/shell', 'datamodels/designsdatamodel',
'durandal/plugins/router', 'viewmodels/designs'], function (shell,
designsDM, router, designs) {
var self = this;
self.design = ko.observable();
self.backClick = function () {
shell.currentNavView('views/designsnav');
shell.currentNavModel('viewmodels/designs');
router.navigateTo("#/designs");
};
self.zoomImage = function () {
var $cont = $('.top-container-left');
if ($cont.is(".zoomed")) {
$cont.removeClass("zoomed");
} else {
$cont.addClass("zoomed");
}
};
self.activate = function (args) {
var dur = $.when(designsDM.getDesign(args.id));
shell.currentNavView('views/designDetailsNav');
dur.done(function (data) {
if (data.viewed() === false)
{
data.views(parseInt(data.views()) + 1);
data.viewed(true);
}
self.design(data);
});
return dur;
};
return self;});
I understand, that i've posted a lot of code, but, maybe, somebody will
see rude mistake somewhere - in code or in logic. I will be very grateful
for all constructive coments. Thanks in advance!
Disabling some checkboxes of choice widget in buildForm()
Disabling some checkboxes of choice widget in buildForm()
I have a form widget of type "choice" which is being displayed as a list
of many checkboxes. Everything works great. So to stress it out: there is
ONE widget, with MANY checkboxes (and NOT several checkbox widgets).
Now, I want to disable some of those checkboxes. The data for that is
avaliable in the $options-Array.
Here is the buildForm()-function of my FooType.php
...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('foo', 'choice', array('choices' =>
$options['choiceArray']['id'],
'multiple' => true,
'expanded' => true,
'disabled' =>
$options['choiceArray']['disabled']
// does not work (needs
a boolean)
'data' =>
$options['choiceArray']['checked'],
// works
'attr' =>
array('class' =>
'checkbox')))
;
}
...
My Twig-template looks like this:
{% for document in documentForm %}
<dd>{{ form_widget(document) }}</dd>
{% endfor %}
I can only disable ALL the checkboxes (by setting 'disabled' => true in
buildForm). And passing an array there does not work (as commented in the
snippet).
How can I disable some selected checkboxed (stored in
$options['choiceArray']['disabled']) of my choice widget?
I have a form widget of type "choice" which is being displayed as a list
of many checkboxes. Everything works great. So to stress it out: there is
ONE widget, with MANY checkboxes (and NOT several checkbox widgets).
Now, I want to disable some of those checkboxes. The data for that is
avaliable in the $options-Array.
Here is the buildForm()-function of my FooType.php
...
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('foo', 'choice', array('choices' =>
$options['choiceArray']['id'],
'multiple' => true,
'expanded' => true,
'disabled' =>
$options['choiceArray']['disabled']
// does not work (needs
a boolean)
'data' =>
$options['choiceArray']['checked'],
// works
'attr' =>
array('class' =>
'checkbox')))
;
}
...
My Twig-template looks like this:
{% for document in documentForm %}
<dd>{{ form_widget(document) }}</dd>
{% endfor %}
I can only disable ALL the checkboxes (by setting 'disabled' => true in
buildForm). And passing an array there does not work (as commented in the
snippet).
How can I disable some selected checkboxed (stored in
$options['choiceArray']['disabled']) of my choice widget?
i Can't able to instal ubuntu 2.04lts from win 8 can anybody help?
i Can't able to instal ubuntu 2.04lts from win 8 can anybody help?
it says 'extracting' & after some it says "Could not retrieve the required
installation files". can anybody help?
it says 'extracting' & after some it says "Could not retrieve the required
installation files". can anybody help?
Saturday, 17 August 2013
Keeping text snippet central within a box
Keeping text snippet central within a box
I am making a dynamic slide show.
I am trying to get some text that I assign dynamically to align itself
centrally and vertically within a box.
So far, I have:
HTML
<body>
<div class="slide">
<span class="content">
<b>Hello. This text needs to be:</b><br><br>
- left-aligned but <br>
- centered in the grey box<br>
- even if it changes<br>
- the center of the white box <br>
should equal center of grey one.
</span>
</div>
</body>
CSS
.slide {
position:relative;
background-color: #ddd;
width: 300px;
height: 300px
}
.content {
position: absolute;
top: 30%;
left: 15%;
background-color: #fff;
}
OUTPUT
This doesn't work because if the text changes, it will no longer be
central. Anyone have any ideas how to fix this?
http://jsbin.com/uyiFiwI/23/edit
I am making a dynamic slide show.
I am trying to get some text that I assign dynamically to align itself
centrally and vertically within a box.
So far, I have:
HTML
<body>
<div class="slide">
<span class="content">
<b>Hello. This text needs to be:</b><br><br>
- left-aligned but <br>
- centered in the grey box<br>
- even if it changes<br>
- the center of the white box <br>
should equal center of grey one.
</span>
</div>
</body>
CSS
.slide {
position:relative;
background-color: #ddd;
width: 300px;
height: 300px
}
.content {
position: absolute;
top: 30%;
left: 15%;
background-color: #fff;
}
OUTPUT
This doesn't work because if the text changes, it will no longer be
central. Anyone have any ideas how to fix this?
http://jsbin.com/uyiFiwI/23/edit
Subscribe to:
Comments (Atom)