Home » Web Development » Page 2

I have a DataFrame (coordinates):



    X   Y   Z
0 11 44 77
1 22 55 88
2 33 66 99


I need to get Y and Z columns values to a list.
If I do something like:



centers = [df['Y'], df['Z']]


or



Y = [df['Y']]


I got a list with index columns like:



print Y

0 44
1 55
2 66


How to create a list without indexes values (0,1,2)?

Now I'm doing it like this, is it correct? Any risks? Thanks in
advance.



-(void)setNetworkStatus:(unsigned int)object{
objc_setAssociatedObject(self, @selector(networkStatus),
@(object), OBJC_ASSOCIATION_ASSIGN);
}

-(unsigned int)networkStatus{
return (unsigned int)[objc_getAssociatedObject(self,
@selector(networkStatus)) integerValue];
}


I have changed OBJC_ASSOCIATION_ASSIGN to
OBJC_ASSOCIATION_RETAIN_NONATOMIC in my code. Is there any
problem?

below is the script where i am trying to validate if the same name,
id and email exists in a table, the problem is that even if i add a
new input for each field i still get a "data already exist", how do i
fix this issue, also how to validate using regular expression for each
fields..for id i need three letters and 3 numbers using regular
expression



if(isset($_POST['register'])){

//Retrieve the field values from our registration form.
$name = !empty($_POST['name']) ? trim($_POST['name']) : null;
$ccode = !empty($_POST['id']) ? trim($_POST['id']) : null;
$email = !empty($_POST['email']) ? trim($_POST['email']) : null;

$sql = "SELECT COUNT(*) AS num FROM users";
$stmt = $pdo->prepare($sql);


$stmt->bindValue(':name', $name);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':email', $email);

$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);


if($row['num'] > 0){
die('The Data already exists!');
}

else{

$sql = "INSERT INTO users (name, id, email) VALUES (:name, :id,
:email)";
$stmt = $pdo->prepare($sql);


$stmt->bindValue(':name', $name);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':email', $email);


$result = $stmt->execute();


if($result){
echo 'User aadded successfully!';
}
}
}


<form action="sign.php" method="post">
<label for="name">Name</label>
<input type="text" id="name" name="name" required><br>
<label for="id">id</label>
<input type="text" id="" name="id" required><br>
<label for="email">Email</label>
<input type="email" id="email" name="email" required><br>
<input type="submit" name="register" value=" Click to
Add"></button>
</form>


and how do i validate if the fields have same name., for example i
have 3 input fields, in the first field i enter the name of a person
and in the second or third field if i enter the same name an error
should display when i click the submit button, can it be done using a
for loop to check each field if it contains the same name

I have a file it has 7 columns and lacks of raws its date column
format and number of date columns are dynamic, maybe one or two or
three columns, date formats are DD-MON-YYYY HH24:MI or
DD-MM-YYYY HH:MI or DD/MON/YYYY HH:MI
etc..



file.txt



OIEX19|BANG37748|DEL37728|WUBXDE|200010291010|201209111625|195210290000
SEETA7|CHA38228|DEL37728|DGSDFE|201211190705|201308071912|195210291010
PRIYS3|ANK37748|DEL37728|KEJRSRC|196004080910|201407061815|195210292110


In the above column 5 and column 7 are date columns



User input date format is DD-MON-YYYY HH:MI



Desired output:



file.txt



OIEX19|BANG37748|DEL37728|WUBXDE|29-10-2000 10:10
AM|201209111625|29-10-1952 12:00 AM
SEETA7|CHA38228|DEL37728|DGSDFE|19-11-2012 07:05
PM|201308071912|29-10-1952 10:10 PM
PRIYS3|ANK37748|DEL37728|KEJRSRC|08-04-1960 09:10
AM|201407061815|29-10-1952 9:10 PM


How can I achieve it using awk?

I am a beginner in programming. I was messing around with java
swing and tried to make a silly app. This is my code. It's not showing
any errors, but it's not working. When the dialog pops up, the
variable's value doesn't show on the dialog. The logic i used is
right, because when i run it in the compiler without the GUI stuff, it
works perfectly. If anyone could tell what am i doing wrong in here,
it would be really helpful.



this is my code for the calculations.



import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JOptionPane;

public class swingApp extends JFrame{
JLabel label;
JButton button;
public JLabel label2;
JTextField textField = new JTextField("enter you nicknamae");
String username=textField.getText();
public int geniusMeter;
public int sum=0;
public String sumAsString;
public void swingAppLogic(String name){
char[] letters = username.toCharArray();
char []
alphabet={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int []
measure={7,3,1,13,8,26,15,18,2,5,22,20,16,9,5,11,23,12,25,6,4,21,24,14,17,10};

for(int count=0;count<letters.length;count++){
for (int count1=0;count1<alphabet.length;count1++){
if (letters[count]==alphabet[count1]){
geniusMeter=measure[count1];
sum=sum+geniusMeter;
break;
}
}
}
sumAsString = Integer.toString(sum);

}

public swingApp(){
super("Genius Calculator");
setLayout(new FlowLayout());
label = new JLabel("Wanna know how genius you are?");
label2 = new JLabel(" ");
button = new JButton("press enter and then click me to know
the results");
handlerClass handler = new handlerClass();
button.addActionListener(handler);
add(label);
add(label2);
add(button);
add(textField);
}
public class handlerClass implements ActionListener{
public void actionPerformed(ActionEvent event){
JOptionPane.showMessageDialog (null, sumAsString, "Title",
JOptionPane.INFORMATION_MESSAGE);

}
}
}


and this is my main method



import javax.swing.JFrame;

public class swingAppTester{
public static void main (String [] args){
swingApp object=new swingApp();

object.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
object.setSize(500,400);
object.setVisible(true);
}
}

How can I print a pdf file displayed inside iframe directly to
printer from Firefox/IE?



The following code works in chrome/opera well,but not in IE and
Firefox.





function printIframe(objFrame) {
objFrame.focus();
objFrame.print();
}

<iframe  id="pdfreport"
name="pdfreport" src="1.pdf" width="100%;" height="80%">
</iframe>
<button type="button" style="float: right" name="btnprint"
onclick='printIframe(pdfreport);'>Print</button>



I recently started learning python.
So I wrote some small code, this code asks for 2 sizes of lists,
creates 2 lists with random integers from 0-9 and then spits out the
intersection between two lists.



The last "for" loop - I had trouble with it because at first my
"intersection" list had repetitions, then I looked up for an answer
and got what I have now, it works, however I don't know why. My
problem is grasping how "for i in l1 and in l2" works?
I know that "for i in range(k)" is going through the numbers 0-k but
this strange for loop with the "and" operator just puzzles me.



l1 = []
l2 = []
C = []
s1 = int(input("Your 1st list size->"))
s2 = int(input("Your 2nd list size->"))
for i in range(s1):
from random import randint
k = (randint(0,9))
l1.append(k)
print("First List ->" , l1)
for i in range(s2):
from random import randint
k = (randint(0,9))
l2.append(k)
print("Second List ->" , l2)
for i in l1 and l2:
if i in l1 and l2:
C.append(i)

print("Intersection ->" , C)


Please let me know if there is another place to submit such
questions(if here is not for suitable).

I have to check whether the words from File1 exist in File2 or not
and then count. Data in both files is shown below.



The words in File1 are like shown below:




  1. 发表

  2. 发愁

  3. 发达

  4. 发抖

  5. 发挥



The data in File2 is like shown below:




  1. 这篇论文是什么时候发表的?

  2. 91 .数据 删掉 被马工程师 了

  3. 92 .驾驶 酒后 很大 危害

  4. 93 .客观地 要 他人 评价

  5. 94 .我不小心 水壶 打翻 了 把



The code I have written is as follows:



File file1 = new File("ChineseWord.txt");
Scanner sc = new Scanner(new FileInputStream(file1));
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> newList = new
ArrayList<String>();

while(sc.hasNext()){
list.add(sc.next());
}

sc.close();

File file2 = new File("RandomData.txt");

Scanner newScanner = new Scanner(new FileInputStream(file2));

int count = 0;

for (int i = 0; i < list.size(); i++) {

while(newScanner.hasNext()){

String word = newScanner.nextLine();
String toMatch = list.get(i);

if(word.contains(toMatch)){
System.out.println("Success");
count++;
}


}

String test = list.get(i);
newList.add(test+"exists" + count+ "times");
count =0;

}


The question is that it returns 0 for all words whereas the very
first word in File1 exists in the very first line of File2. If I
manually do something like this



if(word.contains("发表")){
System.out.println("Success");
count++;
}


It prints successs otherwise it does not ? Why is this so?

I have a problem that i make a spring mvc based web application in
which multiple user wants to access my application simultaneously to
perform operation. I used some global constant in which i assign
ip,port and other information for a particular user like
CAConstant.IP, CAConstant.PORT etc.I use these constant in different
class to perform operation based on particular user.The problem is
that when multiple user access application concurrently then last user
overwrite the global content of previous one that create conflict in
final report(when my main function was not synchronized).So my problem
is how can i resolve this problem or how we can allow multiple user to
access same web application concurrently using thread in java.

I have a dropdown in the login page which fetches company codes and
it's respective ID as value. I need to store this particular value
(ID) in a session variable so I may use it throughout site. So that
when that particular company is selected I may be able to view the
details of that particular company. If there is an alternate method
for this, kindly let me know.



MODEL:



public function login ()
{
$user = $this->get_by(array(
'company_id' => $this->input->post('company_id'),
'username' => $this->input->post('username'),
'password' =>
$this->hash($this->input->post('password')),
), TRUE);

$this->session->set_userdata($user);
if (count($user)) {
// Log in user
$data = array(
'username' => $user->username,
'id' => $user->id,
'loggedin' => TRUE,
'is_admin' => $user->is_admin,
'company_id' => $user->company_id
);
$this->session->set_userdata($data);
return TRUE;
}

}


VIEW:



<tr>
<td>Location</td>
<td><select class="form-control" id="company_code"
name="company_code" required>
<option value="0" selected>Select
Company</option>
<?php foreach($locations as $location){
$selected =
$user->company_id==$location->company_id?"selected='selected'":'';
echo "<option $selected
value='".$location->company_id."'>".$location->company_code."</option>";
}?>
</select>
</td>
</tr>
<tr>
<td>Username</td>
<td><?php echo
form_input('username','','class="form-control" placeholder="Enter User
Name"'); ?></td>
</tr>
<tr>
<td>Password</td>
<td><?php echo
form_password('password','','class="form-control" placeholder="Enter
Password"'); ?></td>
</tr>
<tr>
<td></td>
<td><?php echo form_submit('submit', 'Log in',
'class="btn btn-primary"'); ?></td>
</tr>


I want the above company_id to be posted into a
session variable so it maybe used throughout the program. Any help
will be greatly appreciated.


- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow