sort words separated by a coma in linux console
8
Load images more quickly in a web page by having the browser cache them before they are requested by the user.
This script specifies the location of images that share a common folder. It can be used for multiple images and folders.
This method uses less code and is more maintanable than specifying the location of each image individually.
This script specifies the location of images that share a common folder. It can be used for multiple images and folders.
This method uses less code and is more maintanable than specifying the location of each image individually.
8
This little tool is pretty useful for administrators who wear the hat of both system admin and DBA on Linux/MySQL boxes. I wrote it as kind of a joke for our Perl developers, but now I use it just about every day for everything from at prompt hackups to full on table space utilization monitoring scripts.
The snippet has the library script that you can source into scripts that actually do work, as well as a script that uses the functions in the libraries. Anyone who has used the C API should be able to relate to using this script.
It's pretty fast and lightweight. It makes only one external call to mysql and sed per query. The rest is all bash builtins. Requires bash > 3.0
The snippet has the library script that you can source into scripts that actually do work, as well as a script that uses the functions in the libraries. Anyone who has used the C API should be able to relate to using this script.
It's pretty fast and lightweight. It makes only one external call to mysql and sed per query. The rest is all bash builtins. Requires bash > 3.0
7
A lot of time shell scripts need to do some sort of math. Bash's innability to do floating point arithmatic has lead to some pretty neat workarounds, often times these workarounds are slow. If you need a lot of calculations done with speed, you'll find this snippet useful
9
Parsing newline-delimited data records in bash is simple, if you have this odd redirect up your sleeve. An annoying thing about bash is that it usually equates all whitespace characters, so the first block in the snippet won't let you use a file linewise, but will end up echoing each whitespace-delimited token on a separate line.
bash provides the "read" builtin which can be used to differentiate between newlines and spaces.
bash provides the "read" builtin which can be used to differentiate between newlines and spaces.
5
how to handle arrays in bash
0
Small amount of bash shell code to produce terminal output. I use this to keep alive ssh connections where the server will automatically disconnect a session where input is not received for a small amount of time.
Needs: A terminal that understands ansi.sys escape codes. Most modern interactive terminals. You might have limited success on serial terminals.
CAVEAT: Admittedly
watch date
would do the same job - but is less fun.
In use I have this in a function in my .bashrc
function keepalive () {
}
Needs: A terminal that understands ansi.sys escape codes. Most modern interactive terminals. You might have limited success on serial terminals.
CAVEAT: Admittedly
watch date
would do the same job - but is less fun.
In use I have this in a function in my .bashrc
function keepalive () {
}
2
An implementation of Gnome Sort in 9 lines of Redcode. Smaller and faster than Bubble Sort.
1
An implementation of Gnome Sort in 9 lines of Redcode. Smaller and faster than Bubble Sort. Speed increase of .5x^2-2.5x over version 1.
14
Flexible sorting algorithm based on Quicksort with extra functionality, such as:
- Direction (ie: ascending or descending)
- Sort-by-path (eg: item.name, item.name.firstName or item[5])
- Sorting function (returns true if two items are already sorted)
- Type checking
- All constants and support functions are members of the Sort() function
- Testsuite with hooks for cscript and in-browser javascript, so you can tweak and optimize, and make sure it still works
- Environment agnostic (can use with, say, SpiderMonkey or .Net's jsc)
- Direction (ie: ascending or descending)
- Sort-by-path (eg: item.name, item.name.firstName or item[5])
- Sorting function (returns true if two items are already sorted)
- Type checking
- All constants and support functions are members of the Sort() function
- Testsuite with hooks for cscript and in-browser javascript, so you can tweak and optimize, and make sure it still works
- Environment agnostic (can use with, say, SpiderMonkey or .Net's jsc)
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.









