Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Super Dude
Jan 23, 2005
Do the Jew

Ration posted:

:words:

Maybe I'm having a brain fart, but I don't understand what you're trying to do. When you refer to 'A', is that a person, a district, or something else entirely? Is there a reason why setting up a database would be such a problem for IT? It's a very simple process, especially for something being used internally by your company.

Adbot
ADBOT LOVES YOU

Ration
Dec 3, 2005

My mile could not pump the plumb

Super Dude posted:

Maybe I'm having a brain fart, but I don't understand what you're trying to do. When you refer to 'A', is that a person, a district, or something else entirely? Is there a reason why setting up a database would be such a problem for IT? It's a very simple process, especially for something being used internally by your company.

A is an annotator, prefix, ect. Each district has their own annotator to differentiate the different districts.


An instance:

I get a report. The report indicates that at Z 124.32 something broke.

Person Tim covers the Z district.
Person George covers the X district.
Person Walter covers the W district.
Person William covers the A district.

My hard copy references that I should call person Tim first, and then lists his telephone number. George is second, Walter third, William fourth.

The A is merely a means of differentiation, as Person George has a 124.32 as well.


Setting up the database is a problem because I do not work in IT, in fact I am probably the furthest from IT. In order to even install a program on our computers, it has to be examined by IT. Our IT department is 500+ miles away and do everything remotely. This means that getting in touch with someone who actually knows what they are talking about is quite difficult. They have a team of "help desk" employees who are familiar with "tech" related things, but the average user never needs to know about SQL databases. As a result, getting a database approved will prove difficult.

I could circumvent their security measures, but I enjoy my job. If that is the only way that someone is willing to write this out, I'm okay with that. I'll figure out a way to get the database created. It is just irritating attempting to get IT to do anything other than password resets.

TL;DR, I work for a fortune 500 company with the IT department of a mom and pop shop.

Arrath
Apr 14, 2011


I'd like to rip some models from a mod of an old game (Star Trek: Armada) and I've found a plugin that will let me import the models into modeling software. It would work fine, except that the modding community was (The site of the guys that made this plugin isn't even up anymore) a bunch of spergs, the importer only works on stock models, not any added by mods. Gotta protect their 10 year old models from assholes like me.

Luckily, the download includes the plugin source code. Would any of you fine chaps mind cutting out the check that prevents me from importing non-stock models, and compiling a new .dll?

I've uploaded the soure: http://www.mediafire.com/?ho4nco3vrof5j1h

The check is defined at line 152 and called at 233. Unfortunately reading the code is about as far as my amateur skill goes, I've been mucking with it in visual studio for a while now and haven't made any progress.

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."

Arrath posted:

I'd like to rip some models from a mod of an old game (Star Trek: Armada) and I've found a plugin that will let me import the models into modeling software. It would work fine, except that the modding community was (The site of the guys that made this plugin isn't even up anymore) a bunch of spergs, the importer only works on stock models, not any added by mods. Gotta protect their 10 year old models from assholes like me.

Luckily, the download includes the plugin source code. Would any of you fine chaps mind cutting out the check that prevents me from importing non-stock models, and compiling a new .dll?

I've uploaded the soure: http://www.mediafire.com/?ho4nco3vrof5j1h

The check is defined at line 152 and called at 233. Unfortunately reading the code is about as far as my amateur skill goes, I've been mucking with it in visual studio for a while now and haven't made any progress.

Try this: http://www.mediafire.com/?7vnn7ld5o9wloml

Basically, you pretty much had it done. The validate function you found is function that returns a bool (true or false). All the function does internally is create a string containing what looks like the names of all the stock models in the game, searches through them, and then returns whether (true) or not (false) it found that model name. Fixing it was simply a matter of commenting out the entire function body, and replacing it with
code:
return true;
Hopefully the zip I uploaded works for you. Built on Win7-x64/VC++ 2010, but I don't think the fact that my system is 64-bit will cause a problem.

I just zipped up the entire output folder, but I think all you'll need is the msSODImporter.dll file.

Sri.Theo
Apr 16, 2008
You guys are fantastic!

I'd love some help with hotkey/function keys as well. My Laptop has media buttons that double up with home, pg up, pg dn and end, but what's annoying is that to use the media functions I have to hold down fn.

Is is possible to write a programme that detects whether video is playing and automatically uses the media keys?

Flipperwaldt
Nov 11, 2011

Won't somebody think of the starving hamsters in China?



Sri.Theo posted:

Is is possible to write a programme that detects whether video is playing and automatically uses the media keys?
This seems doable in AutoIt with my level of experience, so I'll take a look at it. What I'll need, however, is a list of the media keys you want supported and the regular key they correspond to on your laptop.

Like:
PgUp=Play/Pause
End=Stop
etc

EDIT
Here's a thing I made that works for me. You can edit which media key corresponds with which keyboard key in the ini file. You can also set the name of the process that triggers the translation there. Keep .exe and .ini file in the same folder. There's not a trace of error checking, so you can make the thing not work by messing up the .ini-file, so maybe keep a copy of that until you've got it figured out.

The .au3-file is the source, if you want a good laugh, not needed for execution.

Flipperwaldt fucked around with this message at 18:34 on Mar 11, 2012

Arrath
Apr 14, 2011


nuvan posted:

Try this: http://www.mediafire.com/?7vnn7ld5o9wloml

Basically, you pretty much had it done. The validate function you found is function that returns a bool (true or false). All the function does internally is create a string containing what looks like the names of all the stock models in the game, searches through them, and then returns whether (true) or not (false) it found that model name. Fixing it was simply a matter of commenting out the entire function body, and replacing it with
code:
return true;
Hopefully the zip I uploaded works for you. Built on Win7-x64/VC++ 2010, but I don't think the fact that my system is 64-bit will cause a problem.

I just zipped up the entire output folder, but I think all you'll need is the msSODImporter.dll file.

This works like a charm, thanks a lot.

Sri.Theo
Apr 16, 2008

Flipperwaldt posted:

This seems doable in AutoIt with my level of experience, so I'll take a look at it. What I'll need, however, is a list of the media keys you want supported and the regular key they correspond to on your laptop.

Like:
PgUp=Play/Pause
End=Stop
etc

EDIT
Here's a thing I made that works for me. You can edit which media key corresponds with which keyboard key in the ini file. You can also set the name of the process that triggers the translation there. Keep .exe and .ini file in the same folder. There's not a trace of error checking, so you can make the thing not work by messing up the .ini-file, so maybe keep a copy of that until you've got it figured out.

The .au3-file is the source, if you want a good laugh, not needed for execution.

It works fantastic thanks! Exactly what I wanted, hope it didn't take you too much work.

It's also nice that the home/end keys still work as long as no media is playing.

So er, can I chance my luck with another request? I'd like the volume slider to go up in larger increments when I use the volume keys. Rather then the tiny increments it uses now is it possible to write a script that makes it go up and down in around 6 large ones?

Thinking about it, it would be really nice if these were standard options in Windows.

Look Around You
Jan 19, 2009

Ration posted:

OS: Windows XP
Email client: Outlook 2003

Long shot request, as I don't know how "tiny" that my request is.

In my job, I call people to go fix stuff. The system that we use now is a book of people with their corresponding areas, a sheet of paper to write what happened and who went to fix it, and a fax to send it to one person. I'd love to be able to get all of this streamlined into one "tiny" app.

I'd like to be able to input 2 fields, all alphanumeric, that pull data from 2 predefined columns in an excel spreadsheet. (Example:
code:
Input: Z 59382.43 
Returns: Z 59382.43 Somewhere St. Somewhere Town, State, Person, Home Tel, Cell)
If a field is null, I'd like "N/A" to be represented.
I can put all of these fields in an SQL database if it is required, but getting IT to allow me is going to be a bitch. Plain text is best.

The way that it works is person A is assigned A 1 through A 9999.99. Person C is assigned C 1 through C 9999.99.

For each range (A 1 - A 9999.99) there is a list of people who will go fix poo poo. Each list is unique in order, partially unique in name. Person A will go to Person C's area, but not person Z's. Person A is second to be called on person B's area, and 5th to be called on person E's. ect ect.

lovely MS Paint mockup:

Link for those safari users

"District A" is one of a few choices. This field corresponds with Field A and Field Name.
Field "A" is a letter, always will be.
Field "Somewhere St" corresponds with Field A and 1234.43.
Field "Somewhere Town" same as above.
Field "Tel" corresponds with Field "name" AND all of the above.
Field "Name" same as above, less name.
Field "Home/Cell" I would like to be radio boxes.
Blank field to the left of Field "Name" should be a second time field.

I don't care where/how any of the fields are displayed. I'd prefer if the Tel field was to the right, as pictured, for ease of use.

Two other things that I would like:
"Vacation" setting. A method to input a time in which calling a field (Entering an input that corresponds with a name) can be skipped as a result of that person being on vacation/rest time.
Email setting. Once the form has been completed, I'd like all data collected (Less the Field "Tel") to stored and automatically emailed. This is not necessary. If you just put a button on there and allow the data to be put into some soft of form (Maybe coordinates on a jpg image), that'd be awesome.

After typing up all of this, I realize that it is not "tiny", at least to me. Perhaps someone who does this poo poo daily can whip it together in no time. If not, perhaps I'll have to pay someone.

Do you have python available? If not, do you have any other scripting languages available? I'll be happy to look into writing something but if you're not allowed to install things I'm not sure if you'd be able to run an arbitrary binary (like if I wrote it in C or w/e) or if you guys have access to stuff like python or whatever.

e: Can you put a little mockup of what the data would look like in plaintext (like as a list of comma separated values)

Look Around You fucked around with this message at 14:02 on Mar 15, 2012

Flipperwaldt
Nov 11, 2011

Won't somebody think of the starving hamsters in China?



Sri.Theo posted:

It works fantastic thanks! Exactly what I wanted, hope it didn't take you too much work.

It's also nice that the home/end keys still work as long as no media is playing.

So er, can I chance my luck with another request? I'd like the volume slider to go up in larger increments when I use the volume keys. Rather then the tiny increments it uses now is it possible to write a script that makes it go up and down in around 6 large ones?

Thinking about it, it would be really nice if these were standard options in Windows.
Updated MediaKeyTranslate!

Same caveats as before. Now there's a section in the .ini file that allows you to set the number of times the {VOLUME_UP}/{VOLUME_DOWN} key is sent when the corresponding keyboard key is pressed.

Sri.Theo
Apr 16, 2008

Flipperwaldt posted:

Updated MediaKeyTranslate!

Same caveats as before. Now there's a section in the .ini file that allows you to set the number of times the {VOLUME_UP}/{VOLUME_DOWN} key is sent when the corresponding keyboard key is pressed.

Works perfectly! Thank you for making it easier to sit around watching TV instead of working on my thesis :-)

Henry Black
Jun 27, 2004

If she's not making this face, you're not doing it right.
Fun Shoe
I need a program to automatically compose and send an email in Thunderbird, including an attachment. I know this part is possible through VBS or just a .bat, but I need it to go one step further and ask the user for a number before doing so. After sending the email, it should then overwrite the file it attached with a standard template, so they can repeat the process without deleting the last set of text etc.

(Basically, this company has switched to VoIP, and in the process has lost their fax machines. Whilst I could get them an analogue adaptor so they could still fax, I'd like to avoid that. They can fax by sending attachments to <faxnumber>@nul.com or whatever, so I'd like to automate the process.)

I know nothing of Windows and it's strange wizardry, so can someone tell me if this is possible?

Hoborg
Oct 19, 2006

by T. Mascis

LittleBob posted:

I need a program to automatically compose and send an email in Thunderbird, including an attachment. I know this part is possible through VBS or just a .bat, but I need it to go one step further and ask the user for a number before doing so. After sending the email, it should then overwrite the file it attached with a standard template, so they can repeat the process without deleting the last set of text etc.

(Basically, this company has switched to VoIP, and in the process has lost their fax machines. Whilst I could get them an analogue adaptor so they could still fax, I'd like to avoid that. They can fax by sending attachments to <faxnumber>@nul.com or whatever, so I'd like to automate the process.)

I know nothing of Windows and it's strange wizardry, so can someone tell me if this is possible?

I did a quick google search for "send email thunderbird vbscript" and found this thread from 2004 ( http://forums.mozillazine.org/viewtopic.php?f=28&t=164233 ). The thread mentions Thunderbird's command-line options, in addition to stating that Thunderbird does support MAPI (which may explain VBScript support). However programming MAPI is a bit difficult and brittle; but documentation is available ( http://kb.mozillazine.org/MAPI_Support ), worryingly that page says that Thunderbird's MAPI implementation is buggy, but if all you want to do is send an email then the command-line options seem simpler ( http://kb.mozillazine.org/MAPI_Support ), the catch being that the user needs to manually hit the "Send" button in the pop-up Compose window themselves.

Doing it in VBS might work, but there are no guarantees - whereas command-line will work, but involves user intervention.

ToxicFrog
Apr 26, 2008


LittleBob posted:

(Basically, this company has switched to VoIP, and in the process has lost their fax machines. Whilst I could get them an analogue adaptor so they could still fax, I'd like to avoid that. They can fax by sending attachments to <faxnumber>@nul.com or whatever, so I'd like to automate the process.)

Wouldn't it be easier to just send the email directly using an SMTP library rather than invoking Thunderbird to do it?

The Pell
Feb 6, 2008
I'm looking for an OS X app (or applescript) where I can choose multiple disk images and the app can partition a disk and deploy all images.

I wrote a simple bash script that basically does what I want, except that I need to modify the script every time an image changes. It would be great if I can click and drag images (or select through a prompt) to a list, and then have the program create the appropriate partitions and restore the images.

Something like this:


Disk [disk1]
APM [X] GUID [ ]
HFS [ ] HFS+ [X] FAT [ ]
Image---------Partition Name---Size
image1.dmg----Stuff------------10G
image2.dmg----Things-----------15G
...
image16.dmg---What Nots--------5G

Hoborg
Oct 19, 2006

by T. Mascis

ToxicFrog posted:

Wouldn't it be easier to just send the email directly using an SMTP library rather than invoking Thunderbird to do it?

By going through a mail program the outgoing message would be saved in the user's Sent Items folder. Also if the SMTP server requires authentication then it means the script doesn't need to maintain its own copy of the un/pw.

the littlest prince
Sep 23, 2006


The Pell posted:

I'm looking for an OS X app (or applescript) where I can choose multiple disk images and the app can partition a disk and deploy all images.

I wrote a simple bash script that basically does what I want, except that I need to modify the script every time an image changes. It would be great if I can click and drag images (or select through a prompt) to a list, and then have the program create the appropriate partitions and restore the images.

Something like this:


Disk [disk1]
APM [X] GUID [ ]
HFS [ ] HFS+ [X] FAT [ ]
Image---------Partition Name---Size
image1.dmg----Stuff------------10G
image2.dmg----Things-----------15G
...
image16.dmg---What Nots--------5G


Can't you just pass the image name to the bash script?

The Pell
Feb 6, 2008
I have the script setup with static entries for each image because I figured it would be a pain to type in each image name and path every time I wanted to run it. Plus, I have the script setup in two main pieces, the first creates the partitions and the second restores the images. My co-workers are kinda afraid of getting their hand dirty, and I rather not have them changing poo poo if they don't know what they are doing.

feld
Feb 11, 2008

Out of nowhere its.....

Feldman

Request: Userscript/UserJS/Extension that hides the loving scores on NHL.com's home page top left to right scrolly thing with links to games, etc. I hate being spoiled when I haven't watched the games yet and they are idiots and don't offer an option on the site.

Requirements: I just really want it to run in Opera, but I'll accept Chrome. I'm super lazy and I know I could port it to Opera. I just don't want to look at the scores while testing this out :v:

Reward: A big giant internet hug and maybe an avatar or forums upgrade is in your future! :greatgift:

feld fucked around with this message at 00:59 on Mar 31, 2012

Met48
Mar 15, 2009
If you have adblock installed it'd be the best solution - just block divs with id "hdrBoard". Then it wouldn't even load.

If not, here's the javascript that will do it:

code:
document.getElementById('hdrBoard').style.display = 'none';
I haven't used Opera but looks like there's a User Javascript feature that will let it work.

feld
Feb 11, 2008

Out of nowhere its.....

Feldman

Metroid48 posted:

If you have adblock installed it'd be the best solution - just block divs with id "hdrBoard". Then it wouldn't even load.

If not, here's the javascript that will do it:

code:
document.getElementById('hdrBoard').style.display = 'none';
I haven't used Opera but looks like there's a User Javascript feature that will let it work.


haven't tested it quite yet but i do want to see everything i just want the actual scores blacked out or something.

Met48
Mar 15, 2009

feld posted:

haven't tested it quite yet but i do want to see everything i just want the actual scores blacked out or something.

Oh. Again, not an Opera user, but a User CSS of something like this will work:

code:
div.score {
display: none !important;
}

feld
Feb 11, 2008

Out of nowhere its.....

Feldman

Metroid48 posted:

Oh. Again, not an Opera user, but a User CSS of something like this will work:

code:
div.score {
display: none !important;
}

Working on rolling this into an opera extension... works as a custom applied CSS to the page but the extension is being a bitch and not working for some unknown reason. I'll keep you updated

Factory Factory
Mar 19, 2010

This is what
Arcane Velocity was like.
Odd request: a program which generates random strings of the characters of the English alphabet + space + comma + period, and when a substring matches a known dictionary word (say, of at least three characters), the program pauses and displays the generated sentence. String length can be fixed (preferably not too long) or perhaps configurable by a text input.

Basically an infinite monkeys program that isn't limited to Shakespeare nor bothers to keep the detritus output around.

I'd love the source code, too, to play around with, but that's optional.

Inspired by Library of Babel.

OnceIWasAnOstrich
Jul 22, 2006

Factory Factory posted:

Odd request: a program which generates random strings of the characters of the English alphabet + space + comma + period, and when a substring matches a known dictionary word (say, of at least three characters), the program pauses and displays the generated sentence. String length can be fixed (preferably not too long) or perhaps configurable by a text input.

Basically an infinite monkeys program that isn't limited to Shakespeare nor bothers to keep the detritus output around.

I'd love the source code, too, to play around with, but that's optional.

Inspired by Library of Babel.

Are you wanting this to print out every time it finds a word, or every time it finds enough real words up to a period to be a sentence?

Factory Factory
Mar 19, 2010

This is what
Arcane Velocity was like.
Every time it finds a word. I realize this will produce a lot of junk, and it would be interesting (but also more complex to program) to have more rigid standards, but this would do for a start. In my mind, the interface is just three elements:

* String length input
* Text output
* "generate next" button

Maybe to aid analysis, a "time to output" counter, too, showing time elapsed from clicking the button to getting an output.

OnceIWasAnOstrich
Jul 22, 2006

Factory Factory posted:

Every time it finds a word. I realize this will produce a lot of junk, and it would be interesting (but also more complex to program) to have more rigid standards, but this would do for a start. In my mind, the interface is just three elements:

* String length input
* Text output
* "generate next" button

Maybe to aid analysis, a "time to output" counter, too, showing time elapsed from clicking the button to getting an output.

I wanted to mess around with suffix trees so I thought this would be amusing to mess with.

code:
import random
from time import time
letters = 'abcdefghijklmnopqrstuvwxyz,.       '
sentence_size = 60
min_word_size = 3
dictionary = [w.strip() for w in open('/usr/share/dict/words','r').readlines()]
def is_word(word):
    if len(word)==1 and not word == 'i' and not word =='a':
        return False
    elif word in dictionary:
        return True
    else:
        return False
print 'Checking 10k lines'
t=time()
for i in xrange(0,10000):
    queue=[letters[random.randint(0,34)] for i in range(0,sentence_size)]
    for word in ''.join(queue).split():
        word=word.strip('.,')
        if len(word)>=min_word_size and is_word_st(word):
            print ''.join(queue)
print "Checked in "+str(time()-t)+' seconds'
But I'm not sure this does what you are thinking. This gives you almost entirely junk (2/3 of randomized lines) like

,kgidzx usbic eirvxxviht d,st .q ue wdzh hb gib kth,ud
q v, dq pkwh.dfwz c ,p y scl ,ipmb tz tra,mwx,af p sz iyo
.tkix kat rw,ga zns yaof,gd zdaj. qh.g nj.h irmn pxs..qm

because 'gib', 'jyo', and 'kat' are words. With this sentence/word size it is crazy slow and checks ~33lines/sec. I have a version that searches a suffix tree dictionary that takes ~1 min to load the dictionary but can check ~5500lines/sec. By the way using this criteria about 2/3 of generated lines have a word.

OnceIWasAnOstrich fucked around with this message at 23:02 on Apr 10, 2012

tarepanda
Mar 26, 2011

Living the Dream
Could I request a tiny custom Android app here, or is that asking too much?

Doctor w-rw-rw-
Jun 24, 2008

tarepanda posted:

Could I request a tiny custom Android app here, or is that asking too much?

Whatcha need?

tarepanda
Mar 26, 2011

Living the Dream

Doctor w-rw-rw- posted:

Whatcha need?

A camera app that lets you superimpose a picture over the camera view. Ideally the right side would have a pull-out drawer that lets you manipulate the superimposed picture (rotation, transparency, size) and the left side would just have the normal Android camera functions. It would be nice to be able to superimpose a couple of pictures at a time...

Thinking about it, it's not a very tiny app, actually.

I've just wanted someone to make that for the last year or so so that I could give them my money. It would be excellent for, among other things, viewfinders, panoramas, time lapse pictures...

mobby_6kl
Aug 9, 2009

by Fluffdaddy

OnceIWasAnOstrich posted:

:words:

Everything was going smoothly until I also realized how time intensive it would be to look up all the junk words in the dictionary. Still, that's actually a very interesting challenge and I'll give it a shot this evening, no matter how useless this program appears to be :D

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

OnceIWasAnOstrich posted:

A silly program

Lists are bad for lookups, you are doing O(n) for every is_word check, where n is number of words in dictionary. Use a set instead, it's like 100x faster.
code:
import random
from time import time
letters = 'abcdefghijklmnopqrstuvwxyz,.       '
sentence_size = 60
min_word_size = 3
dictionary = set(w.strip() for w in open('/usr/share/dict/words','r').readlines())
def is_word(word):
    if len(word)==1 and not word == 'i' and not word =='a':
        return False
    elif word in dictionary:
        return True
    else:
        return False
print 'Checking 10k lines'
t=time()
for i in xrange(0,10000):
    queue=[letters[random.randint(0,34)] for i in range(0,sentence_size)]
    for word in ''.join(queue).split():
        word=word.strip('.,')
        if len(word)>=min_word_size and is_word(word):
            print ''.join(queue)
print "Checked in "+str(time()-t)+' seconds'

Factory Factory
Mar 19, 2010

This is what
Arcane Velocity was like.
I can't wait to start playing with these later. Are these Python?

mobby_6kl
Aug 9, 2009

by Fluffdaddy

peepsalot posted:

Lists are bad for lookups, you are doing O(n) for every is_word check, where n is number of words in dictionary. Use a set instead, it's like 100x faster.

I was planning to use a hashing function that would be more efficient for such lookups. How are actually the sets in Python (?) implemented?

OnceIWasAnOstrich
Jul 22, 2006

peepsalot posted:

Lists are bad for lookups, you are doing O(n) for every is_word check, where n is number of words in dictionary. Use a set instead, it's like 100x faster.


Yeah, I probably shouldn't even have posted that, considering it was a placeholder while I designed a suffix tree class.

After all of my work designing this fancy suffix tree structure:

Time for 10000 lines:

List: 392s
Set: 1.67s
Suffix tree: 1.91s

mobby_6kl posted:

I was planning to use a hashing function that would be more efficient for such lookups. How are actually the sets in Python (?) implemented?

They are a hashtable where the keys are the same as the members with (obviously) O(1) for membership lookups. These are the simplest and best choice. Though I am pretty impressed that my pure python suffix tree apparently has similar performance despite being far more complicated.

mobby_6kl
Aug 9, 2009

by Fluffdaddy
I'm starting to get an idea why higher level languages became popular.
code:
#include <stdio.h>
#include <stdlib.h>

char **hash_table;
unsigned hash_size;

int main (int argc, char* argv[])
{
	char *letters = "abcdefghijklmnopqrstuvwxyz ,.";
	int length = atoi(argv[1]);
	char *str = malloc(length);
	int i, n;
	
	char *str1  = malloc(length);
	clock_t clock_start;
	
	load_file(argv[2]);
	for (n = 0; n< 10000; n++) {
		for (i = 0; i<length; i++)
			str[i]  = letters[rand()%29];
		str[length] = '\0';
		strcpy(str1, str);
		
		if (split_and_check(str1))
			printf("%s\n", str);
	}
}

char *split_and_check (char *str)
{
	char *tmp, *start;
	start = str;
	
	while (*str) {
		if ( *str < 'A') {
			*str = '\0';
			
			if  ((str-start)>2) {
				tmp = hash_table[paul_hash(start)%hash_size];
				if (tmp != NULL && !strcmp(start, tmp))
					return start;
			}
			str++;
			start = str;
		}
		str++;
	}
	return NULL;
}

void load_file(char *filename)
{
	int fsize = 0;
	char *data;
	char *line_start;
	FILE *file = fopen(filename, "r");
	
	fseek(file, 0, SEEK_END);
	fsize = ftell(file);
	rewind(file);
	
	data = malloc(fsize);
	fread(data, fsize, 1, file);
	fclose(file);
	
	hash_size = fsize/9;
	hash_table = calloc(hash_size, sizeof(char*));
	
	line_start = data;
	
	while (*data) {
		if (*data == '\n') {
			*data = '\0';
			data++;
			hash_table[ paul_hash(line_start)%hash_size ] = line_start; 
			line_start = data;
		}
		data++;
	}
}

unsigned paul_hash(const char* s)
{
    unsigned h = 0;
    while (*s)
        h = h * 101 + (unsigned char*) *s++;
    return h;
}
On the other hand, I did seem to have made a much faster and more efficient monkey. This takes about 0.03 seconds to chew through 10k lines, and loading the word list is very fast too. However because I'm lazy, I'm pretending hash collisions don't occur, so this might be a problem if you need a particular word for your magnum opus and it's been overwritten.

The first command line argument is the number of characters to generate per line, and the second is the word file, so monkeys.exe 50 "words.txt" should work.

Here's the same thing in Perl, about an order of magnitude slower but not missing any words:
code:
my $len = shift;
open (my $fh, "<", shift);
my %hash;
@hash{(<$fh>)} = ();
my @letters = qw/a b c d e f g h i j k l m n o p q r s t u v w x y z , , ./;
my $string;

foreach my $benchmark (1.. 10000) {
	$string = '';
	for (my $i = 0; $i< $len; $i++) {
		$string .= $letters[rand(29)];
	}
	foreach (split (/[\.\,\s]/, $string)) {
		print $string , "\n" if  ( (length($_)>2) && (exists $hash{$_."\n"}) )
	}
}

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

This is less of a request for an app, and more request for suggestions on what languages/libraries/etc you might use to build a specific kind of app. I wasn't sure where else to ask general programming thing like this.

I would like to make a simple GUI based application that does some web scraping. basically load up a couple pages that are on servers which I do not control, and grep the source for some particular textual data that the user can specify. My first thought about this sort of thing is to just go with HTML/javascript, as that is the one sort of GUI thing that makes most sense to me, and Javascript is already geared towards handling HTML docs, but then I cringe once I start thinking about jumping through all these hoops to get around javascript cross domain protection crap. So what would you guys use for something like this?

I'm familiar with other languages(aside from javascript); in approximate order of aptitude: python/c#/lua/java/C/C++. I've only ever done actual GUI programming in C#, but something makes me think that I would be more productive/happier/write better code by using what I consider a more dynamic language like javascript or python. How would you do it?

The gui in this case would likely be as simple as a text box and a submit button, with a pane for result output. I realize this could easily be a console app, but I would be writing this for less tech-saavy users that would prefer a more familiar interface.

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."
Well, Python does have the HTMLParser class that you could use, in both v2.7 and v3. Since you're most familiar with Python, perhaps one of those would work?

ToxicFrog
Apr 26, 2008


peepsalot posted:

This is less of a request for an app, and more request for suggestions on what languages/libraries/etc you might use to build a specific kind of app. I wasn't sure where else to ask general programming thing like this.

The general programming questions thread is generally a good place for general programming questions. :)

quote:

I would like to make a simple GUI based application that does some web scraping. basically load up a couple pages that are on servers which I do not control, and grep the source for some particular textual data that the user can specify. My first thought about this sort of thing is to just go with HTML/javascript, as that is the one sort of GUI thing that makes most sense to me, and Javascript is already geared towards handling HTML docs, but then I cringe once I start thinking about jumping through all these hoops to get around javascript cross domain protection crap. So what would you guys use for something like this?

Depending on how robust the HTML handling needs to be, I'd probably use either Lua (with iup for the gui, luasocket for networking, and some simple regexes for scraping) or Python (with tk for the gui and HTMLParser for the parsing).

If it got sufficiently complicated I might move to Scala, but that's not one of the languages you listed, and from what you've described here it probably wouldn't get big enough to warrant that anyways.

Adbot
ADBOT LOVES YOU

sekshun8
Apr 20, 2012
I'm new here. Your friendly gayborhood Sekshun8. Cheers.

Here's the situation. There is a program used at work that's kind of an interactive study guide. It gives you a list of subjects, you select one, it opens with some text, then when you close that it goes into a little video. You can close at any time and select a different subject. The boss is thinking of getting some iPads for the employees and would like to put this program on them. Obviously it's not possible directly, but I'm trying to see if there's a way to do it indirectly.

The only things I can tell you right now for sure is this:

It is currently on a disc.
Disc contains 3 files - .inf, folder with all the .txt and .swf files, and the .exe
When I check the properties of the .swf files, it says they are HPIP video files(which I have never heard of)
When I open the CD in Windows, it says the .exe is a Macromedia Flash.

I included a pic, and I know it's lame to cover up the names. But we have government agencies that over see our work and it's a silly precaution I'm sure.



Any help would be greatly appreciated.

  • Locked thread