Archive & Compression utilities

Compression types and utils in Linux There are many compression utilities available to the average users on a linux system, so which one is best? well it all depends on what your intended use/goal for the file(s) is. Are you planning on sending the file to other OS’s? are you planning on decompressing the file on a new system where you might not have the same tools available? etc etc. I am writing about some of the ones I have used, and since this is from my usage some of it may not be entirely true and I may have dreamed up during my hallucinatory state while attending classes. Zip The Most popular tool, archives and provides basic compression. Works on most OS’s popularly used today. zip <filename> <files to compress>      —– zip files into one archive zip doc1 doc2 doc3 doc4 unzip <filename>       —– unzip files from an archive into their proper paths under current directory. unzip -j <filename>      —– unzip files from the archive into current directory not following directory structure. Tar Archive only, no compression applied by default. usually found with .tar extension tar -cf        —– tar multiple files into one archive with no compression (see bzip2 / gzip for compression) tar -xf <filename>      —– extract files from a tarball Rar Proprietary but with support for almost all popular platforms, decent compression + archival. usually found with .rar extension rar a <filename> <files to compress>      —– archive + compress unrar x <filename>     […]

Cable pronz? A very neatly done Datacenter

[et_pb_section admin_label=”Section” fullwidth=”on” specialty=”off”][et_pb_fullwidth_post_title admin_label=”Fullwidth Post Title” title=”on” meta=”on” author=”off” date=”on” categories=”on” comments=”off” featured_image=”on” featured_placement=”background” parallax_effect=”off” parallax_method=”on” text_orientation=”center” text_color=”dark” text_background=”on” text_bg_color=”rgba(255,255,255,0.9)” module_bg_color=”rgba(255,255,255,0)” title_all_caps=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] [/et_pb_fullwidth_post_title][/et_pb_section][et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_gallery admin_label=”Gallery” gallery_ids=”46,45,44,43,42,41,40,39,38″ gallery_orderby=”rand” fullwidth=”on” show_title_and_caption=”on” show_pagination=”on” background_layout=”light” auto=”on” auto_speed=”7451″ hover_overlay_color=”rgba(255,255,255,0.9)” caption_all_caps=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid” /][/et_pb_column][/et_pb_row][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”bottom above footer” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] [/et_pb_text][et_pb_divider admin_label=”Divider” color=”#ffffff” show_divider=”off” divider_style=”solid” divider_position=”top” hide_on_mobile=”on”] [/et_pb_divider][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] [/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Sed 101

SED aka stream editor is a utility app in linux / bsd systems (among others) which allows you to parse text in files based on simple regexp and change them based on its own set of rules. simple syntax for parsing and replacing text in a file called test.txt that contains the text I love cats and hate dogs n number of times and replace with I love sloths and hate ducks sed -e ‘s/cats/sloths/’ test.txt sed -e ‘s/dogs/ducks/’ test.txt but to make it shorter you can actually add the options to same command. sed -e ‘s/cats/sloths/g’ -e ‘s/dogs/ducks/g’ test.txt the problem with above? it will only do so once per line, so if oyu have multiple instances it wont work. so you need to “globalize” this search/replace. note the added g after the words sed -e ‘s/dogs/ducks/g’ test.txt what if you only want the replacements to happen on lines 2 – 7? sed -e ‘2,7s/dogs/ducks/g’ test.txt How about if you want to only replace on lines begining with the word link? (replace link with any other word you please) and ending in the word pie (again replace pie with whatever) sed -e ‘/^link/,/^pie/s/dogs/ducks/g’ test.txt what if your words have the separator / already in them? say in a path like /home/kingpin ? well you can replace the separator with anything arbitrary you choose at the beginning after the s and it will change the separator all throughout the sed command. sed -e ‘s;dogs;ducks;g’ test.txt or with / in the words sed -e ‘s;/home/kingpin;/home/notkingpin;g’ test.txt […]

php Filter var & common regex patterns

People … quit messing about with ereg_replace / preg_replace / eregi or other things you know nothing of… use the php filter_var. DO IT. Commonly found bullshit on the interwebs : function isValidEmail($email){ return eregi(“^[_a-z0-9-]+(\.[_a-z0-9-]+)@[a-z0-9-]+(\.[a-z0-9-]+)(\.[a-z]{2,3})$”,$email); } eregi is deprecated and silly, the above WILL miss some of the weirder or longer email addresses like school/company addresses. make your life simpler : function isValidEmail($email)    { return filter_var($email, FILTER_VALIDATE_EMAIL); } while not the most perfect thing, its easier to remember AND add to your code. More info regarding this : PHP manual Filter Var Some examples : /*** validate bools ***/ echo filter_var(“true”, FILTER_VALIDATE_BOOLEAN); if(filter_var($url, FILTER_VALIDATE_URL) === FALSE) { /*** no ***/ echo “Sorry, $url is not valid!”; } else { /*** yes ***/ echo “The URL, $url is valid! “; }

New blog! yay! etc.

So I’m starting a blog so i can keep track of tips. tricks and shortcuts I find/come up with or utilize during my daily work as an unappreciated IT drone. yes there’s hundreds of thousands of other blogs. but I have web space + bandwidth etc etc. so yeah. This blog is hosted on quad quad core 24 GB ram gigabit connect machine using nginx, php-fpm, mysql 5.5. overkill? hell no. maybe I will get famous and get 10 million hits a day :D…… hey I can dream right?