Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

10-29-2016 , 12:31 PM
Quote:
Originally Posted by Grue
You can have code on github without a license and its your own IP implied/copywrite i.e. no one can legally use it.
But good luck proving someone used it.

Wolfram, is there any reason that you have to have this hosted somewhere? I wouldn't do this for many reasons. The least of all is that git commits are logged by several sites and your source code, even after being moved to private, is going to be publicly available somewhere for everyone to see anyways. This is why, if you accidentally push your AWS (or whatever else) keys to github, you have to change them immediately, even if you delete the offending code from history.

I'd just put the code on my own server if I really needed it to be hosted and private.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:08 PM
Quote:
Originally Posted by Craggoo
General thoughts on testing frameworks? I've been working in casperjs/phanotmjs. Primary alternative to that is Selenium. The main difference I'm aware of is phantomjs basically create's a webkit browser while Selenium allows you to pop up an instance of most major browsers allowing you to test browser specific quirks. For example, local/session storage won't be available in older browsers so you might want to create a test that asserts that these older browsers degrade gracefully.
casper went several years without any update to their software or site. Looks like they have finally updated so I guess it's back in business? The great thing about casper is that it played nice with phantomjs, which protractor never did (even though it sort of claimed to). And the great thing about phantom is it's headlessness - which allows it to run on our linux test servers. We had to go through all kinds of hoops to test using chrome on a windows server as part of our CI/CD flow.

Selenium is more brute force. But it's battle tested and works pretty well.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:10 PM
Interesting looking coding challenge that showed up on my FB feed with the clickbait title "94% of coders can't do this w/o using brute force": https://codefights.com/challenge/Qjts7cukDvYpDW4Bc

Quote:
The difference between two sequences of the same length a1, a2, a3,..., an and b1, b2, b3,..., bn can be defined as the sum of absolute differences between their respective elements:

diff(a, b) = |a1 - b1| + |a2 - b2| + ... + |an - bn|.

For the given sequences a and b (not necessarily having the same lengths) find a subsequence b' of b such that diff(a, b') is minimal. Return this difference.

Example

For a = [1, 2, 6] and b = [0, 1, 3, 4, 5], the output should be
closestSequence2(a, b) = 2.

The best subsequence will be b' = [1, 3, 5] which has a difference of 2 with a.

Input/Output

[time limit] 4000ms (js)
[input] array.integer a

Constraints:
3 ≤ a.length ≤ 1000,
-1000 ≤ a[i] ≤ 1000.

[input] array.integer b

Constraints:
a.length ≤ b.length ≤ 1000,
-1000 ≤ b[i] ≤ 1000.

[output] integer
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:11 PM
Quote:
is there any reason that you have to have this hosted somewhere?
Convenience (working on the code from any machine) and for cloud backup in case my local hdd crashes or I want to re-install my OS and can't be bothered with local backups.

I don't have my own server to store this on.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:32 PM
Quote:
Originally Posted by suzzer99
Interesting looking coding challenge that showed up on my FB feed with the clickbait title "94% of coders can't do this w/o using brute force": https://codefights.com/challenge/Qjts7cukDvYpDW4Bc
Spoiler:
Not sure I understand the task properly, wouldn't you just take the absolutevalue of a[i] -b[i], put the results into an array and then take the k-smallest differences as subsequence where k = size from a? I guess if the sequence is sorted you can do some binary search trickery.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:42 PM
Quote:
Originally Posted by Wolfram
This might be a silly question.

I'm working on a hobby project to teach myself Golang. There is a small but non-zero chance I might try to monetize the project later. If that happens then most of the value will be in original content that I plan to store on a CDN. The code will be mostly standard api's to serve up the content and a web front end.

I need an online git repo to store my code and I have my public github account. Is it ok to use that account for the intitial work and then move to a private account if this takes off, or can that bite me in the ass later? What would you guys do?
Private git repo with good backup practices or just use GitHub like the other 10 million hobbit projects out there.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:45 PM
Quote:
Originally Posted by Wolfram
Convenience (working on the code from any machine) and for cloud backup in case my local hdd crashes or I want to re-install my OS and can't be bothered with local backups.

I don't have my own server to store this on.
Cloud hosting is not a backup. Those are two independent things. You could use something like Arq or crash plan that makes it convenient to achieve both.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:48 PM
Quote:
Originally Posted by suzzer99
Interesting looking coding challenge that showed up on my FB feed with the clickbait title "94% of coders can't do this w/o using brute force": https://codefights.com/challenge/Qjts7cukDvYpDW4Bc
I can do the same thing. Create a stupid question with ****ty explanations, then claim that only 1% of programmers can solve it because why not?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:54 PM
Quote:
Originally Posted by muttiah
Cloud hosting is not a backup. Those are two independent things.
I'm confused why it's not. Doesn't github back up their servers?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:56 PM
So Windows 10 did an update on my machine, and now Chrome is all messed up. The font changed, things like column alignment isn't working, etc. Any ideas what's going on and how to fix? Google shows it's a common problem but there is no standard fix it seems. Did I lose a plug-in or something?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 01:59 PM
Quote:
Originally Posted by NiSash1337
Spoiler:
Not sure I understand the task properly, wouldn't you just take the absolutevalue of a[i] -b[i], put the results into an array and then take the k-smallest differences as subsequence where k = size from a? I guess if the sequence is sorted you can do some binary search trickery.
Well first you have to figure out how to evaluate every subset of array b. So let's say array a is 233 elements long, and array b is 789 elements long. That's an absolute ****-ton of possible arrays created from 233 out of the 789 elements in b (in sequence).

Brute force would be something like:
  1. Build array from elements 0-232 of array b, compare to array a, record total difference.
  2. Build array from elements 0-231 and element 233 of array b, compare to array a, record total difference.
  3. Build array from elements 0-231 and element 234 of array b, compare to array a, record total difference.

...

542. (or w/e) Build array from elements 0-230 and element 232-233 of array b, compare to array a, record total difference.

...

etc.

Last edited by suzzer99; 10-29-2016 at 02:05 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 02:28 PM
Not the best explanation but I'm not sure how everyone is so confused.

[SPOILER] seems like you could do something like create a dictionary of the values in b and how many times they occur. Then you iterate over a and look up a[i] in the dictionary if not found them you look for a[i] - 1 then +1 then -2 and +2 and so on until you find something, decrement its counter and increment i

If a isn't sorted already you would need to sort it for this method to work and also handle cases where you've already decremented the counter for a value in b to 0

You might also want to track the max and min of b to avoid a lot of wasted checks[/SPOILER]

Last edited by blackize5; 10-29-2016 at 02:36 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 02:44 PM
Wait, what? The question specifically has this:

diff(a, b) = |a1 - b1| + |a2 - b2| + ... + |an - bn|.

There is no reason to think that you have to stack a until you get len b (you would then have to stack b until it equals len a and this will get to absurd lengths if you pick two bad arrays). You certainly don't need a Cartesian product, but I'm not sure if they are saying that all N > len(A | B) should be zero?

From the example:

a = [1, 2, 6] = [1, 2, 6, 0, 0] (I think?)

b = [0, 1, 3, 4, 5]

The result is [1, 1, 3, 4, 5]? Where are they getting two from?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 02:55 PM
I want to grab some params from a route in node and pass them as input to a command line program I wrote in another language. What kind of security measures do I need to take? The route would be something like /board/AsKh8c/range/AK-2,AA-TT,KQ and I want to essentially run
$ myscript.rb AsKh8c AK-2,AA-TT,KQ

It looks like child_process.exec is what I need. Just want to make sure no one can make a request to /board/&& rm -rf \/ or whatever.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:05 PM
Also pros/cons of a long running ruby process and using some type of inter process communication vs just running the program with each request?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:12 PM
Quote:
Originally Posted by Wolfram
I'm confused why it's not. Doesn't github back up their servers?
A backup system keeps multiple versions of your files and allows reliable recovery. Backups allow you to recover specific versions and receiver from human error. Backup protects from malware and hardware failure (don't sync corrupt data).

Nothing wrong with cloud storage for syncing, convenience, and some redundancy, but it's a proper backup.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:13 PM
*not a proper backup.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:18 PM
Dave, I think you're missing something.

With a = [1, 2, 6] and b = [0, 1, 3, 4, 5]

The b' that results in the smallest diff is [1, 3, 5]

Plugging in to their diff formula you get |1 - 1| + |2 - 3| + |6 - 5| = 2

I don't know where you got that 1,1,3,4,5 **** when they gave you a, b, and the optimal b' for their diff algorithm
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:21 PM
How is it not a backup? It's a Git repository. What history would he be missing?

Edit: To the original question, I'd probably just use a public GitHub repo and move it private later if necessary - especially if there's no real 'secret sauce' in your code like a middle-out compression algorithm. Obviously, don't store any sort of credentials or private information unencrypted in the repo (which is just good advice even for private repos). Nothing wrong with using a GitHub alternative that offers free private repos either.

I wouldn't run my own server. Seems like an unnecessary pain.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:26 PM
Quote:
Originally Posted by blackize5
Dave, I think you're missing something.

With a = [1, 2, 6] and b = [0, 1, 3, 4, 5]

The b' that results in the smallest diff is [1, 3, 5]

Plugging in to their diff formula you get |1 - 1| + |2 - 3| + |6 - 5| = 2

I don't know where you got that 1,1,3,4,5 **** when they gave you a, b, and the optimal b' for their diff algorithm
Yeah this. In the example I posted I think the number of sub-arrays you can make is something like 233! - which is:

96880983124035637644628191427119032733410705766804 8414184152
25561765762804210624629481224430320029511142586282 8673485601
05183527088477325371186685286160118876894338289245 2021980925
74546071969642723246616617867678202922360665112163 7220993214
74343230404599030924937888027299552398154265468854 3556375105
34924861247309970389790443978423417096800652347264 3833033511
64354900418398161431781398827918950400000000000000 0000000000
00000000000000000000000000000000

Or maybe it's (789 - 233)! / 233! or or something. But whatever it's obviously too big to loop over.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 03:35 PM
Quote:
Originally Posted by daveT
From the example:

a = [1, 2, 6] = [1, 2, 6, 0, 0] (I think?)

b = [0, 1, 3, 4, 5]

The result is [1, 1, 3, 4, 5]? Where are they getting two from?
some definitions would make the problem more clear

Quote:
In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
the two sequences have to be the same length to find their distance

a = [1, 2, 6]
b = [0, 1, 3, 4, 5]
we find b' = [1, 3, 5] so 1-1 + |2-3| + |6-5| = 2

I thought about greedy solutions for a while before realizing its a weird twist on the https://en.wikipedia.org/wiki/Edit_distance which has dynamic programming solutions.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 05:20 PM
Yeah the problem is crying out for dynamic programming, and something similar to that edit distance approach should work, not much of a spoiler but this should amount to
Spoiler:
Storing the best outcome of a[j:] in b[k:] and then filling that matrix.

I wonder how this compares to what I would do as a human--greedily shuffling the smaller array along the larger one but it would take some effort to understand whether that's any more efficient or just amounts to the same thing. Idea would be to start by greedy selecting the partner for the last element of the shortest array (and continuing recursively), and, once establishing the best possible there, the next candidate would be for the "next best" assignment for the last event of a. It might amount to the same thing, but would take a little more work to nail that down.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 06:17 PM
Why do all digital picture frames suck so bad? I've spent the last hour on Amazon and eliminated every one due to stuff in reviews like "Shuffle isn't actually random, it's the same order every time" or "Defaults to built-in memory every time it comes on, even though SD card is plugged in". Argh.

All I want is basically the iPad photo app with SD support and wall power option:
  1. 8-10" screen
  2. SD card support so I can swap out different picture sets
  3. swipe to next picture/previous picture
  4. video support
  5. slide-show mode with pictures are shown in predetermined order at configurable interval
  6. shuffle mode where random pics are shown at configurable interval
  7. can run battery power OR wall power
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 07:58 PM
Get a cheap tablet?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-29-2016 , 09:16 PM
Quote:
Originally Posted by suzzer99
Interesting looking coding challenge that showed up on my FB feed with the clickbait title "94% of coders can't do this w/o using brute force": https://codefights.com/challenge/Qjts7cukDvYpDW4Bc
Diff Seems close to a Euclidean space distance calculation. I don't know if that gets us closer to a better solution as Google is failing me right now.

Edit: right after I posted I realized this should help us because we can use the closest point algorithms which are O(N Log N) time where

N = number of a length sub-sequences in b + a

Basically we treat the sub-sequences of b and the whole list a as points on an n dimensional plane (where n is the number of elements in a and the subsequences of b).

Does use dynamic programming and divide and conquer I think.

Last edited by just_grindin; 10-29-2016 at 09:31 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m