Programming, computers, etc. [Serious]
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I should really brush up on my Java.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
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)
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
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
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.
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.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Glad you got it fixed. Bugs like that can be a pain to figure out.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Good point.
The other day I fixed a problem with my wife's iTunes by clearing out her cookies in Safari. Go figure.
The other day I fixed a problem with my wife's iTunes by clearing out her cookies in Safari. Go figure.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
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.
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...
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
I just found your facebook page. Now I know all about you. You should be unsettled about this.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
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?
Should I be on the lookout for strange friend requests?
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
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.

- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Why not?
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Re: Programming, computers, etc. [Serious]
(sorry to interrupt anyones topic) has anyone here programmed an arduino? just wondering what code i should learn

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.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
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
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- Dreams
- 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]
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.
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.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
oh wait.. it seems it threw me a nice big error.. some drupal crap. Maybe it got compromised earlier.

- Dreams
- 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]
Unlikely. The real site is ubuntu.net or something like that.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
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!
Cool! For a really user-friendly way to install Ubuntu, there's even an Ubuntu Windows installer!
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.


