Hi
in mysql how to write a sql like this, to get the amount of X 20 and <20
select date, numberOfXMoreThan20,numberOfXLessThan20, otherValues
from table
group by (date, X20 and X<20)
thanks
I'm writing a simple program in Python 2.7 using pycURL library to submit file contents to pastebin.
Here's the code of the program:
#!/usr/bin/env python2
import pycurl, os
def send(file):
print "Sending file to pastebin...."
curl = pycurl.Curl()
curl.setopt(pycurl.URL, "http://pastebin.com/api_public.php")
curl.setopt(pycurl.POST, True)
curl.setopt(pycurl.POSTFIELDS, "paste_code=%s" % file)
curl.setopt(pycurl.NOPROGRESS, True)
curl.perform()
def main():
content = raw_input("Provide the FULL path to the file: ")
open = file(content, 'r')
send(open.readlines())
return 0
main()
The output pastebin looks like standard Python list: ['string\n', 'line of text\n', ...] etc.
Is there any way I could format it so it looks better and it's actually human-readable? Also, I would be very happy if someone could tell me how to use multiple data inputs in POSTFIELDS. Pastebin API uses paste_code as its main data input, but it can use optional things like paste_name that sets the name of the upload or paste_private that sets it private.
a = matrix(1:25,5,5)
B = capture.output(for (X in 1:5){
A = c(min(a[,X]),quantile(a[,X],0.25),median(a[,X]),quantile(a[,X],0.75),max(a[,X]),mean(a[,X]),sd(a[,X])/m^(1/2),var(a[,X]))
cat(A,"\n")
})
matrix(B,8,5)
what i was trying to do is to generate a table which each column has those element in A and in that order. i try to use the matrix, but seems like it dont reli work here...can anyone help
1 2 3 4 5
min
1st quartile
median
SEM
VAR
THIS IS WHAT I WANT THE TABLE LOOKS LIKE ..
Everytime the IWpfTextView's TextBuffer changes I am trying to get the history's redostack and undostack and simply checking the count. When doing this I am encountering a "Method not supported exception" when trying to access the two stacks.
Am I retrieving the history incorrectly or does VS not want me seeing/editing the contents of the stacks?
I can post the code if necessary...
Thanks,
Nick
I have this snippet of the code
char *str = “123”;
if(str[0] == 1) printf("Hello\n");
why I can't receive my Hello thanks in advance!
how exactly compiler does this comparison if(str[0] == 1)?
Want to verify that my understanding of how this works.
Have an unmanaged C++ Class with one public instance variable:
char* character_encoding;
and whose only constructor is defined as:
TF_StringList(const char* encoding = "cp_1252");
when I use this class in either managed or unmanaged C++, the first thing I do is declare a pointer to an object of this class:
const TF_StringList * categories;
Then later I instantiate it:
categories = new TF_StringList();
this gives me a pointer to an object of type TF_StringList whose variable character_encoding is set to "cp_1252";
So, is all that logic valid?
Jim
following piece of code does not compile, the problem is in T::rank not be inaccessible (I think) or uninitialized in parent template.
Can you tell me exactly what the problem is?
is passing rank explicitly the only way? or is there a way to query tensor class directly?
Thank you
#include <boost/utility/enable_if.hpp>
template<class T, // size_t N,
class enable = void>
struct tensor_operator;
// template<class T, size_t N>
template<class T>
struct tensor_operator<T, typename boost::enable_if_c< T::rank == 4>::type > {
tensor_operator(T &tensor) : tensor_(tensor) {}
T& operator()(int i,int j,int k,int l) {
return tensor_.layout.element_at(i, j, k, l);
}
T &tensor_;
};
template<size_t N, typename T = double>
// struct tensor : tensor_operator<tensor<N,T>, N> {
struct tensor : tensor_operator<tensor<N,T> > {
static const size_t rank = N;
};
I know the workaround, however am interested in mechanics of template instantiation for self-education
Assume,
void proc(CString& str)
{
str = "123";
}
void runningMethod()
{
CString str="ABC";
proc(str);
}
I understand that at the exit of runningMethod str will be deallocated automatically; in this case, how does C++ delete the old data ("ABC")?
Thanks,
Gil.
Just came across a place where I'd like to use generics and I'm not sure how to make it work the way I want.
I have a method in my data layer that does a query and returns a list of objects. Here's the signature.
public List getList(Class cls, Map query)
This is what I'd like the calling code to look like.
List<Whatever> list = getList(WhateverImpl.class, query);
I'd like to make it so that I don't have to cast this to a List coming out, which leads me to this.
public <T> List<T> getList(Class<T> cls, Map query)
But now I have the problem that what I get out is always the concrete List<WhateverImpl> passed in whereas I'd like it to be the Whatever interface. I tried to use the super keyword but couldn't figure it out. Any generics gurus out there know how this can be done?
Hello!
I am now working on a some sort of a game engine and I had an idea to put everything engine-related into a static library and then link it to my actual problem.
Right now I achieved it and actually link that library and every functions seem to work fine, except those, which are windows-related.
I have a chunk of code in my library that looks like this:
hWnd = CreateWindow(className, "Name", WS_OVERLAPPED | WS_CAPTION | WS_EX_TOPMOST,
0, 0,
800, 600,
NULL, NULL, GetModuleHandle(NULL), this);
if (hWnd) {
ShowWindow(hWnd, SW_NORMAL);
UpdateWindow(hWnd);
} else {
MessageBox(NULL, "Internal program error", "Error", MB_OK | MB_ICONERROR);
return;
}
When this code was not in the library, but in the actual project, it worked fine, created the window and everything was ok. Right now (when I'm linking to my library that contains this code) CreateWindow(...) call returns NULL and GetLastError() returns "Operation succesfully completed" (wtf?).
Could anybody help me with this? Is it possible to create a window and display it using a static library call and why could my code fail?
Thank you.
Hello everyone-
In my C# Console App I'm trying to use Regex to search a string to determine if there is a match or not. Below is my code but it is not quite working right so I will explain further. sSearchString is set to "_One-Call_Pipeline_Locations" and pDS.Name is a filename it is searching against. Using the code below it is set to true for Nevada_One-Call_Pipeline_Locations and Nevada_One-Call_Pipeline_LocationsMAXIMUM. There should be a match for Nevada_One-Call_Pipeline_Locations But Not for Nevada_One-Call_Pipeline_LocationsMAXIMUM. How can I change my code to do this properly?
Thanks in advance
if (Regex.IsMatch(pDS.Name, sSearchString))
Hi,
I'm doing Grails To Action sample for chapter one. Every was just fine until I started to work with Services. When I run the app I have the following error:
groovy.lang.MissingPropertyException: No such property: quoteService for class: qotd.QuoteController
at qotd.QuoteController$_closure3.doCall(QuoteController.groovy:14)
at qotd.QuoteController$_closure3.doCall(QuoteController.groovy)
at java.lang.Thread.run(Thread.java:619)
Here is my groovie QuoteService class, which has an error within the definition of GetStaticQuote (ERROR: Groovy:unable to resolve class Quote)
package qotd
class QuoteService {
boolean transactional = false
def getRandomQuote() {
def allQuotes = Quote.list()
def randomQuote = null
if (allQuotes.size() > 0) {
def randomIdx = new Random().nextInt(allQuotes.size())
randomQuote = allQuotes[randomIdx]
} else {
randomQuote = getStaticQuote()
}
return randomQuote
}
def getStaticQuote() {
return new Quote(author: "Anonymous",content: "Real Programmers Don't eat quiche")
}
}
Controller groovie class
package qotd
class QuoteController {
def index = {
redirect(action: random)
}
def home = {
render "<h1>Real Programmers do not each quiche!</h1>"
}
def random = {
def randomQuote = quoteService.getRandomQuote()
[ quote : randomQuote ]
}
def ajaxRandom = {
def randomQuote = quoteService.getRandomQuote()
render "<q>${randomQuote.content}</q>" +
"<p>${randomQuote.author}</p>"
}
}
Quote Class:
package qotd
class Quote {
String content
String author
Date created = new Date()
static constraints = {
author(blank:false)
content(maxSize:1000, blank:false)
}
}
I'm doing the samples using Eclipse with grails addin. Any advice?
Regards,
Francisco
I am using the Jquery library to copy the text enter in one textfield to another textfield using a check box when clicked.. which is as follows
<html>
<head>
<script src="js/jquery.js" ></script>
</head>
<body>
<form>
<input type="text" name="startdate" id="startdate" value=""/>
<input type="text" name="enddate" id="enddate" value=""/>
<input type="checkbox" name="checker" id="checker" />
</form>
<script>
$(document).ready(function(){
$("input#checker").bind("click",function(o){
if($("input#checker:checked").length){
$("#enddate").val($("#startdate").val());
}else{
$("#enddate").val("");
}
});
}
);
</script>
</body>
</html>
now here i want the check box to be selected by default, so that the data entered in start date get copied automatically as check box is checked by default... so what event should be called here in jquery script?
please help me in resolving this issue...
Hello everyone, well I'm new here and I really need some help.. I want to create a table and this table's name will be inserted from a textfield. However when I run the query it's giving me an error, any help on this one? Ill paste the code here:
public boolean CreateTable() {
TableNumber=jTextField4.getText();
try {
String password = null;
String s = "CREATE TABLE '"+TableNumber+'" (Item char(50),Price char(50))";
ConnectionForOrders();
stmt = conn.createStatement();
stmt.executeUpdate(s);
boolean f=false;
ConnectionForOrdersclose();
Why doesn't this print 5?
void writeValue(int* value) {
value = malloc(sizeof(int));
*value = 5;
}
int main(int argc, char * argv) {
int* value = NULL;
writeValue(value);
printf("value = %d\n", *value); // error trying to access 0x00000000
}
and how can I modify this so it would work while still using a pointer as an argument to writeValue?
Can anyone tell me why the output of this class is 'xa'?
why the other exception won't be caught?
public class Tree {
public static void main(String... args){
try
{
throw new NullPointerException(new Exception().toString());
} catch (NullPointerException e)
{
System.out.print("x");
}
catch (RuntimeException e)
{
System.out.print("y");
}
catch (Exception e)
{
System.out.print("z");
}
finally{System.out.println("a");}
}
}
how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4
and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself
Hello
Sorry if this is basic but I cannot find the solution anywhere.
I have an java Object ‘Person’ with 3 properties firstname,lastname and username.
I have an Oracle Store procedure returning a Resultset with the 3 column.
All works fine for that.
Now I have another StoreProcedure that will only return firstname and lastname but not username.
I get the following error : « could not read column value from result set username. »
Hibernate tries to fetch the username property from the resultset.
If I remove the property username, then it works.
Do I have to Create a Special Pojo for Each type of resultset or can I tell Hibernate what to map for each result set?
Please help.
Hi Guys,
I am pretty new to xml parsing and I am using XMLREADER to parse a huge file.
Given the following XML (sample):
<hotels>
<hotel>
<name>Bla1</name>
</hotel>
<hotel>
<name>Bla2</name>
</hotel>
</hotels>
And then the XMLREADER in PHP which pulls up the values to my Database:
$reader = new XMLReader();
$reader->open('hotels.xml');
while ($reader->read()) {
if ($reader->name == "name") {
$reader->read();
mysql_query("INSERT INTO MyHotels (hotelName) VALUES (\"$reader->value\")");
}
}
$reader->close();
The problem is that I've got a single empty row between each of the parsed nodes!! Not sure why this happens!
| ID | hotelName |
| 1 | Bla1 |
| 2 | |
| 3 | Bla2 |
| 4 | |
Help is greatly appreciated.
messagecontroller is nothing but object of initialize nib file.
[self.navigationController pushViewController:messageController animated:YES];
this statement executes in normal condition
this statement also works on state maintainace testing ,
this line executes properly but not open new view ,why?
I'm using the twitter search API to get twitter posts based on some keywords, using AND and OR keyword. It works OK, but I seem to get problems using hashtags...
For example :
Not returning any results :
http://search.twitter.com/search.json?q="%23ipad+AND+%23ipod"+OR+"%23joke+AND+%23funny"&rpp=100&callback=?
Returning results :
http://search.twitter.com/search.json?q="ipad+AND+ipod"+OR+"joke+AND+funny"&rpp=100&callback=?
But there's results with #ipod AND #ipad because when I search only for #ipod, I can see a lot of posts with both hashtags.
Example : http://search.twitter.com/search.json?q=%23ipad&rpp=100&callback=?
P.S. %23 = #
Any idea?
Ultimately I am just trying to figure out how to dynamically allocate heap memory from within assembly.
If I call Linux sbrk() from assembly code, can I use the address returned as I would use an address of a statically (ie in the .data section of my program listing) declared chunk of memory?
I know Linux uses the hardware MMU if present, so I am not sure if what sbrk returns is a 'raw' pointer to real RAM, or is it a cooked pointer to RAM that may be modified by Linux's VM system?
I read this: How are sbrk/brk implemented in Linux?. I suspect I can not use the return value from sbrk() without worry: the MMU fault on access-non-allocated-address must cause the VM to alter the real location in RAM being addressed. Thus assy, not linked against libc or what-have-you, would not know the address has changed.
Does this make sense, or am I out to lunch?