Search found 145 matches

by jemthealmighty
Mon Sep 14, 2009 9:58 pm UTC
Forum: Computer Science
Topic: Removable UUID
Replies: 2
Views: 918

Re: Removable UUID

jroelofs wrote:How about some variant of this?:

Code: Select all

tail -n 100 video_ts | md5sum

Using:

Code: Select all

$ tail -n100 VIDEO_TS/* | md5

Seems to run fairly quickly and should be unique enough.
Thanks jroelofs.
by jemthealmighty
Mon Sep 14, 2009 6:51 am UTC
Forum: Computer Science
Topic: Removable UUID
Replies: 2
Views: 918

Removable UUID

Is there something like a UUID for removable media? The background to this is I need a way to cache the output of a program on a DVD but I can't rely on the name of the DVD to be different to any other. What I need is some way to quickly (< 3seconds) hash the contents of a DVD (potentially dual-laye...
by jemthealmighty
Fri Aug 14, 2009 12:58 am UTC
Forum: Coding
Topic: Remote Local Login
Replies: 4
Views: 809

Re: Remote Local Login

lulzfish wrote:What OS are these computers?

The clients run Windows some Vista and some XP and we have a SmoothWall Linux server and a Windows XP Controller.
by jemthealmighty
Thu Aug 13, 2009 11:27 pm UTC
Forum: Coding
Topic: Remote Local Login
Replies: 4
Views: 809

Remote Local Login

I am writing a script to run on a server to control a cyber-cafe. One of the features I want to look into is sending a command from the server to a client to tell it to login as a specified user. 1) Is this even possible? 2) If so, how would I go about it? I have tried google, but since I have no id...
by jemthealmighty
Wed Jul 08, 2009 7:56 am UTC
Forum: Coding
Topic: Auto-insertion of Glossary Links
Replies: 24
Views: 1801

Re: Auto-insertion of Glossary Links

what would be the Javascript syntax needed to retrieve the contents of some other page's one and only <div> tag? (Then I could just stick that script in another page, and direct getJSON to that page instead. Right?) I don't quite follow what you mean, can you explain a little more? EDIT: Also, the ...
by jemthealmighty
Thu Jun 25, 2009 12:51 pm UTC
Forum: Coding
Topic: RGB Selection algorithm
Replies: 12
Views: 1817

Re: RGB Selection algorithm

Heres the above C app translated to python, not optimized or checked to work with the gtk app posted but as far as I know it works properly.
by jemthealmighty
Tue Jun 23, 2009 11:37 am UTC
Forum: Coding
Topic: RGB Selection algorithm
Replies: 12
Views: 1817

Re: RGB Selection algorithm

I know a bit of C and I've never used it with images though and wouldn't know what libraries to use. I did plan to implement this in C once I had working algorithms in python though. I would love to have a look at your code if you don't mind. Haha, done a couple of C + Python scripts/programs. It's ...
by jemthealmighty
Tue Jun 23, 2009 7:17 am UTC
Forum: Coding
Topic: RGB Selection algorithm
Replies: 12
Views: 1817

RGB Selection algorithm

I'm writing a mosaic like script in python. I'm up to selecting the images from a table for each pixel in the image to create. I have all the images to use indexed in a dictionary like: rgb_map = {r_val: {g_val: {b_val: [image_path]}}} and when the channel value for that pixel in the current I use (...
by jemthealmighty
Tue Jun 16, 2009 10:18 pm UTC
Forum: Coding
Topic: Shooting yourself in the foot: Part two
Replies: 50
Views: 5452

Re: Shooting yourself in the foot: Part two

Cithoge wrote:CSS: You create a new leg that looks great, but due to Internet Explorer you have a different number of toes each day, and sometimes the knee bends the wrong way.

Fixed.
by jemthealmighty
Tue Jun 16, 2009 10:49 am UTC
Forum: Coding
Topic: Do you like documentation in code, and if so, how/when?
Replies: 44
Views: 7821

Re: Do you like documentation in code, and if so, how/when?

I comment each class and method with triple quotes and about 1 line of text and I use #'s for most blocks of code (about 5-10 lines accomplishing something) if it isn't blatantly obvious.
by jemthealmighty
Mon Jun 15, 2009 11:44 pm UTC
Forum: Coding
Topic: How do you make you code/script files?
Replies: 34
Views: 2896

Re: How do you make you code/script files?

ash.gti wrote:
MHD wrote:I am unfortunatly a windows XP user. And this system works just fine for me.


And? his example uses vim, which works on just about every system i have heard of, and you can install bash on windows too.

I think he may have been referring to TextExpander, which is mac only.
by jemthealmighty
Sat Jun 13, 2009 11:05 pm UTC
Forum: Coding
Topic: How do you make you code/script files?
Replies: 34
Views: 2896

Re: How do you make you code/script files?

It's faster than opening scite, writing the shebang and saving, having to select your directory. I overcome this problem with textexpander (mac only as far as I know). $ vim filename.py [in file, interactive mode] >python and poof! I have a shebang and copyright sitting there ready to code. I have ...
by jemthealmighty
Thu Jun 11, 2009 11:25 pm UTC
Forum: Coding
Topic: Switches vs. If-Then in C++
Replies: 18
Views: 2041

Re: Switches vs. If-Then in C++

zalzane wrote:Sort of like how tuples are much faster dictionaries in python.

Do you mean lists? As far as I know tuples are nothing like dictionaries (on their own anyway).
by jemthealmighty
Thu Jun 11, 2009 11:15 pm UTC
Forum: Coding
Topic: How do you make you code/script files?
Replies: 34
Views: 2896

Re: How do you make you code/script files?

Either Coda or vi depending on how many files I need quick access to at the time.
by jemthealmighty
Thu Jun 11, 2009 10:04 pm UTC
Forum: Coding
Topic: Auto-insertion of Glossary Links
Replies: 24
Views: 1801

Re: Auto-insertion of Glossary Links

One more thing: is it possible to generate the JSON dynamically? That is, if I have another script that generates an appropriately-formatted list of words and definitions when I view it in my browser, is there some way to pass that list to this new script? (If I just point getJSON to the filename o...
by jemthealmighty
Tue Jun 09, 2009 10:25 pm UTC
Forum: Coding
Topic: Regex help
Replies: 3
Views: 617

Re: Regex help

If you know it will end in -w12.tsv why not use (capturing the variable).

Code: Select all

/(\w+)-.*-w12\.tsv/
by jemthealmighty
Tue Jun 09, 2009 10:17 pm UTC
Forum: Coding
Topic: HTML Parsing suggestions?
Replies: 14
Views: 1747

Re: HTML Parsing suggestions?

Some friends and I built a web crawler a few months back and we just used regex to match /href="<url_validating_regex>"/ but that was in python, and I haven't worked with c++ but I'm pretty sure it has a regex library.
by jemthealmighty
Mon Jun 08, 2009 7:37 am UTC
Forum: Coding
Topic: Python inline conditionals.
Replies: 6
Views: 2044

Re: Python inline conditionals.

As said it has been out for years, the reason

Code: Select all

(False, True)[Cond]
is still used is because there are still many people using Python 2.4 so it is done for backwards compatibility.
by jemthealmighty
Mon Jun 01, 2009 11:56 am UTC
Forum: Coding
Topic: Folder Watcher in C "EXC_BAD_ACCESS"
Replies: 11
Views: 1311

Re: Folder Watcher in C "EXC_BAD_ACCESS"

I'd really like to read up about how compilers work behind the scenes. Does anyone have any good sites or books that explain it well?
by jemthealmighty
Sun May 31, 2009 6:13 am UTC
Forum: Coding
Topic: Folder Watcher in C "EXC_BAD_ACCESS"
Replies: 11
Views: 1311

Re: Folder Watcher in C "EXC_BAD_ACCESS"

That fixed it, thanks Qoppa.
by jemthealmighty
Sun May 31, 2009 5:49 am UTC
Forum: Coding
Topic: Folder Watcher in C "EXC_BAD_ACCESS"
Replies: 11
Views: 1311

Folder Watcher in C "EXC_BAD_ACCESS"

Hey guys, Working on a C script that monitors a folder and runs a command whenever its contents change (mostly to learn C). Here is my source (with debugging): #include <stdio.h> #include <stdlib.h> #include <string.h> #define DELAY 600 // 10 minutes #define STORAGE_FILE ".folder_list" sta...
by jemthealmighty
Thu May 28, 2009 1:46 am UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Personal Game Project in PyGlet

I did a rewrite on a lot of the code but I am still getting a bus error.

I attached my current source.
Can someone please help, at least, explain what is causing the error?

Thanks guys,
Jem
by jemthealmighty
Wed May 27, 2009 10:39 pm UTC
Forum: Coding
Topic: How to add a path for python to import modules from
Replies: 6
Views: 1446

Re: How to add a path for python to import modules from

I have never had a problem with

Code: Select all

import sys
sys.path.append('path/to/module')
import module

Given you are accessing a module located at 'path/to/module/module.py'

I haven't tried it for absolute paths (or on Windows) before, but as far as I can tell there shouldn't be a problem.
by jemthealmighty
Sat May 23, 2009 11:09 pm UTC
Forum: Coding
Topic: Good programming music
Replies: 93
Views: 15945

Re: Music while coding

I can't really say there is a pattern to what I listen to but I find I generally concentrate and thus code better when I have The Dresden Dolls, Paramore, Avril Lavigne, The Veronicas, etc. playing. I just noticed they are all female singers so maybe that has something to do with it?
by jemthealmighty
Wed May 20, 2009 6:17 am UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Personal Game Project in PyGlet

Ok, thanks.

I restarted the coding for most of it with a different approach to drawing.
Hopefully it will work this time.
by jemthealmighty
Mon May 18, 2009 11:37 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Personal Game Project in PyGlet

My Idea didn't end up working so now I am looking into implementing locks. This is my display.py file: #!/usr/local/bin/python2.6 # Copyright 2009 Jeremy Worboys <jemthealmighty@gmail.com> # Licensed for distribution under the GPL version 3 from os.path import join import pyglet import g import help...
by jemthealmighty
Mon May 18, 2009 10:28 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Personal Game Project in PyGlet

Thanks greysquare, I had a feeling I could do that but haven't really worked with threads beyond the basics before. The reason both threads are drawing is because pyglet runs events at the end of each loop (ie drawing, user-input, etc) and in the scripts I am running I call a 'dialogue' function whi...
by jemthealmighty
Mon May 18, 2009 12:05 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Personal Game Project in PyGlet

After hours per day of debugging and googling I have found out that pyglet is not thread-safe.

Is there any way of running a script asynchronously in python that can work around this issue?
by jemthealmighty
Thu May 14, 2009 11:42 am UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Map parsing with regexp

Doesn't exec (or eval) take an optional environment? If that's the case, you can build your own with only the primitives you want. Don't know how this works with print and python <3. Ok, I used your advice and set up a limited scope to run scripts with exec. The problem I'm coming up against now is...
by jemthealmighty
Thu May 14, 2009 7:53 am UTC
Forum: Coding
Topic: linux HTML IDE (kompozer maybe?)
Replies: 6
Views: 1024

Re: linux HTML IDE (kompozer maybe?)

If whatever you're using now has a tabbed interface there are probably hotkeys you can use to go back and forth (should be Ctrl+Tab and Ctrl+Shift+Tab). What I do is just use a regular code editor on one part of the screen and an open web browser pointing at the file on the other. Alt+Tab for movin...
by jemthealmighty
Mon May 11, 2009 12:57 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Map parsing with regexp

Thanks 0xBADFEED. On another note, any advice on the scripting behind the game. ie. I need a system that can run short snippets of code from various point in the game. The idea is that it will have access to a limited set of the game variables and a set of functions including some built-in ones. The...
by jemthealmighty
Mon May 11, 2009 11:52 am UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 785924

Re: Coding: Hacks and Snippets

As far as I know python has had a built in (non-hack) ternary since 2.6. eg: print 't' if x else 'f' Though it isn't backwards compatible, hence the hacky lambda and tuple alternatives. EDIT: Fibonacci using list comprehension: >>> fibs = lambda n: [sum(([1,0]+locals()['_[1]'])[-2:]) for x in xrange...
by jemthealmighty
Mon May 11, 2009 7:20 am UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 785924

Re: Coding: Hacks and Snippets

I use: (false_value, true_value)[condition] That's good, as long as isinstance(condition, bool) or condition in [0,1]. Otherwise, you got excepted. The point of `condition` is an expression that returns a boolean (or equivalent) result. ie. using phlip's example: "%d broken piece%s of code&quo...
by jemthealmighty
Sun May 10, 2009 10:26 pm UTC
Forum: Coding
Topic: Coding: Hacks and Snippets
Replies: 434
Views: 785924

Re: Coding: Hacks and Snippets

Refefer wrote:My simple hack was for satisfying my need of a ternary operator in python (< 2.6):

Spoiler:
t = lambda t, x, y: (t and x) or (not t and y)


Saved me some time and code compared to the one in 2.6 too!

I use:

Code: Select all

(false_value, true_value)[condition]
by jemthealmighty
Sat May 09, 2009 11:31 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Map parsing with regexp

I don't know what the context of the game is, but if it's just a personal project you could just create a Map class or something and use Pickle to read/write the data to file. Not a very good idea if it's anything more serious than a personal project, though. It is a personal project and that's not...
by jemthealmighty
Sat May 09, 2009 12:24 pm UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Re: Map parsing with regexp

Thanks Emu* I'll look into using xml, problem is (as far as I know) python has quite ugly xml libraries.

Also for anyone who is interested I figured out the regexp:

Code: Select all

:(.*?):(\n\s(.*?)$)+


EDIT:
I ended up using json since it is nicer to look at and easier to encode/decode.
by jemthealmighty
Sat May 09, 2009 8:31 am UTC
Forum: Coding
Topic: Personal Game Project in PyGlet
Replies: 17
Views: 7092

Personal Game Project in PyGlet

Hey guys, I'm working on a little game written in python and am thinking of using a recursive function to parse map files. A basic example of a map file is :grid: bb bb bb bb bb bb bb bb bb bb wn wn wn wn wn wn wn bb bb ww aa ab ac aa aa we bb bb ww aa aa aa aa aa we bb bb ww ae ae ae ae ae we bb bb...
by jemthealmighty
Sun May 03, 2009 11:47 pm UTC
Forum: Coding
Topic: Poll: Wich grammatic genre do you favor?
Replies: 29
Views: 2847

Re: Poll: Wich grammatic genre do you favor?

Curly and indented for me.
by jemthealmighty
Wed Apr 15, 2009 10:16 am UTC
Forum: Coding
Topic: Coding Competition #3.141593 (winners)
Replies: 148
Views: 9010

Re: Coding Competition #3.1415927 (BomberTron Isolation)

Right now it's like an upside-down numpad (a common cellphone configuration). I guess that sort of makes sense? I figured so, but just wanted to make sure. Also, how are the squares arranged for the first turns output? I'm assuming something like: 0 1 2 3 4 5 6 7 8 # # # # # # # # # # # 0 # _ _ _ _...
by jemthealmighty
Wed Apr 15, 2009 8:57 am UTC
Forum: Coding
Topic: Coding Competition #3.141593 (winners)
Replies: 148
Views: 9010

Re: Coding Competition #3.1415927 (BomberTron Isolation)

On any subsequent turn, any single character is an acceptable reply (or any number of characters followed by a newline since only the first character will be examined). It will be interpreted in the following way: 1-move northwest 2-move north 3-move northeast 4-move west 6-move east 7-move southwe...

Go to advanced search