• About

Bespoke Blog

~ Science! Culture! Computational Engines!

Bespoke Blog

Category Archives: computer science

Vimrepress View Bug

09 Sunday Mar 2014

Posted by bwkeller in computer science

≈ Leave a comment

Tags

vim, writing

Heads up kids, if you are using vimrepress for blogging, and you want to use
the BlogList and one of the edit (BlogEdit, BlogNew, etc.) features, make sure
you use separate vim sessions. Vimpress keeps a “view” state, so it knows
whether your buffer can be pushed to WordPress, and the state is shared between
tabs. So if you start a list in a second tab after you’ve started editing,
vimrepress will not let you save your edit, unless you fire up another tab in
the edit view to knock the state back to edit.

WRITE MORE

09 Sunday Mar 2014

Posted by bwkeller in computer science, projects

≈ Leave a comment

Tags

markdown, vim, writing

Well, hopefully I will be blogging a bit more frequently. I just finished
writing a manuscript for a paper from the last 2 years of PhD work, and it was
no fun. I am, at this stage, pretty shitty at scientifc writing. I’m hoping
some practice will help improve me. I’ve installe the wicked
vim-repress which will hopefully
make the whole affair more fun. I can’t stand writing with a tool other than
vim, and markdown is a bicycle to HTML’s 18-wheeler. Lighter and more fun to
use.

Parallel Computing with OpenMP & C 1: Introduction

17 Thursday Oct 2013

Posted by bwkeller in computer science, programming

≈ Leave a comment

Tags

OpenMP, parallel

So, I’m taking a class this year on high performance computing, and I figure’d I might as well kill two birds with one stone: write some blog posts, and also get some studying done.  Let’s get to it!

What Is OpenMP?

OpenMP is an API for working with shared memory parallel computers.  Essentially everyone now owns one of these machines, as any multi-core machine is a shared memory parallel machine.  What it isn’t is a tool for GPU programming or programming on distributed memory systems (like a Beowulf cluster).

OpenMP is one of the fastest and easiest ways to squeeze extra performance our of modern multicore CPUs.

How to Set Up OpenMP?

Unlike some parallel tools (I’m looking at you CUDA 2 years ago), OpenMP is ridiculously easy to set up.  If you are running a Debian-like system, it is just:

apt-get install libgomp1

And that’s it!  All you need to do now is compile your code, as you normally would, with gcc and the -fopenmp flag

gcc  -fopenmp

How easy is that?

In the next post, we will write some simple C code using OpenMP.

Illegal Poetry

06 Sunday Oct 2013

Posted by bwkeller in computer science, copyfight, python

≈ 2 Comments

Tags

philosophy, poetry, programming

I have always had a problem with the concept of intellectual property.  The great western tradition of post-enlightenment values have always placed the free flow of art and ideas on a pedestal, as a sacrosanct cornerstone of a just society.  That the ideas living in our heads and flowing from our lips were the domain of no king, pope, or policeman is the one of the most important cultural norms that has emerged from the enlightenment into modern liberal democracies.  The legal constructs associated with intellectual property, in my evaluation, cannot be reconciled with this.  A corpuscle of information cannot be at once free to be spoken or expressed and also be the property of some individual and corporation.  Information Theory, the fantastic work pioneered by Claude Shannon, only swells my distaste for intellectual property.  We know now that with simple coding, all information is reducible to a common binary form.  Film, print, music, photography: all is merely a collection of ordered bits.  Which makes the idea of owning information all the more ridiculous, as the process can be just as easily reversed:  A song can be represented by a string of Shakespeare quotations, a movie can be rendered in musical score.  As an illustration  of this, I’ve written a short program that takes any file and converts it to a long, rambling nonsense-poem.  Poetry as Piracy.

Making the Wordlists

The first step is generating a set of words to use to generate our poems, categorized by their grammatical type.  To do this, I downloaded the English wiktionary.  I then used grep, sed, and awk to split it into plain lists of words:  nouns, past tense verbs, present participle verbs, and adjectives.  I then shuffled these lists, and trimmed them down so that their length was a multiple of 2.  I didn’t need to do this, but it simplified the work slightly.  In the end, I was left with 17 bits worth of information stored in each noun (131,072 words), 13 bits in each past-tense verb (8192), 13 bits in each present-participle verb (8192), and 15 bits for each adjective.

Sentence Skeletons

I then decided on two rough sentence skeletons:

The ADJECTIVE NOUN PAST-VERBED the ADJECTIVE NOUN.

ADJECTIVE NOUN is PRESENT-VERBING the ADJECTIVE NOUN.

Each of those sentences can store 77 bits of information.  A 1Mb file, for example, will require roughly 10,000 sentences, or about a novelette worth of words.  If that 1 Mb file was a copyrighted song, you would not in fact have the freedom to print and distribute your nice new novel (not that you would want to, it would be random nonsense.)

Encoding the File

Now, 77 bits is a bit awkward.  Just choosing between each sentence type gives me 1 bit of information.  I also get punctuation at the end.  If I end each sentence with either a period, exclamation mark, two exclamation marks, or three exclamation marks, that gets me an extra two bits of information.  This gets me up to 80 bits per sentence, or 10 bytes.  I can now easily encode my data as nonsense poetry!  I use the first bit to select which tense of verb, the second two decide if I get a period or exclamation series, and the rest determine the sentence itself.  If my file isn’t nicely divisible into base 10, I simply add an additional line at the end:

All that remains are NUM memories and NUM regrets.

Where NUM is the base-10 representation of the remaining bytes in the first case, and the number of bytes remaining in the second instance (as a long string of leading zeros will get truncated in converting to decimal).

Decoding the File

Decoding the file is as simple as just reading in each line, checking what sentence type it is, and what the punctuation at the end is, and returning it to the original binary form!

Are Password Lockers Safe?

28 Thursday Jul 2011

Posted by bwkeller in computer science

≈ 1 Comment

Tags

memory, passwords, security

Well, I was hoping to make a more interesting post today, but seem to have lost the route through my cluttered mind to get to the synapses that store my github private key passphrase.  So, in an attempt to keep up the quantity if not the quality of my blogging, let me turn to this dire state of mnemonic affairs.  I can’t remember my passwords very well anymore.  I’ve always been leery of password storage utilities, but I think I need to rethink them.  I keep my machines with full disk encryption, and commit those passwords well into my memory, so I should be somewhat secure, right?  Talk me in to this, dear readers, or tell me the path of folly I am embarking upon.

Backup Your Google Life: gback

27 Wednesday Jul 2011

Posted by bwkeller in computer science, programming, projects

≈ Leave a comment

Tags

backup, cloud, coding, computers, gback, google

You should all be watching Steins;Gate There was a rant that bounced up and down the tubes of the internet this week, talking about how one poor fellow migrated all of his important data into google services, only to have google pull the digital rug out from under him by deleting his account after it was algorithmically flagged.  This sucks, but one thing I have always been pestered about is the importance of regular backups.  Just because google is “the cloud” doesn’t mean your data is in a deadly limbo state of potential destruction if you don’t back it up.  The problem is, backing up a machine you control is damn easy, while backing up your cloudified data is not. Continue reading →

What The Hell Is Wrong With My Computer?

26 Tuesday Jul 2011

Posted by bwkeller in computer science

≈ 1 Comment

Tags

bug, computers

So, after my machine ran out of battery power while suspended, I booted it up to be greeted with the most strange bug I’ve ever seen on a linux machine:  All my text was screwed up.  In every application, including GDM.  It disappeared after I ran an apt-get upgrade and rebooted.  Has anyone else ever seen this bug?  I’m running Ubuntu 10.04, for the record.  Screenshot after the jump.

Continue reading →

Battlestations!

25 Monday Jul 2011

Posted by bwkeller in computer science

≈ 1 Comment

Tags

geek, reddit, technology

I’m a huge redditor, and one of my favourite little-known subreddits is r/battlestations.  It’s a nifty page where people show off their computer/desk areas and compare notes for cool monitor setups, epic workstations, and efficient office layouts.  Check it out if you want to kill some time and drool over other peoples offices. That was a short lame-o link post.  Sorry about that, I’ll be including vouchers for free nothing in the next post.

Data Recovery For The Very Lazy

16 Saturday Jul 2011

Posted by bwkeller in computer science, howto

≈ 2 Comments

Tags

bash, sleuthkit, UNIX

After my friend rm’d a bunch of code yesterday, I offered to help.  I first made a copy of her disk using dd, copying it off of her machine and using ssh to take it to another:


sudo dd if=/dev/sda1 | ssh USER@HOST "dd of=/home/USER/backup.img"

I then grabbed a copy of sleuthkit, and used the fls tool to find the inodes pointing at her old files, and icat to restore them.  I new the files were php code, stored in /var/www so I used grep to select those results from all the files listed by fls.  Using grep, I selected the inode numbers from the output, and piped the results to icat.


for i in `fls -r -d backup.img | grep var/www | grep \.php | grep -o [0-9][0-9]*`

do

icat $i > $i

done

Voila, I had a bunch of files, 6 of which were the missing PHP files!  Super easy, and thank goodness the filesystem was ext2, as ext3 is much harder to recover data from.

rm Is Not Your Friend

16 Saturday Jul 2011

Posted by bwkeller in computer science, howto, research

≈ 4 Comments

Tags

bash, UNIX

This afternoon, about 10 minutes before the end of the day, one of the undergrads working in my lab turned to me and asked what the command to undo an rm command was.  I blinked at her, and told her there was none.  I’m now trying to sift through a disk image dumped from the machine she worked on after typing rm -r * in the wrong terminal.  Now, backups, backups, etc. I know.  But even with regular backups, an rm -r * in your home directory is never fun.  If you want to not experience the joys of watching your files turn to dust, add this to your .bashrc:


alias rm="rm -i"

This won’t save you every time, but it will at least prompt you before you blow away 3 weeks of work.  So don’t ignore the prompt. Please?

← Older posts

January 2023
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
« Mar    

Ben’s Tweets

  • RT @OJ_Astro: A blog post by physicist Syksy Räsänen (@SyksyRasanen), who has published with us twice, about why overlay journals are an an… 1 day ago
  • RT @JokesAstro: If the Islands of Hawaii were very massive stars, Kauai would be going supernova soon. https://t.co/NEboP6FRWd 2 days ago
  • RT @AnicaSeelie: @gauravmunjal Imagine if there was a duck but it had human ears 2 days ago
  • RT @jfmclaughlin92: Friendly reminder that if you're at a public university, your institutional email can be searched basically whenever. B… 2 days ago
  • @rcrain_astro Academia has a lot of problems. Precarious employment, massive overworking of junior researchers, poo… twitter.com/i/web/status/1… 2 days ago

Nicholas’ Tweet’s

  • RT @michielsdj: New paper! Retrieval-augmented models are expensive. Make them faster by partially pre-computing passage representations. W… 5 days ago
  • RT @michielsdj: New paper! We propose FiDO, an improved version of Fusion-in-Decoder with faster inference and better performance. Work don… 1 month ago
  • @_julianmichael_ @LukeZettlemoyer @emilymbender @nlpnoah @ssshanest Congrats! 5 months ago
  • RT @michielsdj: Now accepted to @iclr_conf! 🎆 1 year ago
  • @mjskay Yeah, I feel a major point people were missing is that an endless spiral into the drain is actually the perfect visual metaphor. 1 year ago

Top Posts

  • Basic Data Plotting with Matplotlib Part 3: Histograms

Tags

100daychallenge advertising astronomy bash biology blogs BMC books browsers Bulshytt calligraphy canada coding cognitive computers computer science css EEE elvish ereaders ethics evolution experiments facebook google government html humor humour ICP I hate this class iliad internet explorer irex java javascript lego letter libraries marketing materialism matplotlib maze mindstorms mods morality mysql networking neuroscience pens philosophy philsophy php Pilish prime minister programming psychology reading review robots science SENG servers sociology steampunk stupid technology time ubc UNIX url vim web web design writing

Blogs We Read

  • Bad Astronomy
  • Boing Boing
  • Rationally Speaking
  • Terry Project (UBC)

RSS Nicholas’ Terry Posts

  • An error has occurred; the feed is probably down. Try again later.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 162 other subscribers

Create a free website or blog at WordPress.com.

  • Follow Following
    • Bespoke Blog
    • Join 74 other followers
    • Already have a WordPress.com account? Log in now.
    • Bespoke Blog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...