Title,Body,Tags,Quality
How to get all the child records from different tables based on given parent ID in sql server,"I am having 4 different tables like
select * from System
select * from Set
select * from Item
select * from Versions
Now for each system Id there will be **n no.of Sets**, and foe **each set** there qill be **n no. of Items** and for **each item** there will be **n no.of Versions**.
**each system has
n no of set
each Set has
n no of Items
each Item has
n no of Versions**
So, Now when i give **SystemId** then i have to retrieve all the records from
**Set and Items of each set and Versions of each Items** in single storedprocedure.",,LQ_EDIT
Retrieve all except some data of the another table,"I have two table m_master and tbl_appointment
[This is tbl_appointment table][1]
[This is m_master table][2]
[1]: http://i.stack.imgur.com/c7f7y.png
[2]: http://i.stack.imgur.com/hD6Qf.png",,LQ_EDIT
Pandas: read_html,"
I'm trying to extract US states from wiki URL, and for which I'm using Python Pandas.
import pandas as pd
import html5lib
f_states = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
if flavor in ('bs4', 'html5lib'):
662 if not _HAS_HTML5LIB:
--> 663 raise ImportError(""html5lib not found, please install it"")
664 if not _HAS_BS4:
665 raise ImportError(""BeautifulSoup4 (bs4) not found, please install it"")
ImportError: html5lib not found, please install it
I installed html5lib and beautifulsoup4 as well, but it is not working.
Can someone help pls.
",,HQ
Reader Always gimme NULL,"I'm so new to C#, I wanna make an application that can easily connect to the SqlServer database, I have a separated DBConnection class, and I want to call this class from any form.
the problem is my ""reader"" always give Null
class DBconnection
{
private SqlConnection conn;
private SqlCommand cmd;
private SqlDataReader rdr;
private DataTable dt;
private SqlConnection MyConnection
{
get
{
if (this.conn == null)
{
this.conn = new SqlConnection(DrivingSchool.Properties.Settings.Default.cdsConnectionString);
}
return conn;
}
}
private SqlCommand MyCommand
{
get
{
if (cmd == null)
{
cmd = new SqlCommand();
MyCommand.Connection = conn;
}
return cmd;
}
}
public DataTable RunQuery(string query)
{
dt = new DataTable();
MyCommand.CommandText = query;
MyCommand.Connection = conn;
MyConnection.Open();
rdr = MyCommand.ExecuteReader(CommandBehavior.CloseConnection);
if(rdr.HasRows)
{ dt.Load(rdr); }
MyConnection.Close();
return dt;
}
}",,LQ_EDIT
php rearrange array elements based on condition,"basically i have this array:
array(
'08:00-08:40' => array(
't' => '39',
'sub' => 'COMP'
),
'08:40-09:20' => array(
't' => '17',
'sub' => 'KIS'
),
'09:20-10:00' => array(
't' => '36',
'sub' => 'B/ST'
),
'10:20-11:00' => array(
't' => '7',
'sub' => 'ENG'
),
'11:00-11:40' => array(
't' => '36',
'sub' => 'B/ST'
),
'11:40-12:20' => array(
't' => '31',
'sub' => 'HIS'
),
'12:20-13:00' => array(
't' => '26',
'sub' => 'PHY'
),
'14:00-14:40' => array(
't' => '33',
'sub' => 'GEO'
),
'14:40-15:20' => array(
't' => '31',
'sub' => 'HIS'
),
'15:20-16:00' => array(
't' => '20',
'sub' => 'BIO'
)
)
My requirement is that if an **element['sub']** appears twice in the whole array then both instances should be next to each other in the array.
so for the above array i expect to have the following output:
array(
'08:00-08:40' => array(
't' => '39',
'sub' => 'COMP'
),
'08:40-09:20' => array(
't' => '17',
'sub' => 'KIS'
),
'09:20-10:00' => array(
't' => '36',
'sub' => 'B/ST'
),
'11:00-11:40' => array(
't' => '36',
'sub' => 'B/ST'
),
'10:20-11:00' => array(
't' => '7',
'sub' => 'ENG'
),
'11:40-12:20' => array(
't' => '31',
'sub' => 'HIS'
),
'14:40-15:20' => array(
't' => '31',
'sub' => 'HIS'
),
'12:20-13:00' => array(
't' => '26',
'sub' => 'PHY'
),
'14:00-14:40' => array(
't' => '33',
'sub' => 'GEO'
),
'15:20-16:00' => array(
't' => '20',
'sub' => 'BIO'
)
)
i cant figure out how to adapt [this solution][1] to my case..any help much appreciated
[1]: http://stackoverflow.com/questions/3286006/reposition-array-elements-based-on-a-condition-in-php",,LQ_EDIT
How do I make a constructor for a derived class?,"
I am trying to make a constructor for a derived class. Doing it this way doesn't seem to work:
#include <iostream>
class FirstClass
{
public:
int X;
FirstClass(int x)
{
this->X = x;
}
int getXpow() { return pow(X, 2); }
};
class SecondClass : FirstClass
{
public:
SecondClass(int x)
{
FirstClass::FirstClass(X);
}
int getXpow() { return pow(X, 3); }
};
int main()
{
using namespace std;
FirstClass FCobj(3);
cout << FCobj.getXpow() << endl;
SecondClass SCobj(3);
cout << SCobj.getXpow() << endl;
system(""pause"");
return 0;
}
because it says at the first { bracket of SecondClass(int x) the following thing Error: no default constructor exists for class ""FirstClass"". And how does constructor inheritance even work?
",,LQ_CLOSE
how can i create a dynamic tow dimensional array in c++?,"I am using c++ in my lesson and for solving a program i should create an array that may be change in dimensions.
for example:
{
int I,J;
cin>>I;
cin>>J;
double X[I][J];
double B[I][J];
}",,LQ_EDIT
Re-exporting ES6 modules in TS 1.7?,"
I'm getting a bit lost in TS re-exports. Say I create a pair of test modules;
test1.ts;
export function test1() {
return 'test';
}
test2.ts;
export function test2() {
return 'test';
}
I believe I should be able to then do something like this;
combined.ts;
export * from './test1';
export * from './test2';
module.exports = {
test1: test1,
test2: test2
};
But, no such luck. There seem to be lots of GitHub issues discussing various approaches to this, including an old hack using export import * from './test1' but they all seem to argue what the ES6 spec really means, and none actually work..
What's the right way to do a rollup like this? Am I just going down the wrong path to split a module up across files? Are namespaces more appropriate here?
",,HQ
Fetch API with Cookie,"
I am trying out the new Fetch API but is having trouble with Cookies. Specifically, after a successful login, there is a Cookie header in future requests, but Fetch seems to ignore that headers, and all my requests made with Fetch is unauthorized.
Is it because Fetch is still not ready or Fetch does not work with Cookies?
I build my app with Webpack. I also use Fetch in React Native, which does not have the same issue.
",,HQ
Print list content in a given order,"
lt = ['7,777.7', '777.7', '77,777.7', '77.7']
How can I proceed to print the list content like this ?
7,777.7
777.7
77,777.7
77.7
",,LQ_CLOSE
c# - List all primes upto 100,"Written the below code trying to identify all primes up 100. It's outputting 1,2 and 5. Can anyone see any reason why it wouldn't continue past the first 3?
I know there's some efficiency tweaks I can do (only odds numbers etc) but just trying to get the core (overkill) concept down first. I'm a complete noob just trying to enhance my intuition with programming so I know it's probably not the most elegant solution but more interested in why it doesn't work.
Appreciate any help.. HAPPY NEW YEAR!
static void Main(string[] args)
{
int q = 100;
for (int i = 1; i < q; i++)
{
if ((q % i) == 0)
{
bool isPrime = true;
for (int j = 2; j < i; j++)
{
if ((i % j) == 0)
{
isPrime = false;
}
}
if (isPrime == true)
{ Console.WriteLine(i + "" is a prime number... hopefully.""); }
}
}
Console.ReadKey();
}",,LQ_EDIT
Angular2 exception: Token must be defined,"
app/boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
bootstrap(AppComponent);
app/app.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: '{{title}}'
})
class AppComponent {
title: ""app""
}
Error:
EXCEPTION: Token must be defined!
STACKTRACE:BrowserDomAdapter.logError @ angular2.dev.js:23514
ExceptionHandler.call @ angular2.dev.js:1147
(anonymous function) @ angular2.dev.js:14801
NgZone._notifyOnError @ angular2.dev.js:5796
collection_1.StringMapWrapper.merge.onError @ angular2.dev.js:5700
run @ angular2-polyfills.js:141
(anonymous function) @ angular2.dev.js:5719
NgZone.run @ angular2.dev.js:5681
ApplicationRef_.bootstrap @ angular2.dev.js:14906
bootstrap @ angular2.dev.js:25054
execute @ boot.ts:4
u @ system.src.js:4597
execute @ system.src.js:4597
y @ system.src.js:4597
...
",,HQ
Form Validation project,"
I am working on a project for my company and we are not allowed to alter the HTML in any way. There is already a Page set up in the Using html to do Data Validation. There are to separate forms of validation questions on the page and each form contains its own ""submit"" button. Although both submit buttons have the same ""id"". is there any way to figure out how isolate each button to apply a different "".onclick"" method to them. Thanks in advance.
",,LQ_CLOSE
Most Pythonic way to kill a thread after some period of time,"
I would like to run a process in a thread (which is iterating over a large database table). While the thread is running, I just want the program to wait. If that thread takes longer then 30 seconds, I want to kill the thread and do something else. By killing the thread, I mean that I want it to cease activity and release resources gracefully.
I figured the best way to do this was through a Thread()'s join(delay) and is_alive() functions, and an Event. Using the join(delay) I can have my program wait 30 seconds for the thread to finish, and by using the is_alive() function I can determine if the thread has finished its work. If it hasn't finished its work, the event is set, and the thread knows to stop working at that point.
Is this approach valid, and is this the most pythonic way to go about my problem statement?
Here is some sample code:
import threading
import time
# The worker loops for about 1 minute adding numbers to a set
# unless the event is set, at which point it breaks the loop and terminates
def worker(e):
data = set()
for i in range(60):
data.add(i)
if not e.isSet():
print ""foo""
time.sleep(1)
else:
print ""bar""
break
e = threading.Event()
t = threading.Thread(target=worker, args=(e,))
t.start()
# wait 30 seconds for the thread to finish its work
t.join(30)
if t.is_alive():
print ""thread is not done, setting event to kill thread.""
e.set()
else:
print ""thread has already finished.""
I searched for the cause of this error and found that I have to change permissions or run gulp using sudo, but still got the same error.
Can anyone please help...
Error: spawn EACCES
at exports._errnoException (util.js:870:11)
at ChildProcess.spawn (internal/child_process.js:298:11)
at exports.spawn (child_process.js:362:9)
at exports.execFile (child_process.js:151:15)
at ExecBuffer. (/var/www/conFusion/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/exec-buffer/index.js:91:3)
at /var/www/conFusion/node_modules/gulp-rev/node_modules/vinyl-file/node_modules/graceful-fs/graceful-fs.js:42:10
at /var/www/conFusion/node_modules/gulp-cache/node_modules/cache-swap/node_modules/graceful-fs/graceful-fs.js:42:10
at /var/www/conFusion/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/vinyl-fs/node_modules/graceful-fs/graceful-fs.js:42:10
at FSReqWrap.oncomplete (fs.js:82:15)
",,HQ
Filter Name with Starting Letter in C#,"here is my code for select details by checking the name given.
here I want to do name filter by starting letter also.. how can I do it?
select * from tblcustomer
where
customername=case @customername
when null then customername
else @customername",,LQ_EDIT
Django ImageField upload_to path,"
I'm having trouble understanding and using Django's ImageField.
I have a model:
class BlogContent(models.Model):
title = models.CharField(max_length=300)
image = models.ImageField(upload_to='static/static_dirs/images/')
description = models.TextField()
When I run the server and go to the Admin page, I can add BlogContent objects. After choosing an image for the image field, the image has a temporary name. However, after I save this object I can't find the image in the folder specified by the upload_to path.
What is the correct way to do this?
",,HQ
Compiling SASS in Windows 7,
I'm planning to use SASS in making a website instead of CSS. I'm trying to compile a SASS file to CSS. Should I use an application to do so? Or should I use just command prompt?
,,LQ_CLOSE
to get or set the values of controls of a form froma class file,"I am new here,
i need to ask that, how can i get the value of a textbox and store it outside the FORM.cs, and to get that value to show it on a label...
it is just for test application.. i want to code that is independent from GUI.
thanks for your help in advance.
here is what i was trying...
In Form.cs
private void button4_Click(object sender, EventArgs e)
{
cueTextBox2.Text = value;
Calling cal = new Calling();
cal.setntags(value);
}
in Calling.cs
public string setntags(string value)
{
value = tag1;
MessageBox.Show(""done"");
return tag1;
}
i am new in coding.. please help me,.",,LQ_EDIT
i am new to pythn and was trying to fix indentation error : this is my code class Cylinder(object):,"class Cylinder(object):
self.pi = 3.14
def __init__(self,height=1,radius=1):
self.height = height
self.radius = radius
def volume(self):
return self.pi * self.radius**2 * self.height
def surface_area(self):
pass",,LQ_EDIT
I cant UPDATE datetime to MySQL,"
I need a little help.
I'm try to UPDATE a datetime to MySQL, but it didn't work.
After this i want to UPDATE, but in MySQL is still blank always.
UPDATE:
mtquery(""UPDATE table SET end_time = "".$time."" WHERE id = "".$table['id']."""");
If i use NOW() instead of "".$time."", it works perfectly.
If someone can help, please write the solution.
Thanks,
KoLi
",,LQ_CLOSE
How to correctly share JAX-RS 2.0 client,"
To give a little context to my issue...
I have a Java EE web application (as a UI / client) that accesses services for data / business logic via a REST interface using the JAX-RS 2.0 client API (Resteasy implementation).
Currently I inject a new JAXRS Client instance per request using a RequestScoped CDI managed bean, the thinking being that the client app may call multiple backend resources per request and I reuse the same JAXRS Client for the whole request (although I read somewhere this may not be correct as I am potentially changing the URI for each invocation)
The documentation for JAXRS Client seems to suggest that the client is a potentially expensive operation and the app should limit the amount of connections it creates. It also seems to contradict itself and suggest the client should be closed once all the requests to a particular WebTarget are finished.
The client application could potentially support thousands of simultaneous users so creating and destroying thousands of 'expensive clients' does not seem to be the correct approach so am thinking a shared client pool is more appropriate but there doesn't seem to be any information on how this should be achieved.
All examples appear to show creating a new client for the request and a) closing it after or b) not closing it but not really explaining what happens on a second request.
Can you help provide some answers on how you think this would be solved or information on what the best practice for this approach is.
Thanks.
",,HQ
argument of type'NoneType' is not itrable,"I want to build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in alphabetical order.
But when I add sting to list ,it shows ""argument of type'NoneType' is not itrable"".What' worry?
fh = (""But soft what light through yonder window breaks""
""It is the east and Juliet is the sun""
""Arise fair sun and kill the envious moon""
""Who is already sick and pale with grief"")
lst = list()
for line in fh:
words = line.split()
for word in line:
if word not in lst:
lst = lst.append(word)
lst.sort()
print lst",,LQ_EDIT
I am getting a StringIndexOutOfBoundsException when I attempt to use array parts from the children classes,"//Ticket parent class
import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
public class Ticket
{
public Ticket()
{
seatArray = new ArrayList();
}
public void loadIn()
{
//generic seating for plays and concerts
seatArray.add(new TicketObject(""A1"", 40));
seatArray.add(new TicketObject(""A2"", 40));
seatArray.add(new TicketObject(""A3"", 40));
seatArray.add(new TicketObject(""A4"", 40));
seatArray.add(new TicketObject(""A5"", 40));
seatArray.add(new TicketObject(""B1"", 35));
seatArray.add(new TicketObject(""B2"", 35));
seatArray.add(new TicketObject(""B3"", 35));
seatArray.add(new TicketObject(""B4"", 35));
seatArray.add(new TicketObject(""B5"", 35));
}
public String getSeats(int x)
{
return seatArray.get(x).getName() + "" $"" + seatArray.get(x).getPrice();
}
protected ArrayList seatArray;
}
//Concert ticket child class
import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
public class ConcertTicket extends Ticket
{
public ConcertTicket()
{
super();
}
public void loadIn()
{
super.loadIn();
//Special option for concerts
seatArray.add(new TicketObject(""Backstage Pass"", 100));
seatArray.add(new TicketObject(""Backstage Pass"", 100));
seatArray.add(new TicketObject(""Backstage Pass"", 100));
seatArray.add(new TicketObject(""Backstage Pass"", 100));
seatArray.add(new TicketObject(""Backstage Pass"", 100));
}
}
//Play ticket child class
import java.util.ArrayList;
import java.util.Scanner;
import java.io.*;
public class PlayTicket extends Ticket
{
public PlayTicket()
{
super();
}
public void loadIn()
{
super.loadIn();
//Specialized seating for plays
seatArray.add(new TicketObject(""Box 1"", 150));
seatArray.add(new TicketObject(""Box 2"", 150));
seatArray.add(new TicketObject(""Box 3"", 150));
seatArray.add(new TicketObject(""Box 4"", 150));
seatArray.add(new TicketObject(""Box 5"", 150));
}
}
//Ticket object for each seat; also used to populate array
public class TicketObject
{
public TicketObject(String inSeatName, int inSeatPrice)
{
seatName = inSeatName;
seatPrice = inSeatPrice;
}
public String getName()
{
return seatName;
}
public int getPrice()
{
return seatPrice;
}
private String seatName;
private int seatPrice;
}
//Price calculation class
public class Calculations
{
public static double addTax(int total)
{
return total * 1.07;
}
}
//Tester class
import java.util.Scanner;
public class TicketTester
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
try {
//Introduction for user
System.out.println(""Welcome to the ticket purchasing program!"");
System.out.println(""You will be able to purchase either a concert or play ticket"");
System.out.println(""\n"");
System.out.println(""Type concert or play to display available seats and deals"");
running = true;
//Displaying tickets of either a concert or play
String answer = in.next();
if (answer.equalsIgnoreCase(""Concert""))
{
ConcertTicket journeyConcert = new ConcertTicket();
journeyConcert.loadIn();
System.out.println(""Seat Price"");
for(int i=0;i<15;i++)
{
System.out.println(journeyConcert.getSeats(i));
}
System.out.println(""\n"");
System.out.println(""Type in a seat name/option and press enter to reserve it."");
System.out.println(""Type purchase and press enter to finalize your ticket purchase"");
}
else if(answer.equalsIgnoreCase(""Play""))
{
PlayTicket catsPlay = new PlayTicket();
catsPlay.loadIn();
System.out.println(""Seat Price"");
for(int i=0;i<15;i++)
{
System.out.println(catsPlay.getSeats(i));
}
System.out.println(""\n"");
System.out.println(""Type in a seat name/option and press enter to reserve it."");
System.out.println(""Type purchase and press enter to finalize your ticket purchase"");
}
else
System.out.println(""Enter a valid input"");
//Adding up chosen seat numbers and costs
while(running)
{
String seatChoice = in.next();
if ((seatChoice.substring(0,1)).equalsIgnoreCase(""A"") && seatChoice.length() == 2)
{
total = total + 40;
seats = seats + 1;
}
else if ((seatChoice.substring(0,1)).equalsIgnoreCase(""B"")&& seatChoice.length() == 2)
{
total = total + 35;
seats = seats + 1;
}
else if ((seatChoice.substring(0,3)).equalsIgnoreCase(""Box"")&& seatChoice.length() == 5)
{
total = total + 150;
seats = seats + 1;
}
else if ((seatChoice.substring(0,14)).equalsIgnoreCase(""Backstage Pass"") && seatChoice.length() == 14)
{
total = total + 100;
seats = seats + 1;
}
else if (seatChoice.equalsIgnoreCase(""Purchase""))
{
System.out.println(""You reserved "" + seats + "" seats at a price of $"" + Calculations.addTax(total));
running = false;
}
else
System.out.println(""Enter a valid input"");
}
}
finally {
if(in!=null)
in.close();
}
}
private static Boolean running;
private static int total = 0;
private static int seats = 0;
}
When I run the TicketTester class, everything runs correctly until I attempt to add either a backstage pass or a box office seat. I am given this error:
""Exception in thread ""main"" java.lang.StringIndexOutOfBoundsException: String index out of range: 14 at java.lang.String.substring(Unknown Source) at TicketTester.main(TicketTester.java:67)""
From this I can see that the error is occurring at the following line, but I don't know how to resolve it.
else if ((seatChoice.substring(0,13)).equalsIgnoreCase(""Backstage Pass"") && seatChoice.length() == 14)",,LQ_EDIT
In python-telegram-bot how to get all participants of the group?,"
In Python-telegram-bot how to get, if possible, the complete list of all participants of the group at which the bot was added?
Over time (months), you re-organise the project. Refactoring the code to make the modules independent. Files in the megaProject directory get moved into their own directories. Emphasis on move - the history of these files is preserved.
myCode/megaProject
myCode/moduleA
myCode/moduleB
Now you wish to move these modules to their own GIT repos. Leaving the original with just megaProject on its own.
The filter-branch command is documentated to do this but it doesn't follow history when files were moved outside of the target directory. So the history begins when the files were moved into their new directory, not the history the files had then they lived in the old megaProject directory.
How to split a GIT history based on a target directory, and, follow history outside of this path - leaving only commit history related to these files and nothing else?
The numerous other answers on SO focus on generally splitting apart the repo - but make no mention of splitting apart and following the move history.
",,HQ
React Native Post Request via Fetch throws Network Request Failed,"
I´ve came across the following error.
At the moment I developing an Android App with React Native therefore I´m planning to use fetch for doing a post request for me.
When I change the code to a GET-Request it´s working fine, in the browser with a window.alert() as a return it´s cool and also the chrome extension Postman returns data correctly.
",,HQ
What is the mathematical definition of (f(n)) and O(f(n)),"(f(n)) and O(f(n))
Can someone please give the mathematical definition of (f(n)) and O(f(n))?",