|
Avenging Dentist posted:Generally, I think it's best to pick one style and use it for both variables and methods. It just makes things more consistent. i use underscore_deliminated_method_names and CamelCaseVariableNames generally. in some languages it's extremely nice to be able to differentiate between the two at a glance.
|
# ¿ Feb 27, 2008 03:08 |
|
|
# ¿ May 6, 2024 11:55 |
|
Coconut Pete posted:This is not exactly a programming question, but it is related to programming: Do you write your own language and libraries when you contract? Of course it's not cheating.
|
# ¿ Jul 8, 2008 18:52 |
|
Is there a cross platform way to get the rgb value of a specific pixel displayed on screen? The pixel may not be constrained to a certain window, unfortunately. I also need a solution that doesn't rely on dumping screenshots. Language doesn't really matter, but C or Python would be ideal. I also don't really care about OSX, but it would be nice if it worked there too.
|
# ¿ Oct 11, 2008 04:51 |
|
JoeNotCharles posted:PyQt (or use the C++ version directly if you have problems with the Python wrapper). Works on Qt, Mac and Linux. I'm not sure what you mean by "dumping screenshots", but I assume you mean you can't save it to an image on disk and then look at the image. The following code will grab the entire screen into a QPixmap in memory and then you get the individual pixel value: This is fantastic, thankyou!
|
# ¿ Oct 11, 2008 05:39 |
|
This is probably more a question for 'Ask General Programming Questions Worth Their Own Doctoral Thesis' but any recommendations on where to start researching ways to compare two sets for equality? (Assuming you can cache whatever information you want as the sets are constructed). Failing that, a proof that you can't do better than iterating over each member of each set?
|
# ¿ Dec 5, 2009 07:05 |
|
ShoulderDaemon posted:Do you have any more context? There are ways you can design your set representation to make inequalities likely to be detected earlier rather than later in the most common cases for your problem, and there are representations that depend on some degree of observable sharing which can change your decision algorithm from O(n) in the number of elements in the list to O(n) in the number of modifications made to the two lists since the last time you confirmed they were equal, although in practice few people care to use these except for rare cases such as infinite sets. I was criminally vague initially. Sorry. This is what I really want: I've got two systems, completely distinct from one another. They're organized as sets of nodes containing various state. Right now, we're using a tree representation (merkel trees) to calculate a single hash of the state of each system we can compare trivially. However, this restricts us to having systems with identical internal organization. If any state is moved from one node to another, or the number of nodes changes, the hashes now represent the same state, but are distinct and non comparable. I know there are O(n) algorithms to calculate this state, but O(n) is, unfortunately, too much overhead (as N is very large when discussing the entire set). What I really need is a hash function such that hash(A, hash(B, hash(C, hash(D, E)))) = hash(E, hash(D, hash(C, hash(B, A)))) (for any permutation of A, B, C, D, E). I know these exist, but I'm unable to find anything on practical implementations.
|
# ¿ Dec 9, 2009 09:49 |
|
I want to migrate TCP connections from one machine to another (transparently). I know I can use tun/tap to get at the raw packets, but then I have to implement my own TCP/IP stack which is kind of a downer. Is there a c library around (preferably MIT or BSD licensed) that will make this easier, or a documented api already available? (Yes, proxy blah blah, I know. Not gonna work for this).
|
# ¿ Feb 11, 2010 21:31 |
|
Troyo posted:Where should I start? Perhaps I should learn the basics then determine whether I'd like to continue with the endeavor? Read through something like http://www.djangobook.com/ If you can make sense of it, give it a shot.
|
# ¿ Jun 9, 2010 03:06 |
|
Ledneh posted:I'm not really sure how to go about it at all, since we've already conclusively proven that the algorithm in question is exactly the same in both programs. The only thing I could think of is to see if there's a way to figure out an "expected delta" between two processors' implementations of IEEE float 64 (and hell, 32), but again besides googling/asking about I'm not sure where to run with that. One of the processors is probably using extended precision. Can you post the code, or the hardware specs?
|
# ¿ Aug 6, 2010 03:42 |
|
Ledneh posted:As I recall the Sun box is an UltraSPARC T2, but I have no idea about the SGI one at all. the ultra uses 64 bit floats try this on the sgi: double x, y, z; x = 3.0; y = 7.0; z = x/y; if(z == x/y) ... if it's using extended precison that comparison will return false, if it's using IEEE 754 64 bit floats it should return true. the sgi's processer should have an instruction to round all intermediate floats to 64 bit, but you're gonna have to find that yourself. the talent deficit fucked around with this message at 15:12 on Aug 6, 2010 |
# ¿ Aug 6, 2010 15:02 |
|
Triple Tech posted:I sort of understand the motivation for a String Builder class, but do all languages have one? I'm thinking of PHP, Perl, Python, and Ruby. I know C# and Java do. If the others don't, why? Do they not suffer from the same implementation problem? Or do they not care? Erlang has something called an iolist which is a (possibly deep) list of binaries (typically utf encoded string fragments), characters and iolists. All the io functions flatten and combine them efficiently when passed them as an argument. They're rather awesome. An example: ["this is", ["a list", " ", "of the last five commenters encoded as binaries: ", [<<"Mustach">>, " ", <<"Alters">>, " ", <<"ToxicFrog">>, " ", <<"Lurchington">>, " ", <<"Triple Tech">>]], "."] When sent over a port/io, it's converted to: <<"this is a list of the last five commenters encoded as binaries: Mustach Alters ToxicFrog Lurchington Triple Tech.">>
|
# ¿ Aug 12, 2010 03:41 |
|
I have a messaging system that consumes arbitrary binary sequences from a number of producers. Assuming all producers can read all other producers output, is there a way to uniquely identify producers that makes it impossible for producers to masquerade as other producers that doesn't rely on shared keys?
|
# ¿ Dec 6, 2010 01:48 |
|
ShoulderDaemon posted:If you want to uniquely identify a producer, you have to have some kind of information that is unique to that producer. What, specifically, can't you do that makes you think you can't use "shared keys"? If you can be more specific about what your problem is, then we can choose a MAC that will work for you. I can use shared keys, but I'd like to avoid the overhead. I've got a bunch of processes (that I have no control over) writing to a single file (via a proxy that sequences the writes). I want to prevent processes from forging writes from other processes. They all have unrestricted read rights to the file, so I can't just use a unique ID per process. Right now, I use HMAC, but I'm trying to saturate the disk i/o, and the crypto overhead is preventing that. Additionally, I'd like to avoid altering the message in any way, apart from enclosing it in some sort of container. the talent deficit fucked around with this message at 02:12 on Dec 6, 2010 |
# ¿ Dec 6, 2010 02:10 |
|
Yeah, I suspected as much. There's a few other ways to do it, but the all involve modifying the data written and adding padding. I think I'm going to have to stick with the HMAC.
|
# ¿ Dec 6, 2010 02:23 |
|
What's the 'best' (friendliest API, most useful, best designed) web server abstraction layer? ie wsgi, rack, et cetera? any language, I need to port one of them to erlang.
|
# ¿ Oct 2, 2011 03:23 |
|
ICK posted:Are there any good resources for people who are new to software licensing/redistribution? Licensing is only ever really simple or terrifyingly complex. Do you have specific questions? (Please don't ask, 'what license is best?')
|
# ¿ Oct 27, 2011 08:03 |
|
If I want to release a library for non-commercial use only, what are my options? I thought the Sleepycat license was what I wanted, but upon reading, it turns out I'm wrong.
|
# ¿ Dec 6, 2011 05:51 |
|
ShoulderDaemon posted:Creative Commons Non-Commercial is probably your best bet, although it's not a software-specific license. Note that the open source community won't touch it, either, so you are likely to have very few users. A fairly significant portion of the open source community feels very strongly that software should not have licenses that restrict use in any way whatsoever. I've seen a few libraries licensed under CC-NC, but nothing with enough of a profile that I was confident it's actually sensible for software. We already have hundreds of commercial users of our SDK who pay for the right to use it. We want to release a free version (that isn't crippled) as cheap advertising. We're not really concerned with open source idealists, more just increased openness and exposure without hindering our ability to operate as a for profit business.
|
# ¿ Dec 6, 2011 06:28 |
|
Gilg posted:I've got a web API that returns JSON like so return instead: code:
|
# ¿ Apr 12, 2012 07:34 |
|
The new tags are for better 'alternative' interfaces to consume html5. Things like screen readers, mobile browsers, Instapaper like clients, webapps that consume other webpages, etc.
|
# ¿ May 7, 2012 23:56 |
|
I'd whitelist unicode display names, not blacklist. Allow common alphabets and maybe punctuation, special case RTL alphabets and make sure everything normalizes. Even if you do this people are going to be able to 'forge' other user's display names because of the common practice of reusing glyphs for nonequivalent characters.
|
# ¿ Jun 19, 2012 09:55 |
|
stubblyhead posted:I'm getting an http 405 error (method not allowed) using an application's REST inferface. I'm trying to POST, which the API guide says is allowed, and POST is included in the Allow header of the error page I get. As a developer, is the onus upon you to implement all the methods you want a resource to handle, or does that header get built automatically from the implemented methods? Basically I guess I'm asking if I'm doing something wrong (very possible) or if the devs didn't actually implement POST for this resource, despite all other indications (also very possible). At a raw http level, you can shove whatever you want in the Allow header. I could claim my endpoint implements the 'PARTY' method. At a framework level you'd hope these would have some sort of constraint placed on them that verifies the Allow header in a 405 return isn't a filthy liar, but most frameworks are crap. In short, it's probably the API devs, not you.
|
# ¿ Jun 22, 2012 07:39 |
|
I'm playing around with Vagrant and it's beginning to drive me crazy. Trying to use the chef_solo provisioner none of my `chef.add_recipe "foo"` declarations get added to the `run_list` in `dna.json` (in fact, there is no `run_list` key in `dna.json` at all). I feel like I'm missing something obvious.
|
# ¿ Apr 17, 2013 07:52 |
|
pliable posted:Are there any ML and/or functional programming guru's in the house? I'm having trouble conceptualizing/visualizing code from a functional paradigm standpoint, that and the syntax of ML is so crazy to me that it's blowing my mind. do you have a specific question?
|
# ¿ Apr 22, 2013 05:13 |
|
BlackMK4 posted:Where does one start if they want to get into generating 2d/3d graphics and they are coming from a background of building console apps / SAAS stuff in Java/Python? gaming? i'd try unity. or unreal engine. both are basically free (until you start making money with them)
|
# ¿ Jul 23, 2015 05:34 |
|
This book is old but incredibly good and relevant to what you are asking: http://www.wayner.org/node/39
|
# ¿ Aug 3, 2015 18:10 |
|
Cryolite posted:How do people generally commit stuff to GitHub without including sensitive information like API keys that could be a big problem if they become public? encrypt it: https://github.com/mozilla/sops
|
# ¿ Nov 13, 2015 06:30 |
|
Bob Morales posted:Are there some tutorials that explain how to do high-availabilty stuff? Not at the 'cloud' level but how you would manually implement it. yes, but you're asking two different questions here quote:Imagine this, a file uploading service, with a web front end that runs on 2 servers in case one gets busy or goes down. You upload a file and then it gives you the URL you can then access the file from. I'm imagining a load balancer handling these front end servers. this is easy you stand up multiple stateless web front ends behind something like HAProxy or AWS ELB. where i work all our services run on either the jvm or the erlang vm and are trivial to jail so we don't use docker or any other containers. we just use AWS autoscale groups and AWS codedeploy for provisioning. some autoscale groups contain a single application, some contain more. each application gets it's own AWS ELB. this kind of stuff is usually called 'devops' these days quote:Now behind the scenes, whichever of the 2 servers gets the uploaded file, writes it out to say 3 file servers, and stores it in some redundant pattern. Perhaps splitting it up into chunks so that if one of the servers goes down you can read it from the other two. this is hard first you have to learn about consistency and availability. most people have heard of the CAP theorem (you can only get two of consistency, availability and partition tolerance, and you have to pick partition tolerance) but almost no one can define consistency or availability as they are used in the CAP theorem. consistency as used in CAP means a very specific type of consistency where there is one and only one possible history of operations (writes and reads) that all participants (servers and clients) share. availability means that if a server has not failed (and usually that means failed as in stopped completely) any client must be able to get a reply to any request and the server isn't allowed to reply 'try later' or 'sorry not right now'. if you relax these constraints, you can cheat CAP systems like cassandra, zookeeper, postgres, s3, et cetera all make different tradeoffs. cassandra provides consistent transactions with availability, zookeeper provides consistency with an option to forgo it when availability is important stale data is tolerable. postgres has a dial you can turn from from full availability to full consistency depending on needs at the moment. s3 is available with only vague promises of eventual consistency once you learn about consistency and availability (this is a really good starting point) and you figure out what you need and what you can actually get implementation of solutions usually comes down to grabbing the best fit off the shelf, or, if you're ambitious, reading a bunch of research papers by peter bailis, leslie lamport, fb schneider, marc shapiro and eric brewer. chris meiklejohn has a fantastic list here
|
# ¿ Nov 13, 2015 10:22 |
|
Cassandra is the only nosql product that really gets used in 'big data' and it's integration with hadoop/spark is not so great. Aurora and Redshift are way more common (both are SQL, sort of). What kind of tools are you looking for?
|
# ¿ Jan 15, 2016 01:54 |
|
i used to be a thrift contributor and while it has it's uses i think that for 95% of use cases you are better off going with http and json (or xml, i guess) for any sort of internal network api. the tooling and infrastructure is just so much better than what thrift/protobufs can offer. http frameworks in all languages are light years ahead of the codegen that thrift/protobufs have built in and you get pretty major features like auth, caching and sessions almost for free. your client for development is curl or your browser instead of some generated header file you need to wire up to use the schemas you get with thrift/protobufs are nice, but you can get the same thing from jsonschema or avro or something similar
|
# ¿ Jan 26, 2016 18:29 |
|
spark runs fine with no cluster behind it. we have a bunch of spark jobs running on aws lambda and you only get like 1.5 gigs of memory there
|
# ¿ Feb 17, 2016 16:27 |
|
foldl is almost always implemented recursively. (foldr sometimes gets weird)
|
# ¿ May 3, 2016 07:20 |
|
Suspicious Dish posted:OK, so instead of you downloading the schema file, the server sends its schema over at connection time and the client adapts. This was literally the point of SOAP, and one of the parts that they threw out basically as soon as they realized how useless it was. imagine you had a sql client that could render tables with clicky bits. clicking a column would sort by that column or let you add or remove a filter condition on that column. foreign key references would be clicky too and would take you to the table they referenced with the row that contained the foreign key id highlighted or filtered out all other rows or something. also there's a back button to go back to the table you came from and a forward button to go forward again after going back. your client doesn't know anything about the schema of the db other than you're going to get some 'tables' with some 'columns' and 'rows' and 'foreign keys'. any table you can express in sql you can render. that's a restful hateoas interface
|
# ¿ Nov 10, 2018 01:20 |
|
Suspicious Dish posted:It's the "if we link resources together clients will magically figure out their relationships". Basically, you're stuck in the "wikidata is really cool" phase of growing up before coming to the realization of "wikidata is actually useless, generic structured data is really hard and the semantic web will never happen". There are still a lot of people working hard on solving this problem, and we're no more closer to a solution than we were in the 1970s. That's what I said was impossible. what you claim is impossible is exactly how the web has always worked. that's the whole point of fielding's thesis. he wasn't dictating some architectural style; he was describing the most successful implementation of linked resources in the history of civilization also rdf and sparql are a thing that works and is good. we're all just too busy banging rocks together to stop and learn how to leverage them to build a real ecosystem
|
# ¿ Nov 10, 2018 01:25 |
|
|
# ¿ May 6, 2024 11:55 |
|
Suspicious Dish posted:edit: also pulling literally any data out of that page requires the schema of the db. From the other side: "your client doesn't know anything about the records in the JSON blob other than you're going to get some 'dictionaries' with some 'fields' and some 'values'. any table you can express in sql you can json blob. that's a modern restful json api interface" yeah, what's your question?
|
# ¿ Nov 10, 2018 03:49 |