Programming, computers, etc. [Serious]

All things asdf (and anything else)
User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Apr 18, 2012 6:03 pm

I should really brush up on my Java.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Sat Apr 21, 2012 12:39 am

Did something cool with Python today.

Scenario: We delivered a set of 100 or so files (with subdirectories and the works) to a client in UTF-8. They ask for it in "Unicode." I ask for clarification, since UTF-8 is Unicode. They clarify. They want all of the characters that are outside of ASCII to be escaped the Java way - that is, \uhhhh, where h is a hexadecimal digit.

First thought: How am I going to do that? AHHH!

Python to the rescue. It has it built in (with one minor modification)! For 8-bit characters outside of ASCII, it automatically escapes with \xhh. For characters that take more bits than that, it uses \uhhhh.

Here's my very short solution, with comments: (# indicates the beginning of a comment)

Code: Select all

src = r'root folder' #This had the location of the set of files

import os
from os.path import join
import codecs

for root, dirs, names in os.walk(src): #This loops through all of the directories and subdirectories.
    for name in names: #This loops through all of the files in the current directory.
        #r+ lets me read and write from the files. b basically means that the returns are conserved.
        with codecs.open(join(root,name), 'rb+', 'UTF-8') as a:
            #get the file contents in UTF-8, encode in ASCII, and replace characters outside of the ASCII range.
            #In one line.
            temp = a.read().encode('ascii', 'backslashreplace').replace('\\x', '\\u00') #The magic line.
            a.seek(0) #Reset the file cursor to the beginning.
            a.write(temp) #Overwrite the previous file content with the updated content.
print "Done!"
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Tue Apr 24, 2012 12:55 pm

Character encoding is a bitch. Nice job though.

My firefox has a weird issue.. but only on one profile.
It fails to load certain CSS files on some sites. For example on last.fm, or on http://www.bbc.co.uk/news/ . I've tried running a clean firefox profile (with the -p command line parameter), and it works fine, also they all work fine on any other browser. I've tried disabling my addons one by one, and even tried disabling combinations of them, and nothing worked. It's like the profile is corrupted somehow(?). I've even tried loading the css directly, simply http://cdn.last.fm/css/css/214220/master.css doesn't load in my firefox (file not found), while the very same url loads in everything else.
I'm using comodo dragon again. I like it, but the bookmark management is a little difficult. Otherwise it's a decent and fast browser.

edit: of course cleaning the cache and everything with CCleaner fixed it.
I still think it's a stupid thing.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Tue Apr 24, 2012 3:14 pm

Glad you got it fixed. Bugs like that can be a pain to figure out.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Apr 25, 2012 11:33 am

i still haven't figured it out, I just fixed it.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Apr 25, 2012 3:26 pm

Good point.

The other day I fixed a problem with my wife's iTunes by clearing out her cookies in Safari. Go figure.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Apr 25, 2012 5:27 pm

Maybe clearing the cookies could cure cancer?
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Apr 25, 2012 6:21 pm

I'll take care of the chocolate chip ones.

So... I've been spending some time on the Python FaceBook page...

The following is a modified form of something I put up on FaceBook last night:
I really shouldn't spend too much time helping people out with programming on FaceBook pages. Sooner or later, I find myself cranking out answers to someone else's homework assignment... :| Tip: If the question says "I can't use *insert the name of a widely used standard function here*," it's probably homework. Tread with caution.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Apr 25, 2012 7:10 pm

I just found your facebook page. Now I know all about you. You should be unsettled about this.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Wed Apr 25, 2012 8:39 pm

I figured you might do that. There are some things available to the public, but not a whole lot.

Should I be on the lookout for strange friend requests?
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Wed Apr 25, 2012 8:44 pm

No, I'm not facebooking. I just have a fake profile that I can use for stalking people occasionally finding information about stuff only posted on facebook.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
assdef
JKL;'s Nightmare
JKL;'s Nightmare
Posts: 7050
Joined: Sat Jan 02, 2010 9:30 pm

Re: Programming, computers, etc. [Serious]

Post by assdef » Wed Apr 25, 2012 11:46 pm

Is your profile picture that of a submarine?
Image

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Thu Apr 26, 2012 2:39 pm

no..
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Thu Apr 26, 2012 2:54 pm

Why not?
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
gh0st
Regular ASDF'er
Regular ASDF'er
Posts: 93
Joined: Mon Dec 12, 2011 5:05 am

Re: Programming, computers, etc. [Serious]

Post by gh0st » Fri Apr 27, 2012 2:35 am

(sorry to interrupt anyones topic) has anyone here programmed an arduino? just wondering what code i should learn
Image
I was in a tie with with Thingerdudes for Best Artist 2011 lol . but how do i get the picture up here? Oh i'll figure it out and fix that any day now.

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Fri Apr 27, 2012 6:13 am

From here, here and here, it looks like it's C/C++, in the form of a Wiring project. It looks like it does try to simplify things.
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

User avatar
Dreams
ASDF High Priest
ASDF High Priest
Posts: 2306
Joined: Tue Nov 29, 2011 7:04 pm
Location: STOP STALKING ME! I'M INSECURE!
Contact:

Re: Programming, computers, etc. [Serious]

Post by Dreams » Mon Apr 30, 2012 8:48 pm

arduino
Sounds like a narwhal.
Anyways.... I recently got almost-scammed when I tried to get Ubuntu, and I got a site that tried to get me to pay for it. :(

User avatar
atomtengeralattjaro
Site Admin
Site Admin
Posts: 35622
Joined: Wed May 23, 2007 3:43 pm
Location: green
Contact:

Re: Programming, computers, etc. [Serious]

Post by atomtengeralattjaro » Mon Apr 30, 2012 9:14 pm

:o that would require skill.. pretty hard to miss ubuntu.com

oh wait.. it seems it threw me a nice big error.. some drupal crap. Maybe it got compromised earlier.
Ivokyuftaf6666 wrote:
Sun Oct 20, 2019 5:22 pm
Awesome Site, Delivering Fun
Image

User avatar
Dreams
ASDF High Priest
ASDF High Priest
Posts: 2306
Joined: Tue Nov 29, 2011 7:04 pm
Location: STOP STALKING ME! I'M INSECURE!
Contact:

Re: Programming, computers, etc. [Serious]

Post by Dreams » Mon Apr 30, 2012 9:19 pm

Unlikely. The real site is ubuntu.net or something like that.

User avatar
Anonymously Famous
JKL; Assassin
JKL; Assassin
Posts: 11413
Joined: Thu Mar 03, 2011 6:52 pm
Location: Area ???, under Bermuda Triangle

Re: Programming, computers, etc. [Serious]

Post by Anonymously Famous » Mon Apr 30, 2012 10:48 pm

According to Google, it's www.ubuntu.com.

Cool! For a really user-friendly way to install Ubuntu, there's even an Ubuntu Windows installer!
BOTTOM TEXT
ThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Proud poster of the 300kth post in General

Post Reply