Sunday, 15 September 2013

SEO friendly url creation using js, php in html page

SEO friendly url creation using js, php in html page

I am developing a website for a client using html, js and php. For any
database call i am using ajax call
$.ajax({
type: 'POST',
url: "index2.php",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg, status) {
dosomething(msg);
},
error: function (msg, status) {
console.log("failure");
console.log(msg);
}
});
and php pages returns me the output. The problem is that index.html page
url is not getting changed.....I want it to change say index.html?id=23
(creating query string in html page)
Basically my aim to make it SEO friendly url like index.html/helloppl What
is the best method to do this. While googling i found link for
doing....still i need to create query string here...any help is
appreciated.

MySQL error 1462 database.table contains view recursion

MySQL error 1462 database.table contains view recursion

after exporting/importing a table from another database and renaming it as
such:
mysqldump -uroot -p --no-create-db db1 original_table > dump.sql
mysql -uroot -p db2 < dump.sql
mysql -uroot -D db2 -e 'RENAME TABLE original_table TO new_table;'
I try to select from the new table :
mysql -uroot -p
>use db2;
>select * from new_table;
and I get the following error :
ERROR 1462 (HY000): `db2`.`new_table` contains view recursion
I can't find much on google about this one, can anyone help? my mysql
version is 5.1.67-0ubuntu0.10.04.1
Thanks!
Chris

Read a txt file line by line and files from folders, and random line from file, but all results turned out to be the same.

Read a txt file line by line and files from folders, and random line from
file, but all results turned out to be the same.

Read a txt file line by line and files from folders, and random line from
file, but all results turned out to be the same. What is the cause of this
problem? I want to ramdom a template (.html) file from a folder, and
random a line from a file but the value came out the same.
if (comboBox1.SelectedItem.ToString() == "Amazon")
{
affpathname = affcase1;
}
else if (comboBox1.SelectedItem.ToString() == "Clickbank")
{
affpathname = affcase2;
}
int postpermm = Convert.ToInt32(postperm.Text);
this.timer1.Start();
string pfile = textBox1.Text;
DateTime startdatef = dateTimePicker1.Value;
string startdateshorta =
string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"),
"{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now);
FileStream FileOut = new FileStream(Application.StartupPath +
@"\" + "wordpress" + @"\" + startdateshorta + ".xml",
FileMode.Create);
StreamWriter sw = new StreamWriter(FileOut);
StreamReader a = new StreamReader(pfile);
string dd = null;
while ((dd = a.ReadLine()) != null)
{
{
var rand = new Random();
IEnumerable<string> lines =
File.ReadLines(@Application.StartupPath + @"\config\" +
affpathname + @"\title_template.txt");
var lineToRead = rand.Next(1, lines.Count());
var line = lines.Skip(lineToRead - 1).First();
sw.Write(line);
sw.Write("\r\n");
}
{
var rr = new Random();
var files = Directory.GetFiles(@Application.StartupPath
+ @"\config\" + affpathname + @"\layout\",
"*.*").Where(s => Regex.Match(s,
@"\.(html|htm)$").Success);
string randFile = files.ToList()[rr.Next(0,
files.Count())];
sw.Write(randFile);
sw.Write("\r\n");
sw.Write("\r\n");
}
if (comboBox1.SelectedItem.ToString() == "Amazon")
{
affpathname = affcase1;
}
else if (comboBox1.SelectedItem.ToString() == "Other Aff")
{
affpathname = affcase9;
}
string startdatelong =
string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"),
"{0:ddd, dd MMM yyyy HH:mm:ss}", startdatef);
string todaydatelong =
string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"),
"{0:ddd, dd MMM yyyy HH:mm:ss}", DateTime.Now);
string[] arr1 = dd.Split('@');
{
string productname = arr1[0];
string productimg = arr1[1];
string productlink = null;
if (mutiaff.Checked)
{
productlink = arr1[2];
}
else
{
productlink = singleafflink.Text;
}
}
}
sw.Write("</channel>\r\n");
sw.Write("</rss>\r\n");
sw.Close();
FileOut.Close();
}

Custom ListPreference data not stored

Custom ListPreference data not stored

I have a custom LocationsListPreference class written for multiple section
by extending ListPreference. The data you select via multiple selection in
popup saves if im in the same activity., But if i go back to the main
activity and come back the values i have saved form the multiple selection
are not stored. Any idea why?
LocationsListPreference XML:
<com.gm.settings.LocationsListPreference
android:defaultValue="#ALL#"
android:key="list_locations"
android:title="@string/LocationsListPreference_title"
android:dialogTitle="@string/LocationsListPreference_title"
android:summary="@string/LocationsListPreference_summary"
/>
Here a bit of source code of my LocationsListPreference class for the
above ListPreference:
public class LocationsListPreference extends ListPreference {
//Need to make sure the SEPARATOR is unique and weird enough that it
doesn't match one of the entries.
//Not using any fancy symbols because this is interpreted as a regex
for splitting strings.
private static final String SEPARATOR = CommonConstants.SEPARATOR;
private static String val;
private boolean[] mClickedDialogEntryIndices;
public LocationsListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
mClickedDialogEntryIndices = new
boolean[CommonConstants.LOCATIONS_KEYS.length];
}
@Override
public void setEntries(CharSequence[] entries) {
super.setEntries(entries);
mClickedDialogEntryIndices = new boolean[entries.length];
}
public LocationsListPreference(Context context) {
this(context, null);
}
Here is the "Settings" activity which i use to load PreferenceFragment:
public static void launch(Context context)
{
contxt = context;
Intent prompt = new Intent(contxt, Settings.class);
prompt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_NO_USER_ACTION);
contxt.startActivity(prompt);
}
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_settings);
}
}
Now if i select values from the ListPreference it successfully stores even
if i re-click from within the "Settings" activity. But if i go to another
activity and come back to "Settings" activity and load the ListPreference,
those values are not stored but shows all unchecked. Any ideas as to why
this happens?

Decorating a class to monitor attribute changes

Decorating a class to monitor attribute changes

I want to have classes that automatically send notifications to
subscribers whenever one of their attributes change. So if I would write
this code:
@ChangeMonitor
class ChangingClass(object):
def __init__(self, x):
self.x = x
changer = ChangingClass(5)
print("Going to change x.")
changer.x = 6
print("Going to not change x.)
changer.x = 6
print("End of program")
The output would be:
Going to change x
Old x = 5, new x = 6
Going to not change x.
End of program.
My question is how to implement the ChangeMonitor decorator class. In the
above example I assume it will print a line indicating the changes of an
attribute, but for useful purposes it could send notifications to
subscribed objects.

Android:: socket communication between pc and phone over wifi?

Android:: socket communication between pc and phone over wifi?

I have a working code in which i can exchange data between pc and android
emulator. Now, I want to test this application with a real android device.
i.e i want to exchange text between my pc in which i have a java server
and the android phone. For my emulator i was using the emulator virtual ip
address and it was working fine. But, to test my application in phone I
connected the phone and pc in same network and used the ip address of the
phone in my application. Then I installed the application in phone but the
connection did not established. How other changes is to be done in code to
use this application in phone. Here, is my android code,
try {
client = new Socket("10.0.2.2", 9999);
printwriter = new PrintWriter(client.getOutputStream(), true);
printwriter.println(messsage[0] + "\n");
System.out.println("messsage::"+messsage[0]);
printwriter.flush();
BufferedReader in = new BufferedReader(new
InputStreamReader(client.getInputStream()));
serverMessage = in.readLine();
if (serverMessage.equals("exit")) {
runOnUiThread(new Runnable() {
public void run() {
tv.setText("Thankyu visit again!!" + "\n");
}
}); }
else {
runOnUiThread(new Runnable() {
public void run() {
tv.setText(serverMessage.toString() + "\n");
}
});
}
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
Also, i have given this permission in my manifest file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
This is my first android app, So please help!!!

Saturday, 14 September 2013

Map edditor 'Tiled' will not export?

Map edditor 'Tiled' will not export?

I am working with Tiled on Fedora 19 64 bit. I installed Tiled via sudo
yum install tiled which installed Tiled version 0.9.1-1.
I have experience with Tiled on windows, so I created a simple map to test
if the install was working, but when I went to export the map (File >
Export as...), it came up with the error:

I have tried forcing a file extension onto the end of the exported name
(such as .txt), but nothing works. Do I need to install/create a file
exporter for Tiled in Linux? Or is there some config file I am missing?