Hi,
I need to compare two files and redirect the different lines to third file. I know using diff command i can get the difference . But, is there any way of doing it in python ?
i am using two table postjob and job location
want to distinct jobtitle
The query is:
select postjob.jobtitle,
postjob.industry,
postjob.companyname,
postjob.jobdescription,
postjob.postid,
postjob.PostingDate,
Job_Location.Location,
Job_Location.PostigID
from postjob
inner join Job_Location
on postjob.postid = Job_Location.PostigID
Where postjob.industry=' Marketing, Advertising'
output of this query
http://www.justlocaldial.com/Industry_search.aspx?ind=Marketing,%20Advertising
I was reading this Sun's tutorial on Thread.
I found a block of code there which I think can be replaced by a code of fewer lines. I wonder why Sun's expert programmers followed that long way when the task can be accomplished with a code of fewer lines.
I am asking this question so as to know that if I am missing something that the tutorial wants to convey.
The block of code is as follows:
t.start();
threadMessage("Waiting for MessageLoop thread to finish");
//loop until MessageLoop thread exits
while (t.isAlive()) {
threadMessage("Still waiting...");
//Wait maximum of 1 second for MessageLoop thread to
//finish.
t.join(1000);
if (((System.currentTimeMillis() - startTime) > patience) &&
t.isAlive()) {
threadMessage("Tired of waiting!");
t.interrupt();
//Shouldn't be long now -- wait indefinitely
t.join();
}
}
threadMessage("Finally!");
I think that the above code can be replaced by the following:
t.start();
t.join(patience); // InterruptedException is thrown by the main method so no need to handle it
if(t.isAlive()) {
// t's thread couldn't finish in the patience time
threadMessage("Tired of waiting!");
t.interrupt();
t.join();
}
threadMessage("Finally!");
I'm trying construct a PostgreSQL query that does the following but so far my efforts have been in vain.
Problem:
There are two tables: A and B. I'd like to select all columns from table A (having columns: id, name, description) and substitute the "A.name" column with the value of the column "B.title" from table B (having columns: id, table_A_id title, langcode) where B.table_A_id is 5 and B.langcode is "nl" (if there are any rows).
My attempts:
SELECT A.name,
case when exists(select title from B where table_A_id = 5 and langcode= 'nl')
then B.title
else A.name
END
FROM A, B
WHERE A.id = 5 and B.table_A_id = 5 and B.langcode = 'nl'
-- second try:
SELECT COALESCE(B.title, A.name) as name
from A, B
where A.id = 5 and B.table_A_id = 5 and exists(select title from B where table_A_id = 5 and langcode= 'nl')
I've tried using a CASE and COALESCE() but failed due to my inexperience with both concepts.
Thanks in advance.
I have 2 databases with same tables. DBProduction and DBLocal both have testTable. How can i replace testTable of DBProduction with of DBLocal? There are some new rows inserted and some updated rows in testTable of DBLocal.
Using SQL Server 2008
I have a class called GraphicView that takes a Graphic object and draws it in its drawRect method. This Graphic object is basically an array of mutablePaths that comprise an icon that I want drawn. For performance and other issues, I was thinking of taking this icon that is comprised of mutablePaths, and dividing it into a bunch of CAShapeLayers.
I'm wondering is this possible? Considering the points for the mutablePaths of the icon are all interwoven together (ie the icon was initially an SVG file that I converted to code), is it possible to divide different parts of the icon into CAShapeLayers, and reassemble them all together when assigning to the views layer? If so how would it be done? If I assign them as sublayers to a CALayer or CAShapeLayer, will it understand to mesh them all together?
I used this code to connect to a database and fetch results. This worked perfectly until i tried to work in another query to the images table to get associated images. I'm not very experienced with OO programming. So hopefully someone can see where ive gone wrong and help me out.
<?php
global $__CMS_CONN__;
$sql = "SELECT * FROM ecom_products";
$stmt = $__CMS_CONN__->prepare($sql);
$stmt->execute(array($id));
while ($row = $stmt->fetchObject()) {
$imagesql = "SELECT * FROM ecom_product_images where id = $row->id && where primaryImage = '1'";
$imagestmt = $__CMS_CONN__->prepare($sql);
$imagestmt->execute(array($id));
$imageName = $imagestmt->fetchObject();
echo '<a href="'.URL_PUBLIC.$row->id.'">'.$row->productNm.'</a>'.$imageName;
}
?>
Drupal 6.x
I have this module that manages four different content types. For that matter, how do I define permission for each content within the same module? Is that even possible? I can't figure out how to define permission for each content type cuz hook_perm has to be named with module name and it doesn't have any argument(like hook_access $node) to return permission base on content type.
Any help would be highly appreciated.
Hi,
I have a model I named User, and I want use two different Views to edit it: the usual edit view and another view I called edit_profile.
I had no problem in creating routing, controller and views: I added edit_profile and update_profile views, and I added on routes.rb the line:
map.resources :users ,:member => {:edit_profile => :get, :update_profile => :put}
The problem is: when I submit the form in edit_profile and some error occur in some input fields, rails reload the edit_path page instead of edit_profile_path page !
This is the form on edit_profile.html.erb
form_for(:user, @user, :url => {:action => :update_profile}, :html => { :method => :put} ) do |f|
= f.text_field :description
= f.text_area :description
= f.error_message_on :description
....
....
= f.submit 'Update profile'
After clicking Update profile, if input errors occur I want to show edit_profile view instead of edit view
Do You have some ideas ?
many thanks
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
I will take two numbers from user, but this number from EditText must be converted to int. I think it should be working, but I still have problem with compilation code in Android Studio.
CatLog show error in line with:
int wiek = Integer.parseInt(wiekEditText.getText().toString());
Below is my full Android code:
public class MyActivity extends ActionBarActivity {
int Wynik;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
int Tmax, RT;
EditText wiekEditText = (EditText) findViewById(R.id.inWiek);
EditText tspoczEditText = (EditText) findViewById(R.id.inTspocz);
int wiek = Integer.parseInt(wiekEditText.getText().toString());
int tspocz = Integer.parseInt(tspoczEditText.getText().toString());
Tmax = 220 - wiek;
RT = Tmax - tspocz;
Wynik = 70*RT/100 + tspocz;
final EditText tempWiekEdit = wiekEditText;
TabHost tabHost = (TabHost) findViewById(R.id.tabHost); //Do TabHost'a z layoutu
tabHost.setup();
TabHost.TabSpec tabSpec = tabHost.newTabSpec("Calc");
tabSpec.setContent(R.id.Calc);
tabSpec.setIndicator("Calc");
tabHost.addTab(tabSpec);
tabSpec = tabHost.newTabSpec("Hints");
tabSpec.setContent(R.id.Hints);
tabSpec.setIndicator("Hints");
tabHost.addTab(tabSpec);
final Button Btn = (Button) findViewById(R.id.Btn);
Btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"blablabla"+ "Wynik",Toast.LENGTH_SHORT).show();
}
});
wiekEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Btn.setEnabled(!(tempWiekEdit.getText().toString().trim().isEmpty()));
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
I have a need to have a running JVM start another JVM and then exit. I'm currently trying to do this via Runtime.getRuntime().exec(). The other JVM starts, but my original JVM won't exit until the "child" JVM process stops. It appears that using Runtime.getRuntime().exec() creates a parent-child relationship between the processes. Is there some way to de-couple the spawned process so that the parent can die, or some other mechanism to spawn a process without any relationship to the creating process?
Note that this seems exactly like this question: http://stackoverflow.com/questions/2566502/using-java-to-spawn-a-process-and-keep-it-running-after-parent-quits but the accepted answer there doesn't actually work, at least not on my system (Windows 7, Java 5 and 6). It seems that maybe this is a platform-dependent behavior. I'm looking for a platform independent way to reliably invoke the other process and let my original process die.
Table:
DayOfWeek Enrollments
Monday 35
Monday 12
Saturday 25
Tuesday 15
Monday 9
Tuesday 15
Basically I'm trying to sum the total enrolments for each day.
so the Output will look like:
DayOfWeek Enrollments
Monday 56
Saturday 25
Tuesday 30
I've spent around 4 hours trying to work this out trying many many different ways but no luck.
The problem I'm having is i can count how many enrollments for each day but can't have it aligned with the correct day when i run the query e.g. I want The total to be on the same line as the day it was calculated from. (I hope that is clear enough)
Is there a way to initialize an array of primitives, say a integer array, to 0? Without using a for loop? Looking for concise code that doesn't involve a for loop.
:)
Im trying to combine the name field, and msg field, and input all values into #msg, but cant quite get it to work
$('#DocumentCommentsForm_21').bind('submit', function(){
var name = "##" + $('#navn').val() + "##";
var msg = $('#msg').val();
$('#msg').val(name+' '+msg);
});
alert($('#msg').val(name+' '+msg));
i have a table named locations of which i want to select and get values in such a way that it should select only distinct values from a column but select all other values .
table name: locations
column names 1: country values : America, India, India, India
column names 2: state/Province : Newyork, Punjab, Karnataka, kerala
when i select i should get India only once and all the three states listed under India . is ther any way..??? sombody please help
I have a common data schema in XSD that is used by two different applications, A and B, each uses the data differently. I want to document the different business rules per application. Can I do this?
<xs:complexType name="Account">
<xs:annotation app="A">
<xs:documentation>
The Account entity must be used this way for app A
</xs:documentation>
</xs:annotation>
<xs:annotation app="B">
<xs:documentation>
The Account entity must be used this way for app B
</xs:documentation>
</xs:annotation>
<xs:complexContent>
...
Hello,
I 've got a table field (membername) which contains both the last name and the first name of users. Is it possible to split those into 2 fields (memberfirst - memberlast)? All the records have this format "Firstname Lastname" (without quotes and a space in between).
Hi. I am using a PostgreSQL database, and in a table representing some measurements I've two columns: measurement, and interpolated. In the first I've the observation (measurement), and b is the interpolated value depending on nearby values. Every record with an original value has also an interpolated value. However, there are a lot of records without "original" observations (NULL), hence the values are interpolated and stored in the second column. So basically there are just two cases in the database:
Value Value
NULL Value
Of course, it is preferable to use the value from the first column if available, hence I need to build a query to select the data from the first column, and if not available (NULL), then the database returns the value from the second column for the record in question. I have no idea how to build the SQL query.
Please help. Thanks.
For instance, I needed to remove column 25 and replace it with a copy of column 22 in a simple csv file with no embedded delimiters. The best I could come up with was the awkward looking:
awk -F, '{ for(x=1;x<25;x++){printf("%s,", $x)};printf("%s,",$22);for(x=26;x<59;x++){printf
("%s,", $x)};print $59}'
I would expect something like
cut -d, -f1-24,23,26-59
to work but cut doesn't seem to want to print the same column two times...
Is there a more elegant way to do it using anything typicaly available in a linux shell environment?
I just want to toggle some elements when a link is clicked:
This is how i am trying (But i don't really think that it matters much for this question what's inside the event function callback):
/* mostrar exceso de comentarios a peticion del usuario*/
$('.toggleComments').click(function(){
console.log('.toggleComments');
if($(this).parents('.helpContent').find('.commentHideble:visible').length > 0){
$(this).text('+ <?=get_texto_clave('show_old_comments')?>').removeClass('toggleCommentsActive').append(' ('+$(this).parents('.helpContent').find('.commentHideble:not:visible').length+'+)');
}else{
$(this).text('- <?=get_texto_clave('hide_old_comments')?>').addClass('toggleCommentsActive');
}
$(this).parents('.helpContent').find('.commentHideble').slideToggle(100);
});
I even tried a boolean but gave me same result
/* mostrar exceso de comentarios a peticion del usuario*/
var ctoggle = false;
$('.toggleComments').click(function(){
if(ctoggle == false){
ctoggle = true;
console.log('.toggleComments');
if($(this).parents('.helpContent').find('.commentHideble:visible').length > 0){
$(this).text('+ <?=get_texto_clave('show_old_comments')?>').removeClass('toggleCommentsActive').append(' ('+$(this).parents('.helpContent').find('.commentHideble:not:visible').length+'+)');
}else{
$(this).text('- <?=get_texto_clave('hide_old_comments')?>').addClass('toggleCommentsActive');
}
$(this).parents('.helpContent').find('.commentHideble').slideToggle(100);
ctoggle = false;
}
});
Why the log is being fired twice by click?
I have the basic html structure:
<table>
<tbody>
<tr class="1">
<td>
<p style="font-size:large">
<span class="muted"> This is the first object </span>
</p>
</td>
</tr>
<tr class="2">
<td>
<p style="font-size:large">
<span class="muted"> This is second object </span>
</p>
</td>
</tr>
<tr class="3">
<p style="font-size:large">
<span class="muted"> this is the third object </span>
</p>
</td>
</tr>
</tbody>
</table>
and then I have check boxes, the functionality i want is,
if checkbox 1 is checked, only the tr with class 1 be displayed.
if checkbox 2 and 3 are clicked, the tr with class 1 gets hidden and 2, 3 show in the dom.
again if checkbox 2,*3* are unchecked and 1 is checked tr with class 2, 3 do not show and 1 is showed.
How can this be done in jQuery?
Hello,
I'm having trouble identifying a plugin (or perhaps is not even a plugin), but can you tell me what plugin outputs the section at the bottom of the post that has the headers: "Did you like this article?" and "Related Posts", and has a list of bookmarking links, and a list of posts respectively.
Image of the stuff I'm referring to:
Example URL: http://www.escapefromcorporate.com/networking-tools-and-help-upmo/
Thanks!
I am trying to parse a string which in JSON format only that keys are not enclosed in quotes. I can very well parse this string in Javascript, but can not find a Java API which will help me parse this. All the APIs I tried assumes strict JSON format.
Can anyone suggest a library which has an option to parse this, or a whole new approach to the problem (say like use regex instead) ?