Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "k-means"
-
My boss is technically restricted shall we say.
As the cto I have also been designated office IT guy. Which means apparently fixing the printer. Which is ok I guess. I mean it's bullsh*t but hey.
Anyway, about 6 months ago he said he needed a new laptop. He lives his life in excel and outlook, and even though the whole company uses google docs for everything he still exports everything to excel, makes a copy, then saves it back to drive so everything gets out of sync.
It's a fun problem that I have banned everyone from doing obviously but he continues.
Anyway, anyway, he wanted a new windows laptop naturally. I said to spend about £700 on a decent machine rather than buying something cheap that will frustrate and not last long.
He doesn't listen and gets some old windows 7 machine for £300. It's an alright spec for 2009; he must not have got the memo about it being 2017.
4 months go by and he says he needs a new laptop because this one is too slow (not least because he opens 400 chrome tabs and never reboots his machine). Anyway, I fix the problem of uninstalling all his bloatware and it runs quicker but he has his heart set on a new machine.
He insists.
I suggest he spend the money this time so he literally doesn't buy a new one in 4 months. I suggest the surface book that's £1200. A little overpriced but he will love the touch screen, it's powerful enough and it's windows. Ticks all the boxes for him.
He suddenly decides he wants a Mac.
I tell him it will be a nightmare for everyone if he does that.
He insists.
I suggest the Mac book pro as I've had mine for 6 years now and it's still going strong. It's a little more expensive than the surface but it will last.
He then says he wants the air.
I say they haven't updated them in ages and they aren't actually that powerful.
He insists.
That night he just buys an air from the Apple Store.
WHY THE FU*k ARE YOU ASKING ME FOR ADVICE IF YOURE NOT GOING TO LISTEN YOU MOTHERFUC*er. WASTING MY TIME AND YOURS.
Was very close to rage quitting when he wanted me to back up his old machine but didn't bring in his hard drive and didn't want to put it in the cloud. #whatDoYouWantMeToDoWithYourOldPornCollection
To top it all off I ran some benchmarks and my 6 year old Mac book pro is more powerful than his "brand new" air.23 -
Actual email I just sent to a customer:
"I logged into your account and I see the problem. I will update you and have it fixed either by tonight or tomorrow morning. It is a rare bug we have encountered before, and we are working on it as you read this. "
The truth:
"Im fucking drunk right now. I know that error. I put off fixing it for awhile now hoping it wouldn't come up because it's fucking annoying to fix. I'll try to fix it tomorrow morning, k no promises though. If I can't I'll still have your problem taken cats of it just means I'll have to do it manually. Anyway.. Gonna drink some more now, bye. "
P. S. There is no we. It's just me. K bye.4 -
Remember the post about bruce's constant?(4.5099806905005)
Well apparently theres a convergent series for it found all the way back in 2015.
Apparently its an actual thing. Which connects e to the square root of this series.
And it converges on (bruce-1)**0.5.
I confirmed it myself.
The two people who found the series that converges are N. J. A. Sloane and Hiroaki Yamanouchi
Thank you Sloane and Hiroaki!
The actual formula is a series of embedded square roots with the repeating numbers 1,4,2,8,5,7
like so...
sqrt(1+sqrt(4+sqrt(2+sqrt(8+sqrt...
What this means is you can find e using this series.
All you do is run the series, raise by a power of 2, add 1, calculate J and K like so
J = log(2, 1.333333333333333) / log(2, 2)
K = log(2, 1.333333333333333) / log(2, 3)
then calculate (J+K)-(bruce-1)
and out pops our buddy e:
2.7182818284591317
I guess I bullshitted myself for so long, that I didn't believe people like scor when they said they legit witnessed by math skills grow.
Or maybe a blind squirrel occasionally DOES find a nut.
Pretty cool find either way.13 -
I don't understand people who write "Fu*k" instead of "Fuck", dude everyone know what's that means anyway and you definitely not going to become a Honorable man or you will go to heaven by doing this. Seriously.11
-
How about creating a new programming language named "C slang"
highlights from the language:
1. variable declaration :
by default, all declaration are var, but inorder
to declare a constant, write:
cunt a = 15; // means const a = 15;
2. input and output :
suck(b) // input stored in variable b
spit(b) // output b
3. function declaration:
f**k <function_name>(parameters);
4. null or None will be replaced by sh*t
for example: if(node root == sh*t)....
any other sh**y recommendation will be appreciable6 -
))| THE BEST AND WORST WAY|((
))| TO DELETE A LINE IN BASH |((
(Think you can do better? Vote
now on your phones!)
WORST: Hold backspace until satisfied
BEST: Using a pen or other pointing device capable of causing semi or permanent damage to your screen, count how many characters the line in question consists of. Write this down on a piece of paper (after all, your terminal is occupied) and using long division, or any other means, divide this number by two, rounding as you please. Press the "right arrow" key as many times as necessary to reach the end of the line. This might be 0 - if so, congratulations, you may skip this step! Once complete, refer to your piece of paper, and taking your newly calculated number, press the "left arrow" key exactly that many times. If you have a short attention span or are worried you will lose count, take a tally or use some other primitive count recording method. Once the key has been pressed the correct number of times, hold down either control key on your keyboard and take a deep breath - there's no going back now (!) - press the "k" key (you should still be holding a control key!) and take a sigh of relief. You're halfway there! If you need a break, take one. When you're ready to finish the task, hold a control key again and take another deep breath. When you are ready to complete the task (don't hold your breath too long!) press the "w" key. Congratulations!! Your line has been deleted!! Some may call you a fucking idiot for not just pressing ctrl-w at the start, but don't listen to those people! They probably delete stuff by accident all the time! Now, take a lie down, and give a moment's silence for the poor poor line you just brutally dissected and murdered.
Think you can do better? Vote now on your phones!9 -
In the 90s most people had touched grass, but few touched a computer.
In the 2090s most people will have touched a computer, but not grass.
But at least we'll have fully sentient dildos armed with laser guns to mildly stimulate our mandatory attached cyber-clits, or alternatively annihilate thought criminals.
In other news my prime generator has exhaustively been checked against, all primes from 5 to 1 million. I used miller-rabin with k=40 to confirm the results.
The set the generator creates is the join of the quasi-lucas carmichael numbers, the carmichael numbers, and the primes. So after I generated a number I just had to treat those numbers as 'pollutants' and filter them out, which was dead simple.
Whats left after filtering, is strictly the primes.
I also tested it randomly on 50-55 bit primes, and it always returned true, but that range hasn't been fully tested so far because it takes 9-12 seconds per number at that point.
I was expecting maybe a few failures by my generator. So what I did was I wrote a function, genMillerTest(), and all it does is take some number n, returns the next prime after it (using my functions nextPrime() and isPrime()), and then tests it against miller-rabin. If miller returns false, then I add the result to a list. And then I check *those* results by hand (because miller can occasionally return false positives, though I'm not familiar enough with the math to know how often).
Well, imagine my surprise when I had zero false positives.
Which means either my code is generating the same exact set as miller (under some very large value of n), or the chance of miller (at k=40 tests) returning a false positive is vanishingly small.
My next steps should be to parallelize the checking process, and set up my other desktop to run those tests continuously.
Concurrently I should work on figuring out why my slowest primality tests (theres six of them, though I think I can eliminate two) are so slow and if I can better estimate or derive a pattern that allows faster results by better initialization of the variables used by these tests.
I already wrote some cases to output which tests most frequently succeeded (if any of them pass, then the number isn't prime), and therefore could cut short the primality test of a number. I rewrote the function to put those tests in order from most likely to least likely.
I'm also thinking that there may be some clues for faster computation in other bases, or perhaps in binary, or inspecting the patterns of values in the natural logs of non-primes versus primes. Or even looking into the *execution* time of numbers that successfully pass as prime versus ones that don't. Theres a bevy of possible approaches.
The entire process for the first 1_000_000 numbers, ran 1621.28 seconds, or just shy of a tenth of a second per test but I'm sure thats biased toward the head of the list.
If theres any other approach or ideas I may be overlooking, I wouldn't know where to begin.16 -
I'm a C++/Obj-C programmer finding it ludicrously hard to switch to Swift.
I find that the constant ability (leading to very poor programmer code) to reduce syntax and add tokens reduces readability and nowhere is this more apparent that with closures.
I'm working through (to my shame) Ray Wenderlich's Swift course and the closure chapter has this:
PS I loathe K&R as much as I do Swift so it's all in Allman formatting for clarity.
let multiply: (Int, Int) -> Int =
{
(a: Int, b: Int) -> Int in
// do Something else
return a * b
}
Why oh why isn't this more simply and elegantly written as:
let multiply = (a: Int, b: Int) -> Int
{
// do Something else
return a * b
}
The equals sign shows clearly that it's a closure definition assignment, as does the starting 'let'. But this way all of the stupid excesses, like the 'in' keyword, the repetition of the params / return type only this time with useful labels and additional tokens are removed and it looks and reads much more like a regular function and certainly a lot more clearly.
Now I know that with the stupid ability of Swift you can reduce all this down to return $0 * $1, but the point I'm making is that a) that's not as clear and more importantly b) if this closure does something more than just one line of code, then all that complicated stuff - hinted to by the comment '// do Something else' means you can't reduce it to stupid tokens.
So, when you have a clousure that has a lot of stuff going on and you can't reduce it to stupid minimalism, then why isn't is formatted and syntactically better like the suggestion above?
I've mentioned this on the Swift.org (and got banned for criticising Swift) but the suggestions they came up with were 'use type inference' to remove the first set of params / return type and token.
But that still means the param list and return type are NOT on the same line as the declaration and you still need the stupid 'in' keyword!5 -
heres something interesting:
The golden ratio is 1.618...
If you're not familiar with it, doing 1/goldenratio
the result is 0.618...
It gives you back the float component exactly.
Discovered that it is actually part of a series.
First of all:
2-(((5-sqrt(5))/2)-1) =
1.618033988749895 -> thats our golden ratio
In other words:
(2%gold) =
0.381966011250106
While:
((5-sqrt(5))/2) =
1.381966011250105
Ok, now we're getting somewhere. We can turn these into variables
First of all, lets see if we can get the golden ratio back out:
2-(((5-sqrt(5))/2)-1) = 1.618033988749895
Okay good.
The formula looks something like
j-(((i-sqrt(i))/2)-1)
Where j = (i*2)+1
That means we can easily figure out what j we need from our i value. (i-1)/2 = j
We run it back far enough we get
1-(((3-sqrt(3))/2)-1) =
1.3660254037844386
Thats the golden ratios little brother. Doesn't look anything like it, but it is part of the series.
And I found a boat load of research documents scattered *all* over the net, where this number and others in the series inexplicably crop up in power series, in chemistry, and elsewhere. Just looks like random floats if you don't know better.
We can actually go lower in the series:
0.5-(((2-sqrt(2))/2)-1)
1.2071067811865475
At the lowest positive value for j, we get
0-(((1-sqrt(1))/2)-1) = 1
It's kinda elegant.
I even wrote a little script to do the conversions:
def gr(k):
....i = k
....j = (i-1)/2
....return j-(((i-sqrt(abs(i)))/2)-1)
The dots are so devrant doesn't break pythons formatting.3 -
I went to a machine learning meet up.. I asked every one over there to explain me K-means algorithm. I got K different answers, then I applied K-means algorithm on K different answers to form K clusters..1
-
Reading the internets in 2020, I've seen an increase in the usage of the term "Orwellian." It has led to many Inigo-Montoya moments.3
-
Just finished my finals.
Had to run k-means with pen and paper only. I find this kind of question stupid but why not. BUT WHY THE FUCK DID YOU CHOSE SOME INITIALIZATION THAT TAKES 13(!!!!) FUCKING ITERATIONS TO CONVERGE ? Just in case my first 12 iterations are correct by chance ? Guess what, you fucktard, I GOT IT.
And doing the same calculus by hand 13 FUCKING TIMES is moronic as hell, you retarded piece of shit ! When you train your neural networks, do you also backpropagate your gradient all by yourself, mongoloid baboon? Getting sick of those stupid assignements1 -
OpenSource is fun they said. I being a bored teen thought, ah, another chance to experiment. Discover something new. Now I am into piracy, movies, music, software. If I can get it for free I ain't paying for it. So I went on to GitHub to see what exciting new Repos I could contribute to. I hate already implemented plenty of algorithms in GO for GitHub.com/TheAlgorithms so I was looking something more practical, more beneficial to society. Then I saw it, the perfect repo, not too complex and not amateur. SpotDL/spotify-downloader for downloading songs from Spotify, a grey area coz it's technically piracy. Well not from Spotify, we fetch the info from the Spotify API and search for the songs on YouTubeMusic. They were just about to release v3, a complete rewrite of the codebase stressing code readability and stuff. I spend about a day studying the codebase, trying to findout just where I could make my contribution. I can see outright that there's a huge problem with implementation.
First of all the script spawns 4 processes for downloading songs though you might be downloading only one song. Which means for everytime you run the script you have to wait for 4 other processes to be spawned before any downloading can happen. Sure this is faster when you are downloading more than like 4 songs, but it's actually slower when downloading a single song. But I ignored that coz I assumed that most users download playlists and albums. Anyway we talked with the like lead developer and he was all like, make those PRs anytime you feel like. So I made a really minor first contribution.
I introduced download from Spotify URI functionality, modified like 10 lines of code. I was half expecting that the PR would be merged within hours at most 24 hours coz of how minor of a contribution it was, 5 days in it was pending. So I tagged the lead Dev and he was all appreciative of the PR, calling it real 'clean code' and stuff. 3 more days, the PR is still not merged. I have now stacked 4 more commits to the same PR, I tag the dev and he's like he's waiting to see if my 'feature' will get atleast 10 upvotes so that it can be merged, he links an issue. I go to the issue and my feature is not there, So 11 days after I made my PR I have to write a comment explaining the 'feature' introduced in my PR and then wait for 10 upvotes.
I was like f**k this, I'll just develop on my fork if you want the features on my fork, you will make your own PR! I am so done with OpenSource, development is slow. I have no idea how you guys do it. I can't handle development where I don't have write access.6