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
Impotence
Nov 8, 2010
Lipstick Apathy

Newf posted:

When people say 'scripting', does this universally refer to code that is run client side? Web pages can have js which is run client side (eg, <script type="text/javascript"> ... </>), and that js may be internal to the page or from a linked file (which the browser DLs and executes). Is there a sharp divide between what are and are not scripting languages? There must be a per-browser list of languages which are client side 'runnable' (eg, I'm sure there is no way for me to have a client-side browser run a matlab.m script directly, but where do I get comprehensive info about this?). Do servers run code that's written in scripting languages? Or do they typically do their thing in languages which require, for example, more specified software environments (eg JVM)?

Javascript is probably not the best example because it's "runnable" server side, runs code written server side and spits out HTML or something else (any protocol really)?

Adbot
ADBOT LOVES YOU

Catalyst-proof
May 11, 2011

better waste some time with you
Does anybody have any experience with Business Object Notation? I read this article and it seems to praise it highly, and I must admit the simplicity and rigor of its basics expounded here make it seem pretty compelling. It seems easy enough to be able to mock out in a Google Doc but if there were some dedicated online tools that someone knew of that would be even cooler.

tef
May 30, 2004

-> some l-system crap ->

Rocko Bonaparte posted:

Wow somebody did respond after all. For the curious, I was going to post something I actually found through Reddit:

http://infoscience.epfl.ch/record/148043/files/DeprecatingObserversTR2010.pdf

The important thing for me is that I see now that the magic word is "reactive" versus observer. Honestly I think I've been trying to do something similar by just bumbling around. So daddy's got some reading to do. Superficially, that framework looks pretty hardcore. I think I'll have to kick its tires.

See also FrTime for scheme and Flapjax for Javascript

tef
May 30, 2004

-> some l-system crap ->

Fren posted:

Does anybody have any experience with Business Object Notation? I read this article and it seems to praise it highly, and I must admit the simplicity and rigor of its basics expounded here make it seem pretty compelling. It seems easy enough to be able to mock out in a Google Doc but if there were some dedicated online tools that someone knew of that would be even cooler.

It looks like visual programming, except without a compiler.

The Gripper
Sep 14, 2004
i am winner

Fren posted:

Does anybody have any experience with Business Object Notation? I read this article and it seems to praise it highly, and I must admit the simplicity and rigor of its basics expounded here make it seem pretty compelling. It seems easy enough to be able to mock out in a Google Doc but if there were some dedicated online tools that someone knew of that would be even cooler.
I'm pretty confused, that first link is a satirical "I don't understand the point of UML!" article/response!

(I've never used BON or know of anyone that has so that's all I can say!)

Blackclaw
Jan 4, 2008

DUKE NUKEM FOREVER HAS A BETTER CHANCE OF RELEASING IN AUSTRALIA THAN ROCK BAND EVER WILL
Carrying this over here by request of a mod. If you can help me out that'd be great, guys! :)

Blackclaw posted:

Hi guys!

I'm rather new to Android development and I'm using an evaluation version of Mono for Android.

What I'm trying to do is get the Android client to interact with a SCADA system's API (which apparently needs .NET rather than Java), and after coming out fresh from the first handful of tutorials I'm not too confident I know exactly how to tackle this. Mono makes mention of REST/WCF/SOAP services (of which I have no clue). It's got nothing to do with HTTP to my knowledge, it's just a server on an IP address that holds some ODBC databases.

I understand SCADA is pretty niche stuff (for programming/development experts at least) so please let me know if I'm missing any crucial information. Is there anything that you guys can suggest for me to start looking into?

Thermopyle
Jul 1, 2003

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

Blackclaw posted:

Carrying this over here by request of a mod. If you can help me out that'd be great, guys! :)

Hah, I didn't realize I was a mod! I'm not very observant sometimes...

Blackclaw
Jan 4, 2008

DUKE NUKEM FOREVER HAS A BETTER CHANCE OF RELEASING IN AUSTRALIA THAN ROCK BAND EVER WILL

Thermopyle posted:

Hah, I didn't realize I was a mod! I'm not very observant sometimes...

Upon closer inspection, I realise now that you're not a mod of this forum. So I'm not very observant sometimes either. :v: You're right in that this is probably a better place to find help, though...

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Is there any standard or commonly used format for defining a formal grammar?

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


peepsalot posted:

Is there any standard or commonly used format for defining a formal grammar?

Backus-Naur.

qntm
Jun 17, 2009

peepsalot posted:

Is there any standard or commonly used format for defining a formal grammar?

http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form - weak sauce, very little expressive power
http://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_Form - stronger
http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form - very strong, slightly odd syntax. Includes some odd features like "special sequences" and "exceptions", which make it possible to express non-context-free grammars
http://en.wikipedia.org/wiki/Wirth_syntax_notation - gross
http://en.wikipedia.org/wiki/Definite_clause_grammar
http://en.wikipedia.org/wiki/Syntax_diagram - better known as a "railroad diagram". I particularly like how Wikipedia's example diagrams use hard right angles which make it unclear which directions you're allowed to go in, unlike e.g. http://json.org

None of these formats are perfect. Many of the examples are incomplete. One day I may make a notation which actually looks like an extension of standard regex syntax, e.g. using {2,3}, ? and + for multipliers, [^abc] for character classes.

ToxicFrog
Apr 26, 2008


qntm posted:

None of these formats are perfect. Many of the examples are incomplete. One day I may make a notation which actually looks like an extension of standard regex syntax, e.g. using {2,3}, ? and + for multipliers, [^abc] for character classes.

Kind of like Parsing Expression Grammars?

Suspicious Dish
Sep 24, 2011

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

ToxicFrog posted:

Kind of like Parsing Expression Grammars?

PEGs are a parsing technique, not a syntax. You can define a PEG in EBNF or Wirth if you wanted to.

Red_Mage
Jul 23, 2007
I SHOULD BE FUCKING PERMABANNED BUT IN THE MEANTIME ASK ME ABOUT MY FAILED KICKSTARTER AND RUNNING OFF WITH THE MONEY
I guess this is as good a place as any to put this. I don't actually know much about visual basic, and I needed a way to split a large excel file with Committee Assignments for people up into a different sheet for each committee.

With some google-ing and guess and checking on the code I came up with this:
http://pastebin.com/HTbdweXW

The only problem is that every time I want to use it, I need to make a copy of the sheet I want to run it on with just values, since it doesn't seem to like the references and equations that make up most of the sheet. Is there a way to make this macro work with just the values?

Also is there a way to do Office Macros in C#? because that would be swell.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
using Microsoft.Office.Interop.Excel;

Red_Mage
Jul 23, 2007
I SHOULD BE FUCKING PERMABANNED BUT IN THE MEANTIME ASK ME ABOUT MY FAILED KICKSTARTER AND RUNNING OFF WITH THE MONEY

pokeyman posted:

using Microsoft.Office.Interop.Excel;

That's helpful, but AFAICT it doesn't let me make macros that work from the xls file itself, that just lets me work with excel files in C#.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Oh, I thought you wanted to use something instead of a macro. Sorry.

Red_Mage
Jul 23, 2007
I SHOULD BE FUCKING PERMABANNED BUT IN THE MEANTIME ASK ME ABOUT MY FAILED KICKSTARTER AND RUNNING OFF WITH THE MONEY

pokeyman posted:

Oh, I thought you wanted to use something instead of a macro. Sorry.

Sadly I kind of need a macro for this one. Thanks for mentioning that using though. I had also been looking for a way to work with excel files in C# for an unrelated project.

ToxicFrog
Apr 26, 2008


Suspicious Dish posted:

PEGs are a parsing technique, not a syntax. You can define a PEG in EBNF or Wirth if you wanted to.

PEGs are not a parsing technique any more than context free grammars are; they are a type of formal grammar and the paper describing them also describes a syntax for expressing them (using PEG syntax itself for the description, even).

You may be thinking of packrat parsers, which are commonly used to parse languages described by PEGs.

gwar3k1
Jan 10, 2005

Someday soon
I feel defeated for having to ask this. I have a recursive timer function in javacript which works just fine when called once; I want to have a loop which will include a call to the timer function and shouldn't continue until that has completed - javascript doesn't give a gently caress that I want that to happen.

This works when you call it out of a loop:
code:
function timedCount(current,max){
  updateClock(circleFgColor[circleColor],current,max);
  current=current+1;
  if(current>max){
    clearTimeout(t);		  
  } else {
    t=setTimeout("timedCount("+current+","+max+")",1000);
  }
}
I've transposed the function so that it can sit in my for loop and supposedly do its stuff in the same way as before, but the 1000ms pause isn't observed.

code:
function runSequence(){
  var sequence = [10,15,10,15];
  var seqLen = sequence.length -1;
  phase = 0;
  for(var i=0;i<=seqLen;i++){
    updatePhase();
    displayClock(circleBgColor[circleColor]);
    var current = 0;
    do{
      updateClock(circleFgColor[circleColor],current,sequence[i]);
      current=current+1;
      //alert("c: "+current+" : s: " +sequence[i]);
      t = setTimeout(function() { },1000);
    } while (!(current>sequence[i]));
    clearTimeout(t);
  }
}
I've tried changing the position of updateClock and c=c+1 to be inside the setTimeout function. All that happened was the script causes the "too long to execute" message in browsers.

Please can someone point out my obvious mistake?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Your code is architected wrong. setTimeout won't work in a loop like that, it's not how it works. setTimeout(F, T) calls F after T milliseconds have elapsed. It will not pause execution of your program.

gwar3k1
Jan 10, 2005

Someday soon

Red_Mage posted:

I guess this is as good a place as any to put this. I don't actually know much about visual basic, and I needed a way to split a large excel file with Committee Assignments for people up into a different sheet for each committee.

With some google-ing and guess and checking on the code I came up with this:
http://pastebin.com/HTbdweXW

The only problem is that every time I want to use it, I need to make a copy of the sheet I want to run it on with just values, since it doesn't seem to like the references and equations that make up most of the sheet. Is there a way to make this macro work with just the values?

Also is there a way to do Office Macros in C#? because that would be swell.

Try instr(cell.Value,findWhat) or Value2, rather than text. The instr is possibly comparing findWhat to the cell's containing formula rather than its value.

You can minimize your code by putting your findWhat values into an array and for looping the size of that. Take note of the trim function when you copy to a named sheet.

code:
Dim findValue = array("Committee I ","Committee II ",...)

For f = 0 to ...
  findWhat = findValues[f]
  lastLine = ActiveSheet.UsedRange.Rows.Count
 
  j = 1
  For i = 1 To lastLine
      For Each cell In Range("F1:Q1").Offset(i - 1, 0)
          If InStr(cell.Value, findWhat) <> 0 Then
              toCopy = True
          End If
      Next
      If toCopy = True Then
          Rows(i).Copy Destination:=Sheets(trim(findWhat)).Rows(j)
          j = j + 1
      End If
      toCopy = False
  Next
Next
I found this VB.net post on Microsoft to make use of and create macros in Excel.

gwar3k1
Jan 10, 2005

Someday soon

Suspicious Dish posted:

Your code is architected wrong. setTimeout won't work in a loop like that, it's not how it works. setTimeout(F, T) calls F after T milliseconds have elapsed. It will not pause execution of your program.

Thanks, I added a wait function (from a google hit) and changed my do a bit, but the performance is poo poo.

code:
  function runSequence(){
   ...
      do {
        updateClock(circleFgColor[circleColor],current,sequence[i]);		  
        current = current+1;
        wait(1000);
        //alert("a");
      } while (current<=sequence[i]);
    }
  }
	  
  function wait(msecs){
    var start = new Date().getTime();
    var cur = start
    while(cur - start < msecs){
      cur = new Date().getTime();
    } 
  }
I'm giving up because this is supposed to be a fun distraction, but I am curious as to what the correct way to loop times events (animation, or otherwise).

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

gwar3k1 posted:

Thanks, I added a wait function (from a google hit) and changed my do a bit, but the performance is poo poo.

code:
  function runSequence(){
   ...
      do {
        updateClock(circleFgColor[circleColor],current,sequence[i]);		  
        current = current+1;
        wait(1000);
        //alert("a");
      } while (current<=sequence[i]);
    }
  }
	  
  function wait(msecs){
    var start = new Date().getTime();
    var cur = start
    while(cur - start < msecs){
      cur = new Date().getTime();
    } 
  }
I'm giving up because this is supposed to be a fun distraction, but I am curious as to what the correct way to loop times events (animation, or otherwise).

I am not sure you understand how setting timeouts works. If you want to set something up to happen in 5 seconds, say, then you create a timeout using setTimeout (specifying a time of 5000 milliseconds) and then you allow your function (the function in which you used setTimeout) to run to completion. When the timeout has run its course, your function will get called, spontaneously, by the JavaScript engine.

If you want a nice-looking, smooth animation on the other hand, I think it's easiest to use what jQuery offers you.

I made this thing last year for an event I was involved in, it is more complex than is needed for an example but you might find it interesting to look at.

Rello
Jan 19, 2010
Hoping this is the right place to ask this,

Would anyone mind sharing their opinions on what the most important/best Computer Science classes would be?

I've mostly heard Compilers, Computer Graphics, Operating Systems, Data Structures, Algorithms, and Databases.

Thanks,

Red_Mage
Jul 23, 2007
I SHOULD BE FUCKING PERMABANNED BUT IN THE MEANTIME ASK ME ABOUT MY FAILED KICKSTARTER AND RUNNING OFF WITH THE MONEY

gwar3k1 posted:

Try instr(cell.Value,findWhat) or Value2, rather than text. The instr is possibly comparing findWhat to the cell's containing formula rather than its value.

You can minimize your code by putting your findWhat values into an array and for looping the size of that. Take note of the trim function when you copy to a named sheet.

code:
Dim findValue = array("Committee I ","Committee II ",...)

For f = 0 to ...
  findWhat = findValues[f]
  lastLine = ActiveSheet.UsedRange.Rows.Count
 
  j = 1
  For i = 1 To lastLine
      For Each cell In Range("F1:Q1").Offset(i - 1, 0)
          If InStr(cell.Value, findWhat) <> 0 Then
              toCopy = True
          End If
      Next
      If toCopy = True Then
          Rows(i).Copy Destination:=Sheets(trim(findWhat)).Rows(j)
          j = j + 1
      End If
      toCopy = False
  Next
Next
I found this VB.net post on Microsoft to make use of and create macros in Excel.

Thanks for the help, I fixed your arrays to match syntax and tried your code and well... it was a fiasco, something botched horribly. Just gonna stick with my copy paste data workaround.

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

GregNorc posted:

How could I write a bash script to append something to every file in a directory? I have a large number of files I need to append to, and doing it manually will take a really long time...

I've got it in psudocode but I'm having trouble doing it in bash:

code:
string = "text"
FOR filename IN directory
filename = "text" + "_" + filename
rename
code:
rename 's/^/text_/' directory/*

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Rello: Discrete Mathematics.

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Got a crypto question. I'm interested in doing digital signature for the purpose of verified firmware updates on an embedded device. So the firmware updates will come from single source (me), and the embedded device would contain my signature's public key in it's existing firmware.

I know that typically a signature is done by making a hash of the message and then signing that hash, but for my case I would much rather sign the entire message if at all possible. I would just like to discourage the reading/disassembly of the firmware by having sending out plaintext firmware updates(I realize if they have physical access to the device they could hypothetically read the data from the chip by driving pins with external circuitry or whatever, this is just an small added deterrent that I would like to have). So are there appropriate algorithms for doing such a thing? I've been told that some digital signature algorithms have a limited signature length?

From what I've read so far it sounds like some form of Elliptic Curve algorithm is the way to go. I'm not planning on rolling my own because I know I'm not a crypto expert and math is hard, I would be looking for an existing implementation as C lib.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Rello posted:

Hoping this is the right place to ask this,

Would anyone mind sharing their opinions on what the most important/best Computer Science classes would be?

I've mostly heard Compilers, Computer Graphics, Operating Systems, Data Structures, Algorithms, and Databases.

Thanks,

This probably deserves its own thread, but IMO, the most important classes by far are algorithms and architecture. Almost everything else is either in preparation for those two, or relies heavily on what you learned in them.

Rello
Jan 19, 2010

Internet Janitor posted:

Rello: Discrete Mathematics.

What math courses would you recommend?

I have a year of linear algebra, a year of stats, 2 years of Calculus (up to Multivariable Calculus), as well as a year of Computational Theory, with all of them being fairly proof heavy.

Thinking about taking Combinatorics, 'Chaos, Dynamics and Fractals', and Differential Equations, but none of them are required for my degree.

ultrafilter posted:

This probably deserves its own thread, but IMO, the most important classes by far are algorithms and architecture. Almost everything else is either in preparation for those two, or relies heavily on what you learned in them.

Gotcha, I'll be covering software architecture in all my software engineering classes, so hopefully I'll be good.

Thanks,

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Rello posted:

Thinking about taking Combinatorics, 'Chaos, Dynamics and Fractals', and Differential Equations, but none of them are required for my degree.

Of those, I think Combinatorics might be the most directly applicable to CS, although there will be some overlap with good courses on Algorithms and Computation Theory. See if you can find any courses on Cryptography- that can be a lot of fun. When I took Crypto I had a professor who counted source code as "showing your work" and I treated the assignments as programming practice.

etcetera08
Sep 11, 2008

Rello posted:

What math courses would you recommend?

I have a year of linear algebra, a year of stats, 2 years of Calculus (up to Multivariable Calculus), as well as a year of Computational Theory, with all of them being fairly proof heavy.

Thinking about taking Combinatorics, 'Chaos, Dynamics and Fractals', and Differential Equations, but none of them are required for my degree.


Gotcha, I'll be covering software architecture in all my software engineering classes, so hopefully I'll be good.

Thanks,

Read this for algorithm stuff if you're not going to be taking a class directly about it.

Rello
Jan 19, 2010
Looks like the only cryptography course my school offers is a graduate level math course, and I don't think I'll meet the prerequisites :(. I will be taking a class directly on algorithms but I'll skim through that book really quick when I have time.

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:29 on Apr 28, 2019

ToxicFrog
Apr 26, 2008


GregNorc posted:

1 problem: I am on OSX. No rename tool, hence trying to write my own.

Edit: Checked macports too, no luck.

Your original question is kind of confusing, since you start out saying you want to append but then provide pseudocode that prepends. I'm going to assume that the code is what you're after.

You're not actually that far off; a simple pure-bash approach:

code:
prefix="text_"
cd /path/to/dir
for file in *; do
  mv "$file" "$prefix$file"
done
Note that this will not recurse into subdirectories (or process dotfiles, as they aren't matched by *); if you need that things get more complicated.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

peepsalot posted:

Got a crypto question. I'm interested in doing digital signature for the purpose of verified firmware updates on an embedded device. So the firmware updates will come from single source (me), and the embedded device would contain my signature's public key in it's existing firmware.

I know that typically a signature is done by making a hash of the message and then signing that hash, but for my case I would much rather sign the entire message if at all possible. I would just like to discourage the reading/disassembly of the firmware by having sending out plaintext firmware updates(I realize if they have physical access to the device they could hypothetically read the data from the chip by driving pins with external circuitry or whatever, this is just an small added deterrent that I would like to have). So are there appropriate algorithms for doing such a thing? I've been told that some digital signature algorithms have a limited signature length?

From what I've read so far it sounds like some form of Elliptic Curve algorithm is the way to go. I'm not planning on rolling my own because I know I'm not a crypto expert and math is hard, I would be looking for an existing implementation as C lib.

The "don't roll your own crypto" rule applies even more to cryptographic protocols than to the actual crypto algorithms. You are attempting to design your own cryptographic protocol. DON'T DO THAT.

The protocol you want is probably something like CMS which you can find a perfectly good implementation of in OpenSSL. If you can't find a CMS implementation, then try to find PKCS#7. Those protocols will let you send a signed-and-encrypted message and will do all the hard work of making sure it's correctly formatted and delivered.

Literally hundreds of people have worked long and hard to make well-reasoned protocols like CMS. You are not capable of doing a good job on your own. If you're asking the questions you have in your post, then you aren't even qualified to do a lovely half-assed job. OpenSSL is a fine library, and if you can't use it, there are many other fine libraries out there.

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

peepsalot posted:

I know that typically a signature is done by making a hash of the message and then signing that hash, but for my case I would much rather sign the entire message if at all possible.
Just sign the SHA1 hash.

quote:

I would just like to discourage the reading/disassembly of the firmware by having sending out plaintext firmware updates(I realize if they have physical access to the device they could hypothetically read the data from the chip by driving pins with external circuitry or whatever, this is just an small added deterrent that I would like to have).

Encrypt the entire thing with AES using some secret key. You're clearly aware that this isn't an airtight solution.

Sign the message before you encrypt it. (Encrypt the message + the signature, not just the message).

Don't use strncmp to verify the signature. :v:

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