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
redreader
Nov 2, 2009

I am the coolest person ever with my pirate chalice. Seriously.

Dinosaur Gum
I want to limit my daily 'loving around on the internet' internet access, on a mac (my work laptop)

I know how to just block off websites by editing /etc/hosts, but how about something like a time based filter, so I *can* read some news site for 15 minutes a day but no more? Or something that delays all clicks on a website by 30 seconds (as the xkcd guy mentioned once?)


If there's a program I'll just download it. If I have to write some sort of script can someone give me a starting point or tell me what to look up? I don't know much about web-related coding, I'm a back-end dev.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

redreader posted:

I want to limit my daily 'loving around on the internet' internet access, on a mac (my work laptop)

I know how to just block off websites by editing /etc/hosts, but how about something like a time based filter, so I *can* read some news site for 15 minutes a day but no more? Or something that delays all clicks on a website by 30 seconds (as the xkcd guy mentioned once?)


If there's a program I'll just download it. If I have to write some sort of script can someone give me a starting point or tell me what to look up? I don't know much about web-related coding, I'm a back-end dev.

This question is more frequently answered in SH/SC.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I have an app in which the user can drag objects around and resize them with the mouse. I don't want the objects to overlap each other/the edge of the window. All objects are rectangles. Currently I have this (in a mouseDragged method called continually by the OS):

code:
Pseudocode:
//rect is a struct of {x, y, width, height}

xDelta = endPoint.x - startPoint.x;
yDelta = endPoint.y - startPoint.y;

if (corner == northEastCorner) {
    newRect = makeRect(x, y, width + xDelta, height + yDelta);
} else if (corner == northWestCorner) {
    newRect = makeRect(x + xDelta, y, width - xDelta, height + yDelta);
} else if (corner == southEastCorner) {
    newRect = makeRect(x, y + yDelta, width + xDelta, height - yDelta);
} else if (corner == southWestCorner) {
    newRect = makeRect(x + xDelta, y + yDelta, width - xDelta, height - yDelta);
} else { //no corner, ie dragging object
    newRect = makeRect(endPoint.x, endPoint.y, width, height);
}

if (newRect.doesntOverlapEdgesOrOtherObjects) {
    //do it
} else {
    //dont move
}
This works, but if the mouse moves too fast near an object/the edge, it "drops" the object until the mouse shows up in a place where the movement is valid. This results in the object being a bit out from where it could legally be unless you carefully & slowly drag/resize against the edge.

I can't control the rate of mouse updates, so is there an algorithm for "fitting up" against the edge/object? I tried doing the rect construction in a while (!isValid) loop and then having the deltas limit towards 0, but that created weird sideeffects when nearing a corner of another object.

Any algorithms for this?

Jewel
May 2, 2009

Carthag posted:

I have an app in which the user can drag objects around and resize them with the mouse. I don't want the objects to overlap each other/the edge of the window. All objects are rectangles. Currently I have this (in a mouseDragged method called continually by the OS):

code:
Pseudocode:
//rect is a struct of {x, y, width, height}

xDelta = endPoint.x - startPoint.x;
yDelta = endPoint.y - startPoint.y;

if (corner == northEastCorner) {
    newRect = makeRect(x, y, width + xDelta, height + yDelta);
} else if (corner == northWestCorner) {
    newRect = makeRect(x + xDelta, y, width - xDelta, height + yDelta);
} else if (corner == southEastCorner) {
    newRect = makeRect(x, y + yDelta, width + xDelta, height - yDelta);
} else if (corner == southWestCorner) {
    newRect = makeRect(x + xDelta, y + yDelta, width - xDelta, height - yDelta);
} else { //no corner, ie dragging object
    newRect = makeRect(endPoint.x, endPoint.y, width, height);
}

if (newRect.doesntOverlapEdgesOrOtherObjects) {
    //do it
} else {
    //dont move
}
This works, but if the mouse moves too fast near an object/the edge, it "drops" the object until the mouse shows up in a place where the movement is valid. This results in the object being a bit out from where it could legally be unless you carefully & slowly drag/resize against the edge.

I can't control the rate of mouse updates, so is there an algorithm for "fitting up" against the edge/object? I tried doing the rect construction in a while (!isValid) loop and then having the deltas limit towards 0, but that created weird sideeffects when nearing a corner of another object.

Any algorithms for this?

You could just make it always move but instead of just x = mouseX you could do x = min(max(mouseX, screen_width), 0) (but of course factoring your rectangle into that)

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Jewel posted:

You could just make it always move but instead of just x = mouseX you could do x = min(max(mouseX, screen_width), 0) (but of course factoring your rectangle into that)

Hmm, maybe. It'll at least fix the case of going near the edge of the window. It'll be a bit harder to fix the other case, cause there can be multiple objects all laying around, and I don't want to overlap any of them.

Also I just realized I posted the wrong part of my check; here's where the goodies are:

code:
doesntOverlapEdgesOrOtherObjects (newRect, object) {
    if (newRect.x < 0.0f) {
        return NO;
    } else if (newRect.y < 0.0f) {
        return NO;
    } else if (newRect.x + newRect.width > window.width) {
        return NO;
    } else if (newRect.y + newRect.height > window.height) {
        return NO;
    }
    
    for (other in otherObjects) {
        if (intersects(newRect, other.rect)) {
            return NO;
        }
    }
    
    return YES;
}

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
Back in the nineties, I've got fond memories of loading up my hex editors and other script kiddie tools and hacking in shortcuts to my Mac OS 9 application menus.

What's the modern method of adding hotkeys to my XP or windows 7 application file/edit/view menus?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ante posted:

Back in the nineties, I've got fond memories of loading up my hex editors and other script kiddie tools and hacking in shortcuts to my Mac OS 9 application menus.

What's the modern method of adding hotkeys to my XP or windows 7 application file/edit/view menus?

I dunno about Windows, but on Mac OS X it's in System Preferences under Keyboard - you can add shortcuts for any app/menu you feel like there. Not being a platform warrior, just putting that out there in case a current Mac user wants to know.

Also ResEdit was such a fun app for a budding nerd.

baquerd
Jul 2, 2007

by FactsAreUseless
Suppose we have n series of data points, for which each series can be graphed as a line. On this graph, a mouse pointer moves and in real time I need to detect whether the pointer is on top of a line. I have the happy constraint that across all series the x-axis coordinates are shared. That is to say that for any x-value for which I have data, all series will have such a data point.

This can be accomplished in O(n) by taking a first pass through any series to find the upper and lower x-axis values for the data points around the mouse pointer, then a second pass through each series to interpolate the y value of each series at the x-value of the pointer and selecting the closest one (you could get a better fit in O(n) with a third pass to ferret out the edge case with an extremely steep slope that would result closer line to the pointer but this is a good enough fit).

This can be accomplished in O(1) by segmenting the graph into individual pixels (or small boxes), and pre-calculating either a particular series or the absence of any series in each spot. Precalculating is O(n) for any particular pixel using the live O(n) algorithm, and if the graph is segmented into, for example a 200x200 grid, this process is repeated 40,000 times. Each pass can in reality be made much quicker by filtering out series with data points that would result in a pointless interpolation, but this is still a fair amount of processing for large values of n.

Does anyone have any suggestions for other avenues of pursuit?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

baquerd posted:

Suppose we have n series of data points, for which each series can be graphed as a line. On this graph, a mouse pointer moves and in real time I need to detect whether the pointer is on top of a line. I have the happy constraint that across all series the x-axis coordinates are shared. That is to say that for any x-value for which I have data, all series will have such a data point.

This can be accomplished in O(n) by taking a first pass through any series to find the upper and lower x-axis values for the data points around the mouse pointer, then a second pass through each series to interpolate the y value of each series at the x-value of the pointer and selecting the closest one (you could get a better fit in O(n) with a third pass to ferret out the edge case with an extremely steep slope that would result closer line to the pointer but this is a good enough fit).

Just sort the data by x coordinate (if it isn't already) then do a binary search rather than a linear search?

baquerd
Jul 2, 2007

by FactsAreUseless

Plorkyeran posted:

Just sort the data by x coordinate (if it isn't already) then do a binary search rather than a linear search?

Sure, but finding the x-coordinate bounds isn't computationally expensive at all as only a single series data points needs to be looked at. The y-coordinates have to be interpolated (or at least the lower and upper bound checked for each series with the series falling within the bounds having their y-values interpolated), so that's O(n) to get those anyway.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Oh, I misread that as n data points, not n series. Are you actually looking at drawing enough series on a single graph that interpolating between two points for each of them is even vaguely a concern? That sounds like a usability nightmare even if it is fast enough. I suppose if it's a massive graph that's pan and zoomable you might be able to get there.

One idea would be to use a quadtree rather than a grid of fixed size boxes for precomputing which series are potentially near each pixel.

NinjaDebugger
Apr 22, 2008


baquerd posted:

This can be accomplished in O(1) by segmenting the graph into individual pixels (or small boxes), and pre-calculating either a particular series or the absence of any series in each spot. Precalculating is O(n) for any particular pixel using the live O(n) algorithm, and if the graph is segmented into, for example a 200x200 grid, this process is repeated 40,000 times. Each pass can in reality be made much quicker by filtering out series with data points that would result in a pointless interpolation, but this is still a fair amount of processing for large values of n.

It's not repeated 40,000 times, you only have to do it N*(Xmax-Xmin) times.

Start with an array Xmax-Xmin long, each element of which is an array Ymax-Ymin long. For each X, interpolate each member of N, and fill in array[x][y] with a true or or a reference if you need a line reference. That gets you your O(1) in many fewer computations, since you can just assume (probably correctly) that the vast majority of the boxes are going to be empty/false, and thus default them to the correct value. See also: sparse matrices.

baquerd
Jul 2, 2007

by FactsAreUseless

Plorkyeran posted:

Oh, I misread that as n data points, not n series. Are you actually looking at drawing enough series on a single graph that interpolating between two points for each of them is even vaguely a concern? That sounds like a usability nightmare even if it is fast enough. I suppose if it's a massive graph that's pan and zoomable you might be able to get there.

Yes, for example 400 series each with 2000 data points would not be the worst case scenario by far (2 variables on separate axes with 5 years of daily financial data over 200 instruments). It's totally zoomable and pannable, and the mouseover on line functionality shows an annotation with the data over the pointer. I have "acceptable" performance for that size dataset at the moment, but it could be snappier and it would be nice to support even larger datasets.

NinjaDebugger posted:

It's not repeated 40,000 times, you only have to do it N*(Xmax-Xmin) times.

Start with an array Xmax-Xmin long, each element of which is an array Ymax-Ymin long. For each X, interpolate each member of N, and fill in array[x][y] with a true or or a reference if you need a line reference. That gets you your O(1) in many fewer computations, since you can just assume (probably correctly) that the vast majority of the boxes are going to be empty/false, and thus default them to the correct value. See also: sparse matrices.

Good point, and though I need to support values between the x values of the dataset, that's not quite as fine as Xmax-Xmin on my scale so it's even better.

Plorkyeran posted:

One idea would be to use a quadtree rather than a grid of fixed size boxes for precomputing which series are potentially near each pixel.

Veeeery interesting. Here's what I think I'm going to implement:

Precalculated line quadtree with a small bucket capacity (potentially one). Beneath a certain size threshold, additional lines will be discarded. Lookup of pointer to quadtree series bucket in real-time is log(n) (edit: not really log(n), could be better or worse but it's practically going to be similar), then from there direct interpolation can be done to give the desired precision. I need to look into implementation details on the quadtree, but it should offer a nice balance between precalculation time and runtime, as precalculation would need to happen fairly often as the dataset represented can change frequently.

baquerd fucked around with this message at 02:28 on Jan 28, 2012

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

ante posted:

Back in the nineties, I've got fond memories of loading up my hex editors and other script kiddie tools and hacking in shortcuts to my Mac OS 9 application menus.

What's the modern method of adding hotkeys to my XP or windows 7 application file/edit/view menus?

Use auto-it or autohotkey, it's loving amazing at adding shortcuts to things that don't have shortcuts.

Anotehr habit I've picked up is using greasemonkey to modify shortcuts on websites - I wrote a greasemonkey plugin that makes it so if I press left/right arrow, it goes back and forward in a thread (except if I'm typing a reply) by figuring out that there's a link called "next" or "prev" on the page and binding it to left and right unless there's an edit text box on the page. It's actually pretty ludicrously complex now, but here's an excerpt (I have keys for going up forums, smooth scrolling through posts, etc)

code:
var ma = $("textarea[name=message]"); 
if(ma.length)
{
	exit(); //disable navigation on reply pages
}
(function() {

jQuery(document).keydown(function(e) {
	switch(e.which){
	case 39: //right arrow
		
		var a = $("a:contains('Next')"); //does the link say next?
		if(a.length)
		{
			window.location.href=a.attr("href");
		}
		return false;
	break;		
	case 37: //left arrow
		
		var a = $("a:contains('Prev')");
		if(a.length)
		{
			window.location.href=a.attr("href");
		}
		return false;
	break;	
	}	   
}
)
})();

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss
I am looking into writing apps for smart phones, but I'd like to have just one code base, and a separate compile for iOs/iphone, Android, Windows Phone, etc?

I.e., I don't want to write one code base for iOs in objective C, another in Java for Android, and another in C# for Windows Phone, etc...

I recall reading somewhere that C# compiled with Mono, instead of .NET, can be ported to iOs, Android, and Windows Phone.

But, that is just one thing I read...

What do you recommend as a good way to keep one code base and code apps that can be compiled for iOs, Android, etc?

Are there drawbacks to doing it this way? If so, what?

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy

cannibustacap posted:

I am looking into writing apps for smart phones, but I'd like to have just one code base, and a separate compile for iOs/iphone, Android, Windows Phone, etc?

I.e., I don't want to write one code base for iOs in objective C, another in Java for Android, and another in C# for Windows Phone, etc...

I recall reading somewhere that C# compiled with Mono, instead of .NET, can be ported to iOs, Android, and Windows Phone.

But, that is just one thing I read...

What do you recommend as a good way to keep one code base and code apps that can be compiled for iOs, Android, etc?

Are there drawbacks to doing it this way? If so, what?

PhoneGap may help you here.

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

i barely GNU her! posted:

PhoneGap may help you here.

I surfed around and found PhoneGap and also Rhomobile... Are those the standard way of doing things? Their web pages don't mention using C# or Java as the code base, they just seem to talk about the code base as a generality...

EDIT: It seems like PhoneGap and Rhomobile is based on HTML, not Java/C#..

cannibustacap fucked around with this message at 08:08 on Jan 29, 2012

The Gripper
Sep 14, 2004
i am winner

cannibustacap posted:

I am looking into writing apps for smart phones, but I'd like to have just one code base, and a separate compile for iOs/iphone, Android, Windows Phone, etc?

I.e., I don't want to write one code base for iOs in objective C, another in Java for Android, and another in C# for Windows Phone, etc...

I recall reading somewhere that C# compiled with Mono, instead of .NET, can be ported to iOs, Android, and Windows Phone.

But, that is just one thing I read...

What do you recommend as a good way to keep one code base and code apps that can be compiled for iOs, Android, etc?

Are there drawbacks to doing it this way? If so, what?
I've *heard* good things about MonoTouch/Mono for Android, but haven't personally used either of them. It'll definitely let you reuse a lot of code between Android and iOS (though I believe you'll need to rewrite a lot of API accessing parts for each), but for Windows Mobile you'll still need to have a separate XNA oriented project (with entirely different interface/API code). At least it's still .NET though, so if you can properly separate interface/api code from other logic it may be possible to copy and paste parts of it.

Fake Edit; phonegap and rhomobile are really kinda awful, and I don't think they'll let you deploy anything to WM7 because of the XNA requirement.
Real Edit; I guess phonegap can deploy to WM7 now, though it's not entirely production ready (apparently). It's changed a bit since I last used it (2009?) so anything I've said previously can safely be ignored until you've tried it for yourself!

The Gripper fucked around with this message at 08:17 on Jan 29, 2012

cannibustacap
Jul 7, 2003

Brrrruuuuuiinnssss

The Gripper posted:

I've *heard* good things about MonoTouch/Mono for Android, but haven't personally used either of them. It'll definitely let you reuse a lot of code between Android and iOS (though I believe you'll need to rewrite a lot of API accessing parts for each), but for Windows Mobile you'll still need to have a separate XNA oriented project (with entirely different interface/API code). At least it's still .NET though, so if you can properly separate interface/api code from other logic it may be possible to copy and paste parts of it.

Fake Edit; phonegap and rhomobile are really kinda awful, and I don't think they'll let you deploy anything to WM7 because of the XNA requirement.
Real Edit; I guess phonegap can deploy to WM7 now, though it's not entirely production ready (apparently). It's changed a bit since I last used it (2009?) so anything I've said previously can safely be ignored until you've tried it for yourself!

I noticed there is Mono for android: http://xamarin.com/monoforandroid
Then Mono for iOS: http://xamarin.com/monotouch

They almost seem like separate things, and you need the pro version, $399, to make use of them. I'm confused though...

Are those two separate IDE's that I need to use? That makes me think there will be more than one code base.

I'd like there to be just 1 single IDE. I will write wrapper functions to handle the iOs and Android specific functions, and separate simulator windows for each type of phone I am writing for.

Will Mono do that? I don't mind paying $399, if it can do that, it is totally worth it.

idolmind86
Jun 13, 2003

It's better to burn out than to fade away.

It's even better to work out, numbnuts.
I'm a developer who has been at the same job for 9 years. This year I've been given a training budget to do whatever the hell I want with. The only problem is that I use pretty static technologies in my day to day work so I don't know what to do with it.

Does anyone know any good resources for finding training topics/classes? I know I would love to learn some new things but I don't even know where to start. All my google-fu has led me to some pretty sketchy looking courses or stuff that looks way to introductory.

Any ideas? I'd be happy to just find a blog or blogs that said hey, I took this course and I dug it. I must just suck at google.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

idolmind86 posted:

I'm a developer who has been at the same job for 9 years. This year I've been given a training budget to do whatever the hell I want with. The only problem is that I use pretty static technologies in my day to day work so I don't know what to do with it.

Does anyone know any good resources for finding training topics/classes? I know I would love to learn some new things but I don't even know where to start. All my google-fu has led me to some pretty sketchy looking courses or stuff that looks way to introductory.

Any ideas? I'd be happy to just find a blog or blogs that said hey, I took this course and I dug it. I must just suck at google.

Do you have a particular direction in mind? Most of the worthwhile courses are tied a certification, so for example if your job involves networking a lot of people go for the Cisco path (CCNA). If you're doing Microsoft programming there's the MCS* courses as well. Those are just two off the top of my head, but there are also database management courses as well. What would help is knowing more about the area you're working in.

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS

Carthag posted:

I dunno about Windows, but on Mac OS X it's in System Preferences under Keyboard - you can add shortcuts for any app/menu you feel like there. Not being a platform warrior, just putting that out there in case a current Mac user wants to know.

Also ResEdit was such a fun app for a budding nerd.

Yeah, ResEdit kicked rear end.

I need a fairly professional looking solution, so I've got the application I need to modify open in Ollydbg to try and send a command whenever I hit F9. It's been like, a year since I've done any serious disassembling, so we'll see what I can figure out.

idolmind86
Jun 13, 2003

It's better to burn out than to fade away.

It's even better to work out, numbnuts.

Scaramouche posted:

Do you have a particular direction in mind? Most of the worthwhile courses are tied a certification, so for example if your job involves networking a lot of people go for the Cisco path (CCNA). If you're doing Microsoft programming there's the MCS* courses as well. Those are just two off the top of my head, but there are also database management courses as well. What would help is knowing more about the area you're working in.

Well, currently my job doesn't really rely too much (or care about) certifications. And I don't see myself going anywhere in the immediate future that would. I've gotten Oracle certifcations (OCM) out the wazoo and honestly they don't help me in my professional life at all.

A lot of our products are UNIX using c/c++ (mostly c). Recently we do more in java. We also do a lot with Oracle as well.

My first thought was trying to find some super advanced java programming course that would blow my mind but I haven't really been able to find anything like that.

Honestly, I think what I enjoy the most would be taking a graduate class a semester, just for fun and strengthening my brain but my job doesn't want me to pursue an advanced degree as they fear it will interfere with my work.

I have one of those jobs where I'm expected to drop anything/everything if need be, although I am compensated thusly.

mister_gosh
May 24, 2002

I have no idea what thread to put this into, I couldn't find a *nix one.

Anyways, I remember back in the day when I could type this at the Linux prompt:

set path1 = `pwd`

and then be able to echo or cd to $path1 no matter where I was. This was useful for areas I was temporarily concerned with, but didn't warrant something like a symbolic link/setting something in my home profile.

Anyways, this no longer works. Am I not remembering this correctly? I'm in the korn shell, if that matters.

Neslepaks
Sep 3, 2003

Lose the "set" and the spaces and it should work.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

idolmind86 posted:

Well, currently my job doesn't really rely too much (or care about) certifications. And I don't see myself going anywhere in the immediate future that would. I've gotten Oracle certifcations (OCM) out the wazoo and honestly they don't help me in my professional life at all.

A lot of our products are UNIX using c/c++ (mostly c). Recently we do more in java. We also do a lot with Oracle as well.

My first thought was trying to find some super advanced java programming course that would blow my mind but I haven't really been able to find anything like that.

Honestly, I think what I enjoy the most would be taking a graduate class a semester, just for fun and strengthening my brain but my job doesn't want me to pursue an advanced degree as they fear it will interfere with my work.

I have one of those jobs where I'm expected to drop anything/everything if need be, although I am compensated thusly.

Unfortunately I don't think there's a lot that can be done generically then; it sounds like you're going to have to look at local colleges/professional groups and see what they have on offer. You might have some luck looking up if there's a local Unix User's group or something, maybe?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

mister_gosh posted:

I have no idea what thread to put this into, I couldn't find a *nix one.

Anyways, I remember back in the day when I could type this at the Linux prompt:

set path1 = `pwd`

and then be able to echo or cd to $path1 no matter where I was. This was useful for areas I was temporarily concerned with, but didn't warrant something like a symbolic link/setting something in my home profile.

Anyways, this no longer works. Am I not remembering this correctly? I'm in the korn shell, if that matters.

I don't use ksh but maybe it has pushd and popd?

Glans Dillzig
Nov 23, 2011

:justpost::justpost::justpost::justpost::justpost::justpost::justpost::justpost:

knickerbocker expert
So, two stupid things I'd like to learn how to do. Honestly, at this point, I'd like to know if they're even possible. I can (hopefully) figure out the actual mechanics. I've only ever had experience scripting with batch files, so for now, I'd like to just use those. If not, hey, always good to learn something new, right?

1) Is there a way to specify a file by the Date Modified column? I basically want to have a script that auto-deletes the oldest file in a certain folder when I run it.

2) How do you check to see if a program is already running? I'm trying to write a script that checks to see if a couple different programs are running, and if not, to start them.

Like I said, I've only ever used simple batch files. If it can't be done with those, oh well. Guess I'd better learn some languages, hahaha. Thanks in advance, goons.

mobby_6kl
Aug 9, 2009

by Fluffdaddy
I'm pretty sure that's possible even with just the batch files, you can get a list of processes with tasklist and compare it to your programs, same with the modification time and dir (keep track of the oldest file's name and delete it once you checked every file). As to how exactly this can be done, you probably know better than I do as the last time I did any batch programming was in the DOS/Win9x time.

Josh Lyman
May 24, 2009


My officemate asked if you can write a program to detect an infinite loop in code. I said that from what I remember from my ECE days, certain compilers will detect an infinite loop. He seem unconvinced.

gonadic io
Feb 16, 2011

>>=

Josh Lyman posted:

My officemate asked if you can write a program to detect an infinite loop in code. I said that from what I remember from my ECE days, certain compilers will detect an infinite loop. He seem unconvinced.

In general, this isn't possible (see the Halting Problem). Some languages can detect some kinds of infinite loops (GHC's <<loop>> for example).

edit: Agda can apparently do something like this, but then it's not Turing complete.

gonadic io fucked around with this message at 23:37 on Feb 1, 2012

No Safe Word
Feb 26, 2005

Josh Lyman posted:

My officemate asked if you can write a program to detect an infinite loop in code. I said that from what I remember from my ECE days, certain compilers will detect an infinite loop. He seem unconvinced.

You can detect some of them, but being able to detect any infinite loop would be solving the Halting Problem which is provably impossible

e:f;b

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Walter_Sobchak posted:

So, two stupid things I'd like to learn how to do. Honestly, at this point, I'd like to know if they're even possible. I can (hopefully) figure out the actual mechanics. I've only ever had experience scripting with batch files, so for now, I'd like to just use those. If not, hey, always good to learn something new, right?

1) Is there a way to specify a file by the Date Modified column? I basically want to have a script that auto-deletes the oldest file in a certain folder when I run it.

2) How do you check to see if a program is already running? I'm trying to write a script that checks to see if a couple different programs are running, and if not, to start them.

Like I said, I've only ever used simple batch files. If it can't be done with those, oh well. Guess I'd better learn some languages, hahaha. Thanks in advance, goons.

Are you doing Windows batch commands or unix style scripting?

If its Unix command line scripting you can just do something like

ls -rlta . | grep -i ^- | head -n 1 | cut -d ' ' -f 12 | xargs echo "this is the oldest file: "

haveblue
Aug 15, 2005



Toilet Rascal
Yeah, there are some simple conditions under which the compiler can be highly confident that an infinite loop will occur (say, an expression that reduces to while(a || !a)) and be justified in throwing a warning but in the general case there cannot be a perfect detector written.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Walter_Sobchak posted:

So, two stupid things I'd like to learn how to do. Honestly, at this point, I'd like to know if they're even possible. I can (hopefully) figure out the actual mechanics. I've only ever had experience scripting with batch files, so for now, I'd like to just use those. If not, hey, always good to learn something new, right?

1) Is there a way to specify a file by the Date Modified column? I basically want to have a script that auto-deletes the oldest file in a certain folder when I run it.

2) How do you check to see if a program is already running? I'm trying to write a script that checks to see if a couple different programs are running, and if not, to start them.

Like I said, I've only ever used simple batch files. If it can't be done with those, oh well. Guess I'd better learn some languages, hahaha. Thanks in advance, goons.

If you have it Powershell could do it. There's a dedicated thread in this forum too.

Puddy1
Aug 28, 2004
I have a problem with dynamic languages that really slows down my workflow. In a language like Python or Javascript where I have to interact with another library/API (i.e. like feedreader in Python or jQuery) sometimes I have trouble figuring out how to interact with the object returned from a method that I did not write. For the most part, reading documentation usually helps somewhat but sometimes it's not always clear to me how I can interact with objects from external libraries. What ways do you guys use to find out more about these objects?

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Puddy1 posted:

I have a problem with dynamic languages that really slows down my workflow. In a language like Python or Javascript where I have to interact with another library/API (i.e. like feedreader in Python or jQuery) sometimes I have trouble figuring out how to interact with the object returned from a method that I did not write. For the most part, reading documentation usually helps somewhat but sometimes it's not always clear to me how I can interact with objects from external libraries. What ways do you guys use to find out more about these objects?
Well in most dynamically typed languages you don't need to care about the return type, so just save the results to a variable and inspect the object in its interactive shell and scan the properties of the object. For python I think it is dir(obj), in jQuery I am usually using Chrome and I just use Chrome's developer tools to inspect the object.

redleader
Aug 18, 2005

Engage according to operational parameters
Anyone have any favorite hex editors? I want to take a look at some game data files as a little challenge for myself and want to know if anyone has a hex editor they really love. Windows freeware, preferably :)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I've had good results with HxD. That (along with brainpower and lots of wrong guesses) is how I reverse engineered the VFS file format used in Cargo! The Quest for Gravity

Suspicious Dish fucked around with this message at 09:18 on Feb 2, 2012

Adbot
ADBOT LOVES YOU

The Gripper
Sep 14, 2004
i am winner

redleader posted:

Anyone have any favorite hex editors? I want to take a look at some game data files as a little challenge for myself and want to know if anyone has a hex editor they really love. Windows freeware, preferably :)
For a free hex editor I've been using Hexer, written by a goon originally I think but I believe his code was bought by some other company and hasn't been maintained: http://www.zynamics.com/tools.html

For a commercial package, SweetScape 010 editor is hard to beat and particularly good for game data/save game things. Has a built-in c-like templating language that lets you define the format of your file and highlight/separate regions, structs and values.

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