|
Zamujasa posted:Proper escaping What about prepared statements, so you're separating your logic and data, instead of generating a piece of code that gets eval'd?
|
# ? Sep 26, 2012 00:42 |
|
|
# ? May 7, 2024 19:43 |
|
I just found out that changing the screen orientation on android closes the app. Welp
|
# ? Sep 26, 2012 00:55 |
|
JavaScript code:
|
# ? Sep 26, 2012 01:15 |
|
Suspicious Dish posted:What about prepared statements, so you're separating your logic and data, instead of generating a piece of code that gets eval'd? Zamujasa posted:The rest of it is just pure bullshit though. Proper escaping (or just using a real database object and avoid manual queries as much as is feasible) will prevent that poo poo. Having worked with Invision Power Board (which, mind you, has a function usefully named "boink_it") I had a momentary brain-fart that fully-prepared queries (where you never have to manually escape anything) were a thing, and not just the horrifying query-builder IPB uses. Give me a break, someone had their little 3-year old terrors running around the office today. Deus Rex posted:
The end result is that you have at least 5+ instances of the exact same function with a slightly different URL (and sometimes slightly different code that runs when the AJAX request returns), and it only gets better when you realize there are functions that are literally just function dosomething() { doajaxrequest(); } with no arguments or anything. (The sad part is that it turns out that's w3schools example is exactly what was copied and pasted -- I was hoping to just find a similar example with "javascript ajax example", but it turns out it's the exact same. One of the copy-pasted functions is even still named "loadXMLDoc()". ) Zamujasa fucked around with this message at 01:34 on Sep 26, 2012 |
# ? Sep 26, 2012 01:26 |
|
Mesothelioma posted:I just found out that changing the screen orientation on android closes the app. Welp
|
# ? Sep 26, 2012 04:57 |
|
Aleksei Vasiliev posted:Yeah, it serializes the app, changes the orientation, then relaunches the app from the serialized data IIRC. I remember the guy who's is coding the Android version of one of our apps mentions that. His response was "Yeah, a thing."
|
# ? Sep 26, 2012 05:52 |
|
Aleksei Vasiliev posted:Yeah, it serializes the app, changes the orientation, then relaunches the app from the serialized data IIRC. This means that adding header views with state to adapters is such a horrible hack; you can only add them once, before you set the adapter, because it creates a wrapper that can't be changed after the fact, which will then crash. Technically, you can specify "orientation" as one of the configuration changes you'll handle yourself, but this has bad interactions with some ad integrations in my experience, and probably more. When the activity is recreated, then onCreate will be called as well as onRestoreInstanceState, if memory serves. However, the lovely part is that this behavior has changed at some point so that different Android versions treat this state persisting slightly differently. I've taken to using Fragments, lately, and telling them to retain their instance so that, as much as possible, I don't have to reset my state. I don't know how beneficial it is, but it seems to, combined with other things I'm doing, work out better. The real horror is dealing with Android 2.1 VideoView - there is a pause method, but no resume, and restoring their state is a shitshow of awesome proportions. It is a clusterfuck of epic awfulness. Especially if you have to pause video to, say, show a midroll ad. Holy poo poo. Maybe Fragments will save the day (and to some degree, the VideoView state). --- E: now that I'm in front of a computer, I'll expand on this. I'm doing this mostly from memory so it may be incorrect. So VideoViews can be unprepared, preparing, playing, completed, or errored. Activities can be in the process of creation, starting, or resuming, or (correspondingly) pausing, stopping, or destruction. In addition, the VideoView might be paused, and if you set the URL it can reset the state. When you receive a call or see a dialog box. it can go through some but not all of the onPause/onStop/onDestroy method and corresponding unwinding with onCreate/onStart/onResume methods, *in addition to* the onSaveInstanceState and onRestoreInstanceState. What's more, some devices will always destroy backgrounded Activities, because they don't have very much memory at all. Even decent devices give you a scant couple of MB before it brings the reaper down on you. Digression: It should be noted that no destruction or recreation is USUALLY needed for activities switching between one landscape and another, or one portrait and another - they're 180 degree turns, so no relayout is necessary. To specify this, you can use "sensorPortrait" or "sensorLandscape" as their orientation in the manifest. However, pre-2.3 device support poses a challenge. It turns out that most devices seem to treat it like a bitfield, and fall back appropriately when you specify this in the AndroidManifest. The numerical values are sensorLandscape = 6, or 0b110, sensorPortrait = 7, or 0b111, with landscape proper being 0 and portrait being 1. However, for whatever reason, Samsung devices don't work this way. I believe, but don't recall, it causes a crash. So, what you have to do instead, is for EVERY Activity in your application which supports sensor orientation, it has to first detect its API level, then it has to set the orientation. However, it must do this before setContentView is called, so if it is a subclass of an activity which could possibly touch setContentView, you must never call it after super.onCreate. Anyways, back to the VideoView, you basically have five-ish states multiplies by three states as well as playing/paused. However, onSaveInstanceState is only guaranteed to be called before onStop, and will be called before or after onPause. Not to mention, in pre-honeycomb platforms, Activities need only be paused to be killed, meaning that onSaveInstanceState might not even be called. Also, it's easy to make naive mistakes like pausing on onPause or resuming the video in onResume. You might reset the video, or cause it to play immediately on returning to the app if it was paused before you left, and if a dialog comes up, you might have to deal with that before you can get back to the player to pause it. Also, since there's no resume() method, you call start() instead. But if you call start() twice, it might rebuffer the video. So if you try to keep the necessary calls to the VideoView reconciled with the states the Activity could be in or restoring from, it's a crazy matrix of I HAVE NO IDEA WHAT I'M DOING most of the time. tl;dr: If you're trying to stream videos on Android, and want to be able to multitask then come back to where you left off, and back up the resume point to the server at some point and be able to resume from that, be prepared to spend several months dealing with nondeterminism, hating yourself, lots of unintentional bugs, dealing with deep, crippling depression, many many angry users, and just...well...a toxic mix of and ? But yeah. This is Android for you. Years of bullshit you'll never escape, fixes that stare you in the face and tantalize you with their presence only on high version numbers, and compatibility libraries that bridge some of the gap. P.S. BTW, the Android Compatibility Library doesn't include a PreferenceFragment, a glaring omission because it's loving useful - and someone has a proof of concept backport so it's clearly possible - and since PreferenceActivity is not only limiting, but deprecated, your life sucks if you want to support both at the same time) P.P.S. Did I mention that there are three different H.264 decoders in use on different devices or versions of Android (not sure which or if both)? So what plays fine on one might totally break for another. Additionally, GoogleTV runs API 12 and presumably supports HTTP Live Streaming (aka HLS), but Honeycomb (API 11-13) does not, but ICS (14, 15) and JB (16) do. P.P.P.S. Man I keep on thinking of things to add. Basically, the problem is that the Android lifecycle works best when you model the data as unchanging, restorable objects. Since, for a given launch, the Intent stays the same, whenever I use immutable objects, things are pretty fine, since I can just reconstruct them from getIntent() in onCreate, and expect them to remain consistent across Activity destruction. On the other end of the spectrum, streaming video is extremely stateful, and reconciling the propensity of the Activity to destroy+recreate with the VideoView's awkward interface (it's actually a just a wrapper around yet more classes) is a monstrous horror. Doctor w-rw-rw- fucked around with this message at 06:50 on Sep 26, 2012 |
# ? Sep 26, 2012 06:02 |
|
php:<? function addDays($day){ $result = date("Y-m-d",time()+24*3600*$day); return $result; }?> #EDIT: php:<? $EntryDate = addDays(0); $today = addDays(0); ?> php:<? function MakePretty($day){ //$result = substr($day,5,5) . "-" . substr($day,0,4); return $day; }?> bobthecheese fucked around with this message at 08:14 on Sep 26, 2012 |
# ? Sep 26, 2012 08:08 |
|
bobthecheese posted:
php:<? function MakePretty($day){ //$result = substr($day,5,5) . "-" . substr($day,0,4); return $day; }?> php:<? $EntryDate = addDays(0); $today = addDays(0); ?> OK, never mind, this guy needs a paddlin'.
|
# ? Sep 26, 2012 14:48 |
|
Golbez posted:People never consider that not every day is 24 hours long. But once it bites them, they never forget it. This poo poo is why I always use date/time libraries. Let someone else deal with the horrible mess that is the calendar.
|
# ? Sep 26, 2012 21:17 |
|
Holy poo poo the source code for sh is awfulcode:
|
# ? Sep 26, 2012 21:36 |
|
I guess Bourne really wanted to be writing in some other language.
|
# ? Sep 27, 2012 00:29 |
|
Yeah I think it was brought up before butcode:
|
# ? Sep 27, 2012 03:10 |
|
SavageMessiah posted:I guess Bourne really wanted to be writing in some other language. Well if the movie trilogy about him is anything to go by his lifestyle choices made things quite a bit more exciting.
|
# ? Sep 27, 2012 03:59 |
|
The awful do/od, if/fi, case/esac, etc. syntax is from Algol 68.Edsger Dijkstra, EWD230 posted:Dear Editor,
|
# ? Sep 27, 2012 19:35 |
|
AlexG posted:...Edsger Dijkstra quote... I read the quote but I don't get it. What is his complaint?
|
# ? Sep 27, 2012 20:19 |
|
Shinku ABOOKEN posted:I read the quote but I don't get it. What is his complaint? I think someone handed him a thousand page draft spec and he didn't like the complexity of the beast. ALGOL 60 was a pretty simple and easy to implement language, ALGOL 68 was considered Djikstra and others to be be overly broad and a pain to write a compiler for. The report came out in 68 but there wasn't a full compiler written until the mid 70s. dis astranagant fucked around with this message at 20:37 on Sep 27, 2012 |
# ? Sep 27, 2012 20:34 |
|
code:
It made me ponder about life, humanity, and which direction we're headed in as a species. It also made me think about what an "ncchihuahua" looks like and what the little single quotes could represent artistically(a choo-choo train). The man that wrote this code must be a genius. His subtly ironic code paints an allegory of the plight of modern man, the loss of the frontier, and the problems of modern society. These are all perfectly captured in this concise piece of art.
|
# ? Sep 27, 2012 21:09 |
|
if not [x] is null? What flavor of SQL is that? I thought they were all "if [x] is not null"
|
# ? Sep 27, 2012 22:30 |
|
not (x is null) is a synonym (at least without going into specifics) for x is not null.
|
# ? Sep 27, 2012 22:40 |
|
http://jsil.org/quote:JSIL is a compiler that transforms .NET applications and libraries from their native executable format - CIL bytecode - into standards-compliant, cross-browser JavaScript.
|
# ? Sep 27, 2012 23:09 |
|
Isn't that guy a goon? I remember trying to use some of his EVE-related scripts and seeing a CIL to JS compiler in his Github and wondering wtf that was. The code I used wasn't especially horror inducing. OnceIWasAnOstrich fucked around with this message at 23:59 on Sep 27, 2012 |
# ? Sep 27, 2012 23:51 |
|
The horror is that it seems to handle XNA games fairly well?
|
# ? Sep 27, 2012 23:51 |
|
Yeah, he's a goon (i've been using shootblues a lot back in the day). It isn't really a coding horror imo; it certainly has it's uses.
|
# ? Sep 27, 2012 23:56 |
|
Maybe the thought-to-be horror is the world accidentally specifying the only cross-browser virtual machine in the form of interpreted source code?
|
# ? Sep 28, 2012 00:05 |
|
pokeyman posted:Maybe the thought-to-be horror is the world accidentally specifying the only cross-browser virtual machine in the form of interpreted source code?
|
# ? Sep 28, 2012 01:38 |
|
That's not a horror, that's loving awesome.
|
# ? Sep 28, 2012 01:42 |
|
Shinku ABOOKEN posted:I read the quote but I don't get it. What is his complaint? http://repository.cwi.nl/search/fullrecord.php?publnr=9187 PrBacterio posted:You know, that go me thinking ... maybe someone could make a microprocessor that directly executes Javascript as its native machine language. Then we'd finally arrived at the one true architecture to be used everywhere. Someone should get on this! http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-514.pdf http://dspace.mit.edu/handle/1721.1/6334 http://groups.csail.mit.edu/mac/users/mhwu/scheme86/scheme86-home.html http://research.microsoft.com/en-us/um/people/gbell/Computer_Structures__Readings_and_Examples/00000383.htm http://research.microsoft.com/en-us/um/people/gbell/Computer_Structures_Principles_and_Examples/csp0524.htm
|
# ? Sep 28, 2012 03:04 |
|
Wow, if you cut off the index you can fit the entire ALGOL 60 revised spec (EWD was on the team for the first several ALGOL 60 compilers and cranked the first one out in like 2 months) inside the table of contents of that mess. THAT is what his complaint was.
|
# ? Sep 28, 2012 04:06 |
|
The contents of global.csscode:
|
# ? Sep 28, 2012 05:06 |
|
Accurate. And it's tiny when gzipped!
|
# ? Sep 28, 2012 05:33 |
|
that awful man posted:http://repository.cwi.nl/search/fullrecord.php?publnr=9187
|
# ? Sep 28, 2012 15:08 |
|
PrBacterio posted:much in the same way pretty much every machine architecture these days is designed for C/C++. You got it the other way around, young grasshopper. Also, Lisp-machines were very much made just for Lisp, which is very obvious from its ISA, It's a bit like baking in the java VM. The main difference was that they could just modify the Lisp dialect they used to make the implementors happy. Java and Javascript have so much for implementors that it's just not useful to bake it on a chip, even under the massive commercial pressure to do so. For some presentations on 'wtf JVM', check out Cliff Click's presentations/posts. Beef fucked around with this message at 15:58 on Sep 28, 2012 |
# ? Sep 28, 2012 15:47 |
|
Can't give many details but this is a typical New Relic page on the CMS we use: Features: - 500+ SQL queries to show most pages, all stored procedures (in this example some queries were cached) - all content served from the same aspx page - coded in Visual Basic and it seems so convoluted that even the smallest changes require at least a week - No useful version control - Any small change requires DB changes and they are done in a non-backwards compatibleway (haha you want to revert to what version?) Needless to say it's getting replaced. deimos fucked around with this message at 16:18 on Oct 1, 2012 |
# ? Oct 1, 2012 16:15 |
|
bobthecheese posted:
If I'm reading this right, this function is just supposed to add on a number of days from today's date and return it in a YYYY-MM-DD format? I'm guessing this guy never heard of strtotime? PHP has a lot of silly poo poo but strtotime is the most awesome solution I've seen for dealing with dates. Still, life would be much better if we would just shut up and convert to metric time already
|
# ? Oct 2, 2012 17:26 |
|
(classic asp)VB Script code:
|
# ? Oct 2, 2012 20:24 |
|
I... I give up. Seriously, gently caress. I'm out.php:<? $resultProfit = ConnectToDatabase($sqlProfit); if (mysql_num_rows($resultProfit)>500) { $resultProfit = ConnectToDatabase($sqlProfit." LIMIT 500"); } ?>
|
# ? Oct 2, 2012 23:53 |
|
bobthecheese posted:I... I give up. Seriously, gently caress. I'm out. I don't understand how someone has the logical ability to write code, but then writes something so utterly illogical as that.
|
# ? Oct 3, 2012 00:21 |
|
Chopper posted:I don't understand how someone has the logical ability to write code, but then writes something so utterly illogical as that. A new(er) developer that read the analyst's (me) requirements and carried them out in code to a T? I've seen junior devs do things like that quite a bit. Maybe we just recruit terrible junior devs.
|
# ? Oct 3, 2012 01:13 |
|
|
# ? May 7, 2024 19:43 |
|
Chopper posted:I don't understand how someone has the logical ability to write code, but then writes something so utterly illogical as that. Never TA'd a CS 101 class, huh?
|
# ? Oct 3, 2012 01:53 |