Monday, November 26, 2012

Windows 7 Mapped Network Drive Problems

I first had issues connected to a mapped drive so i thought i would remove the mapping and reconnect it.  Then i got an error saying "This network connection does not exist" which was confusing because it clearly existed.  After consulting the all mighty google i found the following forum post with a fixed that worked which i am reiterating below.



1 - Type gpedit.msc in the Start menu’s search box and then press Enter.
2 - Navigate to User Configuration, Administrative Templates, Windows Components, and then select Windows Explorer in the left column of the Group Policy editor.
3 - Double-click Remove “Map Network Drive” and “Disconnect Network Drive” in the Settings section of the Group Policy editor.
4 - Select Enable, Apply and then click OK to save the changes.
5 - Open a command prompt and type "gpupdate /force"
6 - Log off and back on

(optional Step 5 - Restart Computer)

Thursday, November 8, 2012

MS SQL Maintenance

For those of you, who like me, need to reindex your databases every once in a while.  Here is the SQL command to do so:


SET NOCOUNT ON
GO

--Set the fillfactor
DECLARE @FillFactor TINYINT
SELECT @FillFactor=80

DECLARE @StartTime DATETIME
SELECT @StartTime=GETDATE()

if object_id('tempdb..#TablesToRebuildIndex') is not null
begin
drop table #TablesToRebuildIndex
end

DECLARE @NumTables VARCHAR(20)

SELECT
s.[Name] AS SchemaName,
t.[name] AS TableName,
SUM(p.rows) AS RowsInTable
INTO #TablesToRebuildIndex
FROM
sys.schemas s
LEFT JOIN sys.tables t
ON  s.schema_id = t.schema_id
LEFT JOIN sys.partitions p
ON  t.object_id = p.object_id
LEFT JOIN sys.allocation_units a
ON  p.partition_id = a.container_id
WHERE
p.index_id IN ( 0, 1 ) -- 0 heap table , 1 table with clustered index
AND p.rows IS NOT NULL
AND a.type = 1  -- row-data only , not LOB
GROUP BY
s.[Name],
t.[name]
SELECT @NumTables=@@ROWCOUNT

DECLARE RebuildIndex CURSOR FOR
SELECT
ROW_NUMBER() OVER (ORDER BY ttus.RowsInTable),
ttus.SchemaName,
ttus.TableName,
ttus.RowsInTable
FROM
#TablesToRebuildIndex AS ttus
ORDER BY
ttus.RowsInTable
OPEN RebuildIndex

DECLARE @TableNumber VARCHAR(20)
DECLARE @SchemaName NVARCHAR(128)
DECLARE @tableName NVARCHAR(128)
DECLARE @RowsInTable VARCHAR(20)
DECLARE @Statement NVARCHAR(300)
DECLARE @Status NVARCHAR(300)

FETCH NEXT FROM RebuildIndex INTO @TableNumber, @SchemaName, @tablename, @RowsInTable
WHILE ( @@FETCH_STATUS = 0 )
BEGIN
SET @Status='Table '+@TableNumber+' of '+@NumTables+': Rebuilding indexes on '+@SchemaName+'.'+@tablename + ' ('+@RowsInTable+' rows)'
RAISERROR (@Status, 0, 1) WITH NOWAIT  --RAISERROR used to immediately output status

SET @Statement = 'ALTER INDEX ALL ON ['+@SchemaName+'].['+@tablename +'] REBUILD WITH (FILLFACTOR = '+CONVERT(VARCHAR(3), @FillFactor)+' )'
EXEC sp_executesql @Statement

FETCH NEXT FROM RebuildIndex INTO @TableNumber, @SchemaName, @tablename, @RowsInTable
END

CLOSE RebuildIndex
DEALLOCATE RebuildIndex

drop table #TablesToRebuildIndex

Print 'Total Elapsed Time: '+CONVERT(VARCHAR(100), DATEDIFF(minute, @StartTime, GETDATE()))+' minutes'

GO

Tuesday, October 9, 2012

Chuck Norris Programming Jokes

Found this on a forum and through it was worth a post:


1. When Chuck Norris throws exceptions, it’s across the room.
2. All arrays Chuck Norris declares are of infinite size, because Chuck Norris knows no bounds.
3. Chuck Norris doesn’t have disk latency because the hard drive knows to hurry the heck up.
4. Chuck Norris writes code that optimizes itself.
5. Chuck Norris can’t test for equality because he has no equal.
6. Chuck Norris doesn’t need garbage collection because he doesn’t call .Dispose(), he calls .DropKick().
7. Chuck Norris’s first program was kill -9.
8. Chuck Norris burst the dot com bubble.
9. All browsers support the hex definitions #chuck and #norris for the colors black and blue.
10. MySpace actually isn’t your space, it’s Chuck’s (he just lets you use it).
11. Chuck Norris can write infinite recursion functions…and have them return.
12. Chuck Norris can solve the Towers of Hanoi in one move.
13. The only pattern Chuck Norris knows is God Object.
14. Chuck Norris finished World of Warcraft.
15. Project managers never ask Chuck Norris for estimations…ever.
16. Chuck Norris doesn’t use web standards as the web will conform to him.
17. “It works on my machine” always holds true for Chuck Norris.
18. Whiteboards are white because Chuck Norris scared them that way.
19. Chuck Norris doesn’t do Burn Down charts, he does Smack Down charts.
20. Chuck Norris can delete the Recycling Bin.
21. Chuck Norris’s beard can type 140 wpm.
22. Chuck Norris can unit test entire applications with a single assert.
23. Chuck Norris doesn’t bug hunt as that signifies a probability of failure, he goes bug killing.
24. Chuck Norris’s keyboard doesn’t have a Ctrl key because nothing controls Chuck Norris.
25. When Chuck Norris is web surfing websites get the message “Warning: Internet Explorer has deemed this user to be malicious or dangerous. Proceed?”.

Clay Shirky: How the Internet will (one day) transform government

This is a very good video i would recommend you watch.

Key concept: Cooperation without coordination.
http://www.ted.com/talks/clay_shirky_how_the_internet_will_one_day_transform_government.html

Thursday, September 13, 2012

Chocolatey: apt-get for windows

From the website:  Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with windows in mind.

You can even build your own packages and submit them.  I really like the concept and can see myself using this technology as a free alternative to Microsoft System Center.

Website: http://chocolatey.org/
Github Page: https://github.com/chocolatey/chocolatey/wiki


Monday, September 10, 2012

AsteriskNOW 2.0.2 64-bit WAV to MP3

I recently revamped our PBX and installed AsteriskNOW 2.0.2 64-bit (http://www.asterisk.org/downloads).  There were lots of tutorials online dealing with setup and i was able to get the server and 15 Polycom 501 handsets setup in about 3 days.  Because i am often traveling or away from my desk for long periods of time I rely heavily on the voicemail to email feature. The problem was that the .wav files were not opening on my Android Phone. After doing some research i found out that the file was in an odd format (wav|gsm).  I had two options at this point:  I could either pay a couple bucks for an android app that would play this format or i would reconfigure my server to use another format like mp3 for free.

Being a self proclaimed saver and always looking for a challenge, I decided to search the internet for tutorials.  I found a great tutorial outlining the process found here:   http://pcaddicts.ca/rc/2011/06/26/asterisknow-freepbx-mp3-voicemail/.

As i started through the process i quickly realized that this tutorial was written for an x86 setup and not an x64 setup.  Below is the steps i used on my x64 CentOS 5.8 final AsteriskNOW 2.0.2 64-bit setup.

1) Login into your box

2) Goto your home directory
cd /home/

3) Download the lastest version of lame from here http://pkgs.repoforge.org/lame/
wget http://pkgs.repoforge.org/lame/lame-3.97-1.el5.rf.x86_64.rpm

4) install rpm
rpm -Uvh lame-3.97-1.el5.rf.x86_64.rpm

5) Create the following script as /usr/sbin/sendmp3voicemail.pl
nano /usr/sbin/sendmp3voicemail.pl
#!/usr/bin/perl
open(VOICEMAIL,"|/usr/sbin/sendmail -t");
open(LAMEDEC,"|/usr/bin/dos2unix|/usr/bin/base64 -di|/usr/bin/lame --quiet --preset voice - /var/spool/asterisk/tmp/vmout.$$.mp3");
open(VM,">/var/spool/asterisk/tmp/vmout.debug.txt"); 
my $inaudio = 0;
loop: while(<>){
  if(/^\.$/){
    last loop;
  }
  if(/^Content-Type: audio\/x-wav/i){
    $inaudio = 1;
  }
  if($inaudio){
    while(s/^(Content-.*)wav(.*)$/$1mp3$2/gi){}
    if(/^\n$/){
      iloop: while(<>){
        print LAMEDEC $_;
        if(/^\n$/){
          last iloop;
        }
      }
      close(LAMEDEC);
      print VOICEMAIL "\n";
      print VM "\n";
      open(B64,"/usr/bin/base64 /var/spool/asterisk/tmp/vmout.$$.mp3|");
      while(){
        print VOICEMAIL $_; 
 print VM $_; 
      }
      close(B64);
      print VOICEMAIL "\n";
      print VM "\n";
      $inaudio = 0;
    }
  }
  print VOICEMAIL $_;
  print VM $_;
}
print VOICEMAIL "\.";
print VM "\.";
close(VOICEMAIL);
close(VM);

#CLEAN UP THE TEMP FILES CREATED
#This has to be done in a separate cron type job
#because unlinking at the end of this script is too fast,
#the message has not even gotten piped to send mail yet


6) Make the script executable
chmod 775 /usr/sbin/sendmp3voicemail.pl

7)Change default voicemail format to uncompressed WAV (which will be converted to MP3) and set mailcmd script.
FreePBX -> Voicemail Admin -> Settings

Changes:

format= wav
mailcmd= /usr/sbin/sendmp3voicemail.pl


8) Restart Asterisk and test
service asterisk restart

Thursday, September 6, 2012

Thoughts about article "Time to Give Java the Boot?"

I started reading an article titled "Time to Give Java the Boot?" found here:

http://www.pcworld.com/article/261843/time_to_give_java_the_boot.html

I almost stopped reading this article once they made the following statement: "The Mac operating system has been near-bulletproof to vulnerabilities...".

As most system admins know, the only reason that the Mac operating system has been "near-bulletproof" is because until recently they didn't have enough market share to matter to virus/malware authors.  Now that they do, this perception is changing.  Apple itself has had to remove statements like "It doesn't get PC viruses" from their website because it actually does get viruses... see http://www.pcmag.com/article2/0,2817,2406275,00.asp.

I am not an Apple hater.  I use my ipad almost daily but it is statements like this that make people complacent about their security and leave them vulnerable to attack. If technical writes at pcworld believe the apple marketing hype then i can only image what the general public must think.

As far as the point of the article, i agree that java is becoming less important for end users and i believe browser based technologies like HTML 5 will eventually replace java on the desktop but on the server JAVA and the JVM are here to stay.


Phoenix

I am resurrecting this tech blog for notes related to Azure Logic Apps with SAP.