Is String Numeric
9
Generates an 88 character secure hash string for the passed in strings.
7
The modus operandi for this is similar to that taken by PHP's implementation of such functions. It's comparitively memory-intensive, but is much faster than running a whole bunch of tests.
Basically, you set a mask -- an array of 256 null bytes -- and set those that correspond to characters you wish to trim. Then, rather than having to test if a character is in the set of characters to trim(O(n), or linear time on *ws), you just test once (O(1), or unit time) to see if the byte in question is set.
And of course, to trim(), you just wrap trim() around both ltrim() and rtrim().
One point of caution: these functions trim in place, so copy strings before trimming them. (Of course, if you usually want access to both pre- and post-trimmed strings, you could always make these malloc() a new string and return a pointer to it . . . )
Basically, you set a mask -- an array of 256 null bytes -- and set those that correspond to characters you wish to trim. Then, rather than having to test if a character is in the set of characters to trim(O(n), or linear time on *ws), you just test once (O(1), or unit time) to see if the byte in question is set.
And of course, to trim(), you just wrap trim() around both ltrim() and rtrim().
One point of caution: these functions trim in place, so copy strings before trimming them. (Of course, if you usually want access to both pre- and post-trimmed strings, you could always make these malloc() a new string and return a pointer to it . . . )
7
Turns any string backwards. If you input "Test" it gives out "tseT". Hope it's useful.
The snippet shows how to use it.
The snippet shows how to use it.
12
Similar to Perl's CGI::escapeHTML(), though (because we can!) this adds it as a method to all String objects.
8
Add this header after all your other headers. Compiles on standards compliant compilers.
7
I use this function when passing an array to a function being called from setTimeout();
8
This little function puts a string of a specified color and (centered) location. However, keep the word simple in mind. I purposfully not made it capable of supporting newlines.
By the way, this is my first snippet
By the way, this is my first snippet
8
I made this a little while back for a friend who was having trouble learning sockets. Below are snf.h, snferror.h and example.cpp (a little example).
The example opens a "web server" at port 8080 on the machine. However, it displays just one page.
Have fun!
The example opens a "web server" at port 8080 on the machine. However, it displays just one page.
Have fun!
9
I was coding a project that used arrays when the lack of a standard foreach in C/C++ got to me. So, I coded this little function to help me. It applies a function that returns int to each element of the array.
5
Two very usefull functions to have around.
(note: dollarfy requires commify to work)
(note: dollarfy requires commify to work)









