Skip to main content

Posts about python (old posts, page 2)

Recurse Center, 2014-07-22

Mel's talks

  • Mel's talk in the morning was brilliant! I wonder why it's not a part of recommended reading for Hacker Schoolers, or referred to, in the manual.
  • Logically, it makes sense that Mel came now, so that she didn't have to come twice to talk to the firsts and seconds, but it would have been great to have had this talk in the first week of Hacker School!
  • Mel gave us a lot of new information and insights into education and learning styles. I also like the fact that she gave us all a good vocabulary to think about and discuss stuff related to learning. I will try to think, and apply as much of this as I can, for the rest of my time here.
  • She talked about test driven learning which seemed very interesting. Instead of just saying, "wow that would be an interesting thing to do", stop for a moment, think about what you are trying to learn, and how you will assess if you have learnt what you wanted to, and then dive into the project.
  • The learning styles workshop was pretty good too, though I feel like I don't know myself well enough, and I unable to properly "bucket" myself. Later, I took a quiz, and ended up fairly close to the middle, in all the dimensions.
  • Mel introduced us to the idea of cognitive apprenticeship, and encouraged us to try out the different modes when pairing. I really liked the idea of Zone of proximal development and I will try to take the advice of spending most of the rest of my time here in this zone.
  • Do I (really) care? Motivation and mindset, …
  • Be courageous!

Airplay and Raspberry Pi

  • I was trying to wrap libshairport and use it on the RPi to be able to listen to songs being streamed on Airplay, and use that data to drive the LEDs.
  • Shairport, a tool written in C seemed to work. My attempts to wrap libshairport, which is a fork of shairport converting it into a library, failed miserably.
  • The trouble was essentially getting Airplay to discover my service. I tried a bunch of things with pybonjour and avahi, but wasn't able to get it right.
  • Finally, I tried just announcing the service with shairport, and actually running a python script that wraps libshairport to listen to the data. But, this didn't work and iTunes complained that this Airplay device is not compatible. Before going much further with this, I found shairplay which is a tool similar to shairport, but came with a library, and also Python bindings! I happily used this to get stuff working!
  • I'm interested to see today, what exactly I was missing yesterday!

Emacs club

  • I demoed org-mode to a bunch of people for about half an hour, and it was good to see people being blown away by what it can do, exactly the way I was, when I first came across it.

Today

  • Work on RPi to clean up a few things for the party.
  • Compare libshairplay and libshairport to see what I was doing wrong, yesterday.
  • May be write up the whole thing, and make the code available.
  • Learn a little bit about Parsers from rntz.

Recurse Center, 2014-07-21

Yesterday

  • It was exciting to have so many new Hacker Schoolers in the space. But, the excitement was kinda distracting too.
  • I spent most of the day looking at shairport, and libshairport and trying to wrap it, so I can use it to get data for the spectrum analyzer via the Air-play protocol. I was able to call it using ctypes, but it doesn't seem discoverable.
  • I also briefly looked at Julia and dwm, to try and port dwm to Julia. It doesn't seem like too much work, but is going to take me a while given how comfortable I'm with both Julia and C.
  • Yaron Minsky's talk on distributed systems was a great introduction to Distributed systems.
  • After the talk, I spent a little time updating my notes from an old org-mode workshop to present it at the emacs user group meet up today.

Today

  • I hope to get the spectrum analyzer to use libshairport and be able to play music sent through Air play.
  • Spend some time talking to the emacs user group about org-mode.
  • If I have any time, after getting this to work, I may play around with the dwm port.

Recurse Center, 2014-07-20

Saturday & Sunday

  • During the weekend, I had this idea of building a personalized "radio" for myself using a Raspberry pi. The idea is to have a service where all my bookmarks, and feeds are accumulated to, instead of eating up valuable browser tab real estate. And then, I could use a Raspberry pi to randomly play content off of it, based on a theme.
  • I worked on getting things together for it, during the weekend. The project is more like a "thing that needs to be done", rather than something that puts me out of my comfort zone, atleast as far as I can see. So, I'm just going to work on it as a background thing, between other projects, etc.
  • Festival seemed OK initially, while I was trying things out, but when I actually used it to read me a blog post, it was really terrible! I tried demos of a few commercial tools, and they seem much better than what festival had to offer. I wonder what it would take to get Festival, up there. I tried using Google's translate service's tts (unofficial API) and it seemed so good! But, it limits each request to 100 bytes, and the audio will have to be downloaded via the Network.
  • Madhu pointed me to MaryTTS, which seemed to be an active project and it seemed to be much better than Festival, though not as good as Google's tts. I'm going to try getting it to run on a Pi, next.

Monday

  • I don't really know what I'm doing to work on, today. I have been playing around with the Pi, for the past week-ish, and it has been fun! Kyle and I will probably work more on tweaking it, to get it to work the way we want it, for the party!
  • I also did a little bit of Julia with Sean, and it was fun. I may try playing around with it, a little bit, but not sure what to work on. May be continue working through the think-complexity book using Julia?
  • Or jump into something I totally don't know about, inspired by listening to Julia Evans' podcast for Ruby Rogues. I just got this idea of trying to write a window manager to understand how X works, and what wayland is… I could try porting dwm or i3wm to Julia.
  • There's a whole new bunch of excited Hacker Schoolers in the space, and its very exciting!

Recurse Center, 2014-07-17

  • Kyle and I did a demo of our spectrum analyzer/visualizer during the presenations. It was fun to work on, though we mostly just followed a tutorial on the web, and made use of a bunch of libraries.
  • I spent the night in HackerSchool.
  • I was cleaning up the code in the tutorial we were trying to follow.
  • Also, cleaned up the install.sh used by lightshowpi project to not do all the ugly sudo setups, and use a Python virtualenv and install into that.
  • Refactored the ugly looking music part of the tutorial into a smaller script with only the functionality that we were going to use.
  • We hit an interesting bug that would light up all the LEDs on the strip, once in a while. I didn't notice it during the night, because I had a "decay" factor (the max factor by which the height of the columns should get reduced between successive updates) was 0.9, but when the decay factor was reduced to a lower value, it would happen quite often. Also, we didn't see this happening before. So, we thought the bug was in the code I had written, when I should have been sleeping. After reading and debugging my code for a bit, with Kyle and Sean, I thought it was something hardware related that we were doing wrong. But, it turns out that a library we were using lit-up the whole strip, when start and end values were both zero, instead of not lighting up anything!
  • Also, we hit another off-by one error, just before the demo. I didn't do the math for splitting the strip into columns too carefully, and we hadn't noticed the off-by one error until we taped up the strip into different columns on a pillar for demo.
  • There were some cool presentations by others. I'll update the list on Monday, since I currently don't remember them all! Looking at the list of names on the registration sheet would help!
  • The cleaned up code is here

Recurse Center, 2014-07-14

  • Monday morning checkins for our group had only two people. That was strange! Very strange!

Work on cinspect

  • I wrote up a README since David (an alum at Hacker School) showed interest in the project. But, he probably isn't that interested anymore since the code base is Python2.x only.
  • I got rid of assumptions that method names would start with the module name or the type name, and actually look up references to the names in the definitions of types or objects.
  • I also improved the test-suite to actually download sources of CPython and index them. They take very very long!!
  • I tried to get it working with Numpy, but getting all the headers to include wasn't as easy as I assumed it would be!

Recurse Center, 2014-07-11

  • I didn't spend much time at Hacker School on Friday. I reached a bit late for the start of "Recursion day", and did a few problems. The problems were simple, but interesting. After lunch, I headed home to start to Philly.
  • Later in the day, I did some refactoring of the code to have the index reader and writer split out.
  • I also added a setup.py to be able to install the package using the standard tools instead of PYTHONPATH hacks and stuff.
  • During the refactoring, I again hit this bug. I found out from Pankaj that he has from __future__ import print_function, absolute_imports at the start of his files these days. I think I'm going to do it, too.

Saturday & Sunday

  • I didn't do much during the weekend. I ended up adding a TXT record for SPF for this domain, to work around Gmail marking bulk mails for the childrens-park newsletter as spam. I was able to send one newsletter, but not sure if only the SPF is enough or I'll have to setup DKIM, and other stuff. (I don't understand most of these acronyms!)
  • Someone mentioned http://github.com/kennethreitz/autoenv on Zulip, and I really liked the idea. I have started using it for a couple of projects and also got rid of a couple of my bashrc aliases, and created a new project command with completions of the directories in my project directory. I like this setup, as of now.

Recurse Center, 2014-07-09

  • Unicode issues: it turned out that (atleast) one of the files had a character that wasn't UTF-8 encoded. I got around it by trying 'utf-8', if not falling back to 'iso-8859-1'. Now that I think about it, I should fallback to 'utf-8' with replace, if that doesn't work either.
  • I did a little clean up on the way the indexes were stored, to be able to have a getfile, to mimic inspect's API.
  • I also "improved" the IPython startup script to monkey-patch the source code formatter/colorizer to not break with C modules.
  • The one-on-one with Allison was pretty useful, and I feel a little more relaxed now.
  • I paired with Kyle to get streaming audio working for his OSX app. It doesn't work yet, but we made progress! Hope to get it working today.
  • I spent the late evening trying to refactor some of the code and clean it up.
  • Also, updating the py-clang code to the latest version fixed the issue of unknown cursor kinds.
  • I may present my project in today's presentations!

Recurse Center, 2014-07-08

  • I had gone to the emacs weekly meetup, and Samer demonstrated some of the things he liked, and discovered recently.
  • Stopped worrying too much about what the best way to index the data was, and just went about getting the tests running one by one. There is still a small hack, but I got all the tests running except the source for modules.
  • At the end of the day, I thought I had the code to get all the tests passing, but I hit some unicode issues with json serializing, and don't have all the tests passing, yet.
  • I paired with Kyle to work through a simple example to generate a note of a specified frequency.
  • I spent some time reviewing my first month here, and wrote up some notes in preparation for the one-on-one today with Allison.

Recurse Center, 2014-07-07

  • As preparation for a one-on-one this week with one of the facilitators, I was wondering if I was really getting better as a programmer, by doing what I am doing.
  • I have heard at numerous places that reading and reflection are keys to getting better. I feel like I haven't been giving these things much attention in the past couple of weeks. I don't catch up on reading all the awesome reading material shared on Zulip and I switched from writing this blog post first thing in the morning, to any-time-after-lunch. I don't think this worked out very well. Writing the post worked as a way to reflect on what I had done yesterday, and what I should be doing today. So, I am back to writing the blog post, first thing in the morning!
  • Yesterday, I worked on indexing the Python sources in a way that the inspection code can look up, later. During this process, I found that my code to use libclang's AST wasn't generic enough, and I had to clean it up to be able to extract useful information from any file in the cpython sources.
  • We also got to attend a super-awesome talk by Steve Labnik! He talked about his progression from being an application developer, to writing libraries, to working on languages (as a professional developer). He made a lot of interesting and inspiring points during his talk. Some of those that stuck with me are:
    • None of these is particularly harder than any of the other. Depending on each person's personality, or the way their brain works, they are good at doing one or the other.
    • Getting good at programming is a matter of showing up, more than about the "genes". He repeated quite a few times that he disliked the idea of "baby hacker", and left out the story of his childhood and college programming days! I'm totally stealing his idea of meeting every saturday at 1pm, with a bunch of friends and working until it was 10pm or so, when they could get cheap beer and food! And he did this all through his college! It is interesting that this idea is so similar to Hacker School!

    It was a very enjoyable and inspiring talk on the whole.

  • The plan for today is to actually have the parsed information dumped into some persistent format, and modify the inspect code to actually use it.
  • I will also be pairing with Kyle for a few hours on working through some of http://mitpress.mit.edu/books/audio-programming-book

Recurse Center, 2014-07-06

I took it easy during the weekend, and went on a nice camp with my a cousin's family to TobyHanna State Park for a day or so, and spent the remaining (long) weekend at their place in PA. It was a pretty nice break!

Yesterday evening, I talked to Madhu about how ugly my code looked while I was trying to use libclang, and he told me that he found a lot of wrapped C++/C libraries end up being that way, and I also realized that using the Python AST library seemed much cleaner, because it just contained Python objects, but representing C/C++ objects in an AST and interacting with them in Python, isn't that clean.

I cleaned up my code, and removed all the ugly regexes to use libclang to do the parsing of the libs, and get the source code. I basically got all the tests passing, but they were taking an order of magnitude longer to run. So, I guess the next step is to cache things somehow.

I also added support for viewing the sources of built-in types. It was pretty simple, once I had everything working with libclang.