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
Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

Symbolic Butt posted:

have some kind of order but you should never rely on them and treat them as unordered

For full-on :spergin:-ness, it's more accurate to say that you cannot rely on the order of set items or dict keys instead of should not:

Python code:
#!/usr/bin/env python3
s = {'here', 'are', 'some', 'strings', 'in', 'a', 'set'}
print(s)
code:
$ for i in $(seq 10); do ./order.py; done
{'a', 'are', 'in', 'set', 'some', 'here', 'strings'}
{'some', 'in', 'here', 'are', 'strings', 'a', 'set'}
{'a', 'set', 'in', 'strings', 'some', 'here', 'are'}
{'are', 'set', 'here', 'some', 'strings', 'in', 'a'}
{'strings', 'set', 'some', 'here', 'a', 'in', 'are'}
{'some', 'are', 'in', 'strings', 'a', 'here', 'set'}
{'strings', 'some', 'are', 'a', 'in', 'set', 'here'}
{'in', 'here', 'some', 'a', 'strings', 'set', 'are'}
{'some', 'strings', 'in', 'a', 'are', 'set', 'here'}
{'are', 'here', 'strings', 'in', 'set', 'a', 'some'}

Adbot
ADBOT LOVES YOU

TwoDogs1Cup
May 28, 2008

DOUGIE DOUGIE DOUGIE! MY LOVE, HE MAKES MY EMPTY HEART FULL! DOUGIE! THE BEST FOREVER THE BEST DOUGIEEE! <3 <3 - TwoDougies1Cup

<div id="gifdiv">
<img src="staticgif.jpg" />
</div>
<script type="text/javascript">
$("#gifdiv").click(function () {
if ($(this).find("img").attr("data-state") == "static") {
$(this).find("img").attr("src", "animatedgif.gif");
} else {
$(this).find("img").attr("src", "staticgif.jpg");
}
});
</script>

If that's the code, do I only need to put the file name in animatedgif and staticgif?

I'm completely clueless at this sorry

TwoDogs1Cup fucked around with this message at 11:43 on Apr 17, 2014

Boz0r
Sep 7, 2006
The Rocketship in action.

ultrafilter posted:

Have you had a probability course already?

Yes, but it's a couple of years ago and I can't remember poo poo. Also, it wasn't specific for CS, but more general stuff. Biology, actually, now that I think about it.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING

TwoDogs1Cup posted:

<div id="gifdiv">
<img src="staticgif.jpg" />
</div>
<script type="text/javascript">
$("#gifdiv").click(function () {
if ($(this).find("img").attr("data-state") == "static") {
$(this).find("img").attr("src", "animatedgif.gif");
} else {
$(this).find("img").attr("src", "staticgif.jpg");
}
});
</script>

If that's the code, do I only need to put the file name in animatedgif and staticgif?

I'm completely clueless at this sorry

Do you have jQuery added to your website? That code requires the jQuery library -- http://www.jquery.com. If you're not sure or don't know what that is, check it out. For testing purposes you can add jQuery's capabilities to your internet-facing website by adding the following code to your page:

code:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
What that does is tell the user's browser to go to that website ^ and load the contents of that script file. That script file contains all the information of the jQuery library, so all subsequent code that refers to it (i.e. functions/methods/features defined by jQuery) has access to what those references actually mean. If you're still not following, think in Star wars or whatever dumb movies where some evil guy goes "Execute plan 12!" and they kill all the Jedis. jQuery is the manual they open up when they're scratching their heads going "what was plan 12 again?".

To answer your actual question: Yep, but don't forget the preloading. Otherwise there'll be a (slight to medium-length) delay as the browser downloads the larger animated gif.

The <div id='gifdiv'> creates a sort of 'box' and gives it the unique ID 'gifdiv'. The stuff inside it (i.e. inside the <div>...</div>) is its content. To begin with, we load the image into it using <img>. This is the static image, which is usually just a copy of the first frame of the animation.

The following part, in the <script>, is javascript - a bit of script that tells the browser to do something fancy, and also how to handle certain events and actions.

It creates an 'event handler' tied to the element with ID 'gifdiv' that awaits a 'click' event. So when somebody clicks on that element (which contains just the image, so if you click on the image that counts too) it triggers the code inside that definition.

And the code checks to see if the image has an attribute called 'data-state' whose value is 'static' (which to be honest I've never used before so I'm not sure at what level that attribute is being set). If true, it changes the image itself (or rather the 'src' of the image -- where the image element loads its content from from) to the animated one. Otherwise (i.e. under the 'else' part of the conditional check) it sets it back to the static image.

But what you should also have is that later bit of code they mentioned:

code:
  (new Image()).src = "animatedgif.gif"; // this would preload the GIF, so future loads will be instantaneous
Because otherwise the image will lag when you click it for the first time and it loads the new source -- because the animated image hasn't been loaded by the browser before, it still needs to be added to the cache.

e: I'm sorry that was meant to be helpful but I haven't had any coffee today so I'm a bit of a mess. Yes you're correct about changing the file names. Just make sure the images are in the same directory as the html file that calls the javascript code. And add that bit of preloading code later inside a <script>..</script> tag.

Sulla Faex fucked around with this message at 13:43 on Apr 17, 2014

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
You'll also have to do that specifically for each image, which means you'll be copy-pasting all that code each time you add a new image. Which is messy as hell.

What you'd be better off doing is something like this. It's not the best way to do it but at least it'll scale a little better. You just need to add everything under <!-- JS --> once, assuming you don't already have jQuery included.

code:
<!-- Your images go here -->
<!-- All images must have two forms: {name}.gif and {name}_animated.gif -->
<img src='butts1.gif' class='imgstatic'>
<img src='butts2.gif' class='imgstatic'>

<!-- JS -->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$(".imgstatic").click(function () {
	var str = $(this).attr('src');
	var end = str.indexOf(".gif");
	$(this).attr("src", str.substring(0,end) + "_animated.gif");
	$(this).addClass('imganimated');
	$(this).removeClass('imgstatic');
});

$(".imganimated").click(function () {
	var str = $(this).attr('src');
	var end = str.indexOf("_animated");
	$(this).attr("src", str.substring(0,end) + ".gif");
	$(this).addClass('imgstatic');
	$(this).removeClass('imganimated');
});

	<!-- Pre-load each image -->
	$.each('.imgstatic', function() {
		var str = $(this).attr('src');
		var end = str.indexOf(".gif");
		(new Image()).src = str.substring(0,end) + "_animated.gif";
		});

});
</script>

TwoDogs1Cup
May 28, 2008

DOUGIE DOUGIE DOUGIE! MY LOVE, HE MAKES MY EMPTY HEART FULL! DOUGIE! THE BEST FOREVER THE BEST DOUGIEEE! <3 <3 - TwoDougies1Cup
Thank you so much for that

Scaevolus
Apr 16, 2007

Lysidas posted:

For full-on :spergin:-ness, it's more accurate to say that you cannot rely on the order of set items or dict keys instead of should not:
This is only true when hash randomization is enabled. That's the default since Python 3.3. :v:

ErrantSystems
Jul 5, 2009
I'm not sure if this is the best place to ask this (VCS and Linux threads didn't seem appropriate), but I'm a grad student in computational physics and my personal coding projects are getting to a point where I really need some sort of management software for syncing/building/running on our computational clusters (of which there are three, and all need different build/execution scripts). I've just been using rsync over ssh, makefiles, and a lot of slightly different bash scripts, but its quickly become a huge mess.

Basically I'm looking for:
- Something to help me manage keeping my code on our clusters updated with all the different build configurations
- Some sort of project automation software to help with execution scripts/data from different projects
- Project management software in general? Or maybe some good resources/books about managing a lot of small-ish (15k personal loc + lots of libraries/utilities) projects.

For reference, my development machine and our clusters all run Linux and, if it matters, all of the code is Fortran (77 uhggg) and C/C++. Obviously I could just force myself to be organized and just keep using a bunch of scripts and makefiles, but I'm a big baby and would like some nice applications to hold my hand. Any decent books or whatever about this sort of thing would be nice too, since I'm sure what I have going right now is 100% not best practices.

nielsm
Jun 1, 2009



Someone else can probably give more concrete recommendations, but what you seem to be looking for in general is a configuration management system.

You should be able to do something basic if you keep all the logic for building and installing/running the software in a single version control repository. I.e. keep the code for every configuration in a single tree, so they are versioned together and can share code directly. Ideally, also make that the same tree where you keep the actual software source.
Then have some scripting logic that lets a unified build system detect what sort of system it's being set up on and automatically pick the correct configuration. (You can use some thin, non-versioned config files or even just commandline arguments or environment variables to aid the system detection.)

Later on you can then look into systems to fully automate the deployment with perhaps just a single command from a remote machine.

ErrantSystems
Jul 5, 2009
Thanks for the advice, its pretty hard to search for stuff when you aren't sure what to call it, after all, Googling "code project management software" doesn't exactly give anything useful. I think once I find something to configure everything, the rest wont be too bad. I just need a decent automation tool for actually running data through the built programs (which is a question for a different thread).

bjobjoli
Feb 21, 2006
Wrasslin'
I've been messing around with a pH meter's serial output in MATLAB in order to begin writing a simple data logging script. Everytime I press the print button on the meter, it sends the current pH reading to its buffer which I then read and graph with MATLAB. Problem is, the 8-bit binary data (which is supposedly ASCII encoded) doesn't make any sense.

Here's a an output sample:

code:
86 79 73 116 170 250 251 251 251 251 203 191 191 191 191 191 151
 163 157 157 143 191 191 191 191 191 191 31 111 191 191 191 191 
191 123 191 191 177 191 155 149 163 159 191 121 191 191 191 151 
161 155 159 161 157 151 191 191 191 153 139 157 159 191 95 101 2
29 235 0
which, according to the pH meter, should correspond to

code:
#3 4.118 pH B 25.0 C 4/20/14 3:10PM
By looking at the output closely, I've been able to make a key.

191 = whitespace, denoted as []
163 = .
161 = /
159 = 0
157 = 1
155 = 2
153 = 3
151 = 4
149 = 5
147 = 6
145 = 7
143 = 8
123 = B
121 = C
111 = H
101 = M
95 = P
31 = p

Which, when applied to the above output, looks like:

86 79 73 116 170 250 251 251 251 251 203 [] [] [] [] [] 4
. 1 1 8
[] [] [] [] [] [] p H [] [] [] []
[] B [] [] 177 [] 2 5 . 0 [] C [] [] [] 4
/ 2 0 / 1 4
[] [] [] 3 : 1 0 [] P M 2 29 235 0

Good enough for my purposes since I can just graph the pH. However, I can't figure out what type of character encoding is being used here. Obviously I'm getting sensible consistent data. Could it be a framing error on my part or a faulty RS232-to-USB cable or something?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

bjobjoli posted:

Could it be a framing error on my part or a faulty RS232-to-USB cable or something?

If you complement those numbers, and shift them right by 1 bit, then you get something slightly more sensible:
code:
0000000: 5458 5b45 2a02 0202 021a 2020 2020 2034  TX[E*.....     4
0000010: 7731 3138 2020 2020 2020 7048 2020 2020  w118      pH
0000020: 2042 2020 2720 3235 2e30 2043 2020 2034   B  ' 25.0 C   4
0000030: 2f32 302f 3134 2020 2033 3a31 3020 504d  /20/14   3:10 PM
0000040: 7e71 0a7f                                ~q..
This, to me, strongly indicates that something is going wrong in your serial transfer somewhere.

ShoulderDaemon fucked around with this message at 02:02 on Apr 21, 2014

Karl Sharks
Feb 20, 2008

The Immortal Science of Sharksism-Fininism

This may be something incredibly simple, but I can't figure out why these numbers are rounding to whole integers:

code:
Private Sub Run_Button_Click()
    Dim a, b, s, r_sq, r, xNew, yNew As Long
    Dim i, x, y, xSize, ySize As Long
    
    x = Application.WorksheetFunction.Count(Range("A:A"))
    y = Application.WorksheetFunction.Count(Range("B:B"))
    xSize = x - 1
    ySize = y - 1
    
    ReDim x_values(xSize), y_values(ySize) As Long
    
   
    
    For i = 0 To xSize
        x_values(i) = Cells(i + 6, 1).Value
        y_values(i) = Cells(i + 6, 2).Value
    Next i
        
    If ExpOption.Value = True Then
        For i = 0 To xSize
            yNew = Log(y_values(i)) / Log(Exp(1))
            y_values(i) = yNew
            Debug.Print ("new y" & i)
            Debug.Print (y_values(i))
        Next i
        
        a = Exp(Application.WorksheetFunction.intercept(y_values, x_values))
        A_Value.Value = a
        b = Application.WorksheetFunction.slope(y_values, x_values)
        B_Value.Value = b
    End If
End Sub
All of my new y values are rounded to the whole digit, making my regression inaccurate. We've barely done anything in VBA in this class, so I don't know if it's doing integer division somewhere implicitly, even if I change all of the variable types to Long out of precaution.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
You're declaring yNew as a long here
code:
    Dim a, b, s, r_sq, r, xNew, yNew As Long
A long is an integer type. My guess is the expression on the RHS of
code:
yNew = Log(y_values(i)) / Log(Exp(1))
is returning a float (or double, I'm not familiar with VBA), but then it's being cast to a long so it can fit in the LHS. I guess VBA does lossy casts silently?

ToxicFrog
Apr 26, 2008


Karl Sharks posted:

All of my new y values are rounded to the whole digit, making my regression inaccurate. We've barely done anything in VBA in this class, so I don't know if it's doing integer division somewhere implicitly, even if I change all of the variable types to Long out of precaution.

Longs are integers. You are explicitly using integers for everything in that code.

Karl Sharks
Feb 20, 2008

The Immortal Science of Sharksism-Fininism

ToxicFrog posted:

Longs are integers. You are explicitly using integers for everything in that code.

Oh, for whatever reason when I used longs to get around a memory overflow problem I thought they were just better than doubles. I tried using all doubles as well, but the answer is still off a bit, so it threw me off from that solution.

Thanks.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Karl Sharks posted:

Oh, for whatever reason when I used longs to get around a memory overflow problem I thought they were just better than doubles. I tried using all doubles as well, but the answer is still off a bit, so it threw me off from that solution.

Thanks.

Floating-point types will pretty much always be off a bit, it just depends on how much accuracy you need:
https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems

You might want to look into some kind of Decimal type and see if that works for you, but this is basically One Of Those Things

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Karl Sharks posted:

I tried using all doubles as well, but the answer is still off a bit, so it threw me off from that solution.

By any chance would y_values(i) be close to zero for some i?

Pollyanna
Mar 5, 2005

Milk's on them.


Okay, I need a little advice on how to model something.

I'm trying to make a skill planner for a video game, and I'm not sure how I should define the skills. The deal is that each individual skill, e.g. 'swords' or 'poison', are the subset of a larger set of more general skills. These general skills are themselves a subset of a particular field, e.g. 'physical' or 'social'. Each set of general skills and each field have an associated skill learning modifier, that can be positive or negative. A general skill's overall modifier is the sum of the points in each subskill, plus a mood-based modifier. The modifier for a particular field, on the other hand, is ONLY the sum of the subskills' points.

It might make more sense if I show you how I have a field defined right now:

Python code:
social = {
	'modifier': 0.00,
	'skills': {
		'royal demeanor': {
			'modifier': 0.00,
			'subskills': {
				'composure': 0.00,
				'elegance': 0.00,
				'presence': 0.00,
			},
		},
		'conversation': {
			'modifier': 0.00,
			'subskills': {
				'public speaking': 0.00,
				'court manners': 0.00,
				'flattery': 0.00,
			},
		},
		'expression': {
			'modifier': 0.00,
			'subskills': {
				'decoration': 0.00,
				'instrument': 0.00,
				'voice': 0.00,
			},
		},
	},
}
(the more astute of you can prolly guess what game this is)

I'm wondering if this isn't the best way to store this information. I was thinking I could set the Social field's modifier as such:

Python code:
social['modifier'] = math.fsum([social['skills']['royal demeanor']['subskills'][x] for x in social['skills']['royal demeanor']['subskills']])
...but that seems too complicated. How should I store this information? As a dictionary? As objects? Or as just plain variables?

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
Beware hierarchical data storage. They make one kind of query very easy, but every other kind of query a nightmare. Either use a pair of maps - one from subskill names to values and one from parent skills to subskills - or use an object for each skill with links to its parent/children, or better yet learn you some SQL.

Also don't store the modifier for a parent skill if it's wholly defined by the sum of its subskills' modifiers. That's data replication and it's a bad idea because when you need to change something, you need to change it in two places. Instead, just store the mood and the subskill modifiers, and compute the parent skill modifiers when you need them.

coffeetable fucked around with this message at 17:38 on Apr 22, 2014

Ahz
Jun 17, 2001
PUT MY CART BACK? I'M BETTER THAN THAT AND YOU! WHERE IS MY BUTLER?!
Learn a little basic data modelling. It will save you much grief as you continue to work with data structures.

I would have a read on something like this:
http://www.agiledata.org/essays/dataModeling101.html

before trying to learn SQL (cart before the horse).

nielsm
Jun 1, 2009



I would suggest storing all the skills in a single, flat map by their simple name. Then have some other data that defines the skills' relationships (affinities), so you for each skill can look up its group and category. You may even want to make multiple look-up maps to go from either end.

An approach you can take in defining the data storage could be to initially declare the skills in a way similar to the hierarchic form you use right now, but include only the skill names there. Use those data to then generate the other look-up maps.
Defining some data in a simple but hard-to-work-with form but then transforming it into an easier-to-work-with form at runtime is a technique I use often myself.

DholmbladRU
May 4, 2006
I am developing a web application which will be accessed from an html container within a native IOS app. Currently I am testing functionality in safari which hopefully will be similar to the html container. One thing I noticed is that the click action on the checkbox selectors and radio buttons is painfully slow. My menu items were also experiencing this behavior when I was waiting for the 'click' action. Instead of listning for this I switched to the 'touchstart'

code:
$("#rab-icon").on('touchstart', function () {
Is it possible to override the html functionality and select these radiobuttons/checkboxes on 'touchstart' ?

hedgecore
May 2, 2004

DholmbladRU posted:

I am developing a web application which will be accessed from an html container within a native IOS app. Currently I am testing functionality in safari which hopefully will be similar to the html container. One thing I noticed is that the click action on the checkbox selectors and radio buttons is painfully slow. My menu items were also experiencing this behavior when I was waiting for the 'click' action. Instead of listning for this I switched to the 'touchstart'

code:
$("#rab-icon").on('touchstart', function () {
Is it possible to override the html functionality and select these radiobuttons/checkboxes on 'touchstart' ?

You may wish to try something like this library:
https://github.com/ftlabs/fastclick

jimmsta
Oct 24, 2004

Shedding bell-end tears in the pocket of her resistance.
Grimey Drawer
I'm trying to figure out a way to create a list of files that contains numbers in their name that range from 0-63 like so:
code:
sample_[0-63]_[0-63]
where the values in the brackets ranges from 0-63, exponentially through every variant possible. I have no idea how to do this in any programming language.

example output:
code:
sample_0_0
sample_0_1
...
sample_55_2
...
sample_60_27
...
sample_63_63
If anyone could help point me in the right direction, I'd be grateful. I've tried doing some sort of array, but I'm not sure that that's the right vector to this problem or not.

Kumquat
Oct 8, 2010

jimmsta posted:

I'm trying to figure out a way to create a list of files that contains numbers in their name that range from 0-63 like so:
code:
sample_[0-63]_[0-63]
where the values in the brackets ranges from 0-63, exponentially through every variant possible. I have no idea how to do this in any programming language.

example output:
code:
sample_0_0
sample_0_1
...
sample_55_2
...
sample_60_27
...
sample_63_63
If anyone could help point me in the right direction, I'd be grateful. I've tried doing some sort of array, but I'm not sure that that's the right vector to this problem or not.

You could use two for loops. In Ruby, this would create a file called out.txt that contained your list:
code:
out_file = File.new("out.txt", "w")

64.times do |first|
    64.times do |second|
        out_file.puts "sample_#{first}_#{second}"
    end
end

out_file.close
Do you have a preference for which language you'd like to use for this?

edit: fixed an off by one error.

Kumquat fucked around with this message at 07:28 on Apr 27, 2014

jimmsta
Oct 24, 2004

Shedding bell-end tears in the pocket of her resistance.
Grimey Drawer
python would be most useful, mostly so I can learn how to do this sort of stuff in python... I'll take the ruby script though, I've been meaning to spend some time learning ruby :v:

edit: ooo, that's awesome and simple! I think I'll spend some more time on ruby. Gave it a try a long time ago, but never really progressed past chapter 1... Hell, I justified a purchase of a Mac to develop Ruby apps, and never ended up using it for that purpose.

Thanks again!

edit2: I wanted to add a backslash in, which lead me to looking for appropriate escape characters. Thanks to you, I now know how to do this sort of operation for the future!

jimmsta fucked around with this message at 07:54 on Apr 27, 2014

SurgicalOntologist
Jun 17, 2004

Python has a product function in itertools (what you're asking about is a Cartesian product):

Python code:
from itertools import product

with open('out.xt', 'w') as file:
    for a, b in itertools.product(range(64), repeat=2):
        file.write('sample_{}_{}'.format(a, b))

Kumquat
Oct 8, 2010

jimmsta posted:

python would be most useful, mostly so I can learn how to do this sort of stuff in python... I'll take the ruby script though, I've been meaning to spend some time learning ruby :v:

This will do it in python. There is certainly a prettier way to do it, but it's been a minute since I've used python and I'm tired.

code:
outfile = open("out.txt", "w")

for first in range(0, 64):
    for second in range(0, 64):
        outfile.write("sample_" + str(first) + "_" + str(second) + "\n")

outfile.close()

e:fb, with a more elegant solution ^^^^^^

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Here's how I'd do it in gforth:

code:
: sample    ." sample_" 1 .r ." _" 1 .r cr ;
: samples   4096 0 do i 64 /mod sample loop ;

' samples s" out.txt" w/o create-file drop outfile-execute
Of course you could leave off that last line if you simply ran the program and catted the output to a file-
code:
gforth samples.fs -e "samples bye" > "out.txt"

Internet Janitor fucked around with this message at 17:51 on Apr 27, 2014

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

jimmsta posted:

python would be most useful, mostly so I can learn how to do this sort of stuff in python... I'll take the ruby script though, I've been meaning to spend some time learning ruby :v:

edit: ooo, that's awesome and simple! I think I'll spend some more time on ruby. Gave it a try a long time ago, but never really progressed past chapter 1... Hell, I justified a purchase of a Mac to develop Ruby apps, and never ended up using it for that purpose.

Honestly this is something you can do easily in every* language, once you understand loops and that language's way of handling output. You can also use fancy features like in SurgicalOntologist's example, but there's always the general workmanlike "loop inside a loop" way of working through all the combinations. Try doing it in Python, if you understand how the Ruby one is working you should be able to handle it

ToxicFrog
Apr 26, 2008


In bash this is dead easy :v:

code:
$ echo sample_{0..63}_{0..63}
sample_0_0 sample_0_1 sample_0_2 sample_0_3 sample_0_4 sample_0_5
...
sample_63_59 sample_63_60 sample_63_61 sample_63_62 sample_63_63

Vanadium
Jan 8, 2005

I don't understand oauth, what's stopping just about anyone from extracting the client id and then using permissions users have granted to my app in their own app?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Getting an access token requires both the client ID and client secret, and the client secret is supposed to sit on a server under your control, not in the app.

Vanadium
Jan 8, 2005

I was looking at https://developers.google.com/drive/web/auth/web-client and it all sounded like it'd happen in javascript served to users and not my hypothetical server at all.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Doing everything on the client is unfortunately pretty common. I've had trouble getting people to care about the fact that it's completely insecure.

Vanadium
Jan 8, 2005

I did click the "Web (Server-side)" link first but then went to the client-side page because the server-side one said "If your application does not require offline access to user data, consider using the client-side authorization flow, which can be implemented using only JavaScript and HTML." :negative:

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The thing that stops people commandeering your client id is that they can't run JS code on your domain. If you try running your application on a different domain, you'll see the client library error out when it tries to authenticate because it doesn't match what you've set in the console.

Vanadium
Jan 8, 2005

That wouldn't stop someone with a spoofed client library that doesn't do that check, would it?

Adbot
ADBOT LOVES YOU

TheEffect
Aug 12, 2013
Can anyone tell me what causes this mess of javascript to open a new window in IE instead of the User's default browser?

Sorry it's unformatted. It was all on one single line when I copied it.

http://pastebin.com/jRN178qY


This is some script I inherited which is evidently something called "Cool Tree JS" that a predecessor of mine put into place nearly a decade ago. I can see it calling "navigator.appVersion" but does that just mean it's going to use whatever browser the link is clicked from? The page with the links gets rendered in a separate, home-brewed, program that we use here. The links themselves are part of another document that this one references.

Only the bit at the end seems to reference anything browser specific-
code:
{var _24=parseInt(navigator.appVersion);this.ver=navigator.appVersion;
this.agent=navigator.userAgent;this.dom=document.getElementById?1:0;
this.opera=window.opera?1:0;this.ie5=this.ver.match(/MSIE 
5/)&&this.dom&&!this.opera;this.ie6=this.ver.match(/MSIE 
6/)&&this.dom&&!this.opera;this.ie4=document.all&&!this.dom&&!this.opera;
this.ie=this.ie4||this.ie5||this.ie6;this.ie3=this.ver.match(/MSIE/)&&_24<4;
this.hotjava=this.agent.match(/hotjava
/i);this.ns4=document.layers&&!this.dom&&!this.hotjava;
this._E=this.hotjava||this.ie3;this.opera7=this.agent.match(/opera.7
/i);this.gecko=this.agent.match(/gecko/i);this._L=this.opera&&!this.opera7};
function _1l(_1G){for(var i in _1G)(new Image()).src=_1G[i]};
window._1H=window.onload;window.onload=function(){var bw=new 
_1j();if(typeof(window._1H)=='function')window._1H()}
I'm sure I'm gonna need to rebuild this from scratch, but for now I just want it to open in the user's default browser...

edit-

I think our "home-brewed" application itself is choosing what browser to render this in, and it's likely choosing IE since it knows IE will be installed on any of the workstations it's run from.

TheEffect fucked around with this message at 20:01 on Apr 29, 2014

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