May
25
2009
I spent awhile after work today trying to figure out why my mapped drives in windows weren’t working. I kept getting “MSHOME is not accessible” which was annoying because I wanted to watch some cartoons. Turns out that I booted my Linux box first and it became the master browser so I had to turn off my samba server and allow the windows xp machine to become the master browser. I found this out by using these commands and tools.
For informational purposes theres
net config server
net config workstation
ipconfig /all
Those commands can be helpful at times but I found that they do not give enough information about the computer browsing services.
I found a tool called Browstat that you can download for free that gives you the clues to properly debug your windows network. Once you’ve downloaded that file and put it in your C:\Windows folder you’re going to want to open up a command window and type: browstat status.
This will give you most of the information that you need to debug your network.
If anyone knows about any other great networking tools like browstat I would really like to know about them.
2 comments | tags: browstat, commands, networking, windows, windows network | posted in problems and solutions
May
24
2009
Functions are objects. This makes recursion short and sweet in javascript using anonymous functions.
In your html, php, or asp file try this out.
<input type=’button’ id=’myButton’ value=”5″>
<script type=’text/javascript’>
var myButton = document.getElementById(“myButton”);
var i=myButton.value;
myButton.onclick = function() {
if(i==0)
{
alert(“DONE”);
myButton.value = i;
return i;
}
alert(i);
return arguments.callee(–i);
};
</script>
I attached the anonymous function onto the onclick event for the button that was created right above the javascript. When that button is clicked the anonymous function will call itself and decrement ‘i’ until it is zero. When ‘i’ becomes zero the value of the button is set to 0 and the function returns. Nice and simple.
The only possible confusing thing here is the arguments.callee line. Remember I said that functions are objects? The arguments.callee actually calls itself. We need this because we don’t have a handle for the anonymous function. The arguments object is a local variable that all functions have. It can be used like an array to access the values passed to the function. It also holds ‘callee’, ‘caller’, and ‘length’. Since the callee is the function itself then caller is obviously the function that called it and length is the number of arguments passed to the function.
2 comments | tags: anonymous, javascript, programming, recursion | posted in programming, reference
May
24
2009
Learning javascript by copying and pasting useful snippets off the web, the only aspects of Javascript that I’ve ever looked closely at were to change css properties, validate forms, or get some values with ajax. Because of this, there is still a large portion of the language that I’m still learning. I’ve never used anonymous functions in any language, but they’ve always looked like an interesting concept, so I decided to give it a shot. This is what I learned with a few short examples.
This little javascript feature can be hugely useful for passing functions as variables or declaring quick functions inline for the programmer who is to lazy to switch files or scroll to wherever that annoying javascript declaration is.
To pass a function as a variable either with a reference or inline:
<script type=’text/javascript’>
//garbage example data
var array = [ 3, 14, 15, 9, 26 ]
var array2 = [ 3, 14, 15, 9, 26 ]
//This function takes an array and a function as parameters.
//It then executes the passed function on every element of the array.
function execute_on_array( array_of_stuff, anonymous_function )
{
for (var i=0; i<array_of_stuff.length; i++)
{
alert(“before ” + array_of_stuff[i]);
array_of_stuff[i] = anonymous_function(array_of_stuff[i]);
alert(“after” + array_of_stuff[i]);
}
}
//Here’s the anonymous function that is now referred to as nullify_function
var nullify_function = function (x) { if(x) return 0; else return x; }
//Passing an anonymous function in as a variable
execute_on_array( array_of_numbers, nullify_function);
//Here is the call to the previous function with an anonymous function defined inline
function execute_on_array( array2, function (x) { x=0; return x; } );
</script>
I could see how this would make recursion in javascript really easy.
Comments Off on Anonymous Function Examples in Javascript | tags: anonymous functions, javascript, programming | posted in programming
May
24
2009
Stream Video to Iphone with Tversity
After using Tversity for quite some time to stream my media to my Xbox 360 over my local network, I decided I wanted the same functionality on my iphone.
This is how I did it:
Logged on to my wifi with my iphone and pointed safari to: 192.168.2.10:41952 which is the ip address of my tversity windows server.
41952 is the port that the tversity mediaserver listens on.
I was then shown a nice and easy to navigate web interface to browse through all my folders.
After locating a basic xvid tv show I selected “Play in Media Player”.
The iphone loaded the media player and seemed like it was going to load the movie but then this error popped up.
“This movie format is not supported”.
I searched and searched for a solution to this but found none so I transcoded a video file using one of the many ipod touch video converter programs and added it to my media in tversity.
When I browsed to this file in Tversity and clicked play it worked.
It’s kinda a pain that Tversity can’t handle converting these files on the fly but it’s still useful to watch videos on my mobile
Comments Off on Stream Video To The Iphone Using Tversity | tags: iphone, network, Phone, program, tv, web, xbox, xbox 360 | posted in iphone
May
23
2009
I’ve been spending way to much time on my iphone lately and It’s been becoming a little unresponsive. When I scroll I notice the refresh rate is delayed and loading programs like phone, sms and safari are delayed. At first I thought that my theme was the cause but even after turning off all winterboard effects I still have the same problem. I decided to research the issue and here are my results.
- The iphone is said to never shut a program down so the memory of the device is getting saturated. To cure this you need to reset the device.You would think that powering down and back up again would do this but apparently you need to hold the power button and the home button at the same time until the iphone shuts down.
- Remove unused programs. As soon as I got rid of a few of the apps that I never use the phone started responding a lot quicker but still not quick enough.
- Turn off ssh. Running the ssh daemon in the background is using resources. If you’re not scp’d or ssh’d into the phone at the moment then why do you have it running?
- Turn off the GPS services. If you need it then turn it back on. In Settings => General click “Location Services” to off. This will also help with battery life on the iphone.
- If you’re suffering from SMS lag I’ve read that opening and closing the app store solves the problem on the iphone.
Mostly straight forward but still useful. I’ve found that Winterboard does not cause any lag whatsoever. I’ve tried multiple themes and played around with each and they don’t seem to lag the phone out at all.
Comments Off on Iphone Lag Fixes | tags: iphone, iphone 3g, iphone lag, iphone responsiveness | posted in iphone, problems and solutions
May
21
2009
I found a couple new windows hotkeys that I don’t think I’ve ever used before. Decided to put up a poll to see what most people use on a day to day basis. All the useful windows hotkeys with explanations are right under the poll.

Loading ...
CTRL and A Select All
CTRL and C Copy
CTRL and F Find
CTRL and G Go To
CTRL and N New
CTRL and O Open
CTRL and P Print
CTRL and S Save
CTRL and V Paste
CTRL and X Cut
CTRL and Z Undo
CTRL and F4 Close
CTRL+ESC Start menu
ALT+ENTER View Properties
ALT+F4 Close Item
ALT+SPACEBAR Open Shortcut Menu
ALT+TAB Switch Programs
ALT+ESC Cycle Through Programs
F1 key Help
F2 key Rename in Windows Explorer
F3 key Search (Same as CTRL and F)
F4 key Display Address Bar
F5 key Update/Refresh
F10 key Activate Menu Bar
Windows Key Display or hide the Start menu
Windows Key+BREAK Display the System Properties dialog box
Windows Key+D Display the desktop
Windows Key+M Minimize all of the windows
Windows Key+SHIFT+M Restore the minimized windows
Windows Key+E Open My Computer
Windows Key+F Search for a file or a folder
Windows Key+CTRL+F Search for computers
Windows Key+F1 Display Windows Help
Windows Key+ L Lock the keyboard
Windows Key+R Open the Run dialog box
Windows Key+U Open Utility Manager
TAB Move forward through the options
SHIFT+TAB Move backward through the options
CTRL+TAB Move forward through the tabs
CTRL+SHIFT+TAB Move backward through the tabs
If I missed any then let me know
4 comments | tags: hotkeys, poll, windows, windows xp | posted in reference
May
20
2009
Do you ever download those files that are comprised of multiple zip files that always seem to extract individual rar files to their own folders. This would normally require the user to cut and paste all these rar files back into the original folder and then unrar them. This is very tedious, especially when there is lots of these files and folders. I’ve written this little shell script to automate this task for myself and figured that I would share. This script is extremely simple but it has worked great for every double archive that I have tried it on. As always any improvements and comments are welcome.
Call this script from the command line when your current working directory is the folder with all the zip files in it. To get your current working directory use the command ‘pwd’.
unzip -o \*.zip
for f in *.rar;do unrar -o- e “$f”;done
rm *.rar
rm *.zip
You may be asking why I was forced to escape the ‘*’ in the first line. If I didn’t do this then I got a lot of “caution: filename not matched:” errors on the unzip line. Not sure why and if anyone can shed some light on that it would be great. As for the option to the commands, read the man pages. And the for loop is pretty self explanatory.
Enjoy those giant image sets.
Comments Off on unzip and unrar bash script | tags: command line, linux, shell script, unzip unrar | posted in programming, reference
May
19
2009
Why isn’t there a ‘auto increment’ type in postgres?
When I was creating a table in postgres earlier today I needed a unique identifier to use as a foreign key in other tables. There were no unique fields in the postgres table so I wanted to create an auto increment column type. I was surprised after browsing the field types in pgAdmin III that there is no ‘auto increment’ data type in postgres. I was expecting one because I’m so used to using mysql for the actual creation of databases. It seems that when using postgres we are expected to use either sequences for the very specifics or the serial data type for the basic +1 auto increment integer.
Here’s an example of using sequences :
First create the sequence:
CREATE SEQUENCE codys_sequence;
Then create the postgres table:
CREATE TABLE some_postgres_table (
id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval(‘codys_sequence”),
some_field VARCHAR(50),
some_other_field VARCHAR(100)
);
It is a lot easier to just let the postgres database handle the creation and automation by specifying the field as a SERIAL type. Sequences are mostly useful when you want to increment the integer by a certain value like if you’re using master-master replication and don’t want to worry about race conditions.
With either a sequence or a serial field type it is much easier to insert data than with manually updated integer because you don’t need to include anything about the field in your insert statements.
INSERT into some_postgres_table (some_field,some_other_field) values (“auto”,”increment”);
Technorati Profile
2 comments | tags: databases, mysql, postgresql, sql | posted in reference
May
18
2009
Here are a few more little known tricks that can be used to get better results from the google search engine. Save some bandwidth and tell your friends.
Operators
You can add all sorts of arguments to your google search query. The most useful that I’ve found so far is filetype. This allows you to specify the type of file that you want to search for.
If I type :
“iphone” filetype:pdf
into the google search engine then I only get pdf files in my search results, most of which are useful instructional manuals on the iphone.
There are many other arguments that can be useful:
intitle:”tech stuff”
inurl:”codytaylor”
intext:”iphone”
inanchor:”tech stuff”
site:codytaylor.org
link:www.codytaylor.org
cache:codytaylor.org
daterange:2452389-2452389
related:codytaylor.org
info:codytaylor.org
phonebook:”someone”
Stop Words
Google automatically removes certain words from searches. These are called stop words and consist of words like ‘I’, ‘a’, ‘the’, and ‘of’. To force google to use these words then add a ‘+’ to the begining of the word. So searching for a statement with ‘+the’ in it would force the query to look for the ‘the’. If you don’t care wheter these words are included in the search then why even enter them?
Order and repetition matter.
Searching
“codytaylor” scp
emphasizes the “codytaylor” and produces different results than searching
scp “codytaylor”
The keywords to the left are always given higher precedence in the query.
Searching
“codytaylor” scp
produces different results than searching
“codytaylor” scp scp
So if you’re looking for a page that is saturated with a specific keyword then you’ll have much more luck if you type it in more than once.
2 comments | tags: cody taylor, google, save bandwidth, search | posted in reference
May
17
2009
Basic Google Syntax Explanations
Ever see someone spending hours trying to find something in google and just giving up due to the enormous amount of content for any given keyword? I’m amazed at how little everyone knows about using the Google search engine. Most of the population uses google every day but are still unaware of some very basic but extremely simple and effective syntax rules for google queries. This takes energy and bandwidth. In the following I try and outline two of the most common methods of narrowing your search results down to only what you want.
- Basic Boolean: Use ‘AND’ and ‘OR’ in your query. The ‘AND’ will require the result to include both keywords and the ‘OR’ will allow results that have either keywords in them. You can also use the ‘|’ (pipe) character to specify ‘OR’. To make sure that none of the results include a specific word then use the ‘-‘ character in front of the word. So searching ‘cody AND taylor AND -yoyo’ will return results for cody taylor that do not include yoyo.
- Quotes: Use quotes on a query to specify that you only want to search results that are exactly as you write them. If I google codytaylor most of my results are for cody taylor but if I google “codytaylor” then I get results only containing codytaylor without any spaces. Googles forethought in displaying results and splitting up words is very useful but a lot of the time you will want your results to be exactly as you specified. Quotes are also used to specify keyword order. If I wanted results for only the useful and not some sentence or combination of words that include those three words then I would specify “only the useful”. Try it and you’ll notice a huge difference. Try a couple queries to see how much more specific your results become.
These two basic features are surprisingly little known yet so straight forward. Save everyone some bandwidth and explain this to the people around you.
Yes, Google is a verb.
Check out Part 2
Comments Off on Google Query Syntax Explanations: Part 1 | tags: cody taylor, codytaylor, google, keyword, search | posted in reference