making a custom google map (for ingles stores =P)


haven't fiddled with this in forever but i had a need recently to find all the 'ingles' supermarkets. so i simply went out to the company site and got an address list. manually cleaned it up a little bit with some fancy search and replace and then had a tsv basically. went out to google maps to see what i needed. obviously not an address list. found that it wanted kml or georss or something. quick search turned up this great page at http://www.batchgeocode.com/ which will allow you to put in a simple tsv (or | delim'd) set of data with some columns and it will build it for you. super. about 10 minutes later i had my kml and had it uploaded into my new google map. saved at: http://maps.google.com/maps/ms?ie=UTF8&msa=0&ll=34.939985,-82.529297&spn=8.200485,16.907959&z=7&msid=102498971695683833588.000477e9967e48e7ac6af pretty nifty and easy.

author: Roy Ashbrook | posted @ Monday, November 09, 2009 1:01 AM | Feedback (0)

Adding a task item to sharepoint with VBScript and Microsoft.XMLHttp


who'd want to such a crazy thing? well me. i just wanted to find the dirtiest quickest way with zero overhead to push data directly into a sharepoint list. i found a few articles with some information about this, but the closest one was this one using jquery. so here it is in vbscript with no extra libraries or anything (except what is build into windows which is still plenty). one cool thing about this is it was quite faster than the .net method i posted previously. i attribute that to building a nice web reference with all the different methods in it and all that overhead. i'm sure i could speed it up, and i didn't try just using this method in .net which would probably be faster too. this doesn't require .net or a compiler though and i can just open the file to fiddle if i need to so nifty for my current purpose. =D

and yes, i know there are better ways to concat text. i'm done fiddling with this for now so we'll all live =P code is commented below i believe sufficiently. it's not too complicated =P

 

'some vars
url = "http://<yoursitegoeshere>/_vti_bin/Lists.asmx"
list = "<yourlistgoeshere>" 'can be GUID too
id = 2
title = wscript.arguments(0)

'the caml
batch = "<Batch OnError='Continue' ListVersion='1'>"
batch = batch + " <Method ID='1' Cmd='New'>"
batch = batch + "  <Field Name='ID'>New</Field>"
batch = batch + "  <Field Name='Title'>" & title & "</Field>"
batch = batch + "  <Field Name='AssignedTo'>" & id & "</Field>"
batch = batch + " </Method>"
batch = batch + "</Batch>"

'soap wrapper plus some info in body
request =  "<?xml version='1.0' encoding='utf-8'?>"
request =  request + "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
request =  request + "            xmlns:xsd='http://www.w3.org/2001/XMLSchema'"
request =  request + "            xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>"
request =  request + "  <soap:Body>"
request =  request + "  <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>"
request =  request + "              <listName>" & list & "</listName>"
request =  request + "              <updates>" & batch & "</updates>"
request =  request + "  </UpdateListItems>"
request =  request + "  </soap:Body>"
request =  request + "</soap:Envelope>"

'post it up and look at the response
with CreateObject("Microsoft.XMLHTTP")
 .open "POST", url, False
 .setRequestHeader "Content-Type", "text/xml; charset=utf-8"
 .setRequestHeader "SOAPAction","http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"
 .send request
 wscript.echo .responseText
end with

 

 

author: royashbrook | posted @ Thursday, October 15, 2009 10:46 PM | Feedback (0)

Adding an task item to sharepoint with C# .net


There are lots of ways to do things like this. Here's a pretty simple way with c# and .net. forgive some of the using shortcuts, i was just isolating a couple of areas. and as always i normally just post these so i don't forget =P

this is just a console app to add a single item to a task list in sharepoint. very simple. the only thing that was a bit of a pain is you need to find your sharepoint id for the person. the easiest way i found that for myself was simply to go to the list, edit the view settings, select the assign to column and change the 'show' to id. then i grabbed that id and used it to create my items. if i had other people sharing this i would probably just build a small table and do lookups. if it was a really huge amount and critical, you can create a web service. there are a bunch of things out on the web about that but they all require server logic which i didn't want.

"sp" is a web reference to the asmx url below. seems that if you don't set the url property it won't work though. for all i know you can refer to a diff url for the web ref as long as you set the correct property. i didn't fiddle with that much.

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using cc = System.Net.CredentialCache;
using c = System.Console;
using e = System.Environment;
using d = System.Xml.XmlDocument;

namespace todo
{
    class Program
    {
        private const string id = "%sharepointidofpersontoassign%";
        private const string url = "http://%yoursite%/_vti_bin/Lists.asmx";
        private const string list = "%yourlist%"; //can be GUID too
        private const string strBatch = "Newt1assignedto";

        static void Main(string[] args)
        {
            // make sure we have an arg
            if (args.Length != 1)
            {
                c.WriteLine("Syntax: todo title");
                e.Exit(0);
            }

            // get our xml doc together to post
            d x = new d();
            x.LoadXml(strBatch.Replace(
                "t1", args[0].ToString()).Replace(
                    "assignedto", id));

            //connect to the list and do our business
            using (sp.Lists l = new sp.Lists())
            {
                l.Url = url;
                l.Credentials = cc.DefaultCredentials;
                l.UpdateListItems(list, x);
            }
        }
    }
}

author: royashbrook | posted @ Thursday, October 15, 2009 10:38 PM | Feedback (0)

delete objects belonging to a schema in sql


so you try to wack a crazy user who created stuff under his/her own schema in a sql database, but when you try to drop the schema, you get the evil 'something is owned' message. then you look and see they have a billion objects. booo..... oh well, not too big of a deal. you can use something similar to below. the below just drops syn's but you can put a case statement in the build portion based on type and drop everything you need to. obviously this can be tweaked some based on your taste. 

declare @s nvarchar(max)

while (
	select
		count(*)
	from
		sys.objects obj
		join sys.schemas s
			on (s.schema_id=obj.schema_id)
	where
		s.name='') > 0
begin
	select top 1
		@s = N'DROP SYNONYM [].[' + obj.name + ']'
	from
		sys.objects obj
		join sys.schemas s
			on (s.schema_id=obj.schema_id)
	where
		s.name=''
	print @s
	execute(@s)
end

author: Blog Author | posted @ Monday, October 05, 2009 7:51 PM | Feedback (0)

how do i disconnect all of my network drives in windows


net use * /d /y

the /y is undocumented as far as i can see. it provides a 'Y' when it asks if you're sure.

author: royashbrook | posted @ Thursday, September 03, 2009 4:16 PM | Feedback (0)

windows 7 rc


installed this the other day on a few different computers. great experiences so far for me. i used the guide at the following url. http://www.bwana.org/2009/01/11/how-to-install-windows-7-beta-from-a-usb-drive-to-an-hp-mini-1000-without-vista/

author: royashbrook | posted @ Sunday, May 24, 2009 5:59 AM | Feedback (0)

create a custom sendto item to process files... with powershell...


in reply to dennis' comment on my last post on this little thing (http://drowningintechnicaldebt.com/blogs/royashbrook/archive/2009/01/21/create-a-custom-sendto-item-to-process-files.aspx), here's the way to do this with powershell

  1. make sure you have powershell installed and working
  2. create script somewhere with text: foreach ($i in $args) {move-item $i $i.Replace(".mod", ".mpeg")}
  3. create a shortcut in the sendto folder that has the command of '[pathtopowershell.exe] -noexit [pathtoscript]
  4. enjoy!

i was only renaming certain files to certain other files (MOD to MPEG), but obviously you can customize this however you see fit. i had my batch before set not to exit so i could see what was up, but you could take out the -noexit if you wanted it to just run and bail. powershell definitely is more powerful, but IMO still a huge pain for most stuff i would use it for. if most admins invested the amount of time it would take to ramp up using powershell into learning existing tools, they probably wouldn't need it. i'm definitely enjoying playing with it though. here are some references i used:

http://blogs.msdn.com/mikeormond/archive/2008/01/20/powershell-batch-rename.aspx
http://blogs.msdn.com/powershell/
http://sandbox.manning.com/thread.jspa?messageID=62599
http://powershell.wik.is/Cmdlet_Help/Microsoft.PowerShell.Management/Rename-Item
http://adrianba.net/archive/2007/10/29/rename-item-and-square-brackets-in-powershell-no--literalpath.aspx

 

author: royashbrook | posted @ Monday, May 18, 2009 7:27 PM | Feedback (0)

dsquery, dsget, etc


how i have lived this long in my life without familiarity with these commands is beyond me. i'm a big fan of the command line especially commands that are already or mostly built in. these come with the admin pack. so much easier than opening up the ad user group mgr and other gui tools. here's a sample command.

dsquery group -name "any domain group in your domain" | dsget group -members |dsget user -email -samid -display

this command will pipe the full name to the get command to list the members which pipes to the command to show the email, samid, and the display name. obviously tons of different ways to do everything, but this is something i have been using a lot as normally when i open the ad tools it is to get similar simple details, not to do things that that tool really excels at. to me anyway.

dsquery user -samid "domainid" | dsget user -memberof | dsget group -samid

list group memberships for a user using the group samid.

author: royashbrook | posted @ Monday, May 18, 2009 5:56 PM | Feedback (0)

old ruby code for working with sugarcrm


Login and show basic info

require 'soap/wsdlDriver'
require 'digest/md5'
u = "user"
p = Digest::MD5.hexdigest("password")
ua = {"user_name" => u,"password" => p}
wsdl = "http://yoursite.com/soap.php?wsdl"

#create soap
s = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver

#uncomment this line for debugging. saves xml packets to files
#s.wiredump_file_base = "soapresult"

#create session
ss = s.login(ua,nil)

#check for login errors
if ss.error.number.to_i != 0 

	#status message
	puts "failed to login - #{ss.error.description}"
	
	#exit program
	exit
else

	#get id
	sid = ss['id']

	#get current user id
	uid = s.get_user_id(sid)
	
	#status message
	puts "logged in to session #{sid} as #{u} (#{uid}) "
	
	#logout
	s.logout(sid)
	
	#status message
	puts "logged out"
end

Adding an account
After login, you can create new accounts using the code :
        module_name = "Accounts"    
        name_value_list =  [ { "name" => "name", "value" => "theworldcompany" },
                             { "name" => "phone_office", "value" => "01234567" } ]
        s.set_entry(sid, module_name,  name_value_list)

author: royashbrook | posted @ Sunday, March 15, 2009 8:01 PM | Feedback (0)

create a custom sendto item to process files


so i have this video camera and it records files to mod files. i dunno why. mod's are just like mpegs. you can just rename them and open them. i don't know why they aren't just saved as mpegs, but whatever. so i got tired of dropping out to dos and just renaming the files so i could review them. i could also i'm sure find a way to just register mod files with my computer but bah. i decided to just create a custom sendto item so i could just mass rename them. so if you want to rename a bunch of files or really do anything to a bunch of files, you can create a file called whateveryouwant.cmd and put it in your sendto folder inside of your profile folder. then i used the text:

:loop
ren %1 *.mpeg
shift
if %1. NEQ . goto loop

in the file. you could replace the ren command with whatever you want. %1 should be the current file. anyway, if anyone finds this and it doesn't make sense, just comment and i'll clarify.

author: royashbrook | posted @ Thursday, January 22, 2009 3:41 AM | Feedback (2)