find if array contains element
0
Digest::MD5 is core from 5.8.
7
lavaramano
how to remove a string from a plain text using just grep.
7
RobHarrigan
Function to capitalize the first letter in every word in a string, but only if the entire string is in ALL CAPS.
Example:
"I LIKE TO SCREAM" becomes "I Like To Scream"
"I LIKE to RUN" remains "I LIKE to RUN".
Example:
"I LIKE TO SCREAM" becomes "I Like To Scream"
"I LIKE to RUN" remains "I LIKE to RUN".
5
I've found it kind of complicated to strip newline chars from a file with just the commandline. This tiny piece of code does just that.
I've found it especially useful when extracting tabulated data from a grabbed site where each cell is on a different html line. This way I can pre-filter the html, remove the newlines, and insert them again at register boundaries (row end in this case), so that with just a couple more replacement from within a regex enabled text editor I can copy&paste it directly to a database.
I've found it especially useful when extracting tabulated data from a grabbed site where each cell is on a different html line. This way I can pre-filter the html, remove the newlines, and insert them again at register boundaries (row end in this case), so that with just a couple more replacement from within a regex enabled text editor I can copy&paste it directly to a database.
1
From time to time you may have reasons to override the default find method that ActiveRecord provides. In this example, we'll store a side-copy of the record attributes so that we have some basis for discovering changes to the data.
note: this will not override dynamic finders such as find_by_id
note: this will not override dynamic finders such as find_by_id
0
robert
This perl function will output to a file of your choosing the current localtime as defined by perl's localtime function. It will output the date in ISO 8601 date format plus the current localtime such as:
2006-08-21 09:26:35 am
The function also returns the localtime without the date to the calling environment.
2006-08-21 09:26:35 am
The function also returns the localtime without the date to the calling environment.
7
I found this script online, and decided that I would modify it for my needs. As a developer, I like to know how many actual lines of code I have written--not including any comments.
It outputs in a very simple way:
Including Comments: NNN
Without Comments: NNN
One very practical, and quick, way to determine how many lines of code a project has is to pipe it through a find:
find /usr/share/php -name "*.php" -o -name "*.inc" | xargs count-code
If your code is in files of another type (i.e., .c, .h, .cpp, etc), then simply change the extensions and add more '-o -name "*.ext"' tags. If you have directories that you don't want to be counted, simple throw a "| grep -v [path/to/excluded/directory] |" inbetween the find and the xargs, and they will not be counted.
It outputs in a very simple way:
Including Comments: NNN
Without Comments: NNN
One very practical, and quick, way to determine how many lines of code a project has is to pipe it through a find:
find /usr/share/php -name "*.php" -o -name "*.inc" | xargs count-code
If your code is in files of another type (i.e., .c, .h, .cpp, etc), then simply change the extensions and add more '-o -name "*.ext"' tags. If you have directories that you don't want to be counted, simple throw a "| grep -v [path/to/excluded/directory] |" inbetween the find and the xargs, and they will not be counted.
6
A database API written in Perl for a MySQL.
You will need to edit the settings for your server.
Enojy
You will need to edit the settings for your server.
Enojy
12
A little function that returns a greeting based on the local time.
5
Simple function to check for a valid email address. Makes sure the @ and a . are in the right place. There is most likely a perl package on CPAN that would be more extensive, but this happens to work for my uses.









