Why doesn't the u-infinity appear under the limit when I compile? Instead it is appearing to the right of the limit. How do I correct this?
\frac{1}{\lim_{u \rightarrow \infty}}
For every Card, I would like to attach a special number to them that increments by one.
I assume I can do this all in the controller.
def create
@card = Card.new(params[:card])
@card.SpecNum = @card.SpecNum ++
...
end
Or. I can be blatantly retarded. And maybe the best bet is to add an auto-incremement table to mysql. The problem is the number has to start at a specific number, 1020.
Any ideas?
hi all.
i'm a scala newbee. i have one question.
in my code ,i try to import httpparse library like this
scalac -classpath /home/kula/code/201005/kookle/lib/htmlparser.jar crawler.scala
and i run this code.
scala main
and it tell me that
java.lang.NoClassDefFoundError: org/htmlparser/Parser
at FetchActor$$anonfun$act$1$$anonfun$apply$1.apply(crawler.scala:21)
at FetchActor$$anonfun$act$1$$anonfun$apply$1.apply(crawler.scala:13)
at scala.actors.Reaction.run(Reaction.scala:78)
at scala.actors.FJTask$Wrap.run(Unknown Source)
at scala.actors.FJTaskRunner.scanWhileIdling(Unknown Source)
at scala.actors.FJTaskRunner.run(Unknown Source)
i check the file./home/kula/code/201005/kookle/lib/htmlparser.jar and it is no problem.anyone can tell me how cause this bug?
Imagine we need to pass a a number structured objects to the web application - for instance, locale, layout settings and a definition of some query. This can be easily done with JSON or XML similar to the following fragment:
<Locale>en</Locale>
<Layout>
<Block id="header">hide</Block>
<Block id="footer">hide</Block>
<Block id="navigation">minimize</Block>
</Layout>
<Query>
<What>water</What>
<When>
<Start>2010-01-01</Start>
</When>
</Query>
However, passing such structures with HTTP implies (roughly speaking) HTTP POST.
Now assume we're limited to HTTP GET. Is there some kind of a standard solution for encoding structured data in HTTP GET request parameters?
I can easily imagine something like:
Locale=en&
Layout.Block.header=hide&
Layout.Block.footer=hide&
Layout.Block.navigation=minimize&
Query.What=water&
Query.When.Start=2010-01-01
But what I'm looking for is a "standard" syntax, if there's any.
ps. I'm surely aware of the problem with URL length. Please assume that it's not a problem in this case.
Hey guys, another question. I'm trying to do some basic jQuery stuff for my final project. I'll be using it to modify my already existing site created in Dreamweaver a few months ago.
However, no matter how I source the framework, it just won't take regardless of whether I host my own copy or link to someone else's like Google's.
I'm including my jQuery function calls within my already existing .js file that includes some auto generated functions. I also tried creating a new .js specifically for my jQuery functions and still nothing.
I realize this is vague, but any tips? Do I need another framework for jQuery to work off of to make animations like
.fadeIn() or .slideDown()?
Thanks guys and gals!
I've been attempting to bind to buttons within a DataTemplate without much success. The button does not fire. Button Click works successfully outside of the DataTemplate. Yet if I create a Click="button_click" the click button is fired. The Button Content binds perfectly as well.
Example to illustrate..
Why does the command not fire? Advice on how this should be handled this? The example is a simplified version of my real problem, I am currently not using a Listbox. I only recreated the same problem with a listbox..
I have a XSD simple type that should match UUIDs:
<simpleType name="UuidT">
<restriction base="string">
<pattern value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" />
</restriction>
</simpleType>
It correctly matches the following content:
<!-- valid -->
<Uuid>12345678-1234-5678-9012-123456789012</Uuid>
But it doesn't match content that contains excess whitespace:
<!-- not valid -->
<Uuid>
2de25a81-b117-4b2a-b910-50f0878884f7
</Uuid>
Sure, I could add \s* to both sides of the regex, but isn't there a simpler solution in XSD?
I have just started with CanCan and here's a sample of the code:
# Ability.rb
def initialize(user)
user ||= User.new
can :read, Link
end
# view.html.erb
<% if can? :read, @link %>
...
<% end %>
This is from the github repo for CanCan but this doesn't seem to work (it returns false and stops the ... code from running).
When I change the view to <% if can? :read, Link %>, it works. But, this is different to the CanCan readme. Do you know where I'm going wrong here?
What is the easiest way to have an application launch at startup on Ubuntu server as daemon? This is a java application (java com.run.run.Run) etc.
How would I have it launch as a user and possibly have access to write to some log file where the user has permissions to write?
And if I don't end up doing that, how would I launch the application as the root user at startup.
Edited: It is a headless server, I don't have access to the desktop applications.
We were sent this formula to encrypt a string written in Java:
String myInput = "test1234";
MessageDigest md = MessageDigest.getInstance("SHA");
byte[] myD = md.digest(myInput.getBytes());
BASE64Encoder en64 = new BASE64Encoder();
String myOutput = new String (
Java.net.URLEncoder.encode( en64.encode(myD)));
// myOutput becomes "F009U%2Bx99bVTGwS3cQdHf%2BJcpCo%3D"
Our attempt at writing this in C# is:
System.Security.Cryptography.SHA1 sha1 =
new System.Security.Cryptography.SHA1CryptoServiceProvider();
string myOutput = HttpUtility.UrlEncode(
Convert.ToBase64String(
sha1.ComputeHash(
ASCIIEncoding.Default.GetBytes(myInput))));
However the output is no where near the same. It doesn't even have percent signs in it. Any chance anyone would know where we are going wrong?
the code are not so complecated..
private
{ Private declarations }
SpSharedRecoContext1 : TSpSharedRecoContext;
fMyGrammar : ISpeechRecoGrammar;
procedure SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
procedure SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
procedure TForm1.FormCreate(Sender: TObject);
begin
SpSharedRecoContext1 := TSpSharedRecoContext.Create(self);
SpSharedRecoContext1.OnHypothesis := SpSharedRecoContext1Hypothesis;
SpSharedRecoContext1.OnRecognition :=SpSharedRecoContext1Recognition;
fMyGrammar := SpSharedRecoContext1.CreateGrammar(0);
fMyGrammar.DictationSetState(SGDSActive);
end;
procedure TForm1.SpSharedRecoContext1Recognition(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
RecognitionType: SpeechRecognitionType;
const Result: ISpeechRecoResult);
begin
Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;
procedure TForm1.SpSharedRecoContext1Hypothesis(ASender: TObject; StreamNumber: Integer;
StreamPosition: OleVariant;
const Result: ISpeechRecoResult);
begin
Memo1.Text := Result.PhraseInfo.GetText(0,-1,true);
end;
My Problem, was the vista-OS voice command will intercept on my program. if i say "START", instead of writing start on memo1 it press the start menu on my desktop. or what ever command like START CANCEL EDIT DELETE SELECT etc. please help..... sorry for my english
need some help with building a powershell script to help with some basic string manipulation. I know just enough powershell to get in trouble, but can't figure out the syntax or coding to make this work.
I have a text file that looks like this -
Here is your list of servers:
server1
server2.domain.local
server3
Total number of servers: 3
I need to take that text file and drop the first and last lines (Always first and last.) Then I need to take every other line and basically turn it into a CSV file.
The final output should be a text file that looks like this -
server1,server2.domain.local,server3
Any suggestions on where to start? Thanks!
There is a PostgreSQL database on which I only have limited access (e.g, I can't use pg_dump). I am trying to create a local "mirror" by exporting certain tables from the database. I do not have the permissions needed to just dump a table as SQL from within psql. Right now, I just have a Python script that iterates through my table_names, selects all fields and then exports them as a CSV:
for table_name, file_name in zip(table_names, file_names):
cmd = """echo "\\\copy (select * from %s)" to stdout WITH CSV HEADER | psql -d remote_db | gzip > ./%s/%s.gz"""%(table_name,dir_name,file_name)
os.system(cmd)
I would like to not use CSV if possible, as I lose the field types and the encoding can get messed up. First best would probably be some way of getting the generating SQL code for the table using \copy. Next best would be XML, ideally with some way of preserving the field types. If that doesn't work, I think the final option might be two queries---one to get the field data types, the other to get the actual data.
Any thoughts or advice would be greatly appreciated - thanks!
How can I simply the below if statements?
if ( isset(var1) & isset(var2) ) {
if ( (var1 != something1) || (var2 != something2) ) {
// ... code ...
}
}
Seems like this could be condensed to only one IF statement but am not certain if I'd use an AND or OR
I have an NSBezierPath that I'm filling and stroking. I'd like to add some inner glow to the path (a light stroke, just inside of the outer stroke), and the thing that comes to mind is to use the same path shrunk by 1 pixel (the size of the line that is already )stroked. Is there a way to do this?
Alternatively, is there some sort of pattern I can use when applying both a border (stroke) and a glow to a bezier path?
Example, the (extremely subtle) inner glow on the Google Chrome tabs:
Any time I want to replace a piece of text that is part of a larger piece of text, I always have to do something like:
"(?P<start>some_pattern)(?P<replace>foo)(?P<end>end)"
And then concatenate the start group with the new data for replace and then the end group.
Is there a better method for this?
Hello, I have a table with measures and the time this measures have been taken in the following form: MM/DD/YYYY HH:MI:SS AM. I have measures over many days starting at the same time every day.The datas are minute by minute so basically the seconds are always = 0. I want to select only the measures for the first 5 minutes of each day. I would have used the where statement but the condition would only be on the minutes and note the date is there a way to do this?
Thanks
Hello!
I'm writing a very stupid program using Boost Date_Time library.
int main(int srgc, char** argv) {
using namespace boost::posix_time;
date d(2002,Feb,1); //an arbitrary date
ptime t1(d, hours(5)+nanosec(100)); //date + time of day offset
ptime t2 = t1 - minutes(4)+seconds(2);
ptime now = second_clock::local_time(); //use the clock
date today = now.date(); //Get the date part out of the time
}
Well I cannot compile it, compiler does not recognize a type...
Well I used many features of Boost libs like serialization and more... I correctly built them and, looking in my /usr/local/lib folder I can see that libboost_date_time.so is there (a good sign which means I was able to build that library)
When I compile I write the following:
g++ -lboost_date_time main.cpp
But the errors it showed me when I specify the lib are the same of those ones where I do not specify any lib.
What is this? Anyone knows?
The error is
main.cpp: In function ‘int main(int,
char**)’: main.cpp:9: error: ‘date’
was not declared in this scope
main.cpp:9: error: expected ‘;’ before
‘d’ main.cpp:10: error: ‘d’ was not
declared in this scope main.cpp:10:
error: ‘nanosec’ was not declared in
this scope main.cpp:13: error:
expected ‘;’ before ‘today’
TFS Build 2010 is completely different from 2008. There is no "" task - I'm looking for a 2010 equivalent "activity". Is there a way to perform a basic command line execution in TFS Build 2010?
I'm running this out of the VS 2008 debugger on Windows 7, running .Net 3.5.
The idea was to make all ajax requests with jQuery only, rather than .net, following some tutorials online.
Default.aspx - HTML page, jquery triggers method in Default.aspx.cs
http://pastebin.com/pxBvKA2H
Default.aspx.cs - C# Webform, just defines a GetDate fuction, which only returns a string for now (trying to eliminate any possible issues)
(can only post one hyperlink...) pastebin.com/pnHn50hu
The ajax query takes longer than it should. Profiling with firebug revealed that it took 1.03 ms.
1s DNS Lookup |
26ms Waiting |
1ms Receiving
EDIT: It continues to take the same set of times if you continue to click and resubmit the request.
Is there anything I can do to cut down on the DNS Lookup time / what did I do wrong?
Thanks for any help.
Background
Add a constant value to numbers matched with a regular expression, using vim (gvim).
Problem
The following regular expression will match width="32":
/width="\([0-9]\{2\}\)"
Question
How do you replace the numeric value of the width attribute with the results from a mathematical expression that uses the attribute's value? For example, I would like to perform the following global replacement:
:%s/width="\([0-9]\{2\}\)"/width="\1+10"/g
That would produce width="42" for width="32" and width="105" for width="95".
Thank you!
I'm just programming a little function that toggles a content by fading it in and out.
this.advancedSearch = function(fieldset, triggerBtn){
fieldset.hide()
triggerBtn.click(function(){
fieldset.toggle(function(){ $(this).stop(false, true).fadeIn(300) }, function(){ $(this).stop(false, true).fadeIn(300) })
})
}
if just I use toggle() it works, but when i insert the two functions nothing happens and no error is thrown. Is there something i have done wrong?
I need to write a macro (with-hooks (monster method who what) &body body) for a game I'm writing. Monster is a CLOS object, method and who are strings and what is a function (#' notation). The macroexpansion would be something to the effect of
(add-hook monster method who what)
,@body
(remove-hook monster method who)
I have absolutely no idea how to write such a macro, and I would appreciate some help.
Hello, I want to Remove the Sessions from this php code, actually if someone searches i get this url search.php?searchquery=test but if I reload the page, the results are cleaned. how can I remove the Sessions to get the Results still, if someone reloads the page? this are the codes:
search.php
<?php
session_start();
?>
<form method="get" action="querygoogle.php">
<label for="searchquery"><span class="caption">Search this site</span> <input type="text" size="20" maxlength="255" title="Enter your keywords and click the search button" name="searchquery" /></label> <input type="submit" value="Search" />
</form>
<?php
if(!empty($_SESSION['googleresults']))
{
echo $_SESSION['googleresults'];
unset($_SESSION['googleresults']);
}
?>
querygoogle.php
<?php
session_start();
$url = 'http://www.example.com';
$handle = fopen($url, 'rb');
$body = '';
while (!feof($handle)) {
$body .= fread($handle, 8192);
}
fclose($handle);
$json = json_decode($body);
foreach($json->responseData->results as $searchresult)
{
if($searchresult->GsearchResultClass == 'GwebSearch')
{
$formattedresults .= '
<div class="searchresult">
<h3><a href="' . $searchresult->unescapedUrl . '">' . $searchresult->titleNoFormatting . '</a></h3>
<p class="resultdesc">' . $searchresult->content . '</p>
<p class="resulturl">' . $searchresult->visibleUrl . '</p>
</div>';
}
}
$_SESSION['googleresults'] = $formattedresults;
header("Location: search.php?searchquery=" . $_GET['searchquery']);
exit;
?>
thank you for your help!!