Search found 2197 matches

by TheChewanater
Fri Mar 14, 2014 12:32 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

FT: Python 3.x generators can be silly sometimes. Like, I get why it does this, and that I should really just use list comprehension, but still. with open('test.txt') as f:    lines = map(str.upper, f)print(''.join(lines))  $ python2 ./test.py FOO BAR BAZ $ python3 ./test.py Traceback (most recent c...
by TheChewanater
Mon Feb 24, 2014 6:17 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

by TheChewanater
Thu Feb 13, 2014 6:42 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

Okay, so no one's done this yet.

http://xkcd.com/414/ http://xkcd.com/1329/

mistranslations.png
At first I was making fun of it, but joke's on me--the deer is surprisingly kinky, especially the kicks.
by TheChewanater
Fri Jan 31, 2014 2:28 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

http://xkcd.com/934/ http://xkcd.com/889/
turtlepc.png
turtlepc.png (5.58 KiB) Viewed 6521 times


EDIT: Another.
EDITEDIT: Fixed the answer key, thanks teelo.
http://xkcd.com/1044/ http://xkcd.com/889/
romneyturtle.png
by TheChewanater
Fri Jan 17, 2014 7:33 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

teelo wrote:Some weird turtle fetihes up in here :lol:

What can I say? My copy of the Kama Sutra has a few mistranslations in it.
by TheChewanater
Mon Dec 30, 2013 7:56 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

I love light-on-dark for everything. I even use the dark reddit theme. If only I could theme the whole internets. I mean, you could technically do this. It looks kind of bad on some websites, though. // ==UserScript==// @name          Dark// @grant         none// @description   Make everything dark...
by TheChewanater
Mon Nov 18, 2013 5:09 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

I recently realized that my current project would be incredibly simplified if I had an open source units and measures library (like JScience or Boost.Units) for both C++ and Java with the same API. Kind of a shot in the dark, but does anyone happen to know of a solution? I might just make my own and...
by TheChewanater
Sun Nov 10, 2013 6:08 am UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

This one seems kinda obvious now that I think about it.

newssw.png

http://xkcd.com/414/
http://xkcd.com/1288/
by TheChewanater
Tue Nov 05, 2013 1:00 am UTC
Forum: Coding
Topic: Daft Punk - experiment in efficiency
Replies: 34
Views: 16630

Re: Daft Punk - experiment in efficiency

This is only 220 characters. Some messages are wrtten to stderr, but the same lyrics are printed to stdout as before. (base64 -d|gunzip)<<<H4sICJVBeFICA291dC50eHQAvc49DsIwDAXg3ad4B+ASIEBlKB0AdY6E+VGlWrJDz4+dNBM7Q2Jbid7nUXTCKVOfJo66lzYZbkZd0jsr7ThnL8dkUS5ZZX5604syrq80UycfpcHPmRd/OMS1fcTnMYC30bC04d8aa...
by TheChewanater
Sun Nov 03, 2013 11:32 pm UTC
Forum: Coding
Topic: Daft Punk - experiment in efficiency
Replies: 34
Views: 16630

Re: Daft Punk - experiment in efficiency

Nice one, but I can play dirtier. :twisted: 147 characters. r=str.replace;print(r(r(r(__import__('urllib2').urlopen('http://goo.gl/4KvLMV').read()[20960:23114],"<p class='verse'>",''),'</p>',''),'<br/>',''))  Inspired by StackSort , this beautiful piece of code requires Python 2.7, and will probably...
by TheChewanater
Wed Oct 30, 2013 2:21 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

http://xkcd.com/1284/

sw.png
I'm always installing tons of weird experimental keyboards because they enhance my productivity.
sw.png (24.74 KiB) Viewed 13687 times
by TheChewanater
Thu Oct 10, 2013 2:45 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

http://xkcd.com/587/
http://xkcd.com/1275/

number3.png
number3.png (9.55 KiB) Viewed 7392 times
by TheChewanater
Mon Sep 30, 2013 7:13 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

Well, this is fun.

Code: Select all

void magic(x) int* x; {
    (*x)++;
}

void foo(int* x) {
    magic();
    
    printf
("x = %i\n", *x);
}

int main() {
    int x = 10;
    foo(&x);
}
 
by TheChewanater
Tue Sep 10, 2013 12:36 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

Never ran that unit test. Just killed eclipse, checked in the damn code, went home, and let the continuous integration server run it. That's the spirit. Unit tests are for wimps. Real programmers know when code they've written is correct, they don't need no unit tests to confirm what they know in t...
by TheChewanater
Sun Sep 01, 2013 6:56 pm UTC
Forum: School
Topic: Your Schedule
Replies: 655
Views: 162342

Re: Your Schedule

Freshman CS major at WPI, where we have 7 week terms with usually 3-4 classes per term. A term: MA 1024 (Calculus 4) ES 2501 (Intro to Statics) SD 1510 (Intro to System Dynamics) PE 1117 (Pep Band) B term: MA 2051 (Differential Equations) CS 2102 (OOP Concepts) MU 2730 (Jazz Theory) PE 1117 (Pep Band)
by TheChewanater
Mon Jul 08, 2013 1:35 am UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 556589

Re: The "IT DOESN'T WORK!" thread

If you're doing this more than once, I think decorators are a more Pythonic solution. def default_empty_list(f):    return lambda l = None: f([]) if l is None else f(l)@default_empty_listdef foo(l):    l.append(10)    print lfoo() #prints [10]foo() #prints [10]foo([42]) #prints [42, 10]foo([666]) #p...
by TheChewanater
Wed Jun 19, 2013 2:55 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

FT: I really shouldn't find this UI code as funny as I do.

Code: Select all

  setTouchable(Touchable.childrenOnly); 
by TheChewanater
Wed Jun 12, 2013 11:18 am UTC
Forum: Mathematics
Topic: get to the current xkcd comic with next and random button
Replies: 26
Views: 6647

Re: get to the current xkcd comic with next and random butto

Wow. That's intriguing. So if I land on 1173 and start hitting Next, I'm committing to 50 more turns. If I hit Random, the odds are still good that it'll be around 24 more turns. But isn't that equally true for 1174, though? I mean, more simply, isn't the threshold going to equal N less the expecte...
by TheChewanater
Mon Jun 10, 2013 5:56 pm UTC
Forum: Mathematics
Topic: get to the current xkcd comic with next and random button
Replies: 26
Views: 6647

Re: get to the current xkcd comic with next and random butto

(Note: I did not read every other reply) Okay, I'm assuming for this that the threshold idea is true. The best solution involves hitting random until you get to a certain threshold (determined as a function of N), and then you just hit next over and over again. So, I tried running a simulation in Py...
by TheChewanater
Sun Jun 09, 2013 7:28 pm UTC
Forum: Coding
Topic: Reading a file as it is written
Replies: 7
Views: 3507

Re: Reading a file as it is written

You could inject your own fwrite() that prints a line of text for each call, then run it with LD_PRELOAD and pipe stdout to your script. The advantage to this is that it doesn't require you to redundantly read and write from the harddrive, but the disadvantage is that it won't work well if the progr...
by TheChewanater
Tue May 21, 2013 11:57 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

TheChewanater: What are you using to learn Haskell? I am going to learn it for a project this summer, and am looking for a good tutorial. My friend has pointed me to Real World Haskell, but I am looking for alternatives in case it doesn't work well for me. From what I've seen, most tutorials are ju...
by TheChewanater
Sat May 18, 2013 10:02 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

FT: I just started learning Haskell. Is this sort of thing considered evil? data PointFunction = GetX | GetY | GetLengthmakePoint :: Float -> Float -> PointFunction -> FloatmakePoint x y GetX = xmakePoint x y GetY = ymakePoint x y GetLength = sqrt (x*x + y*y)main =    let point = makePoint 10 20 in ...
by TheChewanater
Wed May 15, 2013 5:07 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

So I have an idea for some silly/absurd what-if questions that don't really need answers. Is this the right place to post them? Should I: - Post them in this thread - Make a new thread titled "ITT: We make what-if slightly worse." - Not post them at all and be ashamed for bringing this up...
by TheChewanater
Thu May 09, 2013 2:40 am UTC
Forum: Coding
Topic: So I just had a "magic"/"more magic" moment today.
Replies: 14
Views: 22523

Re: So I just had a "magic"/"more magic" moment today.

You can put the program in a here document. #!/bin/bashpython -u << 'EOF'print 'test'EOF The disadvantage is that you will not be able to use stdin within the program. The cool thing, though, is that you can use it with lisp interpeters that normally don't work with shebangs because # doesn't start ...
by TheChewanater
Tue Apr 23, 2013 7:44 pm UTC
Forum: Coding
Topic: Daft Punk - experiment in efficiency
Replies: 34
Views: 16630

Re: Daft Punk - experiment in efficiency

Some thoughts on this: Don't need the outermost square brackets - str.join(a for b in c) is the same as str.join([a for b in c]), and two chars shorter int(c,16) is shorter than eval('0x'+c) The list of words could be built shorter by "Work it,harder,Make it,etc".split(',') I'm pretty sur...
by TheChewanater
Mon Apr 22, 2013 9:16 pm UTC
Forum: Coding
Topic: Daft Punk - experiment in efficiency
Replies: 34
Views: 16630

Re: Daft Punk - experiment in efficiency

Python version. EDIT: Got it down to 348 characters. print(' '.join([['Work it','harder','Make it','better','Do it','faster','Makes us','stronger','More than','ever','Hour','after','Our','work is','Never','over'][eval('0x'+c)]for c in'024613578acf9bdf0246...
by TheChewanater
Sat Apr 20, 2013 9:42 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

Fine, I'll do it.
integration by parts.png
integration by parts.png (4.99 KiB) Viewed 17454 times

Alt: But usually not.

http://www.xkcd.com/1201/
by TheChewanater
Mon Apr 08, 2013 8:58 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

This doesn't use a tuple, but I think it has the same type-safety you're looking for. #include <iostream>#include <array>struct FooBase {};template<size_t N> class Foo : public FooBase {public:    void do_something() const {        std::cout << "Foo<" << N << ">\n";    }};template<size_t N> class Fo...
by TheChewanater
Fri Apr 05, 2013 3:31 pm UTC
Forum: General
Topic: ITT: We make xkcd slightly worse.
Replies: 8668
Views: 1797995

Re: ITT: We make xkcd slightly worse.

flowchart.png
flowchart.png (13.49 KiB) Viewed 13081 times

http://www.xkcd.com/1195/
by TheChewanater
Wed Feb 06, 2013 6:28 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

I've done a D&D-like game in Python before, and I used a dictionary to store abilities, with the abbreviations as keys. This made it possible to access abilities without using reserved words, yet still have it clear what they are. In other words, "character.str" would use a reserved wo...
by TheChewanater
Thu Oct 18, 2012 10:50 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

Does anyone know where I can find a list of every Unix/Linux/Posix time function? I'm doing some weird stuff with LD_PRELOAD, but it seems like every application uses a different API for getting the current time.
by TheChewanater
Wed Oct 17, 2012 6:19 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

Why do we need pointers to elements when iterator::operator* returns a reference? #include <iostream>#include <vector>void foo(int& i){  i += 5;}int main(){  std::vector<int> v = { 1 };    std::cout << v[0] << std::endl; // Prints "1"    foo(*v.begin());    std::cout << v[0] << std::endl; // Pri...
by TheChewanater
Sun Aug 12, 2012 3:47 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

On an unrelated note, I'm looking at GLM , and while they've done some cool things (like implementing swizzling), I can't get over how they did it. They hard coded all possible arrangements of vector elements when swizzling, and they could do this because they wrote separate classes for four separa...
by TheChewanater
Sun Jul 22, 2012 4:53 pm UTC
Forum: Forum Games
Topic: Picture Pwn4ge!
Replies: 8368
Views: 1200489

Re: Picture Pwn4ge!

Image
by TheChewanater
Thu May 17, 2012 7:03 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9979
Views: 1976582

Re: Coding: Fleeting Thoughts

Ok, cool. I have a question though. Is this acceptable? fun(Foo* x) { unique_ptr<Foo> point(x); } fun(new Foo()); ? It seems to me that unique_ptr should destroy x when it goes out of scope, but since x is being allocated in the function call, I'm not sure that I understand exactly what goes on, an...

Go to advanced search