Not able to wget to ftp server
I am trying to wget a ftp server from a remote machine. The command is not
getting past 'Logging in as anonymous'. This is what i am getting.
wget ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr1.fa.gz
--2013-09-29 22:07:53--
ftp://hgdownload.cse.ucsc.edu/goldenPath/hg19/chromosomes/chr1.fa.gz
=> 'chr1.fa.gz'
Resolving proxy.x.y.z... *.*.*.*
Connecting to proxy.x.y.z|*.*.*.*|:3128... connected.
Logging in as anonymous ...
When i try accessing the site by firefox from the remote machine, it works
fine. I have set my ftp proxy like this
export ftp_proxy="ftp://a.user:password@proxy:3128
Can anyone help me fix this problem?
Thanks
Monday, 30 September 2013
CDF of Euclidean distance between two points.
CDF of Euclidean distance between two points.
2-D plane, a circle $\text{C}_0$ of radius $R$ centered at $A(0,0)$, $N$
random points $D_i(x_i,y_i),i=1\dots N$ are independently uniformly
distributed in $\text{C}_0$.
Choose the point $D_s$ from $D_i$ which has the smallest Euclidean
distance to point $A$, i.e., $$s = \mathop{\arg\min}_{i=1\dots
N}\sqrt{x_i^2+y_i^2},\\ d_s=\min_{i=1\dots N}\sqrt{x_i^2+y_i^2}. $$
I know that the CDF of $d_s$ is
$$F_{d_s}(r)=1-\left(1-\frac{r^2}{R^2}\right)^N,0\leq r\leq R.$$
If there is another point $P(a,0),a>R$, the Euclidean distance from $D_s$
to $P$ is $$d_{sp}=\sqrt{(x_s-a)^2+y_s^2}.$$
How can I find the CDF or PDF of $d_{sp}$ ?
Thanks a lot!
2-D plane, a circle $\text{C}_0$ of radius $R$ centered at $A(0,0)$, $N$
random points $D_i(x_i,y_i),i=1\dots N$ are independently uniformly
distributed in $\text{C}_0$.
Choose the point $D_s$ from $D_i$ which has the smallest Euclidean
distance to point $A$, i.e., $$s = \mathop{\arg\min}_{i=1\dots
N}\sqrt{x_i^2+y_i^2},\\ d_s=\min_{i=1\dots N}\sqrt{x_i^2+y_i^2}. $$
I know that the CDF of $d_s$ is
$$F_{d_s}(r)=1-\left(1-\frac{r^2}{R^2}\right)^N,0\leq r\leq R.$$
If there is another point $P(a,0),a>R$, the Euclidean distance from $D_s$
to $P$ is $$d_{sp}=\sqrt{(x_s-a)^2+y_s^2}.$$
How can I find the CDF or PDF of $d_{sp}$ ?
Thanks a lot!
How to compress/decompress strings in a userscript?
How to compress/decompress strings in a userscript?
I've been trying to figure out why a userscript I'm working on is slow in
Firefox yet blazing in Chrome and Safari. One reason I've identified
(though maybe not the only reason) is that the large file size of the
userscript is having a big effect. The script has ten book length strings
in it, for a file size of 3.8 MB. If I remove the strings the script gets
fast again---basically everything in the browser grinds to a halt while
the file loads (right at the time for a typical user input interaction).
So I was thinking it might help to precompress the strings, then
uncompress as needed during the run. Anyone have a strategy for doing this
within a userscript?
I've been trying to figure out why a userscript I'm working on is slow in
Firefox yet blazing in Chrome and Safari. One reason I've identified
(though maybe not the only reason) is that the large file size of the
userscript is having a big effect. The script has ten book length strings
in it, for a file size of 3.8 MB. If I remove the strings the script gets
fast again---basically everything in the browser grinds to a halt while
the file loads (right at the time for a typical user input interaction).
So I was thinking it might help to precompress the strings, then
uncompress as needed during the run. Anyone have a strategy for doing this
within a userscript?
MDX Get last non empty value for EACH month
MDX Get last non empty value for EACH month
I need to get the last non empty value of Total Cost for EACH month.
M,P,R are parcel types, B is also a parcel type which i don't want to see.
I tried all kinds of codes, here is what i have now:
SELECT { [Measures].[Total Cost Price] } ON COLUMNS,
NON EMPTY {TAIL(NonEmptyCrossJoin([TimeDim].[Date].AllMembers,1),1) *
[Parcel Type].[Parcel Type ID].[Parcel Type ID].ALLMEMBERS ) } ON ROWS
FROM ( SELECT (-{ [Parcel Type].[Parcel Type ID].&[B] } ) ON COLUMNS
FROM [SomeDB])
It gives the following result:
Which is exactly what i need for September, 22/9/2013 is the last date in
September which holds data and the value is correct. But i need this for
each month, August etc.
Can anyone please suggest a solution? I use sql 2008
I need to get the last non empty value of Total Cost for EACH month.
M,P,R are parcel types, B is also a parcel type which i don't want to see.
I tried all kinds of codes, here is what i have now:
SELECT { [Measures].[Total Cost Price] } ON COLUMNS,
NON EMPTY {TAIL(NonEmptyCrossJoin([TimeDim].[Date].AllMembers,1),1) *
[Parcel Type].[Parcel Type ID].[Parcel Type ID].ALLMEMBERS ) } ON ROWS
FROM ( SELECT (-{ [Parcel Type].[Parcel Type ID].&[B] } ) ON COLUMNS
FROM [SomeDB])
It gives the following result:
Which is exactly what i need for September, 22/9/2013 is the last date in
September which holds data and the value is correct. But i need this for
each month, August etc.
Can anyone please suggest a solution? I use sql 2008
Sunday, 29 September 2013
When to use mutable vs immutable classes in Scala
When to use mutable vs immutable classes in Scala
Much is written about the advantages of immutable state, but are there
common cases in Scala where it makes sense to prefer mutable classes?
(This is a Scala newbie question from someone with a background in
"classic" OOP design using mutable classes.)
For something trivial like a 3-dimensional Point class, I get the
advantages of immutability. But what about something like a Motor class,
which exposes a variety of control variables and/or sensor readings? Would
a seasoned Scala developer typically write such a class to be immutable?
In that case, would 'speed' be represented internally as a 'val' instead
of a 'var', and the 'setSpeed' method return a new instance of the class?
Similarly, would every new reading from a sensor describing the motor's
internal state cause a new instance of Motor to be instantiated?
The "old way" of doing OOP in Java or C# using classes to encapsulate
mutable state seems to fit the Motor example very well. So I'm curious to
know if once you gain experience using the immutable-state paradigm, you
would even design a class like Motor to be immutable.
Much is written about the advantages of immutable state, but are there
common cases in Scala where it makes sense to prefer mutable classes?
(This is a Scala newbie question from someone with a background in
"classic" OOP design using mutable classes.)
For something trivial like a 3-dimensional Point class, I get the
advantages of immutability. But what about something like a Motor class,
which exposes a variety of control variables and/or sensor readings? Would
a seasoned Scala developer typically write such a class to be immutable?
In that case, would 'speed' be represented internally as a 'val' instead
of a 'var', and the 'setSpeed' method return a new instance of the class?
Similarly, would every new reading from a sensor describing the motor's
internal state cause a new instance of Motor to be instantiated?
The "old way" of doing OOP in Java or C# using classes to encapsulate
mutable state seems to fit the Motor example very well. So I'm curious to
know if once you gain experience using the immutable-state paradigm, you
would even design a class like Motor to be immutable.
sql order by hardcoded values
sql order by hardcoded values
I have the following query:
select 'junior' as type, value
from mytable
union
select 'intermediate' as type, value
from mytable
union
select 'senior' as type, value
from mytable
Which returns the following data:
type value
Intermediate 10
Junior 5
Senior 1
I just need to reorder it so it looks like this
Junior 5
Intermediate 10
Senior 1
I can't figure out which order by clause to use to achieve ordering by
custom specific values, how would I achieve this?
I have the following query:
select 'junior' as type, value
from mytable
union
select 'intermediate' as type, value
from mytable
union
select 'senior' as type, value
from mytable
Which returns the following data:
type value
Intermediate 10
Junior 5
Senior 1
I just need to reorder it so it looks like this
Junior 5
Intermediate 10
Senior 1
I can't figure out which order by clause to use to achieve ordering by
custom specific values, how would I achieve this?
Find a file Age In php
Find a file Age In php
I need to find the age of a file using php
for eg : i have abc.txt. I need to find how many days old.
ans: abc.txt is 20 day's old...
i have tried below code but i need only day's output
function humanTiming ($time)
{
// to get the time since that moment
$time = time() - $time;
// time unit constants
$timeUnits = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
// iterate over time contants to build a human
$humanTiming;
foreach ($timeUnits as $unit => $text)
{
if ($time < $unit)
continue;
$numberOfUnits = floor($time / $unit);
var_dump($humanTiming);
// human readable token for current time unit
$humanTiming = $humanTiming.' '.$numberOfUnits.'
'.$text.(($numberOfUnits>1)?'s':'');
// compute remaining time for next loop iteration
$time -= $unit*$numberOfUnits;
}
return $humanTiming;
}
$filename = 'H:\xampp\htdocs\doc\index.php';
if (file_exists($filename))
{
$time = strtotime('2010-04-28 17:25:43');
$time = filemtime($filename);
echo '<br/>File age is '.humanTiming($time).'.';
$elapsedTime = time()-filemtime($filename);
}
I need to find the age of a file using php
for eg : i have abc.txt. I need to find how many days old.
ans: abc.txt is 20 day's old...
i have tried below code but i need only day's output
function humanTiming ($time)
{
// to get the time since that moment
$time = time() - $time;
// time unit constants
$timeUnits = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
// iterate over time contants to build a human
$humanTiming;
foreach ($timeUnits as $unit => $text)
{
if ($time < $unit)
continue;
$numberOfUnits = floor($time / $unit);
var_dump($humanTiming);
// human readable token for current time unit
$humanTiming = $humanTiming.' '.$numberOfUnits.'
'.$text.(($numberOfUnits>1)?'s':'');
// compute remaining time for next loop iteration
$time -= $unit*$numberOfUnits;
}
return $humanTiming;
}
$filename = 'H:\xampp\htdocs\doc\index.php';
if (file_exists($filename))
{
$time = strtotime('2010-04-28 17:25:43');
$time = filemtime($filename);
echo '<br/>File age is '.humanTiming($time).'.';
$elapsedTime = time()-filemtime($filename);
}
Query for distinct instance of model + one other field
Query for distinct instance of model + one other field
I have a model called Evaluation. When an evaluation is created, an
eval_number is created with it. There are many evaluations with the same
eval_number.
Here's an example:
- !ruby/object:Evaluation
attributes:
id: 2023
score: 3
created_at: 2013-09-08 13:10:53.000000000 Z
updated_at: 2013-09-08 13:10:53.000000000 Z
student_id: 26
goal_id: 50
eval_number: 33
- !ruby/object:Evaluation
attributes:
id: 2099
score: 4
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 36
eval_number: 34
- !ruby/object:Evaluation
attributes:
id: 2100
score: 3
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 37
eval_number: 34
- !ruby/object:Evaluation
attributes:
id: 2101
score: 4
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 38
eval_number: 34
In a view, I want to show the date that a given evaluation was created in
a table header. It should look like this:
date_1 | date_2 | date_3 | date_4 | etc..
To do this, I need to get distinct evaluation_numbers + the created_at
dates that go with them. I thought that this would help, but it's
returning more than one record per eval_number with this code:
def eval_date(i)
evals = self.goals.first.evaluations
eval = evals.select("distinct(eval_number), created_at").all[i]
eval.created_at.to_date
end
It seems like distinct eval_numbers are being selected, but also distinct
created_at columns (which of course are all different). This makes the
.all[i] basically useless as it's finding the [0], [1], [2], etc element
correctly - but there are far more than whatever the given number of i is
in the returned array.
I want to find a distinct eval_number and load only the created_date that
goes with it. I think I could load the whole record with all attributes,
but I don't need them, so I'd rather not.
I have a model called Evaluation. When an evaluation is created, an
eval_number is created with it. There are many evaluations with the same
eval_number.
Here's an example:
- !ruby/object:Evaluation
attributes:
id: 2023
score: 3
created_at: 2013-09-08 13:10:53.000000000 Z
updated_at: 2013-09-08 13:10:53.000000000 Z
student_id: 26
goal_id: 50
eval_number: 33
- !ruby/object:Evaluation
attributes:
id: 2099
score: 4
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 36
eval_number: 34
- !ruby/object:Evaluation
attributes:
id: 2100
score: 3
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 37
eval_number: 34
- !ruby/object:Evaluation
attributes:
id: 2101
score: 4
created_at: 2013-09-08 13:19:12.000000000 Z
updated_at: 2013-09-08 13:19:12.000000000 Z
student_id: 26
goal_id: 38
eval_number: 34
In a view, I want to show the date that a given evaluation was created in
a table header. It should look like this:
date_1 | date_2 | date_3 | date_4 | etc..
To do this, I need to get distinct evaluation_numbers + the created_at
dates that go with them. I thought that this would help, but it's
returning more than one record per eval_number with this code:
def eval_date(i)
evals = self.goals.first.evaluations
eval = evals.select("distinct(eval_number), created_at").all[i]
eval.created_at.to_date
end
It seems like distinct eval_numbers are being selected, but also distinct
created_at columns (which of course are all different). This makes the
.all[i] basically useless as it's finding the [0], [1], [2], etc element
correctly - but there are far more than whatever the given number of i is
in the returned array.
I want to find a distinct eval_number and load only the created_date that
goes with it. I think I could load the whole record with all attributes,
but I don't need them, so I'd rather not.
Saturday, 28 September 2013
Difficulty in applying search optimization
Difficulty in applying search optimization
I have a 3D data vector and I need to do optimization such that I get the
minimum among all the data. Let the data be Z =
0.3 0.1 0.9
1.2 0.84 0.3
9.312 0.18 1.9
and so on. Z is generated by a function Z = f(a,b,c) ie by putting the
values of a,b,c into some equation. Then, for a particular set of (a,b,c)
Z is calculated. So, the way the algo works is that
Iteration 1 : I found out the L2 norm of Z and did random search. The
minima value along with the a,b,c which gave them are recorded.
At iteration 2: Another new set of a,b,c are used and Z is recalculated.
This continues till all a,b,c have been substituted in Z.
This process of random search takes a lot of computation time if the array
size is huge (5000 data points). Therefore, I wanted to apply Newton's
method On Z but I just cannot understand how to do it as there is no
functional form or equation representation. Can somebody please explain
with code how to apply optimization so that the search process is
optimized and a global single minima across all dimension is obtained.
I have a 3D data vector and I need to do optimization such that I get the
minimum among all the data. Let the data be Z =
0.3 0.1 0.9
1.2 0.84 0.3
9.312 0.18 1.9
and so on. Z is generated by a function Z = f(a,b,c) ie by putting the
values of a,b,c into some equation. Then, for a particular set of (a,b,c)
Z is calculated. So, the way the algo works is that
Iteration 1 : I found out the L2 norm of Z and did random search. The
minima value along with the a,b,c which gave them are recorded.
At iteration 2: Another new set of a,b,c are used and Z is recalculated.
This continues till all a,b,c have been substituted in Z.
This process of random search takes a lot of computation time if the array
size is huge (5000 data points). Therefore, I wanted to apply Newton's
method On Z but I just cannot understand how to do it as there is no
functional form or equation representation. Can somebody please explain
with code how to apply optimization so that the search process is
optimized and a global single minima across all dimension is obtained.
How do I instantiate an object with fields from the parent class?
How do I instantiate an object with fields from the parent class?
I am trying to get an understanding of object oriented programming in Java
and I have this problem.
Say for example, I have a a parent class like this:
public class Shape {
private int location;
private Color color;
// methods such as getLocation() and getColor()
public Shape(int initialLocation, Color initialColor) {
location = initialLocation;
color = initialColor;
}
}
How do I make my child class so that I can construct, say, a rectangle
with an initial location and an initial color in a main method? Do I
create a constructor in the Rectangle class? I can't because location and
color are private fields. Do I create accessor methods for location and
color and just set the location and color after instantiation? I guess,
but is there a way to do this without accessors?
public class Rectangle extends Shape {
public Rectangle(int initialLocation, Color initialColor) {
super();
}
}
I just can't wrap my head around this fundamental concept. Any help?
I am trying to get an understanding of object oriented programming in Java
and I have this problem.
Say for example, I have a a parent class like this:
public class Shape {
private int location;
private Color color;
// methods such as getLocation() and getColor()
public Shape(int initialLocation, Color initialColor) {
location = initialLocation;
color = initialColor;
}
}
How do I make my child class so that I can construct, say, a rectangle
with an initial location and an initial color in a main method? Do I
create a constructor in the Rectangle class? I can't because location and
color are private fields. Do I create accessor methods for location and
color and just set the location and color after instantiation? I guess,
but is there a way to do this without accessors?
public class Rectangle extends Shape {
public Rectangle(int initialLocation, Color initialColor) {
super();
}
}
I just can't wrap my head around this fundamental concept. Any help?
Software for a small Library
Software for a small Library
Library Details a) Books (all books are single authored ones) b) Users –
faculty, staff, students
Book record format: · bookid, bookname, publisher, edition, author,
issued_to, date_of_issue User record format: · uid, uname, utype, gender,
contact
Operations on Books · issuance of a given book · renewal of a given book ·
books that are overdue (should display the bookids and the total number of
books overdue). · check status of a given book (available ? or issued, If
so to whom?) · deleting a given book (no further issuance is possible)
for issuing book: ISSUE BOOKID, USERID
Library Details a) Books (all books are single authored ones) b) Users –
faculty, staff, students
Book record format: · bookid, bookname, publisher, edition, author,
issued_to, date_of_issue User record format: · uid, uname, utype, gender,
contact
Operations on Books · issuance of a given book · renewal of a given book ·
books that are overdue (should display the bookids and the total number of
books overdue). · check status of a given book (available ? or issued, If
so to whom?) · deleting a given book (no further issuance is possible)
for issuing book: ISSUE BOOKID, USERID
unfortunately First App has stopped android-
unfortunately First App has stopped android-
i'm new in android and this is my first application i don't know why it
stoped ?? i use Nexus 4 emulator i think the problem in onClick but don't
know why when i delete in no problem accure
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<EditText
android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="SendMessage"
/>
</LinearLayout>
MainActivity.java
package com.newthinktank.myfirstapp;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE
="com.newthanktank.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendMessage(View view){
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
LogCat:
09-28 10:52:31.686: E/AndroidRuntime(1584): FATAL EXCEPTION: main
09-28 10:52:31.686: E/AndroidRuntime(1584):
java.lang.IllegalStateException: Could not find a method SendMessage(View)
in the activity class com.newthinktank.myfirstapp.MainActivity for onClick
handler on view class android.widget.Button
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$1.onClick(View.java:3578)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View.performClick(View.java:4084)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$PerformClick.run(View.java:16966)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Handler.handleCallback(Handler.java:615)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Looper.loop(Looper.java:137)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.reflect.Method.invokeNative(Native Method)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.reflect.Method.invoke(Method.java:511)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
dalvik.system.NativeStart.main(Native Method)
09-28 10:52:31.686: E/AndroidRuntime(1584): Caused by:
java.lang.NoSuchMethodException: SendMessage [class android.view.View]
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.Class.getConstructorOrMethod(Class.java:460)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.Class.getMethod(Class.java:915)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$1.onClick(View.java:3571)
09-28 10:52:31.686: E/AndroidRuntime(1584): ... 11 more
i'm new in android and this is my first application i don't know why it
stoped ?? i use Nexus 4 emulator i think the problem in onClick but don't
know why when i delete in no problem accure
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<EditText
android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="SendMessage"
/>
</LinearLayout>
MainActivity.java
package com.newthinktank.myfirstapp;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE
="com.newthanktank.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void sendMessage(View view){
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
LogCat:
09-28 10:52:31.686: E/AndroidRuntime(1584): FATAL EXCEPTION: main
09-28 10:52:31.686: E/AndroidRuntime(1584):
java.lang.IllegalStateException: Could not find a method SendMessage(View)
in the activity class com.newthinktank.myfirstapp.MainActivity for onClick
handler on view class android.widget.Button
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$1.onClick(View.java:3578)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View.performClick(View.java:4084)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$PerformClick.run(View.java:16966)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Handler.handleCallback(Handler.java:615)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.os.Looper.loop(Looper.java:137)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.reflect.Method.invokeNative(Native Method)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.reflect.Method.invoke(Method.java:511)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
dalvik.system.NativeStart.main(Native Method)
09-28 10:52:31.686: E/AndroidRuntime(1584): Caused by:
java.lang.NoSuchMethodException: SendMessage [class android.view.View]
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.Class.getConstructorOrMethod(Class.java:460)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
java.lang.Class.getMethod(Class.java:915)
09-28 10:52:31.686: E/AndroidRuntime(1584): at
android.view.View$1.onClick(View.java:3571)
09-28 10:52:31.686: E/AndroidRuntime(1584): ... 11 more
Friday, 27 September 2013
Web application using websockets and node.js
Web application using websockets and node.js
I'm new to HTML5 and node.js. I'm trying to create a very basic
client-server application. Here is the code.
Server side (node.js):
var net = require('net');
var server = net.createServer(function(c) {
console.log('client connected');
c.setEncoding('utf8');
c.on('end', function() {
console.log('client disconnected');
});
c.on('data', function(data) {
console.log(data);
c.write("Got it");
});
});
server.listen(9998);
Client side (websockets):
<!DOCTYPE html>
<html>
<head>
<script>
try {
var ws = new WebSocket('ws://127.0.0.1:9998');
ws.onopen = function() {
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt) {
var message = evt.data;
alert("Message is received: " + message);
};
ws.onclose = function() {
alert("Connection is closed...");
};
} catch (err) {
alert(err.message);
}
</script>
</head>
<body>
</body>
</html>
As far as I understand, the client should connect to the server, send
"Message to send" and the server should reply with "Got it". Instead what
the server receives is an http GET request for the client html page and
none of the client callbacks are ever fired. What am I missing?
I'm new to HTML5 and node.js. I'm trying to create a very basic
client-server application. Here is the code.
Server side (node.js):
var net = require('net');
var server = net.createServer(function(c) {
console.log('client connected');
c.setEncoding('utf8');
c.on('end', function() {
console.log('client disconnected');
});
c.on('data', function(data) {
console.log(data);
c.write("Got it");
});
});
server.listen(9998);
Client side (websockets):
<!DOCTYPE html>
<html>
<head>
<script>
try {
var ws = new WebSocket('ws://127.0.0.1:9998');
ws.onopen = function() {
ws.send("Message to send");
alert("Message is sent...");
};
ws.onmessage = function (evt) {
var message = evt.data;
alert("Message is received: " + message);
};
ws.onclose = function() {
alert("Connection is closed...");
};
} catch (err) {
alert(err.message);
}
</script>
</head>
<body>
</body>
</html>
As far as I understand, the client should connect to the server, send
"Message to send" and the server should reply with "Got it". Instead what
the server receives is an http GET request for the client html page and
none of the client callbacks are ever fired. What am I missing?
How to access particular JSON data in this case?
How to access particular JSON data in this case?
I know i can retrieve total units like this in python using simplejson.
jsondata = json.loads(r.text)
jsondata['data']['total_units']
But how do i go on and fetch data of status field?
{
status: 'ok',
data: {
total_units: 1,
unit_info: [{
type: 'car',
status: 'Blue car',
id: '20513'
}]
}
}
I know i can retrieve total units like this in python using simplejson.
jsondata = json.loads(r.text)
jsondata['data']['total_units']
But how do i go on and fetch data of status field?
{
status: 'ok',
data: {
total_units: 1,
unit_info: [{
type: 'car',
status: 'Blue car',
id: '20513'
}]
}
}
PL/SQL cursor in procedure
PL/SQL cursor in procedure
It's been awhile since I've written anything in PL/SQL and I can't seem to
figure out what's wrong with my procedure. It looks correct from what I've
seen from others posts. Maybe you can help me figure it out.
CREATE OR REPLACE PROCEDURE export_all_ivt
IS
CURSOR tbl_cur IS
select A.TABLE_NAME
from DBA_TABLES A
join DBA_TABLES B ON A.TABLE_NAME = B.TABLE_NAME
where A.OWNER = 'TEST1'
and B.OWNER = 'TEST2'
and B.NUM_ROWS = 0
and A.NUM_ROWS > 0
and A.TABLE_NAME not in ('TABLE1', 'TABLE2', 'TABLE3')
order by A.TABLE_NAME, A.NUM_ROWS;
tbl_name tbl_cur%rowtype;
BEGIN
OPEN tbl_cur;
FETCH tbl_cur INTO tbl_name;
WHILE tbl_cur%FOUND
LOOP
FETCH tbl_cur INTO tbl_name;
EXIT WHEN tbl_cur%NOTFOUND;
dbms_output.put_line(tbl_name.table_name);
END LOOP;
CLOSE tbl_cur;
END export_all_ivt;
/
It's been awhile since I've written anything in PL/SQL and I can't seem to
figure out what's wrong with my procedure. It looks correct from what I've
seen from others posts. Maybe you can help me figure it out.
CREATE OR REPLACE PROCEDURE export_all_ivt
IS
CURSOR tbl_cur IS
select A.TABLE_NAME
from DBA_TABLES A
join DBA_TABLES B ON A.TABLE_NAME = B.TABLE_NAME
where A.OWNER = 'TEST1'
and B.OWNER = 'TEST2'
and B.NUM_ROWS = 0
and A.NUM_ROWS > 0
and A.TABLE_NAME not in ('TABLE1', 'TABLE2', 'TABLE3')
order by A.TABLE_NAME, A.NUM_ROWS;
tbl_name tbl_cur%rowtype;
BEGIN
OPEN tbl_cur;
FETCH tbl_cur INTO tbl_name;
WHILE tbl_cur%FOUND
LOOP
FETCH tbl_cur INTO tbl_name;
EXIT WHEN tbl_cur%NOTFOUND;
dbms_output.put_line(tbl_name.table_name);
END LOOP;
CLOSE tbl_cur;
END export_all_ivt;
/
SQL 2005 Deadlocks
SQL 2005 Deadlocks
In an asp.net application that I work on I wrote the data access layer
with try - catch on every call to the database and in the catch phrase i
log any errors that occur. I also write most of the stored procedure code
and all the select statements are using the nolock hint. Some of these
select statements are getting numerous but not always deadlock errors like
the following "Transaction (Process ID 86) was deadlocked on lock
resources with another process and has been chosen as the deadlock victim.
Rerun the transaction." I need to know a process to discover what other
process is that the error message is referring to. Any help appreciated -
thank you.
In an asp.net application that I work on I wrote the data access layer
with try - catch on every call to the database and in the catch phrase i
log any errors that occur. I also write most of the stored procedure code
and all the select statements are using the nolock hint. Some of these
select statements are getting numerous but not always deadlock errors like
the following "Transaction (Process ID 86) was deadlocked on lock
resources with another process and has been chosen as the deadlock victim.
Rerun the transaction." I need to know a process to discover what other
process is that the error message is referring to. Any help appreciated -
thank you.
Javascript Class and scope
Javascript Class and scope
I want to make a class in javascript to reuse from my main code in the
connection with an indexeddb object. What I have now is:
function DATABASE() {
this.DB_NAME = 'MYdatabase';
this.DB_VERSION = 1;
this.db = null;
this.results = null;
}
DATABASE.prototype.open = function(callback) {
var req = indexedDB.open(this.DB_NAME, this.DB_VERSION);
req.onsuccess = function (evt) {
this.db = this.result;
callback();
};
req.onerror = function (evt) {
console.error("openDb:", evt.target.errorCode);
};
req.onupgradeneeded = function (evt) {
console.log("openDb.onupgradeneeded");
};
}
My problem here is that when the onsuccess executes I loose the scope of
my main class and this is not what I expected. How can I do what I am
looking for? I want to make some connections at the same time with this,
something like:
var DB = new DATABASE(); DB.open(function(res){});
var DB2 = new DATABASE(); DB2.open(function(res){});
var DB3 = new DATABASE(); DB3.open(function(res){});
thanks so much.
I want to make a class in javascript to reuse from my main code in the
connection with an indexeddb object. What I have now is:
function DATABASE() {
this.DB_NAME = 'MYdatabase';
this.DB_VERSION = 1;
this.db = null;
this.results = null;
}
DATABASE.prototype.open = function(callback) {
var req = indexedDB.open(this.DB_NAME, this.DB_VERSION);
req.onsuccess = function (evt) {
this.db = this.result;
callback();
};
req.onerror = function (evt) {
console.error("openDb:", evt.target.errorCode);
};
req.onupgradeneeded = function (evt) {
console.log("openDb.onupgradeneeded");
};
}
My problem here is that when the onsuccess executes I loose the scope of
my main class and this is not what I expected. How can I do what I am
looking for? I want to make some connections at the same time with this,
something like:
var DB = new DATABASE(); DB.open(function(res){});
var DB2 = new DATABASE(); DB2.open(function(res){});
var DB3 = new DATABASE(); DB3.open(function(res){});
thanks so much.
Thursday, 26 September 2013
Jquery mobile right panel works different in browser and in emulator
Jquery mobile right panel works different in browser and in emulator
I want to create a panel as per the facebook so i tried the example shown
here the panel length is greater than the page. When i run the example in
the crome and firefox browser it working properly but when i try to run it
in the emulator then header and footer are moving a bit to left and the
panel opens under the header and footer and the content page moves to
right. here is the code i had return for creating the right panel:
<body>
<div data-url="panel-fixed-page1" data-role="page" class="jqm-demos
ui-responsive-panel" id="panel-fixed-page1">
<div data-role="header" data-theme="b" data-position='fixed'>
<h1>Fixed header</h1>
<a href="#nav-panel" data-icon="bars" data-iconpos="notext" id='menu'
>Menu</a>
<a href="#add-form" data-icon="gear" data-iconpos="notext"
id='add'>Add</a>
</div><!-- /header -->
<div data-role="content" class="jqm-content">
<h1>Panels</h1>
<h2>Fixed positioning</h2>
<p>This is a typical page that has two buttons in the header bar that
open panels. The left panel has the reveal display mode. The right
panel opens as overlay. For both panels we set
<code>data-position-fixed="true"</code>. We also set position fixed
for the header and footer on this page.</p>
<p>The left panel contains a long menu to demonstrate that the
framework will check the panel contents height and unfixes the panel
so its content can be scrolled. In the right panel there is a short
form that shows the fixed positioning.</p>
<h2>Responsive</h2>
<p>To make this responsive, you can make the page re-flow at wider
widths. This allows both the reveal panel menu and page to be used
together when more space is available. This behavior is controlled by
CSS media queries. You can create a custom one for a specific
breakpoint or use the breakpoint preset by adding the
<code>class="ui-responsive-panel"</code> to the page container. We
have added this class on this demo page.</p>
<a href="./" class="jqm-button" data-ajax="false" data-role="button"
data-mini="true" data-inline="true" data-icon="arrow-l"
data-iconpos="left">Back to Panels</a>
<div data-demo-html="#panel-fixed-page1"
data-demo-css="true"></div><!--/demo-html -->
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<h4>Fixed footer</h4>
</div>
<div data-role="panel" data-theme="a" id="nav-panel"
data-display="reveal" data-position-fixed="true">
<ul data-role="listview" data-theme="a" class="nav-search">
<li data-icon="delete"><a href="#" data-rel="close">Close
menu</a></li>
<li><a href="#panel-fixed-page2">Accordion</a></li>
<li><a href="#panel-fixed-page2">AJAX Navigation</a></li>
<li><a href="#panel-fixed-page2">Autocomplete</a></li>
<li><a href="#panel-fixed-page2">Buttons</a></li>
<li><a href="#panel-fixed-page2">Checkboxes</a></li>
<li><a href="#panel-fixed-page2">Collapsibles</a></li>
<li><a href="#panel-fixed-page2">Controlgroup</a></li>
<li><a href="#panel-fixed-page2">Dialogs</a></li>
<li><a href="#panel-fixed-page2">Fixed toolbars</a></li>
<li><a href="#panel-fixed-page2">Flip switch toggle</a></li>
<li><a href="#panel-fixed-page2">Footer toolbar</a></li>
<li><a href="#panel-fixed-page2">Form elements</a></li>
<li><a href="#panel-fixed-page2">Grids</a></li>
<li><a href="#panel-fixed-page2">Header toolbar</a></li>
<li><a href="#panel-fixed-page2">Icons</a></li>
<li><a href="#panel-fixed-page2">Links</a></li>
<li><a href="#panel-fixed-page2">Listviews</a></li>
<li><a href="#panel-fixed-page2">Loader overlay</a></li>
<li><a href="#panel-fixed-page2">Navbar</a></li>
<li><a href="#panel-fixed-page2">Navbar, persistent</a></li>
<li><a href="#panel-fixed-page2">Pages</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">Popup</a></li>
<li><a href="#panel-fixed-page2">Radio buttons</a></li>
<li><a href="#panel-fixed-page2">Select</a></li>
<li><a href="#panel-fixed-page2">Slider, single</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">Text inputs & textarea</a></li>
<li><a href="#panel-fixed-page2">Transitions</a></li>
</ul>
</div>
here is the css and js files i used:
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
here is the css style i used to set the width of the panel:
<style>
.ui-responsive-panel {
width:200px;
}
.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push
{
left: 0;
right: 0;
margin-left:-70px;
}
.ui-panel{
width:12.6em;
}
@media (min-width:35em)
{
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-left
{
margin-right: 17em; }
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right
{
margin-left: 17em; }
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal {
width:auto;
}
.ui-responsive-panel .ui-panel-dismiss-display-push {
display: none;
}
}
.ui-fixed-hidden {
position: fixed;
}
</style>
and is it possible to make only panel scrollable not the page or content.
Any idea is appreciated. Thanks in advance
I want to create a panel as per the facebook so i tried the example shown
here the panel length is greater than the page. When i run the example in
the crome and firefox browser it working properly but when i try to run it
in the emulator then header and footer are moving a bit to left and the
panel opens under the header and footer and the content page moves to
right. here is the code i had return for creating the right panel:
<body>
<div data-url="panel-fixed-page1" data-role="page" class="jqm-demos
ui-responsive-panel" id="panel-fixed-page1">
<div data-role="header" data-theme="b" data-position='fixed'>
<h1>Fixed header</h1>
<a href="#nav-panel" data-icon="bars" data-iconpos="notext" id='menu'
>Menu</a>
<a href="#add-form" data-icon="gear" data-iconpos="notext"
id='add'>Add</a>
</div><!-- /header -->
<div data-role="content" class="jqm-content">
<h1>Panels</h1>
<h2>Fixed positioning</h2>
<p>This is a typical page that has two buttons in the header bar that
open panels. The left panel has the reveal display mode. The right
panel opens as overlay. For both panels we set
<code>data-position-fixed="true"</code>. We also set position fixed
for the header and footer on this page.</p>
<p>The left panel contains a long menu to demonstrate that the
framework will check the panel contents height and unfixes the panel
so its content can be scrolled. In the right panel there is a short
form that shows the fixed positioning.</p>
<h2>Responsive</h2>
<p>To make this responsive, you can make the page re-flow at wider
widths. This allows both the reveal panel menu and page to be used
together when more space is available. This behavior is controlled by
CSS media queries. You can create a custom one for a specific
breakpoint or use the breakpoint preset by adding the
<code>class="ui-responsive-panel"</code> to the page container. We
have added this class on this demo page.</p>
<a href="./" class="jqm-button" data-ajax="false" data-role="button"
data-mini="true" data-inline="true" data-icon="arrow-l"
data-iconpos="left">Back to Panels</a>
<div data-demo-html="#panel-fixed-page1"
data-demo-css="true"></div><!--/demo-html -->
</div>
<div data-role="footer" data-theme="b" data-position="fixed">
<h4>Fixed footer</h4>
</div>
<div data-role="panel" data-theme="a" id="nav-panel"
data-display="reveal" data-position-fixed="true">
<ul data-role="listview" data-theme="a" class="nav-search">
<li data-icon="delete"><a href="#" data-rel="close">Close
menu</a></li>
<li><a href="#panel-fixed-page2">Accordion</a></li>
<li><a href="#panel-fixed-page2">AJAX Navigation</a></li>
<li><a href="#panel-fixed-page2">Autocomplete</a></li>
<li><a href="#panel-fixed-page2">Buttons</a></li>
<li><a href="#panel-fixed-page2">Checkboxes</a></li>
<li><a href="#panel-fixed-page2">Collapsibles</a></li>
<li><a href="#panel-fixed-page2">Controlgroup</a></li>
<li><a href="#panel-fixed-page2">Dialogs</a></li>
<li><a href="#panel-fixed-page2">Fixed toolbars</a></li>
<li><a href="#panel-fixed-page2">Flip switch toggle</a></li>
<li><a href="#panel-fixed-page2">Footer toolbar</a></li>
<li><a href="#panel-fixed-page2">Form elements</a></li>
<li><a href="#panel-fixed-page2">Grids</a></li>
<li><a href="#panel-fixed-page2">Header toolbar</a></li>
<li><a href="#panel-fixed-page2">Icons</a></li>
<li><a href="#panel-fixed-page2">Links</a></li>
<li><a href="#panel-fixed-page2">Listviews</a></li>
<li><a href="#panel-fixed-page2">Loader overlay</a></li>
<li><a href="#panel-fixed-page2">Navbar</a></li>
<li><a href="#panel-fixed-page2">Navbar, persistent</a></li>
<li><a href="#panel-fixed-page2">Pages</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">Popup</a></li>
<li><a href="#panel-fixed-page2">Radio buttons</a></li>
<li><a href="#panel-fixed-page2">Select</a></li>
<li><a href="#panel-fixed-page2">Slider, single</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">New</a></li>
<li><a href="#panel-fixed-page2">Text inputs & textarea</a></li>
<li><a href="#panel-fixed-page2">Transitions</a></li>
</ul>
</div>
here is the css and js files i used:
<link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
here is the css style i used to set the width of the panel:
<style>
.ui-responsive-panel {
width:200px;
}
.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push
{
left: 0;
right: 0;
margin-left:-70px;
}
.ui-panel{
width:12.6em;
}
@media (min-width:35em)
{
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-left,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-left
{
margin-right: 17em; }
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right
{
margin-left: 17em; }
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-push,
.ui-responsive-panel.ui-page-panel-open
.ui-panel-content-fixed-toolbar-display-reveal {
width:auto;
}
.ui-responsive-panel .ui-panel-dismiss-display-push {
display: none;
}
}
.ui-fixed-hidden {
position: fixed;
}
</style>
and is it possible to make only panel scrollable not the page or content.
Any idea is appreciated. Thanks in advance
Wednesday, 25 September 2013
List item repeating in android customized listview
List item repeating in android customized listview
In my customized list view items are repeating.position of item is same
for all item. code is below
ListAdapter.java-
public class ListAdapter extends BaseAdapter{
private List<String> mName;
private List<Drawable> mIcon;
private Context mContext;
public ListAdapter(Context mContext, List<String> Name, List<Drawable>
Icon) {
this.mContext=mContext;
this.mName=Name;
this.mIcon=Icon;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mName.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(final int position, View v, ViewGroup parent) {
View mLayout;
TextView mText;
ImageView mImage;
CheckBox mCheckBox;
if(v==null){
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLayout=new View(mContext);
mLayout=(LinearLayout) inflater.inflate(R.layout.list_menu, null);
mText=(TextView) mLayout.findViewById(R.id.Name);
mImage=(ImageView) mLayout.findViewById(R.id.Icon);
mCheckBox=(CheckBox) mLayout.findViewById(R.id.mCheckbox);
mText.setText(mName.get(position));
mImage.setImageDrawable(mIcon.get(position));
mCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton check, boolean
isChecked) {
if(check.isChecked()){
Toast.makeText(mContext,
"..."+mName.get(position)+"..."+position,
Toast.LENGTH_SHORT).show();
}
}
});
}
else{
mLayout=(View)v;
}
return mLayout;
}
}
In my customized list view items are repeating.position of item is same
for all item. code is below
ListAdapter.java-
public class ListAdapter extends BaseAdapter{
private List<String> mName;
private List<Drawable> mIcon;
private Context mContext;
public ListAdapter(Context mContext, List<String> Name, List<Drawable>
Icon) {
this.mContext=mContext;
this.mName=Name;
this.mIcon=Icon;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return mName.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(final int position, View v, ViewGroup parent) {
View mLayout;
TextView mText;
ImageView mImage;
CheckBox mCheckBox;
if(v==null){
LayoutInflater inflater = (LayoutInflater)
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLayout=new View(mContext);
mLayout=(LinearLayout) inflater.inflate(R.layout.list_menu, null);
mText=(TextView) mLayout.findViewById(R.id.Name);
mImage=(ImageView) mLayout.findViewById(R.id.Icon);
mCheckBox=(CheckBox) mLayout.findViewById(R.id.mCheckbox);
mText.setText(mName.get(position));
mImage.setImageDrawable(mIcon.get(position));
mCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton check, boolean
isChecked) {
if(check.isChecked()){
Toast.makeText(mContext,
"..."+mName.get(position)+"..."+position,
Toast.LENGTH_SHORT).show();
}
}
});
}
else{
mLayout=(View)v;
}
return mLayout;
}
}
Thursday, 19 September 2013
Select2 Error: Object has no method 'destroy'
Select2 Error: Object has no method 'destroy'
I'm getting this error on line 667 of the select2.js script file. It's the
first time select2 is being called on any element on the page.
I'm using version 3.4.2 of the select2 plugin. It's being called on a
element fetched by its id attribute, with no other attributes on the
element.
I'm using jQuery version 2.0.3. I've tried other versions of jQuery with
no success, as well as a few recent versions of the select2 plugin.
Thanks in advance for any assistance.
Edit (showing code):
<select id="my-select">
<option>1</option>
<option>2</option>
</select>
<script type="text/javascript">
$('#my-select').select2();
</script>
I'm getting this error on line 667 of the select2.js script file. It's the
first time select2 is being called on any element on the page.
I'm using version 3.4.2 of the select2 plugin. It's being called on a
element fetched by its id attribute, with no other attributes on the
element.
I'm using jQuery version 2.0.3. I've tried other versions of jQuery with
no success, as well as a few recent versions of the select2 plugin.
Thanks in advance for any assistance.
Edit (showing code):
<select id="my-select">
<option>1</option>
<option>2</option>
</select>
<script type="text/javascript">
$('#my-select').select2();
</script>
I can't send email in network of my company
I can't send email in network of my company
I need help, in my company have a firewall bloked sending email
the code is
MailMessage msg = new MailMessage();
msg.From = new MailAddress("email@email.com", "Im");
msg.To.Add(new MailAddress("email@email.com", "SomeOne"));
msg.Subject = "This is a Test Mail";
msg.Body = "This is a test message using Exchange OnLine";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("my",
"secret");
client.Port = "587";
client.Host = "smtp.gmail.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
MessageBox.Show("Message Sent Succesfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
strange that I have access to the gmail browser.
it is possible to cheat the firewall?
I need help, in my company have a firewall bloked sending email
the code is
MailMessage msg = new MailMessage();
msg.From = new MailAddress("email@email.com", "Im");
msg.To.Add(new MailAddress("email@email.com", "SomeOne"));
msg.Subject = "This is a Test Mail";
msg.Body = "This is a test message using Exchange OnLine";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("my",
"secret");
client.Port = "587";
client.Host = "smtp.gmail.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
MessageBox.Show("Message Sent Succesfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
strange that I have access to the gmail browser.
it is possible to cheat the firewall?
How should I use identifierForVendor during development?
How should I use identifierForVendor during development?
The value of [UIDevice currentDevice].identifierForVendor changes every
time I run my application within the iOS simulator. I need to write logic
around this value persisting across debug / run sessions. Are there any
recommendations for accomplishing this?
The value of [UIDevice currentDevice].identifierForVendor changes every
time I run my application within the iOS simulator. I need to write logic
around this value persisting across debug / run sessions. Are there any
recommendations for accomplishing this?
Media queries catch tablet portrait
Media queries catch tablet portrait
I have the following rules:
@media only screen and (min-device-width : 320px) and (max-device-width :
480px)
@media only screen and (min-width : 321px) /* Smartphones (landscape) */
@media only screen and (max-width : 320px) /* Smartphones (portrait) */
@media only screen and (min-width: 768px) /* tablets and desktops */
How to catch tablet portrait without affect the other rules?
I have the following rules:
@media only screen and (min-device-width : 320px) and (max-device-width :
480px)
@media only screen and (min-width : 321px) /* Smartphones (landscape) */
@media only screen and (max-width : 320px) /* Smartphones (portrait) */
@media only screen and (min-width: 768px) /* tablets and desktops */
How to catch tablet portrait without affect the other rules?
Changing service reference endpoint at runtime, sometimes the wrong endpoint is used
Changing service reference endpoint at runtime, sometimes the wrong
endpoint is used
I have a WCF service that in turn has a service reference to some other
SOAP endpoint. This endpoint has an identical copy at another address with
the same metadata but different data. When a request comes in to my
service, it specifies which of the two identical endpoints that I consume
it wants data from. So, I have something like this:
using (var client = new ServiceClient())
{
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
//do some work, pull some data, bake some muffins
}
This sometimes doesn't work when I have two requests coming in very close
together with different urls. The second request ends up going out to the
same endpoint as the first one. I understand that once the channel is open
I can't change the endpoint, but I thought the client would only be used
once and then disposed. Is there some optimization going on where the same
proxy is being re-used for multiple requests? What's a good approach to
problems like this?
endpoint is used
I have a WCF service that in turn has a service reference to some other
SOAP endpoint. This endpoint has an identical copy at another address with
the same metadata but different data. When a request comes in to my
service, it specifies which of the two identical endpoints that I consume
it wants data from. So, I have something like this:
using (var client = new ServiceClient())
{
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(url);
//do some work, pull some data, bake some muffins
}
This sometimes doesn't work when I have two requests coming in very close
together with different urls. The second request ends up going out to the
same endpoint as the first one. I understand that once the channel is open
I can't change the endpoint, but I thought the client would only be used
once and then disposed. Is there some optimization going on where the same
proxy is being re-used for multiple requests? What's a good approach to
problems like this?
rails 3 multiple language for any user
rails 3 multiple language for any user
I want my app has multiple languages. To do this, I read railscasts #138
But there, the writer put a language column to User model and thus users
can see pages only in their language as I understand right. But I want my
website can be seen in any language by any user just like usual.
How can this be done?
I want my app has multiple languages. To do this, I read railscasts #138
But there, the writer put a language column to User model and thus users
can see pages only in their language as I understand right. But I want my
website can be seen in any language by any user just like usual.
How can this be done?
Python iterate over two nested 2D lists where list2 has list1's row numbers
Python iterate over two nested 2D lists where list2 has list1's row numbers
I'm new to Python. So I want to get this done with loops without using
some fancy stuff like generators. I have two 2D arrays, one interger array
and the other string array like this:
I) Integer 2D list:
Here, dataset2d[0][0] is number of rows in the table, dataset[0][1] is
number of columns. So the below 2D list has 6 rows and 4 columns
dataset2d[][]:
6 4
0 0 0 1
1 0 2 0
2 2 0 1
1 1 1 0
0 0 1 1
1 0 2 1
II) String 2D list:
partition2d[][]
A 1 2 4
B 3 5
C 6
partition[*][0] i.e first column is a label. For group A, 1,2 and 4 are
the row numbers that I need to pick up from dataset2d and apply a formula.
So it means I will read 1, go to row 1 in dataset2d and read the first
column value i.e dataset2d[1][0], then I will read 2 from partition2d, go
to row 2 of dataset 2d and read the first column i.e dataset2d[2][0].
Similarly next one I'll read dataset2d[4][0].
Then I will do some calculations, get a value and store it in a 2D list,
then go to the next column in dataset2d for those rows. So in this
example, next column values read would be dataset2d[1][1],
dataset2d[2][1], dataset2d[4][1]. And again do some calculation and get
one value for that column, store it. I'll do this until I reach the last
column of dataset2d.
The next row in partition2d is B, 3, 5. So I'll start with
dataset2d[3][0], dataset2d[5][0]. Get a value for that column be a
formula. Then real dataset2d [3][1], dataset2d[5][1] stc. until I reach
last column. I do this until all rows in partition2d are read.
What I tried:
for partitionRow in partition2d:
for partitionCol in partitionRow:
for colDataset in dataset2d:
print dataset2d[partitionCol][colDataset]
What problem I'm facing:
partition2d is a string array where I need to skip the first column which
has characters like A,B,C.
I want to iterate in dataset2d column wise only over the row numbers given
in partition2d. So the colDataset should increment only after I'm done
with that column.
I'm new to Python. So I want to get this done with loops without using
some fancy stuff like generators. I have two 2D arrays, one interger array
and the other string array like this:
I) Integer 2D list:
Here, dataset2d[0][0] is number of rows in the table, dataset[0][1] is
number of columns. So the below 2D list has 6 rows and 4 columns
dataset2d[][]:
6 4
0 0 0 1
1 0 2 0
2 2 0 1
1 1 1 0
0 0 1 1
1 0 2 1
II) String 2D list:
partition2d[][]
A 1 2 4
B 3 5
C 6
partition[*][0] i.e first column is a label. For group A, 1,2 and 4 are
the row numbers that I need to pick up from dataset2d and apply a formula.
So it means I will read 1, go to row 1 in dataset2d and read the first
column value i.e dataset2d[1][0], then I will read 2 from partition2d, go
to row 2 of dataset 2d and read the first column i.e dataset2d[2][0].
Similarly next one I'll read dataset2d[4][0].
Then I will do some calculations, get a value and store it in a 2D list,
then go to the next column in dataset2d for those rows. So in this
example, next column values read would be dataset2d[1][1],
dataset2d[2][1], dataset2d[4][1]. And again do some calculation and get
one value for that column, store it. I'll do this until I reach the last
column of dataset2d.
The next row in partition2d is B, 3, 5. So I'll start with
dataset2d[3][0], dataset2d[5][0]. Get a value for that column be a
formula. Then real dataset2d [3][1], dataset2d[5][1] stc. until I reach
last column. I do this until all rows in partition2d are read.
What I tried:
for partitionRow in partition2d:
for partitionCol in partitionRow:
for colDataset in dataset2d:
print dataset2d[partitionCol][colDataset]
What problem I'm facing:
partition2d is a string array where I need to skip the first column which
has characters like A,B,C.
I want to iterate in dataset2d column wise only over the row numbers given
in partition2d. So the colDataset should increment only after I'm done
with that column.
Wednesday, 18 September 2013
css hover creating border but pushing content
css hover creating border but pushing content
Situation
I'm currently building a site and desire to have some elements create a
border/outline upon hovering the mouse over them. This is simple enough to
make work. For reference, please see the staging site at Stagin area link.
I'm using the grid part of the latest bootstrap and the box-sizing model.
Issue
I find that upon hovering, the content below that which is being hovered
gets "pushed" far down below the next element. Using the stagin area as
reference, I can change the behaviour through CSS to fix this on the left
hand side or the right hand side but, not both at the same time.
Code
Here is a snippet of the CSS I use to make the effect:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
}
Using this method, anything but the first element behaves as expected. If
I try this next snippet, the first element works but, then the others
break:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
margin-top: -6px;
}
For the sake of clarification with regard to properties inherited, I have
set the margin/padding on the elements in question to '0 !important' for
standard behaviour until hover
Problem
How can I stop the element below from being pushed?
Situation
I'm currently building a site and desire to have some elements create a
border/outline upon hovering the mouse over them. This is simple enough to
make work. For reference, please see the staging site at Stagin area link.
I'm using the grid part of the latest bootstrap and the box-sizing model.
Issue
I find that upon hovering, the content below that which is being hovered
gets "pushed" far down below the next element. Using the stagin area as
reference, I can change the behaviour through CSS to fix this on the left
hand side or the right hand side but, not both at the same time.
Code
Here is a snippet of the CSS I use to make the effect:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
}
Using this method, anything but the first element behaves as expected. If
I try this next snippet, the first element works but, then the others
break:
.hover-border:hover {
border: 3px solid #3A3A3A;
display: block;
margin-top: -6px;
}
For the sake of clarification with regard to properties inherited, I have
set the margin/padding on the elements in question to '0 !important' for
standard behaviour until hover
Problem
How can I stop the element below from being pushed?
Receiving Intent EXTRA_MESSAGE from Another Application
Receiving Intent EXTRA_MESSAGE from Another Application
In my Eclipse workspace I have my main application: A and I have another
fully functional application: B
I have configured appliction A to open up application B upon the click of
a button by using an Intent and it works.
Here is the issue:
In application B I need to receive the EXTRA_MESSAGE. However, I am unable
to access the info because application B does not recognize application A:
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE_DESC);
states that "MainActivity" cannot be resolved to a variable.
*addendum: I am working on the actual code of application B, as opening
the class reference in application A gives me a uneditable display.
It seems that I would need to alter the manifest of application B, and add
application A in the build path of B... this seems messy and not
reusablely friendly.
Thank you for any help
In my Eclipse workspace I have my main application: A and I have another
fully functional application: B
I have configured appliction A to open up application B upon the click of
a button by using an Intent and it works.
Here is the issue:
In application B I need to receive the EXTRA_MESSAGE. However, I am unable
to access the info because application B does not recognize application A:
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE_DESC);
states that "MainActivity" cannot be resolved to a variable.
*addendum: I am working on the actual code of application B, as opening
the class reference in application A gives me a uneditable display.
It seems that I would need to alter the manifest of application B, and add
application A in the build path of B... this seems messy and not
reusablely friendly.
Thank you for any help
Can't get one click on the mouse using jquery?
Can't get one click on the mouse using jquery?
When I attempt to click on any one selection on of the buttons, sometimes
I get one click (as expected) and sometimes I get more than one click
fired (not what I want) using the code below given by someone on
Stackoverflow...
var $document = $(document);
var clickCount = 0;
var treeLogic = function (event) {
// unbind the element from the event handler
$document.off("click", "#file", treeLogic);
clickCount = clickCount + 1;
// for testing the number of clicks on each click of a button.
// sometimes it shows one click and sometimes it shows more than one
click
// (not what I want).
// bind the element back to the event handler
$document.on("click", "#file", treeLogic);
};
$document.on("click", "#file", treeLogic);
Could be my mouse is bad? Or the logic above is bad, and if so, can
someone show me how to fix it?
When I attempt to click on any one selection on of the buttons, sometimes
I get one click (as expected) and sometimes I get more than one click
fired (not what I want) using the code below given by someone on
Stackoverflow...
var $document = $(document);
var clickCount = 0;
var treeLogic = function (event) {
// unbind the element from the event handler
$document.off("click", "#file", treeLogic);
clickCount = clickCount + 1;
// for testing the number of clicks on each click of a button.
// sometimes it shows one click and sometimes it shows more than one
click
// (not what I want).
// bind the element back to the event handler
$document.on("click", "#file", treeLogic);
};
$document.on("click", "#file", treeLogic);
Could be my mouse is bad? Or the logic above is bad, and if so, can
someone show me how to fix it?
PHP SendToHost function not working
PHP SendToHost function not working
So I'm currently trying to implement the 'SendToHost' function that is
widely used for 'GET' and 'POST' procedures. In my case, I want to use it
for sending a 'postcode' to a shopping website's postcode input form for
use with retrieving that postcode's specific catalogue. More specifically,
the code should automatically generate the web page that has the results
for the postcode. Below is my code coupled with the function and I'd like
to know why it isn't working:
function SendToHost($host, $method, $path, $data, $useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
echo
sendToHost('catalog.coles.com.au','get','/default.aspx','ctl00_Body_PostcodeTextBox=4122');
So I'm currently trying to implement the 'SendToHost' function that is
widely used for 'GET' and 'POST' procedures. In my case, I want to use it
for sending a 'postcode' to a shopping website's postcode input form for
use with retrieving that postcode's specific catalogue. More specifically,
the code should automatically generate the web page that has the results
for the postcode. Below is my code coupled with the function and I'd like
to know why it isn't working:
function SendToHost($host, $method, $path, $data, $useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
echo
sendToHost('catalog.coles.com.au','get','/default.aspx','ctl00_Body_PostcodeTextBox=4122');
Qt server and android ssl client Certificates
Qt server and android ssl client Certificates
I Use Qtas server side,and android as client side. I set in
SSLSocketFactory certification
private ConnectionManager(MBoxConfiguration config) {
try {
this.config = config;
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(trusted);
Socket socket;
socket = ssf.createSocket();
socket.connect(new InetSocketAddress(config.ip, config.port));
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in =
MainActivity.context.getResources().openRawResource(R.raw.truststore);
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
ssf = new SSLSocketFactory(trusted);
ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
}
When i Want connect in QT Give me That error
Thread Address in peerVerifyError "The peer did not present any
certificate" Thread Address in sslErrors ("The peer did not present any
certificate") Thread Address in error QAbstractSocket::SocketError( 13 )
Thread Address in destroyThreadfirst: QThread(0x12ec9448) Thread Address
in destroyThread: QThread(0x12ec9238)
I Use Qtas server side,and android as client side. I set in
SSLSocketFactory certification
private ConnectionManager(MBoxConfiguration config) {
try {
this.config = config;
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(trusted);
Socket socket;
socket = ssf.createSocket();
socket.connect(new InetSocketAddress(config.ip, config.port));
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in =
MainActivity.context.getResources().openRawResource(R.raw.truststore);
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
ssf = new SSLSocketFactory(trusted);
ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
}
When i Want connect in QT Give me That error
Thread Address in peerVerifyError "The peer did not present any
certificate" Thread Address in sslErrors ("The peer did not present any
certificate") Thread Address in error QAbstractSocket::SocketError( 13 )
Thread Address in destroyThreadfirst: QThread(0x12ec9448) Thread Address
in destroyThread: QThread(0x12ec9238)
Asynchronous tableView loading
Asynchronous tableView loading
So I have a class with methods that sends asynchronous requests to my
database and then returns the objects into an array, I use blocks as a
form of callbacks. I save the array in a singleton that can return it with
a method.
The problem is I have almost no experience with tableViews, and I followed
a tutorial that accesses data from an array and then creates tableView
cells based on the number of objects in the array, and populates each
cell's text label with the description of each object. Now I'm trying to
make it work with my method and singleton, however the tableView loads
before my singleton has recieved anything from the database, so how do I
get through this problem?
So I have a class with methods that sends asynchronous requests to my
database and then returns the objects into an array, I use blocks as a
form of callbacks. I save the array in a singleton that can return it with
a method.
The problem is I have almost no experience with tableViews, and I followed
a tutorial that accesses data from an array and then creates tableView
cells based on the number of objects in the array, and populates each
cell's text label with the description of each object. Now I'm trying to
make it work with my method and singleton, however the tableView loads
before my singleton has recieved anything from the database, so how do I
get through this problem?
wpf Datagrid: Auto Increment number column in datagrid
wpf Datagrid: Auto Increment number column in datagrid
Iam new to wpf , I have a datagrid with 5 columns ,now I want to set first
column as a serial number column ,column which has a sequence numbers
starting from 1 to n rows . If the user add or delete one row to the
datagrid the serial number must be auto update how to do this in wpf...?
My Xaml :
<my:DataGrid Name="dataGrid1" ItemsSource="{Binding}"
AutoGenerateColumns="False" Height="150"
BeginningEdit="dataGrid1_BeginningEdit" KeyDown="dataGrid1_KeyDown">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Sl No"
Binding="{Binding}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Code" Binding="{Binding
Product_Code}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Name" Binding="{Binding
Product_Name}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Purchase Rate" Binding="{Binding
PurchaseRate}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Qty" Binding="{Binding
Qty}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Amount" Binding="{Binding
Amount}"></my:DataGridTextColumn>
</my:DataGrid.Columns>
</my:DataGrid>
My code behind is:
public class clsItemCollection
{
public string ProductName { get; set; }
public decimal PurchaseRate { get; set; }
public int Qty { get; set; }
public decimal Amount { get; set; }
}
ObservableCollection<clsItemCollection> obsItems = new
ObservableCollection<clsItemCollection>();
dgvSales.ItemsSource = obsItems; //On window constructor
Iam new to wpf , I have a datagrid with 5 columns ,now I want to set first
column as a serial number column ,column which has a sequence numbers
starting from 1 to n rows . If the user add or delete one row to the
datagrid the serial number must be auto update how to do this in wpf...?
My Xaml :
<my:DataGrid Name="dataGrid1" ItemsSource="{Binding}"
AutoGenerateColumns="False" Height="150"
BeginningEdit="dataGrid1_BeginningEdit" KeyDown="dataGrid1_KeyDown">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Sl No"
Binding="{Binding}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Code" Binding="{Binding
Product_Code}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Name" Binding="{Binding
Product_Name}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Purchase Rate" Binding="{Binding
PurchaseRate}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Qty" Binding="{Binding
Qty}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Amount" Binding="{Binding
Amount}"></my:DataGridTextColumn>
</my:DataGrid.Columns>
</my:DataGrid>
My code behind is:
public class clsItemCollection
{
public string ProductName { get; set; }
public decimal PurchaseRate { get; set; }
public int Qty { get; set; }
public decimal Amount { get; set; }
}
ObservableCollection<clsItemCollection> obsItems = new
ObservableCollection<clsItemCollection>();
dgvSales.ItemsSource = obsItems; //On window constructor
PHP random date and multiple dates
PHP random date and multiple dates
I have a problem regarding randoming a PHP date like this 2013-09-18
12:30. I want to random 6 dates like that one for 6 users, so dates don't
mix (dates can be the same but time must be +/- few hours). To random date
i used:
<?php
echo date('Y-m-d', strtotime( '+'.mt_rand(0,31).' days'));
?>
and had success with it but i can random hours or minutes (seconds i don't
need). The page is for reserving appointments for patients and giving them
random therapy dates. I also have an eventCalendar to show dates.
P.S is it possible to input multiple dates like an array (date1, date2,
date3) and show in mysql table i always get 0000-00-00. Thanks in advance.
I have a problem regarding randoming a PHP date like this 2013-09-18
12:30. I want to random 6 dates like that one for 6 users, so dates don't
mix (dates can be the same but time must be +/- few hours). To random date
i used:
<?php
echo date('Y-m-d', strtotime( '+'.mt_rand(0,31).' days'));
?>
and had success with it but i can random hours or minutes (seconds i don't
need). The page is for reserving appointments for patients and giving them
random therapy dates. I also have an eventCalendar to show dates.
P.S is it possible to input multiple dates like an array (date1, date2,
date3) and show in mysql table i always get 0000-00-00. Thanks in advance.
Tuesday, 17 September 2013
How to change the locale of a web application e.g. JSF, Struts, Spring MVC
How to change the locale of a web application e.g. JSF, Struts, Spring MVC
I have created a JSF application where in to implement localization, I
need to create separate property files for each locale. Is there any way
that these can be generated dynamically. Google translator is not a option
for me.
I have created a JSF application where in to implement localization, I
need to create separate property files for each locale. Is there any way
that these can be generated dynamically. Google translator is not a option
for me.
How to replace comma in textbox?
How to replace comma in textbox?
I have two textboxes, the textbox1 echo's value from database $row and
displays 1,900,200.00 on digit grouping. My textbox2 automatically copies
the exact value of textbox1 using javascript. What I want to do is to
replace the comma (,) in textbox2.
I have two textboxes, the textbox1 echo's value from database $row and
displays 1,900,200.00 on digit grouping. My textbox2 automatically copies
the exact value of textbox1 using javascript. What I want to do is to
replace the comma (,) in textbox2.
SQL Count distinct values within the field
SQL Count distinct values within the field
I have this weird scenario (at least it is for me) where I have a table
(actually a result set, but I want to make it simpler) that looks like the
following:
ID | Actions
------------------
1 | 10,12,15
2 | 11,12,13
3 | 15
4 | 15,16,17
And I want to count the different actions in the all the table. In this
case, I want the result to be 8 (just counting 10, 11, ...., 17; and
ignoring the repeated values).
In case it matters, I am using MS SQL 2008.
If it makes it any easier, the Actions were previously on XML that looks like
<root>
<actions>10,12,15</actions>
</root>
I doubt it makes it easier, but somebody might comeback with an xml
function that I am not aware and just makes everything easier.
Let me know if there's something else I should say.
I have this weird scenario (at least it is for me) where I have a table
(actually a result set, but I want to make it simpler) that looks like the
following:
ID | Actions
------------------
1 | 10,12,15
2 | 11,12,13
3 | 15
4 | 15,16,17
And I want to count the different actions in the all the table. In this
case, I want the result to be 8 (just counting 10, 11, ...., 17; and
ignoring the repeated values).
In case it matters, I am using MS SQL 2008.
If it makes it any easier, the Actions were previously on XML that looks like
<root>
<actions>10,12,15</actions>
</root>
I doubt it makes it easier, but somebody might comeback with an xml
function that I am not aware and just makes everything easier.
Let me know if there's something else I should say.
Assets in Symfony2
Assets in Symfony2
I would like add CSS to one Action/View in my Project. In Symfony i can
use for this config/view.yml in specific folder. This add CSS to section
HEAD. In Symfony i use:
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
but this add CSS in current place, not in section HEAD. How is the best
method in Symfony2 to add CSS and JS for one action/view in section HEAD
of HTML?
I would like add CSS to one Action/View in my Project. In Symfony i can
use for this config/view.yml in specific folder. This add CSS to section
HEAD. In Symfony i use:
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
but this add CSS in current place, not in section HEAD. How is the best
method in Symfony2 to add CSS and JS for one action/view in section HEAD
of HTML?
Validate Date in Rails before it hits the database
Validate Date in Rails before it hits the database
I need to validate two dates that come from create new record form. Right
now the form has drop downs for year, date, month, hour, minute. In the
controller, I need to validate that the start date is not greater than end
date and it will not let me compare it using the params[:start_date] >
params[:end_date].
How can I properly validate that the start date is not larger than the end
date when adding a new record to the database, I should be doing this in
the model but I cannot figure out how you do it. Does anyone here has any
examples I can look from?
I need to validate two dates that come from create new record form. Right
now the form has drop downs for year, date, month, hour, minute. In the
controller, I need to validate that the start date is not greater than end
date and it will not let me compare it using the params[:start_date] >
params[:end_date].
How can I properly validate that the start date is not larger than the end
date when adding a new record to the database, I should be doing this in
the model but I cannot figure out how you do it. Does anyone here has any
examples I can look from?
Where do I put the mapping files for Elasticsearch?
Where do I put the mapping files for Elasticsearch?
I am confused by the ES docs, in fact here they state the the indexes must
go in the mapping dir (and indexname sub dirs):
Mappings can be defined within files called [mapping_name].json and be
placed either under config/mappings/_default location, or under
config/mappings/[index_name] (for mappings that should be associated only
with a specific index).
But then here in the "config" section, it states:
Index templates can also be placed within the config location (path.conf)
under the templates directory (note, make sure to place them on all master
eligible nodes). For example, a file called template_1.json can be placed
under config/templates and it will be added if it matches an index.
I put my mapping in /config/mappings/myindexname/mappinfile.json and it is
like:
{
"template": "maincontentindex",
"settings": {
"index": {
"analysis": {
"analyzer": {
"htmlStrippingAnalyzer": {
"tokenizer": "standard",
"filter": ["standard", "lowercase"],
"char_filter": "html_strip"
}
}
}
}
},
"mappings": {
"rendition": {
"_timestamp": {
"enabled": true,
"store" : true
},
"properties": {
"key": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"parentPage": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"type": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"language": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"device": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"territory": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"channel": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"template": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"meta": {
"properties": {
"content": {
"type": "string",
"store": "yes"
}
}
}
}
}
}
}
if I use the REST Api to put it in the server it works fine and if I call
/maincontentindex/rendition/_mapping I just get the above structure (even
with no data).
But with the directory I just get a 404 and if I insert anything it's just
the usual dynamic mapping.
I am confused by the ES docs, in fact here they state the the indexes must
go in the mapping dir (and indexname sub dirs):
Mappings can be defined within files called [mapping_name].json and be
placed either under config/mappings/_default location, or under
config/mappings/[index_name] (for mappings that should be associated only
with a specific index).
But then here in the "config" section, it states:
Index templates can also be placed within the config location (path.conf)
under the templates directory (note, make sure to place them on all master
eligible nodes). For example, a file called template_1.json can be placed
under config/templates and it will be added if it matches an index.
I put my mapping in /config/mappings/myindexname/mappinfile.json and it is
like:
{
"template": "maincontentindex",
"settings": {
"index": {
"analysis": {
"analyzer": {
"htmlStrippingAnalyzer": {
"tokenizer": "standard",
"filter": ["standard", "lowercase"],
"char_filter": "html_strip"
}
}
}
}
},
"mappings": {
"rendition": {
"_timestamp": {
"enabled": true,
"store" : true
},
"properties": {
"key": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"parentPage": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"type": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"language": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"device": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"territory": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"channel": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"template": {
"type": "string",
"store": "yes",
"analyzer": "keyword"
},
"meta": {
"properties": {
"content": {
"type": "string",
"store": "yes"
}
}
}
}
}
}
}
if I use the REST Api to put it in the server it works fine and if I call
/maincontentindex/rendition/_mapping I just get the above structure (even
with no data).
But with the directory I just get a 404 and if I insert anything it's just
the usual dynamic mapping.
Sunday, 15 September 2013
How to read first numbers from file in C++
How to read first numbers from file in C++
I have txt file like this.
51.5u-07
-6.5 -10
55u-10
-7 -10
55u-10
-7 -10
55u-10
-7 -10
54u-10
-7 -10
54.5u-10
-7 -10
55u-10
-7 -10
54.5u-10
-7 -10
55.5u-10
-7.5 -10
I want to read this file, get all odd line's value into vector of int,
vec1. get all even line's value into vector of int, vec2.
such as vec1 is [51.5, 55,55,55,... vec2 is [-6.5, -7, -7, -7...] can
anybody help me this?
Thank you.
I have txt file like this.
51.5u-07
-6.5 -10
55u-10
-7 -10
55u-10
-7 -10
55u-10
-7 -10
54u-10
-7 -10
54.5u-10
-7 -10
55u-10
-7 -10
54.5u-10
-7 -10
55.5u-10
-7.5 -10
I want to read this file, get all odd line's value into vector of int,
vec1. get all even line's value into vector of int, vec2.
such as vec1 is [51.5, 55,55,55,... vec2 is [-6.5, -7, -7, -7...] can
anybody help me this?
Thank you.
Safari image overlapping issue
Safari image overlapping issue
Having a weird css image issue with Safari, and haven't been able to find
anything regarding this online anywhere.
Each jewellery piece has a small gallery of thumbnails underneath it. If
there's more thumbnails than can fit in that space, I've set up JS to have
them slide back and forth by adjusting the left margin of the outer div (a
lot like smoothdivscroll, but not as complicated).
In Safari for some reason, the first image in the little thumbnail gallery
is remaining static while the others scroll over it. looks really crap.
And I can't figure why. Is it maybe a bug in Safari?
I do feel like it's a CSS problem, because before adding this sliding
feature, we just had a limit to only 5 images and they would load
overlapped and distorted in Safari as well...
http://jeandousset.com/jewellery/engagement-rings/
Sample HTML:
<div class="span12 offset6 product-images-container" style="margin-left:
140px;">
<div class="product-zoom-container">
<img id="eva-main-image" class="main-image"
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
data-post-id="530"
title="eva-engagement-ring-cushion-cut-diamond-angle-" alt="">
</div>
<div id="eva-gallery" class="product-gallery text-center">
<div class="scroll-products-right"></div>
<div class="scroll-products-left"></div>
<div class="scrollable-area">
<div class="product-gallery-inner" style="width: 420px;
margin-left: -30px;">
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg"
title="eva-engagement-ring-cushion-cut-diamond-angle-"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg"
title="eva-engagement-ring-cushion-cut-diamond-under"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg"
title="eva-engagement-ring-cushion-cut-diamond-angle"
alt=""></a>
<a href="#" class="product-thumbnail active"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
title="eva-engagement-ring-round-cut-diamond-front"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg"
title="eva-engagement-ring-cushion-cut-diamond-turned-profile"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
</div>
</div>
</div>
CSS:
.product-gallery {
*zoom: 1;
max-height: 70px;
position: relative;
margin-left: auto;
margin-right: auto;
}
.product-gallery:before,
.product-gallery:after {
display: table;
content: "";
line-height: 0;
}
.product-gallery:after {
clear: both
}
.product-gallery .scrollable-area {
overflow: hidden;
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
}
.product-gallery .scroll-products-right,
.product-gallery .scroll-products-left {
position: absolute;
width: 30px;
height: 100%;
background: url(./../img/arrow-small-left.png) center center no-repeat
#fff;
background-color: rgba(255,255,255,0.6);
top: 0;
left: 0;
z-index: 20;
opacity: .6;
filter: alpha(opacity=60);
}
.product-gallery .scroll-products-right:hover,
.product-gallery .scroll-products-left:hover {
cursor: pointer !important;
background-color: rgba(255,255,255,0.8);
opacity: 1;
filter: alpha(opacity=100);
}
.product-gallery .scroll-products-right {
right: 0;
left: auto;
background: url(./../img/arrow-small-right.png) center center
no-repeat #fff;
background-color: rgba(255,255,255,0.6);
}
.product-gallery .product-thumbnail {
float: left;
max-width: 70px;
opacity: .5;
filter: alpha(opacity=50);
}
.product-gallery .product-thumbnail.active {
opacity: 1;
filter: alpha(opacity=100);
}
.product-gallery .product-thumbnail:before,
.product-gallery .product-thumbnail:after {
content: ""
}
JS:
Dousset.product = {
currentWindowWidthMin: null,
currentInterval: null,
init: function () {
$('#wrapper').on('click', '.product-thumbnail',
Dousset.product.thumbClicked);
// $('.product-thumbnail').css({ // 'float': 'none', // 'display':
'inline-block' // });
$('#wrapper').on('mousedown', '.scroll-products-right',
Dousset.product.scrollThumbsLeft);
$('#wrapper').on('mousedown', '.scroll-products-left',
Dousset.product.scrollThumbsRight);
$('#wrapper').on('mouseup', '.scroll-products-left,
.scroll-products-right', function(e){
clearTimeout(Dousset.product.currentInterval);
Dousset.product.currentInterval = null;
});
if((navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPod/i))) {
$('#wrapper').on('click', '.scroll-products-right',
Dousset.product.scrollThumbsLeftBatch);
$('#wrapper').on('click', '.scroll-products-left',
Dousset.product.scrollThumbsRightBatch);
}
Dousset.product.setCurrentWindowWidthMin();
$(window).resize(Dousset.product.windowResized);
},
thumbClicked: function (e) {
e.preventDefault();
if (!$(this).hasClass('active')) {
var postId = $(this).data('post-id');
var newImg = $(this).data('image');
$('.main-image[data-post-id="'+postId+'"]').attr('src',
newImg);
$('.product-thumbnail[data-post-id="'+postId+'"]').removeClass('active');
$(this).addClass('active');
}
},
scrollThumbsLeft: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
var maxMargin = $inner.width() -
$(this).siblings('.scrollable-area').width();
Dousset.product.currentInterval = setInterval(function(){
if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
$inner.css({
'margin-left' : '-=1'
});
}
},10);
},
scrollThumbsRight: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
Dousset.product.currentInterval = setInterval(function(){
if (parseInt($inner.css('margin-left'),10) <= 0 ) {
$inner.css({
'margin-left' : '+=1'
});
}
},10);
},
scrollThumbsLeftBatch: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
var maxMargin = $inner.width() -
$(this).siblings('.scrollable-area').width();
if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
$inner.animate({
'margin-left' : '-=70'
});
}
},
scrollThumbsRightBatch: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
if (parseInt($inner.css('margin-left'),10) <= 0 ) {
$inner.animate({
'margin-left' : '+=70'
});
}
},
setCurrentWindowWidthMin: function () {
Dousset.product.currentWindowWidthMin = $( window ).width() >
979 ? 980 : $( window ).width() > 767 ? 768 : 480;
},
windowResized: function () {
var oldWinMin = Dousset.product.currentWindowWidthMin;
Dousset.product.setCurrentWindowWidthMin();
}
}
$(document).ready(function(){ Dousset.product.init(); });
Having a weird css image issue with Safari, and haven't been able to find
anything regarding this online anywhere.
Each jewellery piece has a small gallery of thumbnails underneath it. If
there's more thumbnails than can fit in that space, I've set up JS to have
them slide back and forth by adjusting the left margin of the outer div (a
lot like smoothdivscroll, but not as complicated).
In Safari for some reason, the first image in the little thumbnail gallery
is remaining static while the others scroll over it. looks really crap.
And I can't figure why. Is it maybe a bug in Safari?
I do feel like it's a CSS problem, because before adding this sliding
feature, we just had a limit to only 5 images and they would load
overlapped and distorted in Safari as well...
http://jeandousset.com/jewellery/engagement-rings/
Sample HTML:
<div class="span12 offset6 product-images-container" style="margin-left:
140px;">
<div class="product-zoom-container">
<img id="eva-main-image" class="main-image"
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
data-post-id="530"
title="eva-engagement-ring-cushion-cut-diamond-angle-" alt="">
</div>
<div id="eva-gallery" class="product-gallery text-center">
<div class="scroll-products-right"></div>
<div class="scroll-products-left"></div>
<div class="scrollable-area">
<div class="product-gallery-inner" style="width: 420px;
margin-left: -30px;">
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle-.jpg"
title="eva-engagement-ring-cushion-cut-diamond-angle-"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-under.jpg"
title="eva-engagement-ring-cushion-cut-diamond-under"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-angle.jpg"
title="eva-engagement-ring-cushion-cut-diamond-angle"
alt=""></a>
<a href="#" class="product-thumbnail active"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-round-cut-diamond-front.jpg"
title="eva-engagement-ring-round-cut-diamond-front"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-cushion-cut-diamond-turned-profile.jpg"
title="eva-engagement-ring-cushion-cut-diamond-turned-profile"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
<a href="#" class="product-thumbnail"
data-image="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
data-post-id="530">
<img
src="http://doussetwp.loc/wp-content/uploads/2013/07/eva-engagement-ring-asscher-cut-diamond-angle.jpg"
title="eva-engagement-ring-asscher-cut-diamond-angle"
alt="">
</a>
</div>
</div>
</div>
CSS:
.product-gallery {
*zoom: 1;
max-height: 70px;
position: relative;
margin-left: auto;
margin-right: auto;
}
.product-gallery:before,
.product-gallery:after {
display: table;
content: "";
line-height: 0;
}
.product-gallery:after {
clear: both
}
.product-gallery .scrollable-area {
overflow: hidden;
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
}
.product-gallery .scroll-products-right,
.product-gallery .scroll-products-left {
position: absolute;
width: 30px;
height: 100%;
background: url(./../img/arrow-small-left.png) center center no-repeat
#fff;
background-color: rgba(255,255,255,0.6);
top: 0;
left: 0;
z-index: 20;
opacity: .6;
filter: alpha(opacity=60);
}
.product-gallery .scroll-products-right:hover,
.product-gallery .scroll-products-left:hover {
cursor: pointer !important;
background-color: rgba(255,255,255,0.8);
opacity: 1;
filter: alpha(opacity=100);
}
.product-gallery .scroll-products-right {
right: 0;
left: auto;
background: url(./../img/arrow-small-right.png) center center
no-repeat #fff;
background-color: rgba(255,255,255,0.6);
}
.product-gallery .product-thumbnail {
float: left;
max-width: 70px;
opacity: .5;
filter: alpha(opacity=50);
}
.product-gallery .product-thumbnail.active {
opacity: 1;
filter: alpha(opacity=100);
}
.product-gallery .product-thumbnail:before,
.product-gallery .product-thumbnail:after {
content: ""
}
JS:
Dousset.product = {
currentWindowWidthMin: null,
currentInterval: null,
init: function () {
$('#wrapper').on('click', '.product-thumbnail',
Dousset.product.thumbClicked);
// $('.product-thumbnail').css({ // 'float': 'none', // 'display':
'inline-block' // });
$('#wrapper').on('mousedown', '.scroll-products-right',
Dousset.product.scrollThumbsLeft);
$('#wrapper').on('mousedown', '.scroll-products-left',
Dousset.product.scrollThumbsRight);
$('#wrapper').on('mouseup', '.scroll-products-left,
.scroll-products-right', function(e){
clearTimeout(Dousset.product.currentInterval);
Dousset.product.currentInterval = null;
});
if((navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPod/i))) {
$('#wrapper').on('click', '.scroll-products-right',
Dousset.product.scrollThumbsLeftBatch);
$('#wrapper').on('click', '.scroll-products-left',
Dousset.product.scrollThumbsRightBatch);
}
Dousset.product.setCurrentWindowWidthMin();
$(window).resize(Dousset.product.windowResized);
},
thumbClicked: function (e) {
e.preventDefault();
if (!$(this).hasClass('active')) {
var postId = $(this).data('post-id');
var newImg = $(this).data('image');
$('.main-image[data-post-id="'+postId+'"]').attr('src',
newImg);
$('.product-thumbnail[data-post-id="'+postId+'"]').removeClass('active');
$(this).addClass('active');
}
},
scrollThumbsLeft: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
var maxMargin = $inner.width() -
$(this).siblings('.scrollable-area').width();
Dousset.product.currentInterval = setInterval(function(){
if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
$inner.css({
'margin-left' : '-=1'
});
}
},10);
},
scrollThumbsRight: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
Dousset.product.currentInterval = setInterval(function(){
if (parseInt($inner.css('margin-left'),10) <= 0 ) {
$inner.css({
'margin-left' : '+=1'
});
}
},10);
},
scrollThumbsLeftBatch: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
var maxMargin = $inner.width() -
$(this).siblings('.scrollable-area').width();
if (parseInt($inner.css('margin-left'),10) >= -maxMargin) {
$inner.animate({
'margin-left' : '-=70'
});
}
},
scrollThumbsRightBatch: function (e) {
var $inner =
$(this).siblings('.scrollable-area').find('.product-gallery-inner');
if (parseInt($inner.css('margin-left'),10) <= 0 ) {
$inner.animate({
'margin-left' : '+=70'
});
}
},
setCurrentWindowWidthMin: function () {
Dousset.product.currentWindowWidthMin = $( window ).width() >
979 ? 980 : $( window ).width() > 767 ? 768 : 480;
},
windowResized: function () {
var oldWinMin = Dousset.product.currentWindowWidthMin;
Dousset.product.setCurrentWindowWidthMin();
}
}
$(document).ready(function(){ Dousset.product.init(); });
Mongoid, how to keep relations in sync for common parent model?
Mongoid, how to keep relations in sync for common parent model?
I have three models:
Agency
has_many :owners
has_many :properties
Owner
belongs_to :agency
has_many :properties
Property
belongs_to :owner
belongs_to :agency
The agency.properties relation should refer to all properties that all
owners have, but when I create a property inside an owner, the
agency.properties relation is not created. I want this relation to be
automatically fulfilled, as well as deleted when the owner or the property
is deleted.
How can I achieve this behavior with mongoid?
I have three models:
Agency
has_many :owners
has_many :properties
Owner
belongs_to :agency
has_many :properties
Property
belongs_to :owner
belongs_to :agency
The agency.properties relation should refer to all properties that all
owners have, but when I create a property inside an owner, the
agency.properties relation is not created. I want this relation to be
automatically fulfilled, as well as deleted when the owner or the property
is deleted.
How can I achieve this behavior with mongoid?
Python time zone parsing
Python time zone parsing
I have a little problem parsing a date in python
This is the date I have to parse:
Sun Sep 15, 2013 12:10pm EDT
And that is the code I'm using to parse it:
datetime.strptime( date, "%a %b %d, %Y %I:%M%p %Z")
Everything is fine but the time-zone parsing, which always return a
ValueError exception. I've also tried pytz but without any success.
So how can i parse this kind date using python?
I have a little problem parsing a date in python
This is the date I have to parse:
Sun Sep 15, 2013 12:10pm EDT
And that is the code I'm using to parse it:
datetime.strptime( date, "%a %b %d, %Y %I:%M%p %Z")
Everything is fine but the time-zone parsing, which always return a
ValueError exception. I've also tried pytz but without any success.
So how can i parse this kind date using python?
Sort by AVG(rating)
Sort by AVG(rating)
I am trying to write a mySQL-query that sorts by first suburb and then
AVG(rating_table.rating).
Here is the street_table:
id street_name suburb
0 streetone subone
1 streettwo subthree
2 streetthree subthree
3 streetfour subtwo
And here is the rating_table:
street_id rating
1 1
2 1
3 4
2 2
1 3
And this is the result I am looking for:
id suburb avarage_rating
0 subone (no rating)
1 subtwo 1 + 3 / 2 = 2
3 subthree 4 / 1 = 4 (Just one vote..)
2 subthree 2 + 1 / 2 = 1.5
(As you can see, #3 is before #2 because of the avarage_rating)
I am trying to write a mySQL-query that sorts by first suburb and then
AVG(rating_table.rating).
Here is the street_table:
id street_name suburb
0 streetone subone
1 streettwo subthree
2 streetthree subthree
3 streetfour subtwo
And here is the rating_table:
street_id rating
1 1
2 1
3 4
2 2
1 3
And this is the result I am looking for:
id suburb avarage_rating
0 subone (no rating)
1 subtwo 1 + 3 / 2 = 2
3 subthree 4 / 1 = 4 (Just one vote..)
2 subthree 2 + 1 / 2 = 1.5
(As you can see, #3 is before #2 because of the avarage_rating)
Duplicate the old data when the datagridview refreshed
Duplicate the old data when the datagridview refreshed
i already can add the new data to the database and display that database
through datagridview, and i command to refresh the datagridview whenever i
click "Add" button (Adding new data to the database). But it is duplicate
the old data with the new one.
Here is the screenshot that show it duplicate after adding new data and
refresh datagridview:
In the above image, there is duplicate data of ID "16", whenever i enter
the new value and insert it to the database, it add the new (current)
value to the database, but the old value will be duplicated. Therefore, i
have to quit the program and re-launch it again. But, is there any other
ways to solve this (Old data not being duplicated after add a new data to
the database and refresh the datagridview)?
Here is my code:
private void ViewDatabase(object sender, EventArgs e)
{
using (OleDbConnection conn = new
OleDbConnection(connectionString))
{
string query = "SELECT * FROM [Table]";
conn.Open();
using (OleDbDataAdapter adapter = new
OleDbDataAdapter(query, conn))
{
adapter.Fill(ds, "Table");
dataGridView1.DataSource = ds.Tables[0];
}
conn.Close();
}
}
private void Add(object sender, EventArgs e)
{
using (OleDbConnection conn = new
OleDbConnection(connectionString))
{
string query = "INSERT INTO [Table] ([ProductCode],
[Quantity], [Description], [Price]) VALUES (@ProductCode,
@Quantity, @Description, @Price)";
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.Add("@ProductCode",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@ProductCode"].Value =
this.numericTextBox1.Text;
cmd.Parameters.Add("@Quantity",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@Quantity"].Value =
this.numericUpDown1.Value;
cmd.Parameters.Add("@Description",
System.Data.OleDb.OleDbType.VarChar);
cmd.Parameters["@Description"].Value =
this.textBox3.Text;
cmd.Parameters.Add("@Price",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@Price"].Value = this.textBox4.Text;
cmd.ExecuteNonQuery();
if (choice.comboBox1.Text == "English")
{
System.Media.SoundPlayer sound = new
System.Media.SoundPlayer(@"C:\Windows\Media\Windows
Exclamation.wav");
sound.Play();
DialogResult dialogResult = MessageBox.Show("Added
Successfully!", "Success", MessageBoxButtons.OK);
if (dialogResult == DialogResult.OK)
{
ViewDatabase(sender, e);
ClearTextBoxes(sender, e);
}
}
i already can add the new data to the database and display that database
through datagridview, and i command to refresh the datagridview whenever i
click "Add" button (Adding new data to the database). But it is duplicate
the old data with the new one.
Here is the screenshot that show it duplicate after adding new data and
refresh datagridview:
In the above image, there is duplicate data of ID "16", whenever i enter
the new value and insert it to the database, it add the new (current)
value to the database, but the old value will be duplicated. Therefore, i
have to quit the program and re-launch it again. But, is there any other
ways to solve this (Old data not being duplicated after add a new data to
the database and refresh the datagridview)?
Here is my code:
private void ViewDatabase(object sender, EventArgs e)
{
using (OleDbConnection conn = new
OleDbConnection(connectionString))
{
string query = "SELECT * FROM [Table]";
conn.Open();
using (OleDbDataAdapter adapter = new
OleDbDataAdapter(query, conn))
{
adapter.Fill(ds, "Table");
dataGridView1.DataSource = ds.Tables[0];
}
conn.Close();
}
}
private void Add(object sender, EventArgs e)
{
using (OleDbConnection conn = new
OleDbConnection(connectionString))
{
string query = "INSERT INTO [Table] ([ProductCode],
[Quantity], [Description], [Price]) VALUES (@ProductCode,
@Quantity, @Description, @Price)";
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(query, conn))
{
cmd.Parameters.Add("@ProductCode",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@ProductCode"].Value =
this.numericTextBox1.Text;
cmd.Parameters.Add("@Quantity",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@Quantity"].Value =
this.numericUpDown1.Value;
cmd.Parameters.Add("@Description",
System.Data.OleDb.OleDbType.VarChar);
cmd.Parameters["@Description"].Value =
this.textBox3.Text;
cmd.Parameters.Add("@Price",
System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["@Price"].Value = this.textBox4.Text;
cmd.ExecuteNonQuery();
if (choice.comboBox1.Text == "English")
{
System.Media.SoundPlayer sound = new
System.Media.SoundPlayer(@"C:\Windows\Media\Windows
Exclamation.wav");
sound.Play();
DialogResult dialogResult = MessageBox.Show("Added
Successfully!", "Success", MessageBoxButtons.OK);
if (dialogResult == DialogResult.OK)
{
ViewDatabase(sender, e);
ClearTextBoxes(sender, e);
}
}
How to draw multiple lines with finger? (Android)
How to draw multiple lines with finger? (Android)
I have tried to draw multiple lines like this:
`
l1 = new Path();
l2 = new Path();
l3 = new Path();
l4 = new Path();`
---
`mPathList.add(l1...l4);`
---
`public void onDraw(Canvas canvas) {
...
for (Path path : mPathList) {
canvas.drawPath(path, mOverlayPaint);
}
...
}`
---
`case MotionEvent.ACTION_MOVE:
int X = (int)me.getRawX();
int Y = (int)me.getRawY();
l1.moveTo(X, Y);
l2.moveTo(X + 5, Y);
l3.moveTo(X + 10, Y);
l4.moveTo(X + 15, Y);
break;`
But when I'm trying to draw something, FPS will slowly decrease. Any ideas
how to make it works fine? P.S. Sorry for my English, please
I have tried to draw multiple lines like this:
`
l1 = new Path();
l2 = new Path();
l3 = new Path();
l4 = new Path();`
---
`mPathList.add(l1...l4);`
---
`public void onDraw(Canvas canvas) {
...
for (Path path : mPathList) {
canvas.drawPath(path, mOverlayPaint);
}
...
}`
---
`case MotionEvent.ACTION_MOVE:
int X = (int)me.getRawX();
int Y = (int)me.getRawY();
l1.moveTo(X, Y);
l2.moveTo(X + 5, Y);
l3.moveTo(X + 10, Y);
l4.moveTo(X + 15, Y);
break;`
But when I'm trying to draw something, FPS will slowly decrease. Any ideas
how to make it works fine? P.S. Sorry for my English, please
Saturday, 14 September 2013
PERL Mechanize cannot print results when reading input data from a data file
PERL Mechanize cannot print results when reading input data from a data file
I created a PERL program to retrieve the stock exchanges from Yahoo
Finance, given a list of stock symbols.
The following code writes to a file
#!/usr/bin/perl
# program name: FindStockExchange.pl
use strict;
use warnings;
use WWW::Mechanize;
use Storable;
use Getopt::Long;
#cmd: clear; ./FindStockExchange.pl A AA AA.V AAA.TO -f ~/symbol_out.txt
# Find Stock Exchange for a given Stock Symbole
# Command line options:
# -s Symbol
# -f Output filename
# Initialize variables:
my $urlBase='http://finance.yahoo.com/q?s='; # Before symbol
my $urlSuffix='&ql=0'; # After symbol
my $url='';
my $oFile='';
my $symbol='';
my $c='';
# Read command line options.
GetOptions(
'f=s' => \$oFile #Output filename
) or die "Incorrect usage!\n";
# Ouptput file(s)
open(OUTSYM,">$oFile") || die "Couldn't open file $oFile, $!";
my $m = WWW::Mechanize->new( autocheck=>0 );
foreach $symbol ( @ARGV ){
$url=$urlBase . $symbol .$urlSuffix;
$m->get($url);
$c = $m->content; # Places html page source text into variable
# Text pattern: <div class="title"><h2>Electrolux AB (ELUXY)</h2> <span
class="rtq_exch"><span class="rtq_dash">-</span>OTC Markets
</span></div>
$c =~ m{rtq_dash\">-</span>(.*?)</span>}s or next;
print OUTSYM "$symbol\t$1\n"; # Write output file
print "$symbol\t$1\t" . "\n"; # Write to STDOUT
} # End foreach
close OUTFIL;
The following code reads from an input file and creates an empty data
file. The input file contained the following stock symbols:
A AA AA.V AAA.TO
#!/usr/bin/perl
# program name: FindStockExchange2.pl
use strict;
use warnings;
use WWW::Mechanize;
use Storable;
use Getopt::Long;
#cmd: clear; ./FindStockExchange2.pl -i ~/symbol_in.txt -o ~/symbol_out2.txt
# Find Stock Exchange for a given Stock Symbole
# Command line options:
# -i Input filename
# -o Output filename
# Initialize variables:
my $urlBase='http://finance.yahoo.com/q?s='; # Before symbol
my $urlSuffix='&ql=0'; # After symbol
my $url='';
my $oFile='';
my $iFile='';
my $symbol='';
my $c='';
# Read command line options.
GetOptions(
'o=s' => \$oFile, #Output filename
'i=s' => \$iFile #Input filename
) or die "Incorrect usage!\n";
# File(s)
open(OUTSYM,">$oFile") || die "Couldn't open file $oFile, $!";
open(INSYM,"<$iFile") || die "Couldn't open file $iFile, $!";
my $m = WWW::Mechanize->new( autocheck=>0 );
while ( <INSYM> ){
$symbol=chomp($_);
$url=$urlBase . $symbol .$urlSuffix;
$m->get($url);
$c = $m->content; # Places html page source text into variable
# Text pattern: <div class="title"><h2>Electrolux AB (ELUXY)</h2> <span
class="rtq_exch"><span class="rtq_dash">-</span>OTC Markets
</span></div>
$c =~ m{rtq_dash\">-</span>(.*?)</span>}s or next;
print OUTSYM "$symbol\t$1\n"; # Write output file
print "$symbol\t$1\t" . "\n"; # Write to STDOUT
} # End while
close INSYM;
close OUTSYM;
Why would changing from a foreach loop to reading an input file using a
while loop produce different results?
Foreeah code creates a file containing the following: A NYSE
AA NYSE
AA.V TSXV
AAA.TO Toronto
To-Air-Is:~ vlis
While loop creates an empty file.
I created a PERL program to retrieve the stock exchanges from Yahoo
Finance, given a list of stock symbols.
The following code writes to a file
#!/usr/bin/perl
# program name: FindStockExchange.pl
use strict;
use warnings;
use WWW::Mechanize;
use Storable;
use Getopt::Long;
#cmd: clear; ./FindStockExchange.pl A AA AA.V AAA.TO -f ~/symbol_out.txt
# Find Stock Exchange for a given Stock Symbole
# Command line options:
# -s Symbol
# -f Output filename
# Initialize variables:
my $urlBase='http://finance.yahoo.com/q?s='; # Before symbol
my $urlSuffix='&ql=0'; # After symbol
my $url='';
my $oFile='';
my $symbol='';
my $c='';
# Read command line options.
GetOptions(
'f=s' => \$oFile #Output filename
) or die "Incorrect usage!\n";
# Ouptput file(s)
open(OUTSYM,">$oFile") || die "Couldn't open file $oFile, $!";
my $m = WWW::Mechanize->new( autocheck=>0 );
foreach $symbol ( @ARGV ){
$url=$urlBase . $symbol .$urlSuffix;
$m->get($url);
$c = $m->content; # Places html page source text into variable
# Text pattern: <div class="title"><h2>Electrolux AB (ELUXY)</h2> <span
class="rtq_exch"><span class="rtq_dash">-</span>OTC Markets
</span></div>
$c =~ m{rtq_dash\">-</span>(.*?)</span>}s or next;
print OUTSYM "$symbol\t$1\n"; # Write output file
print "$symbol\t$1\t" . "\n"; # Write to STDOUT
} # End foreach
close OUTFIL;
The following code reads from an input file and creates an empty data
file. The input file contained the following stock symbols:
A AA AA.V AAA.TO
#!/usr/bin/perl
# program name: FindStockExchange2.pl
use strict;
use warnings;
use WWW::Mechanize;
use Storable;
use Getopt::Long;
#cmd: clear; ./FindStockExchange2.pl -i ~/symbol_in.txt -o ~/symbol_out2.txt
# Find Stock Exchange for a given Stock Symbole
# Command line options:
# -i Input filename
# -o Output filename
# Initialize variables:
my $urlBase='http://finance.yahoo.com/q?s='; # Before symbol
my $urlSuffix='&ql=0'; # After symbol
my $url='';
my $oFile='';
my $iFile='';
my $symbol='';
my $c='';
# Read command line options.
GetOptions(
'o=s' => \$oFile, #Output filename
'i=s' => \$iFile #Input filename
) or die "Incorrect usage!\n";
# File(s)
open(OUTSYM,">$oFile") || die "Couldn't open file $oFile, $!";
open(INSYM,"<$iFile") || die "Couldn't open file $iFile, $!";
my $m = WWW::Mechanize->new( autocheck=>0 );
while ( <INSYM> ){
$symbol=chomp($_);
$url=$urlBase . $symbol .$urlSuffix;
$m->get($url);
$c = $m->content; # Places html page source text into variable
# Text pattern: <div class="title"><h2>Electrolux AB (ELUXY)</h2> <span
class="rtq_exch"><span class="rtq_dash">-</span>OTC Markets
</span></div>
$c =~ m{rtq_dash\">-</span>(.*?)</span>}s or next;
print OUTSYM "$symbol\t$1\n"; # Write output file
print "$symbol\t$1\t" . "\n"; # Write to STDOUT
} # End while
close INSYM;
close OUTSYM;
Why would changing from a foreach loop to reading an input file using a
while loop produce different results?
Foreeah code creates a file containing the following: A NYSE
AA NYSE
AA.V TSXV
AAA.TO Toronto
To-Air-Is:~ vlis
While loop creates an empty file.
caesar cipher problems in python
caesar cipher problems in python
I have the following code which gives me error saying it cannot convert
'int' object to str implicitly. the if statements were used so if a letter
in WORD is ascii 125 and i had to shift it by 5, I wanted the shift to
goto ascii 32 and calculate. if any of the letters in word was less than
ascii 32 shift, then shift to 32.
word=input("enter something to encrypt")
offset=int(input("Enter a number to shift it by"))
for char in word:
newword= ord(char)
newword =newword+ chr(newword) + offset
if newwword<32:
result=result+95
elif newword >126:
result=result-95
I have the following code which gives me error saying it cannot convert
'int' object to str implicitly. the if statements were used so if a letter
in WORD is ascii 125 and i had to shift it by 5, I wanted the shift to
goto ascii 32 and calculate. if any of the letters in word was less than
ascii 32 shift, then shift to 32.
word=input("enter something to encrypt")
offset=int(input("Enter a number to shift it by"))
for char in word:
newword= ord(char)
newword =newword+ chr(newword) + offset
if newwword<32:
result=result+95
elif newword >126:
result=result-95
Cleaner Syntax for HTTP Object in AJAX?
Cleaner Syntax for HTTP Object in AJAX?
AJAX noob here... So this code below works for me which is called during
an onclick event:
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
http.send();
}
However, when I tried to clean it like below, it no longer works. Is the
code below not a correct callback syntax?
function handleHTTPResponse() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = handleHTTPResponse;
http.send();
}
AJAX noob here... So this code below works for me which is called during
an onclick event:
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
http.send();
}
However, when I tried to clean it like below, it no longer works. Is the
code below not a correct callback syntax?
function handleHTTPResponse() {
if (http.readyState == 4) {
document.getElementById("myDiv").innerHTML=http.responseText;
}
}
function updateText() {
var http = getHTTPObject();
http.open("GET","ajax_info.asp",true);
http.onreadystatechange = handleHTTPResponse;
http.send();
}
Change table contents on hover?
Change table contents on hover?
I have a table like this:
<div class="footer_row_3">
<table class="tableA">
<tr>
<td><img class="popcorn" src="http://i.imgur.com/HUjq2Va.png"></td>
<td><span class="statement">Lorem Ipsum</span></td>
<td><img class="popcorn" src="http://i.imgur.com/HUjq2Va.png"></td>
</tr>
</table>
</div>
What I want to do is that when the mouse hovers over tableA at any
location within tableA, the following two changes happen:
1) Popcorn images change to this image: http://i.imgur.com/K29T3Fw.png 2)
The text color changes to red.
Also, it should have with a CSS 'fade' style transition, so that the
contents fades into the updated style contents.
Also, BOTH changes mentioned above should happen when I hover tableA from
any place within tableA.
I know how to individually change text and image on hover, but I don't
know how to do it together for multiple items.
How can I achieve this effect ?
I have a table like this:
<div class="footer_row_3">
<table class="tableA">
<tr>
<td><img class="popcorn" src="http://i.imgur.com/HUjq2Va.png"></td>
<td><span class="statement">Lorem Ipsum</span></td>
<td><img class="popcorn" src="http://i.imgur.com/HUjq2Va.png"></td>
</tr>
</table>
</div>
What I want to do is that when the mouse hovers over tableA at any
location within tableA, the following two changes happen:
1) Popcorn images change to this image: http://i.imgur.com/K29T3Fw.png 2)
The text color changes to red.
Also, it should have with a CSS 'fade' style transition, so that the
contents fades into the updated style contents.
Also, BOTH changes mentioned above should happen when I hover tableA from
any place within tableA.
I know how to individually change text and image on hover, but I don't
know how to do it together for multiple items.
How can I achieve this effect ?
Windows phone:access subproperty of binding
Windows phone:access subproperty of binding
I have a custom pivot control where all the UI is generated using
template.It looks like this:
<controls:Pivot ItemsSource="{Binding superSets}">
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding Source={StaticResource
SortedNews}}">
<ListBox.ItemTemplate>
<!- datatemplate Code -->
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
Now,I want to sort the contents of listbox so I designed a
collectionviewsource like this:
<CollectionViewSource x:Key="SortedNews" Source="{Binding Path=Articles}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription
PropertyName="Pubdate"></scm:SortDescription>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
About the superSets: It contains an Observable collection type property
Articles
Now when I run the program I get an error saying Property 'Articles' not
found
Any Ideas?
I have a custom pivot control where all the UI is generated using
template.It looks like this:
<controls:Pivot ItemsSource="{Binding superSets}">
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTemplate>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding Source={StaticResource
SortedNews}}">
<ListBox.ItemTemplate>
<!- datatemplate Code -->
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
Now,I want to sort the contents of listbox so I designed a
collectionviewsource like this:
<CollectionViewSource x:Key="SortedNews" Source="{Binding Path=Articles}">
<CollectionViewSource.SortDescriptions>
<scm:SortDescription
PropertyName="Pubdate"></scm:SortDescription>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
About the superSets: It contains an Observable collection type property
Articles
Now when I run the program I get an error saying Property 'Articles' not
found
Any Ideas?
Real-Time Updates: Certificate verify failed
Real-Time Updates: Certificate verify failed
I am currently trying to set up Real-Time Updates to my site through the
facebook app interface. When I attempt to test the callback to the
callback url of https://messageall.com/facebook/callback/ I am getting an
error message of:
Callback verification failed:
SSL certificate problem, verify that the CA cert is OK.
Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
failed
However from what I can tell the certificate key chain is working fine and
verifies when I test via http://www.digicert.com/help/
What could the facebook servers think is wrong with my CA?
I am currently trying to set up Real-Time Updates to my site through the
facebook app interface. When I attempt to test the callback to the
callback url of https://messageall.com/facebook/callback/ I am getting an
error message of:
Callback verification failed:
SSL certificate problem, verify that the CA cert is OK.
Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
failed
However from what I can tell the certificate key chain is working fine and
verifies when I test via http://www.digicert.com/help/
What could the facebook servers think is wrong with my CA?
Can't declare Class field type of the other class
Can't declare Class field type of the other class
Why i can't declare Class field type of the other class? This gives me
C4430 error:
//Entity.h file
class Entity
{
public:
Box test;
};
class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
Why i can't declare Class field type of the other class? This gives me
C4430 error:
//Entity.h file
class Entity
{
public:
Box test;
};
class Box
{
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
Friday, 13 September 2013
Android Fragment: View fully from code causes binding to null-object
Android Fragment: View fully from code causes binding to null-object
I have quite a few fragments, that are 90% common in layout. And because I
really like layout from code (I never create XIBs for iOS anymore), I
thought: lets do the same for Android. That was not as easy as I thought
it would be. The trouble is in MvvmCross, and after scouring the web for
solutions, only hints pointing to the solution can be found.
The problem: when the fragment is displayed, and I perform the binding, I
get all messages the source property cannot be found because it tries to
bind to a null-object.
Unable to bind: source property source not found
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken
on null-object
The layout is displayed on screen, the ViewModel is set, the
bindingcontext is set (both created by myself, because that was not done
automatically).
I suspect something is done in inflation to 'register' the created
controls, and because I do not use inflation, they are not registered. I
read in other questions about the MvxBindingContextStackRegistration,
watched the sources for that. Second cause might be the bindingcontext
itself: somehow it is not handled automatically, and that points to
something necessary missing beging called in the below code.
I might have done some strange thing, because this is the final attempt to
get it working:
public class IndexTocFragment : MvxFragment
{
// two statics to save on typing
public static int WRAP = ViewGroup.LayoutParams.WrapContent;
public static int FILL = ViewGroup.LayoutParams.FillParent;
public LinearLayout NewVerticalLinearLayout(Orientation orientation,
Boolean fillparent) {
var ll = new LinearLayout (Activity) { Orientation = orientation };
ll.LayoutParameters = new ViewGroup.LayoutParams (FILL, fillparent
? FILL : WRAP);
return ll;
}
public new IndexTocViewModel ViewModel { get { return base.ViewModel
as IndexTocViewModel; } set { base.ViewModel = value; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
{
base.OnCreateView (inflater, container, savedInstanceState);
var layout = NewVerticalLinearLayout (Orientation.Vertical, true);
if (ViewModel == null)
ViewModel = Mvx.IocConstruct<IndexTocViewModel> ();
BindingContext = new MvxAndroidBindingContext (Activity, new
MvxSimpleLayoutInflater(inflater));
using (new
MvxBindingContextStackRegistration<IMvxAndroidBindingContext>(((IMvxAndroidBindingContext)
this.BindingContext)))
{
//var layout = NewVerticalLinearLayout (Orientation.Vertical,
true);
layout.SetBackgroundColor (Color.ParseColor("#FFFFFF"));
var titlelayer = NewVerticalLinearLayout
(Orientation.Horizontal, false);
titlelayer.LayoutParameters.Height = 40;
var title = new TextView (Activity) { LayoutParameters = new
ViewGroup.LayoutParams (FILL, FILL) };
title.SetTextColor (Color.ParseColor ("#212121"));
var titlebutton = new Button (Activity) { LayoutParameters =
new ViewGroup.LayoutParams (WRAP, FILL) };
titlelayer.AddView (title);
titlelayer.AddView (titlebutton);
layout.AddView (titlelayer);
var twobuttonlayer = NewVerticalLinearLayout
(Orientation.Horizontal, false);
twobuttonlayer.LayoutParameters.Height = 40;
var twobuttonklein = new Button (Activity) { LayoutParameters
= new ViewGroup.LayoutParams (FILL, WRAP) };
twobuttonklein.Text = "Klein";
twobuttonklein.SetBackgroundResource
(Resource.Drawable.kleingrootbutton);
var twobuttongroot = new Button(Activity){ LayoutParameters =
new ViewGroup.LayoutParams (FILL, WRAP) };
twobuttongroot.Text = "Middel/groot";
twobuttongroot.SetBackgroundResource
(Resource.Drawable.kleingrootbutton);
twobuttonlayer.AddView (twobuttonklein);
twobuttonlayer.AddView (twobuttongroot);
layout.AddView (twobuttonlayer);
var zoekvak = new EditText (Activity) { LayoutParameters = new
ViewGroup.LayoutParams (FILL, WRAP) };
zoekvak.Hint = "Zoek in inhoudsopgave";
layout.AddView (zoekvak);
var emptytext = new TextView (Activity) { LayoutParameters =
new ViewGroup.LayoutParams (FILL, WRAP),
Text = "Er zijn geen resultaten." };
emptytext.SetBackgroundColor (Color.ParseColor ("#BBAA00"));
layout.AddView (emptytext);
var listadapter = new
BindableExpandableListAdapter(this.Activity,
(IMvxBindingContext) BindingContext);
var list = new BindableExpandableListView (Activity, null,
listadapter) { LayoutParameters = new ViewGroup.LayoutParams
(FILL, FILL) };
list.SetMinimumHeight (50);
list.ItemTemplateId = Resource.Layout.indextocsectionlistitem;
list.GroupTemplateId = Resource.Layout.indextocitem;
list.SetGroupIndicator (null);
list.SetBackgroundColor (Color.ParseColor ("#AAAA00"));
layout.AddView (list);
this.DoBind += () => {
var bs = this.CreateBindingSet<IndexTocFragment,
IndexTocViewModel> ();
if (ViewModel == null) {
Console.WriteLine ("ERROR ViewModel not set");
}
if (BindingContext == null) {
Console.WriteLine ("ERROR BindingContext not set");
}
bs.Bind (title).For (x => x.Text).To (vm => vm.IndexTitle);
// the following title displays some data from the
ViewMode, and that works OK.
Console.WriteLine("Index title value:
"+ViewModel.IndexTitle);
bs.Bind (twobuttongroot).For ("Click").To (vm =>
vm.SwitchKleinGrootCommand);
bs.Bind (twobuttonklein).For ("Click").To (vm =>
vm.SwitchKleinGrootCommand);
bs.Bind (zoekvak).For (x => x.Text).To (vm => vm.SearchText);
bs.Bind (emptytext).For (x => x.Text).To (vm =>
vm.TextForEmptyList);
bs.Bind (listadapter).For(x => x.ItemsSource).To(vm =>
vm.Chapters);
bs.Apply ();
};
// the next binding was never called
//this.DelayBind (() => {
//
//});
}
//var view = this.BindingInflate(Resource.Layout.IndexTocView, null);
Console.WriteLine ("LAYOUT RETURNED");
return layout;
}
private Action DoBind;
public override void OnResume()
{
// doing the binding here to make sure everything should have been
set,
but it is of course not the logical location
base.OnResume();
Console.WriteLine ("RESUMING");
if (DoBind != null)
DoBind ();
}
}
For now I will create a fragment layout with everyting I need, and hide
the elements that are not needed, that will probably work. But I hope I
can use creating views from code.
Thanks for helping.
I have quite a few fragments, that are 90% common in layout. And because I
really like layout from code (I never create XIBs for iOS anymore), I
thought: lets do the same for Android. That was not as easy as I thought
it would be. The trouble is in MvvmCross, and after scouring the web for
solutions, only hints pointing to the solution can be found.
The problem: when the fragment is displayed, and I perform the binding, I
get all messages the source property cannot be found because it tries to
bind to a null-object.
Unable to bind: source property source not found
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken
on null-object
The layout is displayed on screen, the ViewModel is set, the
bindingcontext is set (both created by myself, because that was not done
automatically).
I suspect something is done in inflation to 'register' the created
controls, and because I do not use inflation, they are not registered. I
read in other questions about the MvxBindingContextStackRegistration,
watched the sources for that. Second cause might be the bindingcontext
itself: somehow it is not handled automatically, and that points to
something necessary missing beging called in the below code.
I might have done some strange thing, because this is the final attempt to
get it working:
public class IndexTocFragment : MvxFragment
{
// two statics to save on typing
public static int WRAP = ViewGroup.LayoutParams.WrapContent;
public static int FILL = ViewGroup.LayoutParams.FillParent;
public LinearLayout NewVerticalLinearLayout(Orientation orientation,
Boolean fillparent) {
var ll = new LinearLayout (Activity) { Orientation = orientation };
ll.LayoutParameters = new ViewGroup.LayoutParams (FILL, fillparent
? FILL : WRAP);
return ll;
}
public new IndexTocViewModel ViewModel { get { return base.ViewModel
as IndexTocViewModel; } set { base.ViewModel = value; } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState)
{
base.OnCreateView (inflater, container, savedInstanceState);
var layout = NewVerticalLinearLayout (Orientation.Vertical, true);
if (ViewModel == null)
ViewModel = Mvx.IocConstruct<IndexTocViewModel> ();
BindingContext = new MvxAndroidBindingContext (Activity, new
MvxSimpleLayoutInflater(inflater));
using (new
MvxBindingContextStackRegistration<IMvxAndroidBindingContext>(((IMvxAndroidBindingContext)
this.BindingContext)))
{
//var layout = NewVerticalLinearLayout (Orientation.Vertical,
true);
layout.SetBackgroundColor (Color.ParseColor("#FFFFFF"));
var titlelayer = NewVerticalLinearLayout
(Orientation.Horizontal, false);
titlelayer.LayoutParameters.Height = 40;
var title = new TextView (Activity) { LayoutParameters = new
ViewGroup.LayoutParams (FILL, FILL) };
title.SetTextColor (Color.ParseColor ("#212121"));
var titlebutton = new Button (Activity) { LayoutParameters =
new ViewGroup.LayoutParams (WRAP, FILL) };
titlelayer.AddView (title);
titlelayer.AddView (titlebutton);
layout.AddView (titlelayer);
var twobuttonlayer = NewVerticalLinearLayout
(Orientation.Horizontal, false);
twobuttonlayer.LayoutParameters.Height = 40;
var twobuttonklein = new Button (Activity) { LayoutParameters
= new ViewGroup.LayoutParams (FILL, WRAP) };
twobuttonklein.Text = "Klein";
twobuttonklein.SetBackgroundResource
(Resource.Drawable.kleingrootbutton);
var twobuttongroot = new Button(Activity){ LayoutParameters =
new ViewGroup.LayoutParams (FILL, WRAP) };
twobuttongroot.Text = "Middel/groot";
twobuttongroot.SetBackgroundResource
(Resource.Drawable.kleingrootbutton);
twobuttonlayer.AddView (twobuttonklein);
twobuttonlayer.AddView (twobuttongroot);
layout.AddView (twobuttonlayer);
var zoekvak = new EditText (Activity) { LayoutParameters = new
ViewGroup.LayoutParams (FILL, WRAP) };
zoekvak.Hint = "Zoek in inhoudsopgave";
layout.AddView (zoekvak);
var emptytext = new TextView (Activity) { LayoutParameters =
new ViewGroup.LayoutParams (FILL, WRAP),
Text = "Er zijn geen resultaten." };
emptytext.SetBackgroundColor (Color.ParseColor ("#BBAA00"));
layout.AddView (emptytext);
var listadapter = new
BindableExpandableListAdapter(this.Activity,
(IMvxBindingContext) BindingContext);
var list = new BindableExpandableListView (Activity, null,
listadapter) { LayoutParameters = new ViewGroup.LayoutParams
(FILL, FILL) };
list.SetMinimumHeight (50);
list.ItemTemplateId = Resource.Layout.indextocsectionlistitem;
list.GroupTemplateId = Resource.Layout.indextocitem;
list.SetGroupIndicator (null);
list.SetBackgroundColor (Color.ParseColor ("#AAAA00"));
layout.AddView (list);
this.DoBind += () => {
var bs = this.CreateBindingSet<IndexTocFragment,
IndexTocViewModel> ();
if (ViewModel == null) {
Console.WriteLine ("ERROR ViewModel not set");
}
if (BindingContext == null) {
Console.WriteLine ("ERROR BindingContext not set");
}
bs.Bind (title).For (x => x.Text).To (vm => vm.IndexTitle);
// the following title displays some data from the
ViewMode, and that works OK.
Console.WriteLine("Index title value:
"+ViewModel.IndexTitle);
bs.Bind (twobuttongroot).For ("Click").To (vm =>
vm.SwitchKleinGrootCommand);
bs.Bind (twobuttonklein).For ("Click").To (vm =>
vm.SwitchKleinGrootCommand);
bs.Bind (zoekvak).For (x => x.Text).To (vm => vm.SearchText);
bs.Bind (emptytext).For (x => x.Text).To (vm =>
vm.TextForEmptyList);
bs.Bind (listadapter).For(x => x.ItemsSource).To(vm =>
vm.Chapters);
bs.Apply ();
};
// the next binding was never called
//this.DelayBind (() => {
//
//});
}
//var view = this.BindingInflate(Resource.Layout.IndexTocView, null);
Console.WriteLine ("LAYOUT RETURNED");
return layout;
}
private Action DoBind;
public override void OnResume()
{
// doing the binding here to make sure everything should have been
set,
but it is of course not the logical location
base.OnResume();
Console.WriteLine ("RESUMING");
if (DoBind != null)
DoBind ();
}
}
For now I will create a fragment layout with everyting I need, and hide
the elements that are not needed, that will probably work. But I hope I
can use creating views from code.
Thanks for helping.
Android Studio for Windows is not installing and updating packages
Android Studio for Windows is not installing and updating packages
When I run the Android SDK Manager and I try to install or update it fails
and I can't install anything.
How can I do to install or update new packages?
Thank you
When I run the Android SDK Manager and I try to install or update it fails
and I can't install anything.
How can I do to install or update new packages?
Thank you
Django's mark_for_escaping doesn't work with custom template tags?
Django's mark_for_escaping doesn't work with custom template tags?
I have a Django template tag that looks like this:
from django import template
from django.utils.safestring import mark_for_escaping
register = template.Library()
@register.simple_tag(takes_context=True)
def hello_world(context):
return mark_for_escaping("Hello, <world>!")
But when it's used in templates the output isn't being escaped.
What's going on? Is the output of template tags always assumed to be safe?
I have a Django template tag that looks like this:
from django import template
from django.utils.safestring import mark_for_escaping
register = template.Library()
@register.simple_tag(takes_context=True)
def hello_world(context):
return mark_for_escaping("Hello, <world>!")
But when it's used in templates the output isn't being escaped.
What's going on? Is the output of template tags always assumed to be safe?
Subscribe to:
Posts (Atom)