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.
 
  • Post
  • Reply
Doctor w-rw-rw-
Jun 24, 2008
I don't know the answer to your other questions, but that is definitely obfuscated/minified JavaScript.

Adbot
ADBOT LOVES YOU

Sylink
Apr 17, 2004

How do you guys do versioning for small projects?

I like to play around and it would be nice to have versioning that updates every so often or upon file changes automatically based on a list of folders or whatever I want it to monitor.

I've used git but I don't want to have to commit manually. I'd rather just do what I'm doing, make new files, change stuff, and have it recorded and uploaded automatically.

ToxicFrog
Apr 26, 2008


Sylink posted:

How do you guys do versioning for small projects?

I use git and commit frequently.

quote:

I like to play around and it would be nice to have versioning that updates every so often or upon file changes automatically based on a list of folders or whatever I want it to monitor.

I've used git but I don't want to have to commit manually. I'd rather just do what I'm doing, make new files, change stuff, and have it recorded and uploaded automatically.

You could use a versioning filesystem, or you could use cron or inotify or something and just have it automatically git add . && git commit -m "Autocommit $(date)", although even suggesting that makes me feel dirty.

Opinion Haver
Apr 9, 2007

That's an awful way to do version control. The point of manual commits is that you commit when you're in a known good state, so you don't have to sift through the 8 syntax error fixes you made.

nielsm
Jun 1, 2009



Sylink posted:

How do you guys do versioning for small projects?

Either I don't, or I use git.
I like having my code on one monitor and testing (if it's a web thing), logs and version control on the other. (You do have at least two monitors, right?) Then it's quite easy so just reach over and do a commit.

But usually I don't do any version control of the very initial things. Until I get a basic skeleton up of what I want to make, it just doesn't seem useful (1. Produce some code that does something; 2. Begin doing version control; 3. More systematically transform the code into something that does the right thing.)

Bunny Cuddlin
Dec 12, 2004

Sylink posted:

How do you guys do versioning for small projects?

I like to play around and it would be nice to have versioning that updates every so often or upon file changes automatically based on a list of folders or whatever I want it to monitor.

I've used git but I don't want to have to commit manually. I'd rather just do what I'm doing, make new files, change stuff, and have it recorded and uploaded automatically.

git commit -a -m "Added collision detection" isn't that hard to type and it will make it so you don't have broken commits you have to sift through.

Doctor w-rw-rw-
Jun 24, 2008

yaoi prophet posted:

That's an awful way to do version control. The point of manual commits is that you commit when you're in a known good state, so you don't have to sift through the 8 syntax error fixes you made.

Branch, commit frequently, test, then merge-squash to master when it's not broken. Best of both worlds.

The ghetto-versioning method I've seen is to use Dropbox. But IMO just use git and adapt yourself to a workflow that works with it. It's going to be a staple of a large amount of development for quite some time, I think.

Bunny Cuddlin
Dec 12, 2004

Doctor w-rw-rw- posted:

Branch, commit frequently, test, then merge-squash to master when it's not broken. Best of both worlds.

The ghetto-versioning method I've seen is to use Dropbox. But IMO just use git and adapt yourself to a workflow that works with it. It's going to be a staple of a large amount of development for quite some time, I think.

Have the best of both worlds! (I actually do this for a small project I share with two friends)

shrughes
Oct 11, 2008

(call/cc call/cc)

Bunny Cuddlin posted:

git commit -a -m "Added collision detection" isn't that hard to type and it will make it so you don't have broken commits you have to sift through.

It's even faster to type if you use git commit -am

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Sylink posted:

I've used git but I don't want to have to commit manually. I'd rather just do what I'm doing, make new files, change stuff, and have it recorded and uploaded automatically.

Why are you using version control if you don't want to reap the benefits of having logical changes? You should record a message saying how and why something changed (see here), in case you or a teammate needs the rationale later. Tools like bisect depend the ability to have a sane tree at any one time.

hypernova
Apr 12, 2005
Ok, completely inexperienced with programming of any kind, but I have just a very general question about what kind of coding etc. would be necessary for this kind of project.

Basically, I want to extract data from a webpage that is only available to an account that's currently logged in. Without any activity, accounts typically log out after about 15 minutes. The data is in text form; however, the data appears at random intervals. Usually, the web page displays text to the effect of 'No data available.' Without this data extraction, the only way to be see the text, when it pops up, would be to keep the page active and watch it in person.

Can anyone just give me a brief idea of what could be used to accomplish something like this? If it's not as straightforward as I'm thinking it might be, I'm ok with hearing that as well. Thanks for any answers!

Bunny Cuddlin
Dec 12, 2004
It's fairly easy to cheat at whatever it is you're trying to cheat at.

hypernova
Apr 12, 2005

Bunny Cuddlin posted:

It's fairly easy to cheat at whatever it is you're trying to cheat at.

Ah, that's good to hear. Mind offering a general idea of what would be involved in order to accomplish such a task?

Jewel
May 2, 2009

What I'm confused about here is how does the data "appear at random". If you hadn't continued, I would have expected you'd have to keep refreshing the page until it's there, but then you said "The only way to see the text, when it pops up, would be the keep the page active and watch it in person."

Doesn't that mean the page has to already contain the data within the source? It'd have to have some kind of php/javascript/whatever timer in the background or something, and even if the data's loaded from an external part of the site when the timer runs out, that'll be in the source too, so wouldn't you be able to just figure out where it's loading the data from, or get it straight from the source?

hypernova
Apr 12, 2005

Jewel posted:

What I'm confused about here is how does the data "appear at random". If you hadn't continued, I would have expected you'd have to keep refreshing the page until it's there, but then you said "The only way to see the text, when it pops up, would be the keep the page active and watch it in person."

Doesn't that mean the page has to already contain the data within the source? It'd have to have some kind of php/javascript/whatever timer in the background or something, and even if the data's loaded from an external part of the site when the timer runs out, that'll be in the source too, so wouldn't you be able to just figure out where it's loading the data from, or get it straight from the source?

Hm, yeah, random is maybe not quite the right word for it. Basically, other people decide when to post the data and it's completely up to them when they decide to do so. I have no idea, for the most part, who these people are or when they'll decide to post the data. That's why it appears as 'random' to me. Perhaps a better way to phrase it would be: the data is posted at unspecified times, with varying intervals of time between each posting.

The frame source (using Chrome) only shows the data when it's actually on the page. Being able to monitor the frame source and then alerting me when that data is there is what I'd like to do, but I'm not really sure what combinations of programming types would be necessary to do such a thing.

o.m. 94
Nov 23, 2009

You would probably want to use something like Selenium to do browser automation tasks. If you can't achieve what you're trying to do with SeleniumIDE then it looks like you're going to have to learn some Python or Java you cheating scumbag. But at least you'll learn something!

In fact, if you're polling the page to search the source for the existence of a string the IDE probably won't cut it. You could easily write a script in something like Python that would GET the page source on a frequent interval and search it for the content you're after.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I doubt the data just appears out of the blue, there's likely to be some javascript that polls something and updates the page when new data arrives.

The correct solution is probably to figure out where that javascript is getting the data from and looking there yourself.

hypernova
Apr 12, 2005

oiseaux morts 1994 posted:

You would probably want to use something like Selenium to do browser automation tasks. If you can't achieve what you're trying to do with SeleniumIDE then it looks like you're going to have to learn some Python or Java you cheating scumbag. But at least you'll learn something!

In fact, if you're polling the page to search the source for the existence of a string the IDE probably won't cut it. You could easily write a script in something like Python that would GET the page source on a frequent interval and search it for the content you're after.

Ok, that's good to hear that just one language such as Python might be able to do what I want to do. Also, not that it's important, but it's not really for cheating. It's basically a site where people are posting freelance work that I'm able to do. It's just a pain in the rear end to wait around on the site all day waiting for people to post the work. Much easier if I could set something up to get the data from the job when it's posted, examine it quickly, then decide whether I want to accept the job or not.

Jabor posted:

The correct solution is probably to figure out where that javascript is getting the data from and looking there yourself.

All the important information on the page is contained entirely in a frame (I don't really know how this works btw). If I reload the page, it signs me out. If I use the "Reload frame" option in Chrome, it refreshes the job list and keeps the page active. I've tried searching through the frame source and it contains about 3/4 page with script called "Client Event Handlers" which seems to contain a bunch of admin functions and 1/4 the part of the page contains what seems to be the information relevant to me. I'm not quite sure I see any references to a function etc. that gets data from an external source, but you may be able to chalk that up to my inexperience with JS and how webpages are structured.

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice

hypernova posted:

Much easier if I could set something up to get the data from the job when it's posted, examine it quickly, then decide whether I want to accept the job or not.

Are you sure this site doesn't offer some sort of RSS feed that you can integrate with?

Bunny Cuddlin
Dec 12, 2004

hypernova posted:

Ok, that's good to hear that just one language such as Python might be able to do what I want to do. Also, not that it's important, but it's not really for cheating. It's basically a site where people are posting freelance work that I'm able to do. It's just a pain in the rear end to wait around on the site all day waiting for people to post the work. Much easier if I could set something up to get the data from the job when it's posted, examine it quickly, then decide whether I want to accept the job or not.


All the important information on the page is contained entirely in a frame (I don't really know how this works btw). If I reload the page, it signs me out. If I use the "Reload frame" option in Chrome, it refreshes the job list and keeps the page active. I've tried searching through the frame source and it contains about 3/4 page with script called "Client Event Handlers" which seems to contain a bunch of admin functions and 1/4 the part of the page contains what seems to be the information relevant to me. I'm not quite sure I see any references to a function etc. that gets data from an external source, but you may be able to chalk that up to my inexperience with JS and how webpages are structured.

So it's in an iframe. Have you tried going to the URL of the page in the iframe?

hypernova
Apr 12, 2005

Bunny Cuddlin posted:

So it's in an iframe. Have you tried going to the URL of the page in the iframe?

After messing around with Chrome's element inspector tool, the frame seems to point to an .aspx page. It has the same source info as what I was looking at before. I do not see any other URL in this source. When I have just the .aspx page open, the only thing displayed on the page is the "No data available." screen, instead of having a menu on the left hand side etc. When I try to access the .aspx page from a different browser, it prompts me to log into the website, which seems to indicate whatever the .aspx page is displaying is unique to my active user account.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I'm going to be implementing a transaction ledger as part of a site built on Django. I found this bit about django-money so I guess I'll be using that.

I'm not an accountant, so I'm a little nervous about making boneheaded mistakes when helping other people manage and track their money. Does anyone have any advice, or any references for reading, about implementing Quicken-like ledgers?

fubarsapfu
Aug 4, 2004
I'm trying to develop a folder action in AppleScript to automatically send images to my iPhone the moment a new image file appears to the folder (the file is discarded after the transfer). I thought it was going to be a simple procedure but I'm only getting the results I want when I perform the steps in this script manually.

code:
tell application "Finder"
	set folderPath to folder "System:Users:self:Pictures:send"
	set theFile to first file in folderPath as alias
	set fileName to name of theFile
end tell

set theSubject to " "
set theBody to " "
set theAddress to "xxxxxxxxxx@vzwpix.com"
set theAttachment to theFile
set theSender to "xxxxxxxxx@gmail.com"

tell application "Mail"
	set theNewMessage to make new outgoing message with properties 
	{subject:theSubject, content:theBody & return & return, visible:true}
	tell theNewMessage
		set visibile to true
		set sender to theSender
		make new to recipient at end of to recipients with properties 
		{address:theAddress}
		try
			make new attachment with properties 
			{file name:theAttachment} 
			at after the last word of the last paragraph
			set message_attachment to 0
		on error errmess -- oops
			log errmess -- log the error
			set message_attachment to 1
		end try
		log "message_attachment = " & message_attachment
		send
	end tell
end tell
Works great when I'm pointing and clicking this myself. The image is received as an MMS message. When I use the Folder Action though, the message I receive on my phone is a blank text message.

Very confused. Any ideas?

some kinda jackal
Feb 25, 2003

 
 
Is there any way to have Eclipse clear out the Errors/Problems pane once you re-issue a build order?

Maybe it's just a problem with my setup, but errors linger on in that pane long after I've fixed them. The only way for me to clear them is to manually go in and delete each one.

fubarsapfu
Aug 4, 2004
In the end I decided to just use GUI scripting (so much for elegance), but if anyone has any explanation as to why the code I posted above behaved the way it did, I'd love to know.

Mniot
May 22, 2003
Not the one you know

fubarsapfu posted:

Works great when I'm pointing and clicking this myself. The image is received as an MMS message. When I use the Folder Action though, the message I receive on my phone is a blank text message.

Very confused. Any ideas?

You can get a hint by running it in the editor and then looking at the "Events" tab. You'll see an error like
code:
(*Can’t make «class docf» "attachment file name" of «class cfol» path to the file into the expected type.*)
The actual answer is here: https://discussions.apple.com/thread/2735237?start=0&tstart=0
You need to add "as alias" at the end of the file description before passing it to Mail. When I made that change to the script, it worked for me.

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice
I need some help with epydoc. I'm trying to generate some UML diagrams. I'm on OSX 10.6, I've installed graphviz and can run it without issue, however, epydoc will not produce UMLs with the following command:

code:
epydoc --graph all --dotpath=/usr/local/bin/dot -v class.py
Graphviz is installed at /usr/local/bin/dot, I can run it fine from command line. Any advice?

Sinestro
Oct 31, 2010

The perfect day needs the perfect set of wheels.
What sort of algorithm is used to get a sort of "predominant color" thing like nu-iTunes uses?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I assume it's a standard 3D histogram.

mobby_6kl
Aug 9, 2009

by Fluffdaddy

Sinestro posted:

What sort of algorithm is used to get a sort of "predominant color" thing like nu-iTunes uses?

I remembered reading an article about how Chrome does this to with favicons for some reason (I don't even use Chrome) so I looked it up again and it seems like they use K-means clustering and then pick the largest cluster as the dominant color. Whether this is better or worse than other methods probably depends on needs in terms of performance and results.

http://www.quora.com/Google-Chrome/How-does-Chrome-pick-the-color-for-the-stripes-on-the-Most-visited-page-thumbnails
http://apps.visualpulse.net/kmean_chrome_color_stripe/?url=somethingawful.com&k=3#faq_calculate_k

1337JiveTurkey
Feb 17, 2005

It's 8:30 on the night before a customer handover and apparently they don't like the capitalization of their company name in some of our config files enough that it's going to be a problem. QA server is going down for patching in 5....

edit: Crap wrong thread

1337JiveTurkey fucked around with this message at 02:56 on Dec 7, 2012

emanresu tnuocca
Sep 2, 2011

by Athanatos
I have a very stupid newbie question, I'm very new to coding and am just basically trying to figure stuff out on my own at the moment.

I'm trying to write a few java classes that are supposed to create a very very simple model of the human cardiac cycle, basically I want to create a 'human()' object, that contains 'heart' and 'blood', and then execute heart.pump() which should access the blood object, take some blood from it, hold on to it for a while, and then give the blood back.

Now, basically, how do I let the heart object have access to the blood object? and how do I make sure I'm not copying the object but rather sharing access to it?

For instance, I know I can send the "Blood" object to the "Heart" class either as a constructor or as a field for the 'Pump' method; I assume that this should work cause I'm not creating a new instance of blood, however, this seems a little complicated. I'd rather be able to execute Pump() rather than Pump(Blood()).

So basically, how can I make the blood object accessible to methods from the 'heart' object?

nielsm
Jun 1, 2009



In Java, variables of object types hold references to objects, not objects themselves.
That means that assignment with the = operator copies the reference, not the object.
Basically, you only get a new/different object when you use the new operator to construct a new object, or call a method that promises to create a new object (such as Object.clone().)

(Note about strings: Java strings are immutable objects, so using e.g. the + operator to concatenate strings also creates new, distinct objects.)

nielsm fucked around with this message at 15:28 on Dec 7, 2012

emanresu tnuocca
Sep 2, 2011

by Athanatos
Thanks, that's good to know for sure.

As for my other question, I think I'm just approaching this incorrectly, basically I should have the 'Human' class handle taking blood from 'blood()' and delivering it to 'Heart()', i.e handle the class that invokes the objects manage the mutual interactions between the objects.

I'm very bad at code-talk.

nielsm
Jun 1, 2009



I'm not sure if this relates directly to your assignment, but consider this:

A Human has a Heart.
A Human also has a circulatory system.
The Heart is connected to the circulatory system. (It has two intakes and two outtakes, as far as I remember, but for modeling it's probably easier to pretend there is just one intake and outtake.)
When the Heart pumps, it pushes blood into the outtake and pulls in from the intake.

The way I would model this (apart from being a silly thing I would never actually model) would be having a Human object own a CirculatorySystem and a Heart. The Heart would have been connected to two endpoints of the CirculatorySystem, so it holds references to each of those two endpoints. When the Heart receives a Pump impulse from whatever, it would input and output blood from the connections it has.
A basic circulatory system could be modeled as something simple such as a List of Blood objects, where the list is used as a first-in first-out queue, which gets pre-filled with some Blood objects by the Human constructor.

Jewel
May 2, 2009

emanresu tnuocca posted:

Thanks, that's good to know for sure.

As for my other question, I think I'm just approaching this incorrectly, basically I should have the 'Human' class handle taking blood from 'blood()' and delivering it to 'Heart()', i.e handle the class that invokes the objects manage the mutual interactions between the objects.

I'm very bad at code-talk.

From what I can think, if I wanted to do it complicated, I'd do this: I'd have the Human class contain Heart, and other organs. The parts that blood flows (I'm having a mental blank about how humans look inside :v:) between should be linked with a fake "vein", by which I mean the organs should be stored in a circular singularly linked list, of sorts, by storing references to the next organ inside each one (heart would be an Organ). Each organ would have a float supply of blood, and when an organ is Pump()'ed it would subtract blood from itself and transfer it to the next organ, simultaneously calling whatever function that organ is supposed to do when blood flows into it. The blood itself shouldn't really be a class, I don't think, but thinking about it you could get away with maybe treating blood as a Packet of sorts, just a node of "Blood" that gets transferred along the list, and could have different references inside it such as the blood type, viruses present, etc etc.

Obviously this is all way too in depth but I've always been fascinated by the idea of simulating real world things with code :allears:

Also it could be useful to be this in-depth programming a game like Dwarf Fortress.

emanresu tnuocca
Sep 2, 2011

by Athanatos
Thanks guys that's very helpful.

Nielsm, what you're suggesting is basically what I was trying to describe, thanks for clarifying this for me, I don't actually have an assignment I'm just giving myself silly assignments. At the moment I'm not even going to have store Blood objects I'll just have a few ints for "totalBloodCapacity", "venialBloodCapacity" and "arterialBloodCapacity". Keep it simple.

Jewel, that's basically what I'm trying to do, I actually started creating this very complex data structure with 'Organs' and 'Bones' and 'Body Regions' and just got completely drowned in just managing the data structure and trying to have my main loop access the organs in a simple fashion and realized I should basically start with some basic component of the system and take it from there. I would definitely like take a more complex approach with the Blood object itself in the future and packets definitely seem like a good approach, I should better familiarize myself with those.

Jewel
May 2, 2009

emanresu tnuocca posted:

Thanks guys that's very helpful.

Nielsm, what you're suggesting is basically what I was trying to describe, thanks for clarifying this for me, I don't actually have an assignment I'm just giving myself silly assignments. At the moment I'm not even going to have store Blood objects I'll just have a few ints for "totalBloodCapacity", "venialBloodCapacity" and "arterialBloodCapacity". Keep it simple.

Jewel, that's basically what I'm trying to do, I actually started creating this very complex data structure with 'Organs' and 'Bones' and 'Body Regions' and just got completely drowned in just managing the data structure and trying to have my main loop access the organs in a simple fashion and realized I should basically start with some basic component of the system and take it from there. I would definitely like take a more complex approach with the Blood object itself in the future and packets definitely seem like a good approach, I should better familiarize myself with those.

Well by packets I just used a word that meant roughly what I wanted to. They're not actual packets or anything special, they're just a reference to a single Blood object that gets passed around the circle kinda like a packet, it's always just "there". You'd probably have a lot more than one all passed around, slowly diminishing and creating more from an energy source like the stomach or something. Interesting~ Also I like how you think. Keep me/the thread updated on this please~!

emanresu tnuocca
Sep 2, 2011

by Athanatos
Java is cool but object oriented thinking is giving me a headache, I feel that merely trying to stuff helps me figure out both coding in general and what I need to do to implement my own ideas.

Since I wanted to create some mechanism that allows a classes to 'schedule events' on the main 'world clock' and having the world clock actually call those events up and execute the relevant methods I found myself creating a GameEvent interface and a GameEventQueue class which contains an arrayList object that collects GameEvents. GameEvents have a Beginning, Duration and Expiration, each of them also contains an .execute(), so now I can just call up events, compare them to my world clock and execute them.

The downside for me is that I have to create a new GameEvent type for every action, which I guess is acceptable but I dislike the fact that it generates a million new files in Eclipse. What's the best way to deal with API classes like that? should I make them all belong to a new package?

Adbot
ADBOT LOVES YOU

nielsm
Jun 1, 2009



emanresu tnuocca posted:

The downside for me is that I have to create a new GameEvent type for every action, which I guess is acceptable but I dislike the fact that it generates a million new files in Eclipse. What's the best way to deal with API classes like that? should I make them all belong to a new package?

Inner classes. Anonymous classes.

Java allows you to declare a class inside a class, and even give that class access restrictions (public/protected/private). Those inner classes can naturally inherit from any other class visible to it, and implement any interface visible to it, and you can then have functions returning objects of those public classes/interfaces that the inner class implements.

Java also lets you make anonymous classes, a class that doesn't even have a name by itself, and is defined entirely inside a method of another class. Those are useful for passing short bunches of code around, especially when it doesn't make sense to have that code normally accessible outside the method creating it.


Some example-ish stuff:
(Might contain syntax errors, it's been a long time since I last wrote anything in Java.)

GameEvent.java
Java code:
interface GameEvent {
  void execute();
}
Head.java
Java code:
class Head implements GameObject {
  // this declares an inner class only visible to the Head class itself.
  // because this is not a static inner class, it objects of it implicitly have access
  // to the object that created it, i.e. the EyeBlinkEvent knows which Head created it
  // so it will blink the eyes of that head.
  private class EyeBlinkEvent implements GameEvent {
    public void execute() {
      leftEye.close();
      leftEye.open();
      rightEye.close();
      rightEye.open();
    }
  }
  private Eye leftEye;
  private Eye rightEye;
  public void run(GameState state) {
    EyeBlinkEvent e = new EyeBlinkEvent;
    state.enqueueEvent(100, e); // 100 milliseconds from now
  }
}
Stomach.java
Java code:
class Stomach implements GameObject {
  private List<Nutrient> contents;
  private CirculatorySystem circulatorySystemLink;
  public void run(GameState state) {
    // this declares an anonymous class that implements the GameEvent interface
    // and creates an object of that class, passing it into the enqueueEvent method
    state.enqueueEvent(2500, new GameEvent {
      public void execute() {
        // digest some of the contents of the stomach and send it into the circulatory system
        circulatorySystemLink.addNutrient(contents.remove(0));
      }
    });
  }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply