Posts

Regex vba searching in workbook

 Option Explicit Sub qd_Flag_Cells_by_RegeXeq() ' ' Converts each text hyperlink selected into a working hyperlink ' Dim strSearch As String Application.ScreenUpdating = False strSearch = InputBox(Prompt:="Search String.", _           title:="Search")                    If strSearch = vbNullString Then            Exit Sub         Else             Dim re As New RegExp             re.Pattern = strSearch             re.IgnoreCase = True                          Dim xCell As Range             For Each xCell In Selection                 If re.Test(xCell.Text) = True Then                    xCel...

Install the tiny_tds gem on Mac OS X

Install the tiny_tds MS SQL Server GEM on Mac OS X. I kept getting this annoying error $ gem install tiny_tds -- --with-iconv-include=/usr/local/include/ --with-iconv-lib=/usr/local/lib/ Building native extensions with: '--with-iconv-include=/usr/local/include/ --with-iconv-lib=/usr/local/lib/' This could take a while... ERROR:  Error installing tiny_tds: ERROR: Failed to build gem native extension.     /Users/zhangj/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-iconv-include=/usr/local/include/ --with-iconv-lib=/usr/local/lib/ checking for iconv_open() in iconv.h... no checking for iconv_open() in -liconv... no ----- libiconv is missing. ----- *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options. Provided configuration options: --with-opt-dir --with-opt-include --withou...

Make links active in Excel 2007

Make text links in cells active in Excel 2007 Sub AddCustomHyperlink() ' ' Converts each text hyperlink selected into a working hyperlink ' For Each xCell In Selection ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Value Next xCell ' ' End Sub

Mac itunes fade in alarm clock!!

Ok so you like to wake up to your tunes, but you want to do this the geeked out way. ok then.. this script will slowly raise the volume to gently wake you up in the morning from itunes... open up the terminal on your mac create a file called wake.sh jcp$ nano wake.sh paste this into the screen but change the song name MY_FAVSONG_IN_ITUNES to something you like **IT MUST MATCH THE NAME OF A SONG EXACTLY THAT IS IN YOUR iTUNES LIBRARY** IMPORTANT #!/bin/bash osascript -e "set Volume 9" # set the MAC speaker volume to max osascript -e 'tell application "iTunes" to set sound volume to 0' ; osascript -e 'tell application "iTunes" to play track "MY_FAVSONG_IN_ITUNES"' ; i=1; while [ $i -le 100 ] ; do osascript<<EOT tell application "iTunes" to set sound volume to "$i" # raise the volume every 2 seconds EOT sleep 2 ; (( i++ )); done ; sleep 480 ; osascript -e 'tell application ...

Script to ban hosts from connecting to your server by searching apache logs for keywords and odd browsers.

#I noticed several entires from a browser script obviously used by hackers. ## Lets block the bastards for hackerhost in `cat /var/log/httpd/access_log | grep XXSOMEWORDXX | awk '{ print $1 }' | uniq ` do `iptables -A INPUT -s $hackerhost -j DROP` done

Get all the host names of people who visited your web server

typographo@jpnyc:~ #cat /var/log/httpd/access_log* | awk '{print $1 }' | sort | uniq | nslookup | grep name > 144.205.50.70.in-addr.arpa name = 92.f5.344af.static.theplanet.com. > 164.233.101.75.in-addr.arpa name = ec2-75-101-233-167.compute-1.amaffzonaws.com. > 13.254.75.75.in-addr.arpa name = sithe.megaglobexghf.net. > 125.123.15.76.in-addr.arpa name = user-160v6bs.cable.minddspring.com. > 34.113.125.79.in-addr.arpa name = ec2-79-125-118-35.eu-west-1.cofmpudte.amazfhonaws.com. > 114.44.102.94.in-addr.arpa name = client-112-8-102-94.revgffgerse.nif.nget.tfr. > 113.251.179.94.in-addr.arpa name = 94.179.211.110.povol.3g.uftel.uga. > 83.41.239.96.in-addr.arpa name = pool-96-239-51-89.nycvmdny.eastf.verizon.net.

Find countries in a file's text using regular expressions and Perl

If you have a file with multiple rows of columns such as: RowID, year, address, journalist separated by tabs, how would you create a report of the rowID, year , country the article was written in? #!/usr/bin/perl use Uniq; $file = "The_text_file_with_addresses.txt"; $filename = $file ; $filename =~ s/\.txt// ; open OUTFILE, "+>$filename.out.txt" or die $!; open INFILE, $file or die $!; print "running...\n" ; close(OUTFILE); $docs = 0 ; while (<INFILE>) { my @agents ; $currentline = $_ ; chomp $currentline ; ( $row_id , $year, $address, $journ) = split(/\t/,$currentline ); if ($address =~ /(Afghanistan|Akrotiri|Albania|Algeria|American Samoa|Andorra|Angola|Anguilla|Antarctica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier Islands|Australia|Austria|Azerbaijan|Bahamas, The|Bahrain|Bangladesh|Barbados|Bassas da India|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Bouvet Islan...