How Debuggers Work – thanks Gargi

Uncategorized

After last thursday’s presentations I asked Gargi Sharma, to walk me through the debugger that she wrote for go.  It was super cool and I just going to review the highlights.

First off how does the debugger work….  Well you pass in the binary of the program you want to debug as a binary.  Then you generate a symbol table, which associates an address of memory with a command. This is important because in Gargi’s code when you set a breakpoint you replace the command where you want to break with an INTERRUPT CODE (think ctrl-z) BRILLIANT!  You also need a data structure to map the line numbers to the commands in the symbol table.

But the main takeaway… debuggers (or this one at least) works by inserting an INTERRUPT – []byte{0xCC}.

You could theoretically debug any binary this way, but this code generates a sym table for go, so you can only use it to debug go. If you wanted to debug another language you would need to use the symtable for that language.

Also this code uses some unix based tools, so Gargi runs it in docker on her osx. If you wanted to run it natively on osx or windows you would have to replace these tools such as ptrace.  Ptrace allows the debugger to inspect the code of the process it is debugging.

Gargi also introduced me to ELF. ELF is a format for binary and object codes etc.  It lets you search for a section of code when you initialize your debugger. For example in line 156 of Gargi’s  debugger.go She looks for .text. I assume she knows to do this because of the ELF format. If I am wrong let me know.

Anyway, I am super grateful that Gargi took the time to walk me through this. Debuggers are something I have used for a long time but they were mysterious. Now I know the secret -CTRL-Z!  I forked Gargi’s code and may do some sort of musical debugger experiment. But I highly recommend going over to her github and checking it out. It is only 226 lines.

 

 

Kaggle Deep Dive and Humpbacked Whales

Uncategorized

When I watched the fast ai videos, the instructor said it was worthwhil to just go through a bunch of kaggle competitions, download the data, and the submit the results. So for a while I have wanted to spend a few hours becoming familiar to the kaggle eco system and submitting to a bunch of kaggle competitions and becoming familiar with the ecosystem.   I roped Mari into what became an involved afternoon of data munging,

First we installed the kaggle cli. There were some issues with the the token and the kaggle json as well as accepting terms and conditions for each competition we were interested in, but once we figured this out the kaggle cli is relatively easy. It lets you download data and upload results pretty seamlessly. It does some other stuff but I am not sure what that is.

The first competition we looked at was the digit recognizer.  The sample data is a csv.  I believe it comes from the MNIST dataset, which is a dataset of handwritten numbers. Each line is a id with a list of pixels. The pixels, if drawn out, would contain a number. The ML project is to guess the number. We looked at some examples on how to do this, but most of our experience was with image classification so we put this aside. Also Mari is running fastai v3 (the latest) and there were some inconsistencies with the online samples and the v3 library.

We looked for an image classification project and found the humpback whale identification.  90% of the project involved creating a directory structure to support fast ai and then manipulating the result set data into the right file format.  There was also a fair amount of time training the data and downloading the data.  Also trying to figure out the correct functions to use from the fast ai library to extract labels and what not.

It was very helpful to work with Mari because I got a sense of how to go about tweaking learning rates and freezing layers.  A lot of this is still mysterious to me, and I think fast ai makes it even more mysterious. But it was very useful to go through this project and try and apply the ideas from fast ai.   I would like to work in some consistent kaggle competitions into my programming practice. It is a really different way of thinking, I would not call it programming exactly, but a sort of debugging.

 

 

Programming Prep

Uncategorized

As I am considering what is next for me, a friend has been lobbying for me to interview at google. She sent me a bunch of of programming interview books and told me to talk to coach!

Coaching is something that is fascinating to me. As a high school athlete I never had a good coach, so it was never something I considered. But when I was an adult and I read a bunch of ‘life hacking’ type books, they all extolled utility of a coach. And as an adult I see the benefit, a coach is helpful to learn new skills, to move to the next level in any endeavor, and to pinpoint and work on trouble spots.

When I spoke to this programming coach, she said 75% of her clients were programmers and only 25% were job seekers. This is fascinating. What sorts of issues were they going through?  Some of the issues were regular job issues, that perhaps would have been discussed with a therapist in the past, like how do I promote my work, or talk about a problem, or deal with a difficult colleague. Other issues are how do I deal with a thorny technical problem or learn something new.

We chatted for a bit and she said some interesting things. First, she said don’t do interview prep by doing hundreds of leetcode problems. That is more important to go deep and truly understand a few problems than superficially do hundreds of problems. This actually adds to anxiety, she said. And anxiety is worse than the actual problems themselves. Instead she suggested I get a programming problems book in the language I want to focus on, make a spreadsheet of the hardest 2 or 3 problems in each chapter and every day work for 90 min or on the next problem on the list. Dont spend more than 30 min on a problem. Play with the problem, dont just start coding. Color code the problems. The ones that give you problems make red, and as they become easier make them green. When you can do the problems in your sleep you are ready.

I am really excited to try this. This morning I created my spreadsheet and I am ready to rock and roll.

Kickstarter Creative Residency

Uncategorized

Jesse and I, as part of print all over me are doing a creative residency at Kickstarter. I love kickstarter. I remember years ago when kickstarter was kickstartr and I was like – why didn’t I think of that! Such a great solution to a problem. Print all over me in part started because people were having problems fulfilling kickstarted manufacturing projects.  I love the vibe at kickstarter. The space is beautiful, they have a garden, a library, free kombucha! The people that work there all seem fascinating individuals. Kickstarter has built such an amazing culture – it really something to admire.

At Kickstarter, ostensibly we will be working on a mental health card game based on DBT. DBT is a treatment for borderline personality disorder and cannot be entirely treaded with psychotropic drugs. It is about the dialectic between being who you are and changing.The tag line in something like: You are perfect just the way you are, just change.

However as we are doing this part of me wants to kickstart a line of code metal tee shirts, or gender fluid jumpsuits.

One thing I am going to focus on is conscious computation and a lot of the work I started at Recurse.  At the end of my time there, I am considering kickstarting the prayer blockchain glowing orb!  I am also thinking about the ideas around conscious computation, and some of the ideas around anthropology  – like the idea of prayer tech and perhaps turning that into something, perhaps a podcast, series of classes, or website.

The other residents are fascinating, one person is working on erotica, another on sci fi comics, another on African American farmers,  I could go on. I just cannot wait to talk with the other folks and learn more about what they are doing.

 

Middle – the tidalcycles python mashup

Uncategorized

So I redid the text to voice + poem junk generation + tidalcycles. I need to save supercollider to buffer so you can’t hear my keystrokes. BUT all the sound is made with the text to speech poem generator. Thats cool.

I feel like it starts to pick up at min 1 and you can hear me curse at like  min 3.

But what happened before….

I took a look to see why my text to voice clips in tidalcycles did not work as expected . After some googling I found this great documentation.  To Quote:

As you can hear, Tidal will keep triggering the sample each cycle, even if it’s very long. Even if you stop the pattern playing, you will still need to listen while the samples play out.

This is sort of what I thought I was hearing. So how do we fix that?

something like:

d1 $ sound “bev” # cut 1

repeats the same clip again and again. Also “hush” does not work as expected because it I think needs to wait for all the cycles to finish.

Something like

d1 $ slow BIGNUM $ sound “bev ~” # cut 1

Keeps the clip going throughout many cycles

and

d1 $ chop 32 $ sound "bev"
d1 $ striate 32 $ sound "bev"

Let you play a clip from the middle!

When I went back and listened to all the clips I realize the audio did not record! Riley at RC was correct.

Here are the original clips of the two poems:

I am sticking my config here so I remember:

Quarks.checkForUpdates(); Quarks.install("SuperDirt", "v1.0")

(
s.waitForBoot {
	~dirt = SuperDirt(2, s); // two output channels

        // load samples from multiple folders:
	~dirtloadSoundFiles("/Users/Parmenides/projects/RC/tsamples/
	~dirt.loadSoundFiles("/Users/Parmenides/projects/sounds/*"); 

	s.sync; // wait for supercollider to finish booting up
	~dirt.start(57120, [0, 0]); // start superdirt, listening on port 57120, create two busses each sending audio to channel 0
};
);
SuperDirt.start

Random Lexical Experiments continued -Phonemes and Graphemes

Uncategorized

Poem of the day: It sort of reminds me of the futuristic Hawaiian dialect from cloud atlas.

freckled te mortality
terrible violent wounded great ti take
great mighty veritable
sperm sperm commentator
sperm Norwegian ta wondrous American to certain
American sperm State
dying to Greenland to mistake
Greenland Greenland ke stand
Greenland sperm important
sperm te entire Trumpa Physeter pa momentary
Sperm Greenland ki take
right po sperm pe right right ti distance
sperm humpbacked important
Greenland Greenland captain
Greenland sperm totally
sperm Hyena instant
Tusked involuntarily
Horned te Unicorn Folio ta stand
white white white to white metaphysical
white white te stand
white white ti white Albino po sperm sperm Captain
entire sperm pe sperm white established
white sperm po tallest
sperm sperm po sperm te sperm to instance
right sperm metaphysical
English snowy entailed
true take
Right to stranded living to take
Greenland boiling foremost particular Patagonian
sperm spermaceti sperm stricken ke sperm waning te talk
same heaving understanding
tremendous great beheaded involuntarily
mightiest pa great sperm dead towing tapered
fagged pe sperm tapping
right sperm tar
sperm stricken substantial
wounded potatoes
sunken to sunken first po stricken flying stature
towing whole mountaineers
sperm towing to tablecloth
unborn stricken schoolmaster controverted te unaccountable
drugged other understand
blasted ki other lighter te Dutch slack stricken stayed
sperm white other table
adult last hunted great eternal standing
living last pa dead dead stains
stricken white famous ti white tanning
gliding sperm ki take
white white uncomfortableness
white fatal
white hated before Stammering

What I did was generate a bunch of words via regex in Moby Dick, then find pair of letter frequencies and randomly inject them, and then find word pairs within words and add them to the end of lines. I would like to experiment more with stanzas here and punctuation.

I was chatting with Colin about my python poetic experiments and he said that had built a library a long time ago for rhyming based on espeak (the cool unix version of say).  So what is a phoneme? It is a unit of sound like p or th. When you want to rhyme it is useful to know the phonemes the of word endings.  There is also the  grapheme, that is a way of writing down a phoneme. I was thinking of sound when I generated my poem today. Chapter 3 is about tokenization and fileio and some encoding so it was somewhat useful in this endeavor.

I was really interested in finding frequencies of pairs of words. Here the frequency of ka is 40, of pa 1694 (in I think Moby Dick)).

a e i o u
k 40 2727 930 24 39
p 1694 3122 1124 2372 552
r 3347 11627 4113 4672 863
s 2059 6577 2721 3199 1799
t 3339 6929 4933 7126 1669
v 737 5695 1437 481 18
>>>

Things get interesting when you load in a corpus like:

from nltk.corpus import gutenberg, nps_chat
>>> moby = nltk.Text(gutenberg.words(‘melville-moby_dick.txt’))

So if I want to match a _ whale:

>> moby.findall(r”<a> (<.*>) <whale>”)
dead; great; mightier; right; live; good; southern; white; white;
white; particular; sperm; sperm; sperm; sperm; flying; dead;
Greenland; Polar; sperm; small; dead; right; sperm; DEAD; nursing;
dead; lone; fine; blasted; second; blasted; sick; certain; discovery

or

>>> moby.findall(r”(<.*>) <fast>”)
was; it; they; a; those; him; got; when; got; locked; go; as; still;
iron; was; ;; and; be; making; so; get; him; him; when; party;
technically; technically; her; very; ,; as; walks; himself; my; the;
very; reefed; was; and; ,; held; themselves; hold; now; all; so;
travels

>> moby.findall(r”(<.*>) <blubber>”)
their; and; thousand; “; de; de; of; the; great; of; the; the; the;
the; the; his; That; same; the; or; his; the; the; fresh; the; of;
the; of; veteran; of; shrivelled; of; and; curved

This is fun! Unfortunately this prints to sysout and not to a string, so I need to do some massaging in order to make this actually usable.. BUT

Stemmers is also introduced in ch3. This is how we determine the root of a word, like “go” for “going” there are different type of stemmers and you just have to use the one you like. That is sort of the advice that the documentation gives.  The WordNetLemmanizer returns the word if it is in its dictionary. So for example if go and not going is in the dictionary go is returned.  We looked at lemmas the other day, but lemmas, similar to stemming, remove inflections/endings to return the root word.

I am not sure how this would be interesting poetically.  Perhaps you want to create a rhythm, or use root words at different parts in a line – the endings perhaps.  For languages where words are not divided by spaces, tokenization is more difficult. The analysis of segmentation addresses this and is fascinating. Basically word endings are demarcated by binary strings (1 being end of a word).  One idea is remove spaces from sections of moby dick and reconstitute them based on distribution of word length and sentence length.

Sumana posted this fantastic python library, olipy,  for this sort of poetic generation.  Oulipo is a writing style where you introduce certain constraints into the writing, like writing without the letter e. Christian Bok is one of my favorite oulipo-esque writers.  Look what happens when I google for an article on Bok and Oulipo… an article on Bok Oulipo and Bergvall come up– that my friends is synchronicity – maybe.

 

Small Experiments Continued

Uncategorized

I was not sure what was inspiring to me today. I considered looking at some concrete poetry and a nice collection of ee cummings, but I decided to just go and click around ubuweb.  Here I became happily sidetracked with the films of Agnes Varda – who I love and listened to some Kathy Acker (trigger warnings) it hard to take.  I love the accents of midcentury native new yorkers. I hope I have something like that. A ghost of it perhaps. I finished it all off with some Samuel Beckett as a palate cleanser while coding.

Today I experimented with lexical relationships and text generation. I started with some simple definitions and examples of usage based on the word ‘middle’:  Here is the audio text to speech which is slightly more interesting. I discuss why I did this below.

Middle
it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
a n a r e a t h a t i s a p p r o x i m a t e l y c e n t r a l w i t h i n s o m e l a r g e r r e g i o n
he hit the ball to deep center
t h e p i e c e o f g r o u n d i n t h e o u t f i e l d d i r e c t l y a h e a d o f t h e c a t c h e r
they were raising money to build a new center for research
a b u i l d i n g d e d i c a t e d t o a p a r t i c u l a r a c t i v i t y
a l o w – l y i n g r e g i o n i n c e n t r a l F r a n c e
it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
a n a r e a t h a t i s a p p r o x i m a t e l y c e n t r a l w i t h i n s o m e l a r g e r r e g i o n

a p o i n t e q u i d i s t a n t f r o m t h e e n d s o f a l i n e o r t h e e x t r e m i t i e s o f a f i g u r e

it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
a n a r e a t h a t i s a p p r o x i m a t e l y c e n t r a l w i t h i n s o m e l a r g e r r e g i o n
A whole is that which has beginning, middle, and end”- Aristotle
a n i n t e r m e d i a t e p a r t o r s e c t i o n
young American women believe that a bare midriff is fashionable
t h e m i d d l e a r e a o f t h e h u m a n t o r s o ( u s u a l l y i n f r o n t )

in your heart you know it is true her story would melt your bosom
t h e l o c u s o f f e e l i n g s a n d i n t u i t i o n s
he stood still, his heart thumping wildly
t h e h o l l o w m u s c u l a r o r g a n l o c a t e d b e h i n d t h e s t e r n u m a n d b e t w e e n t h e l u n g s ; i t s r h y t h m i c c o n t r a c t i o n s m o v e t h e b l o o d t h r o u g h t h e b o d y
he kept fighting on pure spunk you haven’t got the heart for baseball
t h e c o u r a g e t o c a r r y o n
t h e o r g a n o f s i g h t
she has an eye for fresh talent he has an artist’s eye
g o o d d i s c e r n m e n t ( e i t h e r v i s u a l l y o r a s i f v i s u a l l y )
he tried to catch her eye
a t t e n t i o n t o w h a t i s s e e n

The functions that generate these sentences return lists. As you can tell some are lists of words and some are lists of letters. I sort of visually like the way it looks when I concatenate indiscriminately however it is completely unreadable.

Some of these lines I love and it is sort of like an exquisite_corpse surrealist experiment.  How can I get beyond the surreal, into something new? Something with a deeper structure that gives rise to the meaning of the thing.

This is what happens when I start to play with parts of speech such as antonyms.

it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
an area that is approximately central within some larger region

the central area on a theater stage

the central part of a city

the part of a city where financial institutions are centered
the playground is the hub of parental supervision the airport is the economic hub of the area
a center of activity or interest or commerce or transportation; a focal point around which events revolve

the older and more populated and (usually) poorer central section of a city

the part of a city where medical facilities are centered

(sports) the middle part of a playing field (as in football or lacrosse)

the middle of a stream

a center of authority (as a city from which authority is exercised)

the central area or place of lowest barometric pressure within a storm

he hit the ball to deep center
the piece of ground in the outfield directly ahead of the catcher

they were raising money to build a new center for research
a building dedicated to a particular activity

a center where patients with severe burns can be treated

a center equipped to handle a large volume of telephone calls (especially for taking orders or serving customers)

a center where the members of a community can gather for social or cultural activities

a center where conferences can be conducted
the general in command never left the control center
the operational center for a group of related activities

a center where research is done

a recreational center for servicemen

a center in an underprivileged area that provides community services

a center for student activities at a college or university

a low-lying region in central France

it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
an area that is approximately central within some larger region

the central area on a theater stage

the central part of a city

the part of a city where financial institutions are centered
the playground is the hub of parental supervision the airport is the economic hub of the area
a center of activity or interest or commerce or transportation; a focal point around which events revolve

the older and more populated and (usually) poorer central section of a city

the part of a city where medical facilities are centered

(sports) the middle part of a playing field (as in football or lacrosse)

the middle of a stream

a center of authority (as a city from which authority is exercised)

the central area or place of lowest barometric pressure within a storm
a point equidistant from the ends of a line or the extremities of a figure

the middle part of a slack rope (as distinguished from its ends)

the center of the Earth

the center of a target

the center of the circle of curvature

the point within something at which gravity can be considered to act; in uniform gravity it is equal to the center of mass

point representing the mean position of the matter in a body
the ball has a titanium core
the center of an object

the central part of the Earth
the Incas believed that Cuzco was the navel of the universe
the center point or middle of something

the center point on a shield

the positively charged dense center of an atom

(astronomy) the center of the head of a comet; consists of small solid particles of ice and frozen gas that vaporizes on approaching the sun to form the coma and tail
it is in the center of town they ran forward into the heart of the struggle they were in the eye of the storm
an area that is approximately central within some larger region

the central area on a theater stage

the central part of a city

the part of a city where financial institutions are centered
the playground is the hub of parental supervision the airport is the economic hub of the area
a center of activity or interest or commerce or transportation; a focal point around which events revolve

the older and more populated and (usually) poorer central section of a city

the part of a city where medical facilities are centered

(sports) the middle part of a playing field (as in football or lacrosse)

the middle of a stream

a center of authority (as a city from which authority is exercised)

the central area or place of lowest barometric pressure within a storm

A whole is that which has beginning, middle, and end”- Aristotle
an intermediate part or section

young American women believe that a bare midriff is fashionable
the middle area of the human torso (usually in front)
in your heart you know it is true her story would melt your bosom
the locus of feelings and intuitions

he stood still, his heart thumping wildly
the hollow muscular organ located behind the sternum and between the lungs; its rhythmic contractions move the blood through the body

enlarged heart commonly found among athletes trained for endurance

a heart (as of mammals and birds and reptiles) having two auricles

the muscle tissue of the heart; adapted to continued rhythmic contraction

the artery that branches from the aorta to supply blood to the heart

a valve to control one-way flow of blood

a structure in a hollow organ (like the heart) with a flap to insure one-way flow of fluid through it

he kept fighting on pure spunk you haven’t got the heart for baseball
the courage to carry on

the organ of sight

in insects and some crustaceans: composed of many light-sensitive elements each forming a portion of an image
it is not safe to look directly at the sun with the naked eye
the eye unaided by any optical instrument that alters the power of vision or alters the apparent size or distance of objects

the right eye

the left eye

an informal term referring to the eye

an eye having a single lens

a natural opening in something

either of the corners of the eye where the upper and lower eyelids meet

a branch of the ophthalmic artery; enters the eyeball with the optic nerve

a highly vascular membrane in the eye between the retina and the sclera; a dark pigmentation minimizes the scattering of light inside the eye

one of several arteries supplying the choroid coat of the eye
the ciliary body produces aqueous humor
the part of the tunic of the eye between the choroid coat and the iris

a transparent lubricating mucous membrane that covers the eyeball and the under surface of the eyelid

the transparent dome-shaped anterior portion of the outer covering of the eye; it covers the iris and pupil and is continuous with the sclera

a vertical fold of skin over the nasal canthus; normal for Mongolian peoples; sometimes occurs in Down’s syndrome

the ball-shaped capsule containing the vertebrate eye
his lids would stay open no longer
either of two folds of skin that can be moved to cover or open the eye

muscular diaphragm that controls the size of the pupil which in turn controls the amount of light that enters the eye; it forms the colored portion of the eye

the structures that secrete and drain tears from the eye

an artery that originates from the ophthalmic artery and supplies the lacrimal gland and rectal eye muscles and the upper eyelid and the forehead

drains the lacrimal gland; empties into the superior ophthalmic vein

biconvex transparent body situated behind the iris in the eye; its role (along with the cornea) is to focuses light on the retina

a protective fold of skin in the eyes of reptiles and birds and some mammals

one of the small muscles of the eye that serve to rotate the eyeball

a ring of smooth muscle surrounding the iris

the innermost light-sensitive membrane covering the back wall of the eyeball; it is continuous with the optic nerve

the whitish fibrous membrane (albuginea) that with the cornea forms the outer covering and protection of the eyeball

the part of the eye that contains the iris and ciliary body and choroid

a tubule that drains excess aqueous humor

she has an eye for fresh talent he has an artist’s eye
good discernment (either visually or as if visually)

he tried to catch her eye
attention to what is seen

I feel like perhaps this is a way to generate raw material for a piece rather than the piece itself.

So I went and decided to some how use this for my daily tidal cycle/music experiment. I am using tidalcycles (vim tidal) and supercollider.  To use tidalcycles with vim (or neovim) you need to use tmux- which I do not have much experience with.

Basically tmux lets you tile windows in the command line.  At first I thought that vi was opening a bash prompt but no, the terminal was itself opening up a tidal cycles or a haskell repl.  This was confusing because I kept trying to change vi buffers and it was not working.

Ok so tmux commands:

  1.  exit – this closes application windows (detach also detaches the processes)
  2. : you can type ‘:’ to get to the tmux prompt – very VI like.
  3. ctrl-b arrow should move me to the other pane
    1. This did not work, instead i used ctrl-b o to cycle through panes

then I put SuperDirt.start (shift + return) but  error ERROR: Input sample rate is 16000, but output is 44100. Mismatched sample rates are not supported. To disable input, set the number of input channels to 0. I fixed this by opening /Applications/Utilities – Audio Midi Setup  and fixing the input rate. I had some old midi keyboard hooked up it seemed like.

A bunch of samples could not be found – oops – had to install

include("SuperDirt");

For some reason I could not get audio coming through on my earbuds – I need to debug this. I also dont have the Super Dirt samples. No matter. I played around with a bunch of random stuff and had a good time. I feel like there is no time signature there is just the cycle that we can speed up or slow down. We can put as much stuff in the cycle as we want and we can alter it programatically.   I set up a simple set of instructions and it was interesting to hear it change over time. Like a really crapy audio version of game of life.

I converted one of the poem outputs to text via Say  < poemX.txt although this seemed to loop.  When I listened to the poem it was more interesting than reading it. I noticed that middle had been interpreted as center – as in the hub of activity. This is different from the middle – as I was in the middle of my life – as in the beginning of the Divine Comedy.  I used ffmpeg to convert m4a to wav.

Basically I think the clips are too long – but these are some early experiments. I use the audio that I generated from the mac os text to speech but you cannot really tell.  Baby steps.