Friday, February 19, 2016

Working with Bitbucket and Transferring Ownership for Class Coding Projects

I recently started using BitBucket due to their handy free private repositories feature.

I started out with a repo for class but I named it the class name, now I need to create another project, but I can't with the same primary name, and it doesn't make a lot of sense to put all the files under the same repo (the repo won't get huge or anything, but it's an organization issue). I found out there was a solution called Transfer Ownership (or transfer repository)

Teams to the rescue.

I created a team for my class, Then I created a new repo. But wait... that isn't how you should do it!

Create a Team (whatever name you want to give it)

 

NEXT create a Project (logically it would be your classes name). So I'll give an example structure below.





* Be Sure to select Private


Next you can take your existing repos and transfer ownership to that KBAI project (or whatever you call yours).

1. Go to your repo
2. Hit Settings.
3. Then Transfer Repository
4. Select the team you created above.






5. Now you select the project.



Or you can create a new repo, just point to the Project and everything for your "class" will fall under this project. Clones will be smaller as you won't clone all of them.




Now as you can see here are the repos grouped all nice and stuff.





 Now if you click on Cognitive Cooking it's this is the clone path
git clone https://onaclov2000@bitbucket.org/onaclovtech/cognitivecooking.git

(Which is wrong for all intents and purposes, but pretending it's right, and I'll post a followup regarding this).

You can see that the git repo is associated with the team, but the structure in bitbucket is that the repo is associated with a project, which allows some organization, but you also don't have to download one repo for your entire class or program or whatever, you can just have the repos grouped.

You'll want to make sure to update your origin/master since they're probably pointing to the wrong place (if you're transferring repositories).

Good luck!

Updating Git Remote URL's

This is a follow-on to the last post, so you've moved your git repos around a bunch now you need to fix your push/pull locations. This is a really easy fix.

Go to the folder where your repository lives and edit .git/config (for me command line gedit .git/config) and change the url to the one you want.

With BitBucket, for me the URL that contains onaclov2000@bitbucket.org isn't right (not sure who that would be right for).

So for me the URL's look something like this (much more githubish).

https://bitbucket.org/onaclovtech/rpm.git

Good luck!

Friday, January 8, 2016

Python For Loop Fun

I had a problem recently where I needed to loop through a for loop to find some lines then only combine some lines so I thought for i in range(len(list)): ought to do it. It did not, I'm here to tell you the sad story of what happened. (Well actually this is a conversation I replied to with my buddy Phil, who should start a blog, cause he's awesome and probably could teach you many more things than I could).

Actually there is duplication but I think you forgot to include 'shut your dirty mouth' in the l array anyway... ;)
I added a "blah" to the 3rd element (0 based) so you can see when it's being printed vs the 2nd element.
Phils Function:


l = ['blah', 'blah blah', 'blah blah blah', 'blah blah blah blah']
for i in range(len(l)-1)):
   print l[i], l[i+1]

Phils Output
0blah blah blah
1
1blah blah blah blah blah
2
2blah blah blah blah blah blah blah
3
Tysons Function:


q = range(len(l)).__iter__()
for i in q:
   print l[i], l[i+1]
   q.next()

Tysons Output
0blah blah blah
2blah blah blah blah blah blah blah

Note the difference in the number of blahs and the number of lines
Phils approach prints current line plus next line through the entire list (and skips the last element due to the -1) Also note that even though we did a +=1 the next time through the loop the number is back is back....
Mine skip lines and print the current line and the next
Now this is obviously a contrived example as you can do range(0,len(l),2) and I think get the same result, but in my particular case I only wanted to combine certain lines, so only if line + 1 (or l[i+1] contained X would I want to print l[i] and l[i+1] afterwhich I wouldn't want to print the "new" l[i] (which was the same as the old i+1).
I hope that makes some more sense.
Here is a (only slightly) less contrived example.

My new function

l = ['one', 'my', 'buckle', 'my', 'shoe']

q = range(len(l)).__iter__()
for i in q:
    if 'my' in l[i]:
        if 'buckle' in l[i+1]:
            print str(i) + l[i], l[i+1]
            q.next()
        else:
            print l[i]
    else:
        print l[i]

My New Output
one
1my buckle
my
shoe

See now I only want to combine my buckle on the same line but not my shoe
So long story short, I can't just i+= 1 in my loop, I have to do a 'next()' but I can't just do that on an int (i.next() won't work in the above context) but I can do a next() on the range business (if it's got the iter, which I'm not sure about), however you need a variable to fiddle with to do that.


Anywho, next time you need to do the same thing as a simple c style for loop with numbers and want to increment remember.... it won't work like you expect it to.


Wednesday, January 6, 2016

It's not You, it's Me


Clearly that has to be the problem. I mean millions of people use computers every day and have little to no problems...right?  I must be doing something wrong.

I'll tell you my pathetic story.

So I wanted to combine some content from an excel spreadsheet into a word document as comments, so first approach was to just extract the text, add comments in a fancy "html" page. Did this, but tables and the like didn't export to plain text well. So I thought I could come up with something better.
Racoon accidentally dissolves cotton candy in water

Next shot, let's try VBA and just extract some comments from a CSV to insert in a Word Doc. (Seems like it should be straightforward, open CSV, grab data in columns 1 and 2, search in word doc for data in column 1, add comment from column 2). Nope Couldn't figure out how on earth to extract column data from a Excel application within a Word macro (using VBA).

Next, well, Word is a Zip file, lemme try unzipping the file and seeing how that works. Tried adding a single comment, Saved. Clearly they're not going to make this easy for me. Comments are in a comments.xml file with some unique identifiers and then in the document.xml file is the.... you guessed it, document, with the comment reference. This is do-able, but painful, so I thought I'd avoid this for the time being. (Oh by the way, if you haven't looked at the Office Open XML yea it's roughly 7k pages... AINT NO BODY GOT TIME FOR THAT)

Oh wait I nearly forgot, I tried adding a comment, very blindly, that failed, so I tried just unzipping the contents with python, tossed the output into a folder and rezipped, then renamed to .docx, yea word thinks the file is corrupted, no clue what the appropriate "re-zipping" is but good luck figuring that out too.

Next I tried out Mammoth something that attempts to convert a docx to a passable html file using python.... yea tried printing the resulting "HTML" and get unicode errors. Tried a few google searches, and approaches, no luck. Finally decided on a loop through all characters, then doing a Try Catch when printing to command line (Stderr), and storing "successful" prints to an array, for later printing. otherwise passing the "exception" catch. Only problem with a large doc, it takes FOREVER to print all to the command line (due to delays from printing to the command line, in this case not file IO). Oh Wait..... mammoth died, about 2 hours later..... yay for me.

It seems like anytime I need to fight with a Word doc to extract data, I can't seem to find the right incantation in google to solve my problem. Case in point again, find document line number of a comment, Not the section offset but the ABSOLUTE LINENUMBER OF THE DOCUMENT. Good luck. I dare you. I flipping dare you to try. If it takes you less than 8 hours before you give up you haven't tried hard enough, if you've been going on more than 8 hours.....Good luck, but you'll likely miss out on the rest of your life if you keep going.

You see, you can't just go through a word document line by line, you have to go section by section, but then lines aren't really lines in there, they're paragraphs, so how can you ever figure out what line in a paragraph something is? You can't you have to somehow figure out how many characters are on a line and possibly have to do some kind of mod operation ON EVERY PARAGRAPH to get EACH PARAGRAPH linecount and then FINALLY you can sum them up.... but oh wait, you have to do that for all preceeding sections. I won't get into the pain too much more, suffice to say, I finally finished with something that just gives you a section number and the line of the paragraph on that PAGE. No flipping clue how you can even figure that out, but it was the first solution I found and I finally had to give up and use that.

I probably could come up with a dozen horror stories of word if I was really pressed to it, but I'm fairly certain my PTSD would attack and I'd just blog.

Did I mention that 2015 just wasn't my year for computers? I gotta be honest 2016 isn't looking any better.

Tuesday, January 5, 2016

Knowledge Based AI:Cognitive Systems Udacity Custom Curriculum

I love Udacity for the ability to have a free set of lectures/learning etc online, with forums etc. However one thing that annoys me is that sometimes having an assignment really solidifies learning, so I would like to remedy that.

When going through the Knowledge Based AI:Cognitive Systems lectures, it has a reference link to a pdf to read for supplemental reading, I went through the links and found this site:

http://courses.csail.mit.edu/6.034s/resources.html

I haven't gone too far down the road of finding what is up with it, but perhaps some options are in there, or we can find other "open" assignments online that are available. Or create our own, for folks NOT in the GA-Tech program or even the ones in it, looking for additional projects to learn from.

Just something to consider and I'll probably post some additional ones here.

(Book reference, minus the blah.pdf reference, can be found here:
http://courses.csail.mit.edu/6.034f/ai3/)

Friday, January 1, 2016

Why computers aren't a viable business future 2015

This is a bit of a joke post but I wanted to highlight the pains I have felt (and one of my friends Phil) with computers in the last year. Most of these are/will be linux/Ubuntu specific systems that we saw these problems with, but occasionally were other systems.

10. Opening Image Writer in Ubuntu 15.10 causes a system crash (right click menu), opening with command line doesn't. However when trying to restore the rasbian image to an sd card, it wouldn't work right, and the card refused to be recognized after until I shutdown for a solid 5 minutes.
Solution:
df -h (to find the SD identifier of the drive) then
sudo dd if=/home/hotdog/Downloads/2015-05-05-raspbian-wheezy.img of=/dev/sdf
 9. Python list.sort() and sorted(list) behave different. Simply put, list.sort() sorts in place and, sorted(list) returns the sorted list.

8. My daughter has nearly bought hundreds of dollars in gems on a game by disney, fortunately we don't have a credit card associated with our account.

7. 3 monitors in Ubuntu and Mint is pipe dream. Don't waste your time.

6. Switch from Ubuntu Unity to Plasma 5/KDE, Nothing works.

5. Never mind about the rest, i tried installing my new bluray drive and now my computer which i just upgraded, no longer works. I give up on computers

Friday, November 20, 2015

Cameras, Tablets, and Remotes Oh My

If you've got a reasonably nice camera, and you've ever gotten professional pictures, you've realized that things can get expensive pretty quick. So you decide to do it yourself, but setting the timer, then running to get in the picture only works so well, plus if you have little ones it makes it about 10x harder. I did some searching and found some really awesome bits and pieces to help things out.

Goal #1 Quit having to run back and forth to start the timer.

Things start to get tricky, you can set everything up and take pictures remotely now, but you don't know if they're turning out, and well, you run into the same problem again, you gotta keep running back and forth.

Goal #2 Quit having to run back and forth to check the picture turned out right.
You'll need a few pieces to get this part working.
1. EyeFi Mobi (If you'd like there is a different version but I haven't used that).
2. SD/SDHC/MMC/Eye-Fi card to Compact Flash CF (Assuming you have a CF card).
3. EyeFi Mobi App (Android) or EyeFi Mobi App (Apple)

So once you install the app, and put the card in, there is an option (at least in the android app) where you can tell it to start a slideshow of incoming photos, so now when you take a picture, it'll transfer the photos within a few moments and you're done.

One final note, when I started saving the pictures to my phone, google plus photos asked me if i wanted to back up the folder, so this means that when I take pictures with my nice camera, all my photos get automatically uploaded to the cloud, no more download to computer, then upload to picasa (well google plus photos now). This is crazy handy.

Finally if you wanted to you could install the tools on your laptop/wifi enable desktop and the pictures will show up there as well, using their tools.

Good luck!


Here is an example video of someone using this with an iPhone


Friday, November 6, 2015

Programming Anywhere: Rudy BBQ

I decided to try out Rudys for breakfast and working. I love their tacos (Red Chile + Sissy Sause = BEST EVAR). Rudys has tons of space, if you're not around during main lunch and dinner crowds you can hang out in the outer area, there is great music playing (little older music so it's kinda fun). And its not distracting. The temp is comfy (well right now in mid October) too! (Inside may be more distracting and a little less awesome).

Pro's: Free Wifi, Great Breakfast Tacos (cheap too), Good music, and most of all not distracting.
Con's: Again you really should buy food, and don't go around busy times.