Chris2048

Chris2048

16 thoughts; 4 streams
last posted Oct. 14, 2015, 1:02 a.m.
0

I'm a British Programmer.

UK
Joined on Nov. 10, 2013, 10:55 p.m.
get recent cards as: atom

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Brian W. Kernighan and P. J. Plauger in The Elements of Programming Style

5 thoughts
updated Oct. 14, 2015, 1:02 a.m.

Note to self: next time I move, order some moving boxes.

6 thoughts
updated Aug. 17, 2014, 7:45 p.m.

Music? Grooveshark and YouTube now, too hard to maintain a music collection on an actual device, I'm always on the internet when I listen anyway.

On the YouTube front, I strongly reccommend ScottBradleeLovesYa.

I also found Focus@Will to be nice, not sure if it actually helps me focus though.

2 thoughts
updated Aug. 3, 2014, 11:10 a.m.

wrt above ^

I don't know if you'll see this, why not just have messaging between users, and allow references to posts in those messages.

Then either owner can just create a post, quoting the contents of the message they received (perhaps linking to poster's profile, a thought-stream, or a post, or any mix of these) at their own discretion.

i.e. they can make the private discussion public by posting its contents.

That way we don't get the runaway comments section that other sites get, since everything in a TS is still audited and maintained by its owner. comments only get in if deemed relevant, and then only in a form edited for relevance.

3 thoughts
updated July 12, 2014, 10:33 p.m.
3 thoughts
updated July 12, 2014, 10:33 p.m.
2 thoughts
updated Aug. 3, 2014, 11:10 a.m.
6 thoughts
updated Aug. 17, 2014, 7:45 p.m.
5 thoughts
updated Oct. 14, 2015, 1:02 a.m.

Streams by this user that have been favorited by others.

No favorited streams yet.

0

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Brian W. Kernighan and P. J. Plauger in The Elements of Programming Style

0

Is it a bad practice? Perhaps. But it really is fun.

Pythonthusiast! - Flask Biography Tutorial Part XIII

0

Note to self: next time I move, order some moving boxes.

0

I think in terms of building career and skillset, it's important to recognise the difference between being busy, and being productive...

0

Music? Grooveshark and YouTube now, too hard to maintain a music collection on an actual device, I'm always on the internet when I listen anyway.

On the YouTube front, I strongly reccommend ScottBradleeLovesYa.

I also found Focus@Will to be nice, not sure if it actually helps me focus though.

7 years, 11 months ago
0

Anyone know how to define self-contained python function (but not a generator) that returns different values each time it is called ?

e.g.

def somefunc()
    // define here

somefunc() # 1
somefunc() # 2
somefunc() # 3 ...

I guess we'd just need to store state somehow.

I don't think functions can rebind their variables (pass-by-value, not reference), so that's out.

Could a function that can redefine itself directly (acting on the function object)?

Here's something like javascript (state stored in attributes of function) :

def clos():
    def func():
        func.val += 1
        return func.val
    func.val = 0
    return func

foo = clos()

print foo(),foo(),foo() # 1 2 3

Some other ideas; using global variable :

def redef():
    global func
    f = (lambda x: x)(func)
    func = lambda : f()+1
    return 1

func = redef

print func(),func(),func() # 1 2 3

defined as bound method on class instance :

class Foo:
    def bar(self):
        return 0
    def baz(self):
        bar = (lambda x:x)(self.bar)
        self.bar = lambda : bar()+1
        return self.bar()

foo = Foo()

print foo.baz(),foo.baz(),foo.baz() # 1 2 3

And as a static class method :

class Foo:
    x=0
    @classmethod
    def baz(cls):
        cls.x += 1
        return cls.x

foo = (lambda x:x)(Foo)

class Foo:
    pass

print foo.baz(),foo.baz(),foo.baz() # 1 2 3

Mutable (list) to store state (fudged to be able to use lambda...) :

foo = (lambda z: lambda :z.append(z[0]+1)==None and z.pop(0))([0])

print foo(),foo(),foo() # 1 2 3

Any other ideas?

0

Here's another one :

f1 = lambda : 1
f2 = lambda : 2

closure = lambda *x: x
foo, bar = closure(f1, f2)
f2 = lambda : 3
baz, = closure(f2)

# another way to do above
closure2 = lambda *x: x if len(x)>1 else x[0]
baz = closure2(f2)

f1 = lambda : 4
f2 = lambda : 5

print foo(), bar(), baz() # 1 2 3

Interesting how lambdas can make closures.

This also works with regular functions (def); It's the parameters that become lexically bound.

0
class someclass:
    someattr = "foo"
    def somemethod(self):
        #self.y = self.y
        self.__class__.someattr = "bar"
        print self.someattr

someclass().somemethod()

interesting how that commented-out line makes a difference - I just learned a quirk of the python scoping rules.

1

My latest gripe is with Jelly, which advertises itself as “executable XML”. It flaunts this, in fact, as if it were actually a desirable feature. It’s like saying, “hey, look, we’ve got a burrito that you can actually drive!”

Jamis Buck @ Jelly: Scripting for the Soulless

0

when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create.

why the lucky stiff @ favstar/twitter

0

The biggest challenge with managing engineers is they often hide that fact they're behind in the hope they'll make it up without anyone noticing.

J. Tauber @ management/

7 years, 11 months ago
7 years, 11 months ago
7 years, 11 months ago
7 years, 11 months ago
0

I used to run linux directly, and use the console from there (xterm, tended to be the safe choice, coupled with tmux).

Now I run windows from a laptop, and remote into a linux VM. The gitbash console used to be nice for this, but I ended up going with cygwin for the extra programs it supported.

I also used putty (in the form of superputty - tabs and nice cut/paste support).

Having putty style keys (a gpg file of some sort) and gitbash-style ssh (a kind of virtual unix-like fs mapped to windows fs) was a pain, so I decided to just switch to one.

Given that I was going to use cygwin now, putty was out, so I figured on just using the cygwin console, which uses the same fs-mapping as gitbash. that said, it's not the same mapping (different directory), but I believe you can install a cygwin-based version of gitbash? In any case, I'd sooner get the same functionality by copying the gitbash config myself (so I know what's going on), so I figure on just customising the cygwin shell.

Except I discovered ConEmu, which seems better (managing to attach any other window is nice, now I can put my powershell in there, plus any repl I like). Now I can just ssh in to a certain 'dev/hack' workhorse server, from which I run a persistent tmux session (plus a load of other services) and connect to any other server from there.

Still thinking about the security implications of this though.

Also, hackpack is a nice idea.

1

wrt above ^

I don't know if you'll see this, why not just have messaging between users, and allow references to posts in those messages.

Then either owner can just create a post, quoting the contents of the message they received (perhaps linking to poster's profile, a thought-stream, or a post, or any mix of these) at their own discretion.

i.e. they can make the private discussion public by posting its contents.

That way we don't get the runaway comments section that other sites get, since everything in a TS is still audited and maintained by its owner. comments only get in if deemed relevant, and then only in a form edited for relevance.

2

Incidentally, TS is a great service. I guessed what a certain url might be (ala REST principles) and it worked! the url was right!

Shows something was build right!

1

I've tried blogging before, but maybe my standards are too high, because I never see the things I write as good/finished enough to publish. hopefully this excellent service will encourage me to write more, get things out there.

I think I can refine this stuff later if I can just verbalise it first. Then distil in in a proper blog posting - not to knock thought streams though.

0

Found out about JavaScript being 'prototypal' structure, as opposed to Object-Oriented (or at least having proper OO features, if that's too vague). Always wondered if OO was the best ways to handle things.

I mean, we still need things like encapsulation, and modularisation - but do that have to go hand-in-hand with OO practise? Aren't there other ways of achieving these things?

The way general concepts sometimes get folded into OO philosophy, in such a way that they are seen as being defined there reminds me of all those TDD arguments that reduce to arguments about regression testing - you can regression test without TDD, just as you can pursue the four-pillars without OO.

Problem is, you can't learn without making your own mistakes, and how can I know what advantages OO bring, without really trying anything else? At this stage, OO is so mature that any other methodologies would come short from sheer lack of popularity. As such, I can't see the forest for the trees - I can't put OO in context, and contrast it with non-OO easily, without all counter-examples being toy examples.

A such, maybe my scepticism is really a yearning for experience outside my bubble. It's healthy to be aversive to a biased perspective, and natural for any truth-seeking, objective professional to want to step outside their experience (if it's too predominated in one particular aspect) to learn more about the things they might be missing, and get a more holistic grasp of the things they know;

You don't realise you can hear the sound of you own breathing until you enter a quiet room; You don't perceive your own thoughts until you stop and try to be mindful of them; you don't properly understand the concepts/forms given to you, unless you know what else they could have been, and why they aren't that;

This often will require knowledge of their history, the constraints and influences that shaped them, and as such the meaning, philosophy and design decisions baked into their final form - often the forms they where not created (and why that was) is often needed to be known.

BTW - I know this stream (first post here) is a bit ranty, starting from a single thought on JS, and leading to a very general thought - intend to clean this up at a later date. For now, I'll publish or perish!

Thoughts by this user that have been liked by others.

1

I've tried blogging before, but maybe my standards are too high, because I never see the things I write as good/finished enough to publish. hopefully this excellent service will encourage me to write more, get things out there.

I think I can refine this stuff later if I can just verbalise it first. Then distil in in a proper blog posting - not to knock thought streams though.

2

Incidentally, TS is a great service. I guessed what a certain url might be (ala REST principles) and it worked! the url was right!

Shows something was build right!

1

wrt above ^

I don't know if you'll see this, why not just have messaging between users, and allow references to posts in those messages.

Then either owner can just create a post, quoting the contents of the message they received (perhaps linking to poster's profile, a thought-stream, or a post, or any mix of these) at their own discretion.

i.e. they can make the private discussion public by posting its contents.

That way we don't get the runaway comments section that other sites get, since everything in a TS is still audited and maintained by its owner. comments only get in if deemed relevant, and then only in a form edited for relevance.

1

My latest gripe is with Jelly, which advertises itself as “executable XML”. It flaunts this, in fact, as if it were actually a desirable feature. It’s like saying, “hey, look, we’ve got a burrito that you can actually drive!”

Jamis Buck @ Jelly: Scripting for the Soulless