Hello there!
If I have a code like this:
$file = basename($filename);
How do i get the file extension of $file? The variabel file could contain any kind of file, like index.php or test.jpeg.
Hi, I have a Greasemonkey script that processes Google search results. But it's failing in a few instances, when xpath searches (and document body) appear to be empty.
Running the code in Firebug's console works every time. It only fails in a Greasemonkey script. Greasemonkey sees an empty document.body.
I've boiled the problem down to a test, greasemonkey script, below.
I'm using Firefox 3.5.9 and Greasemonkey 0.8.20100408.6 (but earlier versions had the same problem).
Problem:
Greasemonkey sees an empty document.body.
Recipe to Duplicate:
Install the Greasemonkey script.
Open a new tab or window.
Navigate to Google.com (http://www.google.com/).
Search on a simple term like "cats".
Check Firefox's Error console (Ctrl-shift-J) or Firebug's console. The script will report that document body is empty.
Hit refresh. The script will show a good result (document body found).
Note that the failure only reliably appears on Google results obtained this way, and on a new tab/window.
Turn javascript off globally (javascript.enabled set to false in about:config).
Repeat steps 2 thru 5. Only now the Greasemonkey script will work.
It seems that Google javascript is killing the DOM tree for greasemonkey, somehow. I've tried a time-delayed retest and even a programmatic refresh; the script still fails to see the document body.
Test Script:
//
// ==UserScript==
// @name TROUBLESHOOTING 2 snippets
// @namespace http://www.google.com/
// @description For code that has funky misfires and defies standard debugging.
// @include http://*/*
// ==/UserScript==
//
function LocalMain (sTitle)
{
var sUserMessage = '';
//var sRawHtml = unsafeWindow.document.body.innerHTML; //-- unsafeWindow makes no difference.
var sRawHtml = document.body.innerHTML;
if (sRawHtml)
{
sRawHtml = sRawHtml.replace (/^\s\s*/, ''). substr (0, 60);
sUserMessage = sTitle + ', Doc body = ' + sRawHtml + ' ...';
}
else
{
sUserMessage = sTitle + ', Document body seems empty!';
}
if (typeof (console) != "undefined")
{
console.log (sUserMessage);
}
else
{
if (typeof (GM_log) != "undefined")
GM_log (sUserMessage);
else
if (!sRawHtml)
alert (sUserMessage);
}
}
LocalMain ('Preload');
window.addEventListener ("load", function() {LocalMain ('After load');}, false);
I'm experitmenting with the Twitter API (OAuth). I have a test bed that can tweet from my dev box, but fails in production. I get a status code of 424 returned when trying to tweet.
I can't spot the difference between my live environment and my dev environment so really need to understand what a '424' is, but can find no documentation relating to it.
I'd like to start using HTML5's basic features, but at the same time, keep my code backwards compatible with older browsers (graceful degradation). For instance, I'd like to use the cool CSS3 properties for making rounded corners. Is there any available tutorial for writing gracefully degradable HTML5 ?
Additionally, what browsers should I support so that my app. is functional for at least 95% of visitors? What are the ways to test those browsers painlessly ?
Im beginner and im experimenting on a website with fixed and relative postions, what i want to do is to stop bottom part when the two bottom lines(div .top_divider_line) touches nav menu(div .top_holder) here is the preview from site where im stuck.
http://elexoj.com/test/
I think making it with jquery will be lot easier but i've no idea how to do it, i'll really appreciate your help.
Thank You!
I am using spring mvc in which i convert the arraylist into json string. I have one object 1) results.
My output from spring looks like this:
{
"data":"[{\"userName\":\"test1\",\"firstName\":\"test\",\"lastName\":\"user\"}, {\"userName\":\"test2\",\"firstName\":\"test1\",\"lastName\":\"user1\"}]",
}
I get output as null when i do '$.parseJSON' with this output. When i tried testing only with data object it works fine
Any help would be great.
I want to test my Entities that are built using Entity Framework.
My concern is that using Entity Framework means directly working with data source.
So any ideas how to unit testing Entity Framework based components?
Kick me if I'm being silly but some some reason I'm having a heck of time building a dynamic array in magento.
Example:
$data = array();
$data[0] = 'test';
$data[1] = 'what';
I keep getting an ERROR:
Notice: Undefined offset: 0
Any ideas?
Do I need to handle these arrays differently since they are in a class?
Hi all;
<% int i = Eval("NAME").ToString().IndexOf("."); string str = Eval("NAME").ToString().Substring(i + 1); %>
<img src="../images/img_<%= str %>.gif" alt="" />
EVAL("test.txt")
I need "txt" how to make ? Please Help
Thank you
When I submit a form, I can see my browser's progress bar slowly increased, it takes 4-6s to submit a form.
It was a generic form like :
<form id="someid" name="someName" action="someAction.do">
...
</form>
I test it in IE8 and Firefox 3,both are very slow.
My network condition is fine, my server works great.
What could be the problem?
I am writing a script to run under the korn shell on AIX. I'd like to use the mkdir command to create a directory. But the directory may already exist, in which case I don't want to do anything. So I want to either test to see that the directory doesn't exist, or suppress the "File exists" error that mkdir throws when it tries to create an existing directory.
Any thoughts on how best to do this?
Hi,
I'm having a small problem with mod_rewrite
I have the following in my .htacces:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.htm$ index.php?name=$1 [NC]
This is my index.php file:
<?php echo $_GET['name]; ?>
This works great for the following url:
www.mySite.com/this is an example.htm
this would display "this is an example"
What i'm trying to do however, is get it to do the same, without the .htm extension:
for example:
www.mySite.com/this is an example
Any ideas?
(dont think it's relevant but i'm using xampp to test this)
I have an XML file located at a location such as
http://example.com/test.xml
I'm trying to parse the XML file to use it in my program with xPath like this but it is not working.
Document doc = builder.parse(new File(url));
How can I get the XML file?
Our installer program is going to be installing a number of system services, under both Windows and UNIX, using JavaServiceWrapper. There will be a class responsible for creating JavaServiceWrapper config files, installing the services, etc.
Can I have some suggestions on how to unit-test this class?
same as in title? I have a test server with mentioned OS and my app is .net 3.5 based. I do want to know if win 2008 r2 comes with service pack 1 for .net 3.5 from the box. And does it come with .net 3.5 sp1 family update as WELL, since after I downloaded the update, the installer says I do not have software required to update. Could some win 2008 guru perhaps explain it to me?
thanks
luke
Unfortunately, Java has no syntax for multi-line string literals. No problem if the IDE makes it easy to work with constructs like
String x = "CREATE TABLE TEST ( \n"
+ "A INTEGER NOT NULL PRIMARY KEY, \n"
...
What is the fastest way to paste a multi-line String from the clipboard into Java source using Eclipse (in a way that it automagically creates code like the above).
I know from experience that b-trees have awful performance when data is added to them sequentially (regardless of the direction). However, when data is added randomly, best performance is obtained.
This is easy to demonstrate with the likes of an RB-Tree. Sequential writes cause a maximum number of tree balances to be performed.
I know very few databases use binary trees, but rather used n-order balanced trees. I logically assume they suffer a similar fate to binary trees when it comes to sequential inputs.
This sparked my curiosity.
If this is so, then one could deduce that writing sequential IDs (such as in IDENTITY(1,1)) would cause multiple re-balances of the tree to occur. I have seen many posts argue against GUIDs as "these will cause random writes". I never use GUIDs, but it struck me that this "bad" point was in fact a good point.
So I decided to test it. Here is my code:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[T1](
[ID] [int] NOT NULL
CONSTRAINT [T1_1] PRIMARY KEY CLUSTERED ([ID] ASC)
)
GO
CREATE TABLE [dbo].[T2](
[ID] [uniqueidentifier] NOT NULL
CONSTRAINT [T2_1] PRIMARY KEY CLUSTERED ([ID] ASC)
)
GO
declare @i int, @t1 datetime, @t2 datetime, @t3 datetime, @c char(300)
set @t1 = GETDATE()
set @i = 1
while @i < 2000 begin
insert into T2 values (NEWID(), @c)
set @i = @i + 1
end
set @t2 = GETDATE()
WAITFOR delay '0:0:10'
set @t3 = GETDATE()
set @i = 1
while @i < 2000 begin
insert into T1 values (@i, @c)
set @i = @i + 1
end
select DATEDIFF(ms, @t1, @t2) AS [Int], DATEDIFF(ms, @t3, getdate()) AS [GUID]
drop table T1
drop table T2
Note that I am not subtracting any time for the creation of the GUID nor for the considerably extra size of the row. The results on my machine were as follows:
Int: 17,340 ms
GUID: 6,746 ms
This means that in this test, random inserts of 16 bytes was almost 3 times faster than sequential inserts of 4 bytes.
Would anyone like to comment on this?
Ps. I get that this isn't a question. It's an invite to discussion, and that is relevant to learning optimum programming.
http://something.com:80/somedir/index.html?type=test;one=onevalue#nose
This is typical URI structure my question is what is "#nose" and how i can use/utilize it as web developer ?
Thanks all.
I have this (simplification):
$(li).click(function{alert("test");});
<li>
<input>
</li>
What's the best way to bind an event to li but not fire when the user clicks on the input element?
I'm wondering if its possible to configure Intellij's smart insert to suggest hamcrest and mockito dsl idioms when in test classes. Really I'm looking for something like eclipse's 'static favorites', so that when I hit ctrl + space or ctrl +shift +space the idioms are present.
In general is it possible to configure autocomplete/smart insert or the suggestions balloon for that matter. I've looked through the settings without much luck but could easily have overlooked something.
Hello :)
I need to test a piece of code which only seems to fail on Windows XP RTM. Unfortunately, all my disks came slipstreamed with SP2 on-disk. Is there any way to install an RTM install using my SP2 CD and key?
Billy3
PS: Not sure if this belongs on SU or not -- please vote it over there if you think so.
I don't normally use VB, and even less vba for excel, but I'm writing a function inside a macro and seem to not understand even the basics of creating a function
For example
Public Function test() As Integer
return 1
End Function
This gives a compile error.
This is profoundly stupid, but how do I make a function return an integer in vba?
Hi,
I would like to open a webpage and run a javascript function from within a java app.
For example I would like to open the page www.mytestpage.com and run the following javascript code:document.getElementById("txtEmail").value="[email protected]";submit();void(0);
This works in a browser...how can I do it programatically?
Thanks!
I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments. Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is testing for AR associations really required ?
Almost all of my JUnit tests are written with the following signature:
public void testSomething() throws Exception
My reasoning is that I can focus on what I'm testing rather than exception handling which JUnit appears to give me for free. But am I missing anything by doing this? Is it against best practice? Would I gain anything by explicitly catching specific exceptions in my test and then fail()'ing on them?