subscribe
Tags:
 
2010
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
2010-07-25

A bit of Computer Repair

My good buddy Constance has a rather old computer. Actually, it is an original ibook with a speedy 300Mhz processor and a whopping 192M of RAM.

OK, the RAM has obviously been updated, but other than that, the computer is still original.

One day, Constance told me a tale of tripping over her computer cord and then the adapter started sparking. Crap! The machine may be crap, but it is all she has and it has all of her writings on it.

Ah, the slow as dirt machine. See that "yo-yo" power adapter? Aside from always burning out, those things are $80 from Apple. I'll be damned if I let Apple get any of my poor writer friend's money. Let's fix that shit!

First thing first: find out where the cord is fried. Well, I'll be damned, it just happens to be fried where every other "yo-yo" adapter gets fried.
(That's me being sarcastic)

It went like this:
1. cut off part of the plastic housing
2. cut and strip wires
3. determine that the amount of exposed wire is to too short for my pathetic soldering skills
4. cut off all of the plastic housing
5. discard the metal housing under the plastic housing

Hit it with some magic!

After soldering the wires, I used hot glue to re-attach part of the plastic housing and then I wrapped the wires with electrical tape. Just to be save, I slather on a crapload of hot glue to keep everything together.

Solder, electrical tape, and hot glue. Shazaam! That's three adhesives in one project!

When the repair was completed, I put the machine in bag and pedaled over to Constance's house, where I was greeted ecstatically. It should be noted however, that there was a serious lack of cookies/coffee/beer/scotch waiting for me when I got there. cough cough, cough cough cough, hint hint.

Now quit reading, and go repair a crappy 11 year old laptop.

P.S. If anyone has an old laptop gathering dust, and the laptop isn't as crappy as Constance's current piece of shit, let me know. (Constance really needs an upgrade)

Comments
Yes she do.

She will make some cookies when you tell her which kind.


(Are Tacos a cookie? )
jezra:
Can I get jalapeno and bacon cookies?

seriously
hey pretty cool. I did something similar to my wife's laptop (which we no longer use.... your friend want to buy it on the cheap? ;-) )

The connector port cracked on the inside of the laptop case, so I took it apart and soldered in some braided wire that exits the chassis. Then I put a phoenix connector on the end. I then snipped off the end of the power adapter cord, and wired it into a phoenix connector also.

Works perfectly now. Common problem due to the stress on that connector or something.
What a coincidence - my cousin recently dropped his laptop, and the connector for the power adapter broke off... internally.

I had to solder it back on, and then tape it in place because the solder points would be the only thing holding it in place otherwise. It sorta works now, but you have to be ginger with it.

As for newer laptops: I don't have anything past the Pentium I era that functions (and most of those don't function, either), but I'll make sure to keep my eyes open.
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
6 minus 3
Answer:
required
2010-07-16

Quite a few of my coding projects have a large text field where the user is expected to do a lot of typing. Actually, it would appear that none of my projects have a large text field. I suppose I should make markdowner and scripsi official jezra.net projects. Anyway, both of the previously mentioned apps have a large text field where the user types and types and types( hey, they are text editing programs ).

  • scripsi is a special purpose dual paned text editor written in Vala
  • markdowner is a special purpose text editor written in Python

Both applications use the GTK+ toolkit to create the user interface.

The Problem


When a GTK TextView widget is used to create a large text input area, if the user's cursor travels past the viewable area of the TextView, which happens when typing to the bottom of the screen, the cursor is below the visible area and the user will need to stop typing and scroll the TextView until it is visible. If the user were a typing ninja then I suppose they wouldn't care about typing without knowing what text is showing up in the TextView. Well, I am not a typing ninja.

The Solution


There is probably a more elegant solution to the problem, but I couldn't find it so you are stuck with what I figured out, and this is my solution:

When the text changes, get the coordinates of the cursor and scroll to those coordinates. This will ensure that the cursor is always visible to the user. How would you like to see a working example in Vala?

Enter the Vala

/* woohoo */
using Gtk;
public static void mainstring[] args) {
  //initialize gtk
  Gtk.init(ref args);
  //make a window
  Window window new Window();
  //make a textbuffer
  TextBuffer textBuffer new TextBuffer(null);
  //make a textview with our buffer
  TextView textViewnew TextView.with_buffer(textBuffer);
  //let the textview wrap at word or char
  textView.set_wrap_mode(WrapMode.WORD_CHAR);
  //we need to know when the text buffer changes
  textBuffer.changed.connect( ()=>{
    //make a textiterator
    TextIter iter TextIter();
    //what is the cursors x coordinate?
    int textView.virtual_cursor_x;
    //what is the cursors y coordinate?
    int textView.virtual_cursor_y;
    //get the text iter at the cursor's coordinates
    textView.get_iter_at_location(out iter,x,y);
    //scroll to the cursor's text iter
    textView.scroll_to_iter(iter,0,false,0,0);
  });
  //make a scrolledwindow to hold the textviw
  ScrolledWindow scroll new ScrolledWindow (nullnull);
  //set the scrollwindow's scrolling policy
  scroll.set_policy (PolicyType.AUTOMATICPolicyType.AUTOMATIC);
  //add the textview to the scollwindow
  scroll.add (textView);
  //add the scrollwindow to our window
  window.add(scroll);
  //show all the widgets
  window.show_all();
  //run the gtk main loop
  Gtk.main();
}

Save the above code in a file named "cursor.vala" and compile with

valac --pkg=gtk+-2.0 cursor.vala -o cursor

Now I need to port the code to Python and implement the change in markdowner.

Now quit reading, and go fix a problem with a dirty hack.

Comments
Have you considered combining the two apps, and simply having different modes? I know, I know you hate features, but just a thought for the betterment for jezracorp
jezra:
combining the apps would require rewriting markdowner in Vala (because I would prefer to have the app in Vala) and I'm too lazy to port the markdown library to Vala.
Just a note - raw Markdown is getting pushed to the planet through your RSS feed. Not necessarily a bad thing, but it always gives me the feeling I'm watching you write in your underwear. :s

Also, I'm still working on that FOSScon blog post; depending on how things go, you might even see it today!
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
2 plus 3
Answer:
required
2010-07-11

The Warm Up

Not very long ago, I made three stickers from a photograph of yours truly. Because the original intent of making the stickers was never met, I decided to give away the stickers with a simple contest.

Sticker #1 has gone across the Atlantic Ocean an now resides in Germany.

Sticker #2 has traveled across the United States and now resides in Upstate New York.

Sticker #3: well this sticker is probably going to travel more than #1 and #2 combined (and then possibly doubled).

Wait, didn't the third postcard come from Switzerland? How can the sticker have such an unknown travel distance? I'm glad you asked.

allow me to spin a yarn....

A few weeks after sticker #2 was shipped off, I received a message from my buddy asking if I could fix his computer. I heartily agreed and five days later I was picking up the computer at the post office. Yea, the machine was so bad my friend mailed the computer to me.

The machine itself was a sweet little Asus netbook that was infected with Microsoft Windows XP. Asus really did a disservice to computer users everywhere by putting Windows on their netbooks. By itself, XP made the machine sluggish and all of the extra bells and whistles that were tacked on ( and tacky looking ) by Asus didn't help.

Aside from slowing down the machine significantly, XP made the machine vulnerable to the plethora of malicious code that seems to be floating about these days, and the machine had a few trojans and a rootkit. Damn, that machine was fucked up, and it took quite a while to clean; but clean it I did and it was time to send it back to my buddy.

My buddy rides bicycles and he goes on bike adventures. I'm not talking about pedaling 5 miles across town for a cup of coffee at a new café (now that is my kind of adventure). I'm talking about really really riding; packing camping gear on a bike and riding for days, weeks, months, and years. Right now, he's in New Mexico, having recently ridden the Continental Divide Trail.

Anyway, it was time to send the computer back to my buddy. Before shipping the machine, I added a few items to the computer bag:

  • a stamped envelope addressed to me
  • a stamped blank envelope ( he should write to someone else on his adventure)
  • a sticker of me,to adorn his bike (AHA!, so that's where it went)

If you are interested, you can check out his blog at http://pocket-thunder.blogspot.com/ and I found out that the package had arrived safely when I read his blog post about it.

The Quandary

It had been a few weeks and I didn't think that anyone would send a postcard for the last sticker. As life would have it, three days after shipping the netbook to New Mexico I received a phone call from the bartender of a local drinking establishment who informing me that I had some mail at the bar. What do you know, it was a post card for the sticker contest thingy.

I must say, the newest postcard followed the rules of the contest to a "tee", which is awesome! Yet here I am with no more stickers. What is a Jez to do? Make more stickers of course! ( I should start numbering them)

It looks like I've got a busy week ahead of me.

Now quit reading, and go make more stickers than you think you'll need.

Now quit reading, and go make more stickers than you think you'll need.

Comments
Name:
not required
Email:
not required (will not be displayed)
Website:
not required (will link your name to your site)
Comment:
required
Please do not post HTML code or bbcode unless you want it to show up as code in your post. (or if you are a blog spammer, in which case, you probably aren't reading this anyway).
Prove you are human by solving a math problem! I'm sorry, but due to an increase of blog spam, I've had to implement a CAPTCHA.
Problem:
2 plus 3
Answer:
required