And how do I convert it to a datetime.datetime instance in python?
It's the output from the New York State Senate's API: http://open.nysenate.gov/legislation/.
I'm using Java sockets for client - server application. I have a situation when sometimes client needs to send a byte array (using byteArrayOutputStream) and sometimes it should send a custom java object. How can I read the information from the input stream on the server side and determine what is in the stream so that I can properly process that?
I'm wanting to use http_build_query to change an array to html tag properties. Problem is, it's changing my single-quoted values into %27. So if I have
http_build_query( array("type"=>"'hidden'", ... ), '', ' ' );
I get
<input type=%27hidden%27 ...>
How can I get around this?
I am using the insert() function from Zend_Db_Table_Abstract.
The data being inserted is user input, so naturally I am curious if ZF does the data cleansing for me, or if I should do it myself before I call the insert() function.
On occasion, I find myself wanting to search the text of changelist descriptions in Perforce. There doesn't appear to be a way to do this in P4V. I can do it by redirecting the output of the changes command to a file...
p4 changes -l > p4changes.txt
...(the -l switch tells it to dump the full text of the changelist descriptions) and then searching the file, but this is rather cumbersome. Has anyone found a better way?
How print format string passed as argument ?
example.cpp:
#include <iostream>
int main(int ac, char* av[])
{
printf(av[1],"anything");
return 0;
}
try:
example.exe "print this\non newline"
output is:
print this\non newline
instead I want:
print this
on newline
Is there a way to print the layout of a C++ object using the g++ compiler or any other means.
A simplified example (assuming int takes 4 bytes)
class A{
int a;
};
class B:public A{
int b;
}
so the output would be
A -
0 4
+ a +
B-
0 4 8
+ A.a + b +
It would be useful to understand the layout of objects (in my case virtual machine code).
Thanks in advance.
Regards,
Zaheer
Notice the following result when I submit blank :title and :description fields
The validations are in the controller:
class Question < ActiveRecord::Base
validates_presence_of :title
validates_presence_of :description
And, the form is generated with those names:
-form_for(@question) do |f|
= f.error_messages
= f.label :title
= f.text_field :title, :size => 50, :onchange => remote_function(:url => {:action => :display_tag_suggestions}, :with => 'Form.Element.serialize(this)')
#suggestions
= f.label :description
= f.text_area :description
...
But, for some reason, only :title gets wrapped in the error div tags:
<form action="/questions" class="new_question" id="new_question" method="post">
<div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=" /></div>
<div class="errorExplanation" id="errorExplanation">
<h2>2 errors prohibited this question from being saved</h2>
<p>There were problems with the following fields:</p>
<ul>
<li>Title can't be blank</li>
<li>Description can't be blank</li>
</ul>
</div>
<label for="question_title">Title</label>
<div class="fieldWithErrors"><input id="question_title" name="question[title]" onchange="new Ajax.Request('/questions/display_tag_suggestions', {asynchronous:true, evalScripts:true, parameters:Form.Element.serialize(this) + '&authenticity_token=' + encodeURIComponent('6HQaiu1D0gBQcKw2pLeZP6Jvn0FSClPD5Sk9HwegzPg=')})" size="50" type="text" value="" /></div>
<label for="question_description">Description</label>
<textarea cols="40" id="question_description" name="question[description]" rows="20"></textarea>
...
I don't think that behavior is expected. The problem most people have is that it's wrapping things with divs, which won't display properly. My problem is that fields aren't being wrapped with divs to begin with!
I haven't made any (conscious) changes to how errors are handled, so I'm not sure why it's not working properly.
Obviously, there must be something stupid i'm doing. The unicode chart for subscripts and superscripts says #00B2 is superscript 2, but i get scrambled output. 0078 is x, but I get N, and 0120 is x. Am i reading wrong manual?
EDIT
$x = 'N';
print html_entity_decode($x, ENT_NOQUOTES, 'UTF-8') . "\n";
I have a 1 : M relationship.
I built a dynamic query based on input from users to return the listing of parents entities along with their children (using predicate builder:
(done successfully new TDataContext().Ps.Where(predicate) )...
but need to order the results by a field found only on the child entities.
I'm at a loss: new TDataContext().Ps.Where(predicate).OrderBy(p = p.Cs. ??)
where Ps = parents collection relationship with Cs = child entities
any help appreciated.
I have a piece of code that looks like this:
Dir.new(path).each do |entry|
puts entry
end
The problem comes when I have a file named ???????.txt in the directory that I list.
On a Windows 7 machine I get the output:
???????.txt
From googling around, properly reading this filename on windows seems to be an impossible task. Any suggestions?
I wonder if this is possible with straight SQL on MySQL. I need to do SELECT COUNT(*) FROM on each table in the database and output results in one result set.
Is it possible to do with just SQL?
I am trying to read .doc/.docx file with stream reader, but it give me output as unspecified character ie.
??[ ?L?f???C???.
I'm writing the file using a text editor. Here's a snippet of my code:
string filePath = baseUrl+ "Sample.docx";
using (StreamReader reader = new StreamReader(filePath, Encoding.UTF8))
{
txtBody.Text = reader.ReadToEnd();
}
I'm using VS 2010. Thank you.
I have a class, containing a list property, where the list contains objects that has an enum property.
When I serialize this, it looks like this:
<?xml version="1.0" encoding="ibm850"?>
<test>
<events>
<test-event type="changing" />
<test-event type="changed" />
</events>
</test>
Is it possible, through attributes, or similar, to get the Xml to look like this?
<?xml version="1.0" encoding="ibm850"?>
<test>
<events>
<changing />
<changed />
</events>
</test>
Basically, use the property value of the enum as a way to determine the tag-name? Is using a class hierarchy (ie. creating subclasses instead of using the property value) the only way?
Edit: After testing, it seems even a class-hierarchy won't actually work. If there is a way to structure the classes to get the output I want, even with sub-classes, that is also an acceptable answer.
Here's a sample program that will output the above Xml (remember to hit Ctrl+F5 to run in Visual Studio, otherwise the program window will close immediately):
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace ConsoleApplication18
{
public enum TestEventTypes
{
[XmlEnum("changing")]
Changing,
[XmlEnum("changed")]
Changed
}
[XmlType("test-event")]
public class TestEvent
{
[XmlAttribute("type")]
public TestEventTypes Type { get; set; }
}
[XmlType("test")]
public class Test
{
private List<TestEvent> _Events = new List<TestEvent>();
[XmlArray("events")]
public List<TestEvent> Events { get { return _Events; } }
}
class Program
{
static void Main(string[] args)
{
Test test = new Test();
test.Events.Add(new TestEvent { Type = TestEventTypes.Changing });
test.Events.Add(new TestEvent { Type = TestEventTypes.Changed });
XmlSerializer serializer = new XmlSerializer(typeof(Test));
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
serializer.Serialize(Console.Out, test, ns);
}
}
}
i have file with contents in list form such as
[1,'ab','fgf','ssd']
[2,'eb','ghf','hhsd']
[3,'ag','rtf','ssfdd']
i want to read that file line by line using f.readline and assign thn to a list so as to use it is the prog as a list for using list properties
tried like
k=[ ]
k=f.readline()
print k[1]
i xpected a result to show 2nd element in the list in first line
but it showed the first bit and gave o/p as '1'
how to get the xpected output..
please suggest
I have a list of items sorted alphabetically:
list = [a,b,c,d,e,f,g,h,i,j]
I'm able to output the list in an html table horizonally like so:
| a , b , c , d |
| e , f , g , h |
| i , j , , |
What's the algorithm to create the table vertically like this:
| a , d , g , j |
| b , e , h , |
| c , f , i , |
I'm using python, but your answer can be in any language or even pseudocode.
Thanks
I have:
tXML = "<type p_type=\"All\"/>";
if I do
Response.Write(tXML);
I get a blank space.
Is there anyway to output this string so I know it is being created?
My question is easily summarized as: "Why does the following not work?"
teststruct = struct('a',3,'b',5,'c',9)
fields = fieldnames(teststruct)
for i=1:numel(fns)
fns(i)
teststruct.(fns(i))
end
output:
ans = 'a'
??? Argument to dynamic structure reference must evaluate to a valid field name.
Especially since teststruct.('a') does work. And fns(i) prints out ans = 'a'.
I can't get my head around it.
[root@jiaoyou ~]# test 1 = 1 -a 0 = 1
[root@jiaoyou ~]# if [1 = 1 -a 0 = 1]then echo 1;else echo 2;fi
-bash: syntax error near unexpected token `else'
Why test doesn't give any output and the if statement fails?
Can someone point out what's wrong here?
Problem
Hello all!
I have this code which takes my jpg image loops through altering pixels and finally saving it as a png type. The problem is that the resulting image has a bit depth of 32 bits. I need it to be 24 bit, can any one shiny some light on the correct method of setting it? Am I along the right tracks looking at setting the pixel format to PixelFormat24bppRGB?
Code
static inline void Brighten(Gdiplus::Bitmap* img)
{
int width = img->GetWidth()/8,height = img->GetHeight(), max = (width*height),r,g,b;
Gdiplus::Color pixel;
for(int a = 0,x = 0, y = -1; a < max; ++a)
{
x = a%width;
if(x == 0)
++y;
img->GetPixel(x,y,&pixel);
r = pixel.GetR();
g = pixel.GetG();
b = pixel.GetB();
if (r > 245) r = 245;
if (g > 245) g = 245;
if (b > 245) b = 245;
r = 10;
g = 10;
b = 10;
pixel = Gdiplus::Color(r,g,b);
img->SetPixel(x,y,pixel);;
}
}
ULONG_PTR m_dwToken = 0;
Gdiplus::GdiplusStartupInput input;
Gdiplus::GdiplusStartupOutput output;
Gdiplus::GdiplusStartup( &m_dwToken, &input, &output );
USES_CONVERSION_EX;
Gdiplus::ImageCodecInfo* pEncoders = static_cast< Gdiplus::ImageCodecInfo* >( _ATL_SAFE_ALLOCA(1040, _ATL_SAFE_ALLOCA_DEF_THRESHOLD));
Gdiplus::DllExports::GdipGetImageEncoders(5, 1040, pEncoders );
CLSID clsidEncoder = pEncoders[4].Clsid;
Gdiplus::Bitmap img1((CT2W)L"IMG_1.JPG");
Brighten(&img1);
img1.Save((CT2W)L"IMG_1_R3.PNG",&clsidEncoder,NULL);
Thanks in advance!
My company is working on end user/developer docs using mediawiki. I'd like to take a lot of the API docs that phpdoc spit out (for specific functions/methods) and have it in wiki markup for easy transfer.
Any solutions out there for getting wiki markup or wiki output from phpDoc? I've looked around and found nothing.
Hi!
I try to upload file, how can i check if file is upload
when i send empty input witch file upload i get
AttributeError: 'unicode' object has no attribute 'filename'
How can i check added file?