Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Sun Sep 21, 2014 8:08 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Write Code Every Day
PostPosted: Tue May 06, 2014 10:25 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 7112
Location: Wilts, Englandshire
Not really news, but something I thought I'd post up here for discussion:

http://ejohn.org/blog/write-code-every-day/

John is a lead coder on jQuery, has worked at Mozilla and is currently working at Khan Academy so he knows a thing or two.
I heard about this blog post which sounded interesting, as I'm getting back into coding after a lot of distractions and random work projects that spilled into my home life.

To compress the post to a TL;DR, John say that if we force ourselves to produce some meaningful code every day, even a small amount, productivity goes up and stress goes down.

I'd be interested to hear what you guys think and I'll post back my results if I manage to get in to this mindset.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Wed May 07, 2014 4:29 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3807
Location: South Africa
This is something that I really dig Python for. For a while, after work, I would spend some time learning a new piece of Python and writing some silly thing with it. Came across a lot of useful techniques and it was fun. Don't know about reducing stress though :P The nice thing about Python is that there's very little barrier between thinking and coding. List comprehensions are my current favourite thing to abuse!

For some crypto stuff I was reading about, wanted to generate a one-time pad:
Code:
>>> "".join([random.choice(string.letters) for i in range(40)])
'QWupjDjCKNRLMsOQCwcXAxEWiWmhvXUcMaCiCdqv'


To see if a particular key in a dictionary contains any of a list of words:
Code:
>>> def dfind(dict, key, *text):
...     if dict.has_key(key):
...             return any(map(lambda t: dict[key].lower().find(t.lower()) != -1, text))
...
>>> data = {"a":1, "b":2, "x":3}
>>> data = {"item1": "a few key words", "other items we don't care about":"etc"}
>>> dfind(data, "item1", "keyword1", "keyword2")
False
>>> dfind(data, "item1", "keyword1", "keyword2", "words")
True


Python's really good at parsing text too, in an afternoon I made a thing to parse csv output from my internet banking statements and convert it into a format that was easy to paste into an excel spreadsheet so that I can keep a long-term record of my bank balance.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Wed May 07, 2014 5:57 pm 
Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 364
Location: Here (where else?)
I agree with John.

I work during the week and often have just an hour or less to do some coding in the evening. However after 5 such days, you really did make a few steps. It works best if you have a concrete and relative simple thing you are coding on, sit down, open the editor, and start typing :)

As for relieving stress, I experience that best when programming for a longer time. I push everything out of my mind, except for the programming problem. Afterwards, I get a fresh view on my other troubles :)

@IGTHORN:
List comprehensions eh? :)
They are a bit old, it's generators nowadays. They are a small step from list comprehensions in the sense that they stop creating these intermediate lists, ie your example does really
Code:
t = [random.choice(string.letters) for i in range(40)]
"".join(t)
which works for a list of 40 elements, but for longer lists, it needs a lot of memory to store "t".

Generators are the streaming version of list comprehensions:
Code:
"".join(random.choice(string.letters) for i in range(40))       # Same as you had, but without the [ and ]
Each character is generated and immediately "eaten" by join, no more temporary list storage. You can do the same with a chain of functions using 'yield', leading to pipe-lines. Beazley gave a nice talk about that http://dabeaz.com/generators/
(if you don't know about generators, beware wild rollercoaster ride ahead :) )
While finding that reference I stumbled over his talk about co-routines, which apparently is also generators, in case you want more :)


Sorry but this looks so very bad :(
Code:
if dict.has_key(key):
    return any(map(lambda t: dict[key].lower().find(t.lower()) != -1, text))
map, lambda, and find == -1??? omg
Sorry but I needed to rewrite that to
Code:
return dict.has_key(key) and any(t.lower() in dict[key].lower() for t in text)

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Wed May 14, 2014 9:56 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 7112
Location: Wilts, Englandshire
Well, it's been over a week and I have stuck to the mantra. I've written something every day, whether it's been a minor tweak to the site or some work on exploring OpenGL (again!) with C++.

Some days have been a little tenuous (last night's commit was one solitary line of code, but it took me 45 minutes to work it out), and others have been very productive, but overall it's been positive. As the author said, the pressure is removed and thinking time between sessions means I always sit down with something in mind, even if it's a small task. I'm making progress on converting AMBER to OpenGL3 with proper VBOs and shaders, plus I've cleaned up a few things on the site that have been on my todo list for ages.

It can be a challenge to fit the coding in. My kids are older now and stay up later, plus Monday night is Game of Thrones night, but I would definitely recommend trying this.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Thu May 15, 2014 10:53 am 
Digerati

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1814
Location: burrowed
I thought it's curious. i couldn't make up my mind what i think of the method initially, but i think it's an interesting concept.
I'm usually a bit wary when it comes to productivity methods, but this seems worth a try.

Especially since i've been employed (yes, really!) i don't find the time or enthusiasm to work with code at home, but i very well know the feeling that creeps up on you when you haven'd written a line of code for a few days and it keeps getting worse.
I might try it out, but i cannot fully commit to it since there are days where i dont even get home after work and will only be back late at night, but time management is an entirely different issue.
Maybe i will take the approach and modify it a tad, so i will at least write some code if i'm at home.

I plan to start a new project, yet another one :D, and i have a bunch of things to figure out beforehand. I wanna try to create a design doc that is comprehensive and use milestones for progress tracking, so i'll probably not get productive for a while aside from small tests or prototyping. (networking huzzah!)

Let's see how this goes

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Thu May 15, 2014 12:24 pm 
Ankle Nibbler
User avatar

Joined: Tue Sep 25, 2012 12:57 pm
Posts: 141
Location: Adelaide, Australia
I've been doing a similar thing with Chaotic Rage for a while now. I commit to releasing every three or so weeks. It forces me to keep doing things instead of thinking about getting the implementation perfect; and you can always fix it in the next release, which is only ever three weeks away.

It sometimes slips past three weeks, but never from over-thinking, always from trying to add even more features

_________________
Chaotic Rage - a fast paced, shooter game that's a little odd, but still fun.


Top
 Profile  
 
 Post subject: Re: Write Code Every Day
PostPosted: Thu May 22, 2014 3:22 pm 
Fish Doggy
User avatar

Joined: Mon Jun 27, 2005 4:50 pm
Posts: 1708
Location: Ontario, Canada
My brother and I figured this out too with our game. As long as we tried to get at least half an hour in a day it always seemed like we were actually making progress. Normally half an hour turns into a couple hours and even if it doesn't, at least you tried.

-- Geoff

_________________
In brightest day, in blackest night. No evil shall escape my sight. Let those who worship evil's might, beware my power... Green Lantern's light!
Twitter!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group