Monday, 9 September 2013

How would I be able to duplicate my auto_increment? DATABASE PHP

How would I be able to duplicate my auto_increment? DATABASE PHP

Hey how would I be able to duplicate my only auto increment key to another
key, basically I want my (' id ') to display the same information on my ('
user_id '), here is the code:
CREATE TABLE IF NOT EXISTS `".$db_table_prefix."users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(10) NOT NULL,
`user_name` varchar(50) NOT NULL,
`username` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`id`)
How would I be able to input the same information from my id to my user_id?

playing with javascript function - object with naming and cloning

playing with javascript function - object with naming and cloning

I stunbled on this through stackoverflow and it is a great resource and
there is alot of conversation on this but i'm just still baffled why
certain things dont work?
I studied c++ in college and sorta remember pointers
http://www.permadi.com/tutorial/jsFunc/index2.html
my problems are started in the code certain things aren't working
function theAdd(a, b){
return a*b;
}
//creating a copy of the function
var add3 = new theAdd();
add3.name = 'nameProperty';
//alert( add3(1,2)) //why doesn't this work?
alert(theAdd(5,5) + " " + theAdd.name);
function Ball() {
return 'balltext';
}
var ball0=new Ball(); // ball0 now points to a new object
alert( Ball() ); // this works
alert( ball0() ); // why doesn't this work? shouldn't it return
balltext?

Count the total pairs of two characters in a string

Count the total pairs of two characters in a string

Basically I need to count the total number of agrupations inside a string,
this is to display some information like an advise of the total number of
opened submarked expressions in a RegularExpression application.
Then I need to count the total number of closed "()", not the total of "("
and the total of ")" separated.
For example in this string:
Hello (world)
The expected result would be: 1 closed
Here:
Hello (world) ((how are (you)?
The expected result would be: 2 closed and 2 opened
And here:
Hello ) ( World?
The expected result would be: 2 opened
Just pleae can something give me ideas of which can be the improved way to
calculate them?
I got the total amount of "(" and ")" characters, now I don't know what to
do.

onLoadFinished not called on offscreen fragment until going back

onLoadFinished not called on offscreen fragment until going back

I'm trying to implement List->Detail scheme with details pagination.
I've single Activity for ListView and different Activity with ViewPager.
In FragmentStatePagerAdapter.getItem i instatniate new fragment for page
and pass item id via setArguments Bundle.
After opening pager Activity two Fragment pages are created and onCreate,
onCreateView, onActivityCreated being called.
BUT
onLoadFinished is called only for first Fragment (currently visible). If i
go back onLoadFinished is called for second Fragment.
Strage thing is that when i swipe to second (onLoadFinished for third not
called), back to first and again go forward to second OnLoadFinished is
called for third fragment and every next - after going back and forward
always next fragment is being fully created in advance.
Is this bug or feature? How fully loading can be forced?

AJAX load in same page causes divs to repeat

AJAX load in same page causes divs to repeat

I'm performing the ajax call to the same page which works perfectly
however it reload existing divs. I was wondering if there was a way to
suppress it? Here's more details:
My project setup
index.php - Open records Controller
/**app logic**/
view('open',$data); //require '../views/layout.php';
layout.php
/*all the js scripts and stylesheets loaded here*/
<div id='logo'></div>
<div id='nav'></div>
include($path); //loads the open.view.php file
open.view.php
/*AJAX call to self*/
function getViaAjax(chosenGroup){
$.post('index.php',{group:chosenGroup},
function(data)
{
$("#default").remove();
$('#group-tickets').html(data);
});
}
As you might be able to tell, this causes the #logo and #nav div to
duplicate on the page. I understand that I can do a AJAX post to a
different file and I will get around the issue altogether but I was
wondering if there's a way to do this?

"CustomAnnotation is tapped" usage in MKMapView

"CustomAnnotation is tapped" usage in MKMapView

I need to put custom annotation views to mapview, and they need to be
clickable. i need rather than classic callout, i will tap on the
annotation and it will perform some functions.
I tried many things but still not achieved.

Sunday, 8 September 2013

Connecting Heroku to PGAdmin to Restore

Connecting Heroku to PGAdmin to Restore

In a unique situation here trying to hook up pgadmin to heroku.
I have created a rails 4 application and pushed it to my own heroku. It
imitates the clients previous project which had pushed to heroku on a
different repository.
So I've followed this answer: Connect to a heroku database with pgadmin
Successfully connected, but when clicking restore I get the following
error /Volumes/pgAdmin3/pgAdmin3.app/Contents/SharedSupport/pg_dump --host
ec2-54-243-234-148.compute-1.amazonaws.com --port 5432 --username
"objnjcsgcbwvje" --format tar --blobs --verbose --file "/Documents/cpr"
"d6oesvq4pk09d0" pg_dump: server version: 9.1.9; pg_dump version: 8.3.1
pg_dump: aborting because of version mismatch (Use the -i option to
proceed anyway.) pg_dump: * aborted because of error
Process returned exit code 1.
which means i have the wrong version of pgdump?