Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

48 total results found

What are the differences between addslashes(), mysql_escape_string() and mysql_real_escape_string()

Programming and Web Development PHP

addslashes() escapes single quote (’), double quote ("), backslash (\) and NUL (\x00).mysql_escape_string() and mysql_real_escape_string() escapes the characters above plus: CR (\r), LF (\n) and EOF (\x1a). Apparently (according to the manual), MySQL wants the...

escape
MySQL
PHP

Passing command-line arguments into PHP

Programming and Web Development PHP

Say you have a PHP script and you want to pass command-line arguments into the script, e.g. calling the script like this:php script.php datafile.txt 10 100PHP stores all command-line arguments in an array:$argv 0 => “script.php”$argv 1 => “datafile.txt”$...

argument
command line
parameter
PHP

Passing command-line argument into a DOS (including Windows) batch file

Programming and Web Development

You can use these variables in a batch file:%0 – the batch file’s name%1 – the 1st argument%2 – the 2nd argument%3 – the 3rd argument…%9 – the 9th argumente.g. Support the content of test.bat is as follows:@echo offecho param0: %0echo param1: %1echo param2: %2...

OpenSSH "permission denied" error

Internet and Web Browsers

If your private key file (e.g. ~/.ssh/id_rsa) has too much permission, OpenSSH will complain “permission denied” and not work. By default, the permission might be something like 644 or 700. You need to set it to 600. (Got the solution from this article)

Checking CPU load on multi-processor machines

MacOS, Windows, and Linux

If your machine has more than 1 CPU, the “CPU states” shown by the top(1) command shows the states of all CPUs combined. Suppose your machine has 8 CPUs. A program is saturating 1 CPU and there is no other activity (besides top(1), which uses negligible CPU ti...

csh and single quotes

Programming and Web Development

In csh, using quotes in a quoted string can be tricky, especially if the string contains both single and double quotes. If you use single quotes to quote the string, use ‘\’’ (a single quote, a backslash followed by two single quotes) where you want to insert ...

csh
escape
quote
shell programming

Speed of unpack() in PHP

Programming and Web Development PHP

I needed to extract a list of integers from a binary string. I was curious to know if PHP’s unpack function is fast compared to a custom function, so I wrote a test for it.<?php$filename = '<some large file>';$unpack_time = 0.0;$unpack_time2 = 0.0;$un...

pack
PHP
unpack

Manual setting of filename and type in a dynamically-generated web page

Programming and Web Development

Problem: Suppose you have a CGI script (PHP or otherwise), say genimage.cgi, that generates an image and sends it to the browser. If the user visits the URL of the script and tries to save the generated image, the browser might suggest “genimage.cgi” as the de...

MIME
download
file
PHP
save as

What characters can go into a valid HTTP URL?

Programming and Web Development

Section 5 of RFC 1738 – Uniform Resource Locators specifies the format of an HTTP URL:httpurl = "http://" hostport [ "/" hpath [ "?" search ]][definition of hostport omitted]hpath = hsegment *[ "/" hsegment ]hsegment = *[ uchar | ";" | ":...

escape
HTTP
URL

Opening a Unix text file on Windows

MacOS, Windows, and Linux

Problem: If you save a multiple-line text file on Unix (e.g. Linux) and open it on Windows, the text editor ignores the link breaks and shows the content in one giant line.Cause: Different operating systems use different characters to mark the end of line (a.k...

Compiling Lucene with GCJ

Programming and Web Development Lucene

BackgroundLucene is a open-source search library written in Java.GCJ is a Java to native-executable compilter. As shown in a LinuxJournal article, using gcj is similar to using gcc.Versions UsedAs of 1/26/08, the latest version of Lucene is 2.3.0. It needs Jav...

Lucene
full text search
gcj
Java

svn: Working copy '<filename>' is missing or not locked

Programming and Web Development Git and Version Control

Problem: While doing a svn update, you get the following message: “svn: Working copy ‘[filename]’ is missing or not locked”Cause: The directory that the file [filename] is in needs executable (i.e. list) permission on for the user that issues the command.Solut...

SVN

Create a Java class that is only comparable to itself

Programming and Web Development Java

In Java 5 and above, how to create a Java class that is only comparable to itself? The answer is to extend Comparable&lt;TheClass&gt;. This works even if TheClass uses generics.public class SelfComparableOnly&lt;T&gt; implements Comparable&lt;SelfComparableOnl...

generics
Java

Free/open source information retrieval libraries

Programming and Web Development

What are they and why using oneInformation retrieval libraries are software libraries that provides functionality for searching within databases and documents within them. In particular, this often refers to searching text document for combinations of words an...

Lucene
Sphinx
information retrieval
MySQL

Scope of environment variables in shells and shell scripts

Programming and Web Development

A environment variable defined in a shell (or a shell script) stays defined everywhere, including inside new shells (or shell scripts) executed within the shell, until the shell (or the shell script) terminates or the variable gets unset explicitly. E.g.script...

environment
bash
shell programming

Performance of array_shift and array_pop in PHP

Programming and Web Development PHP

We have confirmed that array_shift is much slower than array_pop in PHP.Code:&lt;?// Create an array with 100000 elements$array = array();for ($i = 0; $i &lt; 100000; $i++) { $array[] = rand();}// Remove the last 1000 elements using array_pop$start = microtime...

PHP

Effect of file operations on its own and its parent directory's modification times

MacOS, Windows, and Linux

\ File added File modified File renamed File deleted File Y Y N N/A Parent directory Y N Y Y(Y = mtime updated, N = mtime not updated)This has been tested under Windows XP and Solaris. I think the effect is the same on other OS but...

Lucene spans

Programming and Web Development Lucene

IntroductionIn Lucene, a span is a triple (i.e. 3-tuple) of &lt;document number, start position, end position&gt;. Document numbers start from zero. The positions are term positions, not character positions, and start from zero (i.e. the first token of a field...

Lucene
span query