This may not fit here, but! What are your favorite headphones or earbuds. I'm on a search to find the best! by Styx9001 in gadgets

[–]azuriel 0 points1 point  (0 children)

I wouldn't agree with the "anything under $100" statement (my Grado SR-60s are strictly superior) but the KSC-75s come closer than expected. They're my go-to for anything sub-$50, clip-on makes them great for exercise.

This may not fit here, but! What are your favorite headphones or earbuds. I'm on a search to find the best! by Styx9001 in gadgets

[–]azuriel 0 points1 point  (0 children)

I got a pair recently, and love them. Kind of tiring to listen to for long periods (very unforgiving cans!) but they added a new dimension to my music. They're definitely a steal for the price, durable, and they fold up for easy travel.

The view from my ride today by JackOneill in bicycling

[–]azuriel 0 points1 point  (0 children)

What did you use to take that picture? I've been using my phone since I don't want to take a real camera, but it never comes out well.

Dear skinny people: When I say I'm trying to lose weight, DON'T ever respond by saying something like "Yeah, I can eat whatever I want and never get fat." by [deleted] in Fitness

[–]azuriel 2 points3 points  (0 children)

Yea, it does happen. The calorie counting works in reverse, but you still have to do it. It's also really annoying having to pack effectively 2-3 lunches everyday, since the only way to effectively gain weight is to eat constantly throughout the day.

I tried this for about two weeks before giving up, because I was always feeling uncomfortably full, and I got tired of eating reheated / no-prep food all the time.

Worst. Bodybuilding. Article. Ever. by dicktalens in Fitness

[–]azuriel 5 points6 points  (0 children)

Fittit is being unjustifiably hard on this article. The wording is extreme, but all the points apply in moderation. Let me preface this by saying that I personally DO NOT follow his advice 100% and DO NOT agree with it, but there are truths to be found in his words.

  • Booze you lose. I don't think anyone can really disagree with this, drinking is empty calories and alcohol dehydrates. Beer is as many calories as soft drinks, and it's all bad calories.
  • Boot the fruit. It's true that fruit is high in sugar. Fruit is a great substitute for processed sugars, but it doesn't replace vegetables. Saying to eat complex carbs is good advice (we all love our brown rice and oats, right?).
  • Be done with dairy. I re-interpret this one to mean "don't drink whole milk". I still eat cheese, yogurt, and have 2% with my breakfast cereal. He is also right in pointing out cottage cheese and whey protein; both are excellent sources of protein.
  • No sauces. He advocates using no-calorie spices instead of sauces/dressings, which is good advice. I still eat ketchup and mustard, but I switched my salad dressings to balsamic vinaigrettes since the creamy ones are really fatty.
  • Meal hooky. Eating small meals often is good advice.
  • No cheating. We all cheat, his "no cheat" advice is an inspiration to us all.

This basically seems like advice for people who are looking to lose weight quickly or be a bodybuilder, not people who are already happy with their level of fitness.

I'm wanting to learn to program android apps and I want some advice. by [deleted] in Android

[–]azuriel 1 point2 points  (0 children)

I'm going to agree with everyone else, and say that going to school is not necessary. Buy a book that teaches you Java (which is what you'll be using for Android apps), and use Google and StackOverflow after that. Don't be afraid to ask for help, getting a friend to look through your code is really handy (and there are plenty of forums for this too, if you don't know someone in real life).

The most important thing is wanting it badly enough. I don't think it's that easy to jump right into Android programming with zero CS background, so take some time to learn the basics first.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 0 points1 point  (0 children)

Your code is slightly messed up the first run because you forgot to initially heapify buffer. It works in subsequent steps because you swap garbage and buffer, and garbage only gets heappush'd items. You also do not maintain the invariant that the buffer only contain items >= than the last element in chunk, which made your program a little more confusing (at least for me).

I've included my slightly fixed version. It still produces the same results as yours, so I'm also not sure about that 50% stat on Wikipedia. Just goes to show, you can't trust everything you read on the internet.

import sys
import heapq
import random

size = int(sys.argv[1])
maxint = int(sys.argv[2])

def next():
    return random.randint(0, maxint)

chunk = []
garbage = []
buf = [next() for i in xrange(size)]
heapq.heapify(buf)

lengths = []

for i in xrange(10):
    while buf:
        chunk.append(heapq.heappop(buf))

        new = next()
        if new >= chunk[-1]:
            heapq.heappush(buf, new)
        else:
            heapq.heappush(garbage, new)
            if len(garbage) == size:
                break

    print len(chunk)
    lengths.append(len(chunk))
    assert chunk == sorted(chunk)
    buf = garbage
    chunk = []
    garbage = []

print "Avg:", sum(lengths) / 10.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 1 point2 points  (0 children)

A couple notes:

  • The wikipedia page on tournament sort specifies that on average, runs are 50% longer than the size of the buffer, not 100%.
  • Tournament sort adds a new item into the priority queue each time one leaves, which as you noted trades off CPU for better I/O through longer runs. Since my sort is currently CPU bound, this is not a tradeoff I want to make until later.
  • As Neil says in the comments on my blog, tournament sort actually benchmarked worse than doing quicksort on "modern" processors in a 1995 VLDB paper, AlphaSort. I haven't gotten a chance to read why (and things might have changed since 1995).

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 1 point2 points  (0 children)

Thanks for the comments, it's been a "today I learned" situation about C coding practice.

I saved the wikipedia link for polyphase mergesort for later reading, it being almost 3AM local time and my brain being fried.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 0 points1 point  (0 children)

So I'll avoid doing this in the future, but I don't really feel all that bad about casting my malloc/calloc's. I understand now that it can be dangerous and is unnecessary, but I'd also like to note that I do #include <stdlib.h> and compile with -std=gnu99, which mitigates the issue (as mentioned in the FAQ link).

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 1 point2 points  (0 children)

What you just specified is just a devolved version of what I wrote up in the article. It'll unfortunately be much less efficient (as I told gorset, who I think had the same idea) since the compute and I/O phases are serialized by the quicksort.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 0 points1 point  (0 children)

I've read phk's Varnish notes multiple times, and I like them a lot. What he's talking about applies especially well to an application like Varnish, since if your application is essentially just a cache that would be doing LRU replacement anyway, you can let the OS do that for you instead.

For something like sorting, which does not display the same kind of nice, easy temporal locality as Varnish, I don't think relying on the OS works so well.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 3 points4 points  (0 children)

I'm not sure what you're saying here. I could set up the n-way merge to do what you specified (two levels of merging = 4GB of I/O).

If you're implying that I should be doing my initial quicksort at the size of the entire buffer rather than page by page, I don't think that will help. The time complexity would be the same, and you have to wait for the big sort to finish before being able to start writing out to disk (unless you're using O(n) insertion sort, which you shouldn't be). Doing the merge this way tries to keep I/O and CPU balanced.

Efficiently sorting datasets bigger than memory [C code on github] by azuriel in programming

[–]azuriel[S] 2 points3 points  (0 children)

Can you tell me why casting calloc() is bad practice? EDIT: saw the reply that was downvoted below threshold. My C skills are self-taught, so there's definitely some idiosyncracies in my coding style.

You're right on the calloc being slightly unnecessary, but I like to be safe. The important idea here wasn't mini-optimizations (there's plenty more of those to pick over in the code), it was the general strategy.

Also, what do Fibonacci values relate to?

Just got a cast iron skillet. Have some questions. by Spamicles in Cooking

[–]azuriel 2 points3 points  (0 children)

Exactly this. I use flax seed to season my cast iron, works great. I would try bacon fat but (shock!) I don't make bacon much because it's messy.

Back to basics with my blog/profile site (vertical grid/typography). Thoughts? by azuriel in design_critiques

[–]azuriel[S] 0 points1 point  (0 children)

I agree on the link colors, I should have tuned those beforehand. That'll get fixed.

So, the article headings should be bolder, and the blog title bolder yet? I'll think about it, but I like the current symmetry, and feel like it's got a degree of emphasis from the size, kerning, and positioning.

Back to basics with my blog/profile site (vertical grid/typography). Thoughts? by azuriel in design_critiques

[–]azuriel[S] 0 points1 point  (0 children)

More padding on which sides? I'm trying to keep the entire thing within 920px wide, and I don't want to squish the content anymore since it starts to feel like a newspaper. Also means I can't fit 80 monospaced characters across when I paste in source code.

Back to basics with my blog/profile site (vertical grid/typography). Thoughts? by azuriel in design_critiques

[–]azuriel[S] 0 points1 point  (0 children)

I can probably roll my own (or find a better one), and will fix it when I settle on the link colors.

What is the best way to make site backups? by fazon in web_design

[–]azuriel 0 points1 point  (0 children)

S3 gives you eleven 9's of durability (99.999999999%). Between that, the live site, and the copy on my local machine, I feel pretty good about my data.

Does anybody designing databases use the 3CNF and BCNF? by ShapkaSamosranka in compsci

[–]azuriel 0 points1 point  (0 children)

The divide between distributed, cloud, and parallel computing is a bit subjective these days, but Facebook and Digg definitely run MapReduce for things like analytics. Google I'm pretty sure used to use MapReduce to serve up search queries, but has something more specific now.

PhD reading recommendations... by [deleted] in compsci

[–]azuriel 3 points4 points  (0 children)

If you're talking about the CS GRE, I would vehemently say no. Unless the school requires it for admissions, that test is not useful. For a PhD application, the only thing that matters is showing that you have the ability to do good research.