feed   myspace   facebook   last.fm   send an email   twitter   tumblr   send a message via aim to graykicksass

Archive for the ‘Uncategorized’ Category.

Writing webapps in QuickBasic 4.5

Disclaimer: I realize this has no real valuable use whatsoever.

First off, credit where credit is due, when I initially had to setup the CGI I ran into a problem solved buy a guy on reddit, who managed to write a website clone in quickbasic. You have to do a simple C++ stub app that can direct the output from quickbasic apps into the server.

In order to pull this off, you’ll need a copy of the following tools:
1. Dev C++ (For compiling the stub app, to make your life easier, grab the one with a compiler built into the install) here

2.Quickbasic 4.5 (capable of generating EXE files) here

I also recommend xampp, very quick installation, works perfectly for this example. Grab it here


Now, to actually install quickbasic from this zip on windows, you have to create a fake A drive, or copy the files to a floppy.

The trick to doing this is a command line trick called subst

So, copy the quickbasic disk1 folder from the download, place it in a folder on C: like, FLOPPY1 and run this:
subst a: C:\FLOPPY1

Run the quickbasic setup app on the fake disk, when prompted to insert another disk, copy the contents of disk2 into the fake drive. Hopefully you’ll be able to run quickbasic now, and be greeted by this screen:

QuickBasic 4.5 welcome screen

QuickBasic 4.5 welcome screen

Once your in quickbasic, navigate the menus with ALT or your mouse, type out this simple program:

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT “”

Move over to the run menu and hit make EXE file, save your app. The app will be in the saved file directory, take it, rename it something simple (e.g. ‘app.exe’) and close.

Now, open up dev C++, navigate to File->New->Project and select console application, select C++ for the language, copy and paste this code into main.cpp:

#include <iostream>
#include <string>
#include <stdio.h>
int main(int argc, char *argv[])
{
std::string piper;
FILE* data = popen(“app.exe”,”r”);

for(char c = getc(data);c != EOF;c = getc(data))
{
piper.push_back(c);
}
pclose(data);

std::cout << piper;
return 0;
}

Press ctrl+F9 to compile or select compile from the menu. Open the directory where you saved the project, and copy the generated EXE file over to your cgi-bin directory (in htdocs for apache, with xampp it’s in the root directory of xampp/cgi-bin).

Now, with the stub in cgi-bin, rename your compiled quickbasic app to ‘app.exe’, and copy it to cgi-bin. Navigate to http://localhost/cgi-bin/stub.exe where stub.exe is whatever your compiled C++ application is called, you should now see a screen something like this:

hello world from quickbasic

hello world from quickbasic

Now you can run your webapps and display output in the browser, all you need now is to parse CGI variables, which is done via the ENVIRON$ function.

PRINT “Content-Type: text/html”
PRINT “”
PRINT “”
PRINT “
<h1>Hello World!</h1>

PRINT ENVIRON$(“QUERY_STRING”)
PRINT “”

QUERY_STRING is set by the CGI gateway, accessing this page with a url like http://localhost/cgi-bin/qload.exe?bla would print:
“Hello World! bla”

This has no real practical use anymore, but it’s just interesting to try out. Also, sorry about the code blocks here being screwed up, wordpress managed to mangle them.

X-ID3 header in modern web servers

I’ll keep this post short and straight to the point, it just seems like this idea should have followed suit right after streaming media became a common feature in HTTP Servers (e.g. lighthttpd).

With the standard format for online music being MP3 files, and the versatile format of streaming MP3’s (can be played while downloading), I see no reason why we shouldn’t be able to add some minimal support for these files in the web server.

It seems like a good idea to me to build an apache module in for MP3 metadata. It could be configured / disabled & enabled via the apache.conf file, preferably something that works with ID3 and HTTP headers. Which is why I propose the x-id3 header standard.

It should be simple enough, basically parsed Mp3 metadata in the Id3 format, passed in the HTTP headers in the following format:

x-id3-(id3 field name): Content

Just like every other HTTP header, I don’t know. Seems pretty basic and overlooked to me. I’d like to hear your thoughts though, so leave a comment with your opinion / ideas.

[Disclaimer: wrote this after pulling an all-nighter, so if it's written poorly, my bad]

Welcome to 2010. (And some new years resolutions..)

Howdy,

Man it’s been a while since I posted, so much on my plate and not a ton to post about. And the whole ‘not having time’ thing. Since I last posted we made it to 2010. Hell yea!

In my last year of blogging, looking back I did some pretty stupid stuff. Especially as far as my code went. Yikes.. But, although a bit late, this year I will actually set some solid new years goals that I can hopefully meet.

  1. By midyear, I hope to have a consistent revenue stream from online worth monthly. i.e. earning $xxxx a month. Would be nice to have a steady income stream.
  2. Be more successful with managing money.
  3. Post more on my blog in 2010, blog neglect must end!

Hopefully I’ll be able to stick to these ones, it shouldn’t be *too* hard.  Also, hopefully I should be back into the posting routinely scenario next week.. Maybe..

Axcid Search Engine

Sup,

So last night (10-20-09) I made a tweak to the search engine part of Axcid that greatly improved the service. So before yesterday, keyword searches such as:

mac dre, dr dre, rem

would return nothing. Also words under 4 letters in length weren’t counted, resulting in less relevance in search results & various other bugs. Last night I set out to correct that and did so successfully.

You’ll notice that specific searches now get more results, as well as the searches above which before returned nothing, now all return results.

This is just another step for Axcid’s future as a search engine, it gets better nearly every day.

Riptune

It’s like tunebin was a while ago:

http://riptune.org/

+ the conf*ulator radio/playlist thing. powered by the wonderful and awesome axcid.

@Android Developers

http://developer.yahoo.com/everything.html

It’s all there. Prettymuch everything that needs to be replaced. Collective effort anyone?

Android got screwed over

Let me just start by saying, since the start I have been an android supporter, and have invested a good $1000 or so into the platform as far as phones go.

Anyways, I did not use the ‘official’ rom, I used the rooted Cyanogen Mod. Which just received a cease and desist order from Google. Google’s official response seems to boil down to ‘Android is open, but google apps are not’. The bottomline being the phone doesn’t really function without those apps.

So here’s whats out:
-Contacts Sync
-Maps
-Youtube
-Gmail
-Google Talk
-And last, but most important, the ‘android market’

And anything else not in the android source tree.

Most of the community could probably live without those except android market, after all, the latest maps.apk can be downloaded and installed from android market. Without the market there is no consumer friendly way to install apps on the phone. Ouch.

Some people (Including myself) have kicked around the solution of rebuilding those apps. I personally like that idea and the idea of a ‘google stripped’ android. Most of what they provided could be recreated with public API’s.

It’s just something to think about though, with no real commercial open mobile os, developers are being placed in a walled garden no matter where they go.

I guess it’s a waiting game now for a developer to start the ‘openandroid’ tree or whatever it will be called. But I look forward to the day when that project starts with curiosity.

Rebuilding a HTC Music Adapter (EMU Headphone Adapter)

Wassup?

After having at _least_ THREE ‘g1 headphone adapters’ die on me within the space of 5 months, and having to spend more then $10 a piece to replace them, I got sick of paying for these rubbish wires. The phone is great but the headphone adapters are not, but I managed to pull my self a Hi-Fi one with just a bit of DIY and Tape.

What you need:
(Minimum)
- A lighter
- Electrical Tape
- Wire Strippers
- Something with a 3.5 audio jack on the end (In my case, half of a audio splitter)

Connecting the wires:

First at the tip of each wire you see after stripping the coat from the original EMU connector cord, run a flame from the lighter under the wire until it catches fire, then blow it out. This exposes the wire by removing the chemical coating.

The annoying part about these (And I didn’t care to do much trial and error as to what does what) is that with Android, if several wires are not connected it won’t detect it as headphones.

In order to wire this up, you should have left, right and ‘center’ (gnd) coming from your 3.5 jack. See picture (http://graysblog.org/wp-content/uploads/2009/09/IMAG0010.jpg). All bronze / semibronze wires should be tied together and used as the gnd/center (at the ends where they were opened by burn). The blue and the white wire are microphone / button wires. You can safely set them aside.

The red(Organish) and green wires are respectively, right and left channel. See picture.

Wires all done:

In Progress

http://graysblog.org/wp-content/uploads/2009/09/IMAG0010.jpg

Taping it all up:

Alright this is pretty simple, the way I like to do it is a strip of tape on every separate connection you make, then tape everything up. I’d advise listening to the headphones while doing this, the risk of shortage is low and it ensures that it works. No solder or mess. And for lazy people like me little work

Finished Product

And.. It's done

And.. It's done

Surprisingly this works well, and the audio quality is great.

I apologize for the crap quality of this ‘miniguide’, I was rushed and just wanted the info out there

References:
(Soldering the wires)

http://hackaday.com/2009/05/24/soldering-headphone-wire/

http://www.alexwhittemore.com/?p=205

(Pinout)

http://androidforums.com/t-mobile-g1/4480-how-create-emu-3-5mm-headphone-jack-adaptor.html

Python

Alright so it’s been a while since I posted anything and I wanted to put something out there, while I have been working a lot on many projects I couldn’t really speak of, I have a few quick things to update you on before I get on to the main content:

First thing, the staff of Opensock have acquired MMOCCForum, this is pretty exciting and we are going to help get that place in shape.
Second, Axcid.org has had a complete rewrite of it’s API, now including keyword search. http://tunebin.info/ does a great job showing this.

Alright now onto the main content of the post:

After hating python and it’s syntax for a few years, I got the push of actually LEARNING the language, including some of it’s many libraries and functions. Once you get used to it, the syntax isn’t too bad actually. It’s actually pretty easy, for example:

import system, string """ Python block style comments """ # Python one line bash-style comments # Rather then braces for syntax blocking, python uses whitespace #Functions in python must be declared before use, unlike in javascript. # The Syntax for this is def # e.g. def SayHello(text):         # This is the body of the function         print(text) # Say Hello would be considered a 'function alias', and would be used like this: SayHello("test") # Some built in python functions string = "123" # set a variable integer = int(string) # Convert string to integer string = str(integer) # Convert integer to string # And block statements use : to start the block, e.g. if (string = str(integer)):         SayHello(str(integer))         # Else if is elif         elif (string = int(string)):         SayHello("Oh..")                 # Not gonna reach this else:         SayHello("Else reached, so none of them was correct")

Just for an example of python, Axcid’s new JSON api can be used like this:

# axcid import sys, string, urllib import simplejson as json AXCID_URL="http://two.axcid.org/new/api/?method=search.keyword&format=json&allpages=1&q=" def GetResults(query):         query = query.replace(" ", "%20")         url = AXCID_URL+query         f = urllib.urlopen(url)         obj = json.load(f)         return(obj["track"])

And the result from that:

results = GetResults("sublime") if (results):         for track in results:                 print(track["title"]+" - " + track["artist"]

Writing a IRC bot in python the other day was simple as well. And a python-spidermonkey binding exists so it would be possible to bind the syntax of JS to python, Python-Spidermoney

Anyways, that’s all for my update. Hope it was useful to someone.

Although you can’t see it with the P2 T…

Although you can’t see it with the P2 Theme active, all posts older then this have been put into the ‘Archive’ category. This meaning I no longer find them relevant to the content of this blog, or a reflection on my current coding standards.

In other words, when reading form a professional standpoint, ignore them.