Just A Small Guideline

Feel free to browse the site. Don't be afraid to leave comments, they're supportive.
Please follow me on Twitter @ehldmnt and retweet my posts.
Showing posts with label troubleshooting. Show all posts
Showing posts with label troubleshooting. Show all posts

Thursday, July 18, 2013

[Python][Tidbits]Building A Python Module For "Personal" Use

My module has three different functions. Though, I feel that three functions is too many. It would seem that by using *kwargs, between the parenthesis I cannot create any other kind of parameter. *Sigh* I guess I'm going to have to either rebuild it, or edit the README. My goal is to minimize the code and maximize the performance. The construction of a Module that would be used "strictly for personal use" is not a bad thing here or there, but in excess, you'd pretty much spend more time writing modules, less time actually getting some things done. And that can be fun, but not when you're tried for time, or on a deadline.

You're better off googling around for code that someone else created, read the API, and then move on.

As a side note, I've recognized an issue in a scripting style that I've used just recently, the problems very easily being solved by reading over the Python 3 documentation, which I've only done about once or twice, but not as heavily as I have recently. Built-in String methods. Everything in Python is an object of a class, in this case: str(). A few good ones are:

.startswith():

This tests for a specific set of characters at the beginning of a message. It's case sensitive, so be careful. It returns true.

.endswith():


Tests for the end of a statement, this can be useful, though is restricted as far as case is concerned. Returns True.

.upper():


Makes all of the letters inside of the string uppercase.

.lower():



Makes all letters in the text lowercase.

Pro Tip:

When I first started out, I used to make massive, and ugly logic:

yesorno = input("Y\n ")
if yesorno == "Y" or yesorno == "y":
somecommand()
else:
 someothercommand()

Now I just:

yn = input("[Y\n]: ")
 if yn.lower() == "y":
somecommand()
else:
someothercommand()

It's just neater, easier to read, and far less code.

.capitalize():


This capitalizes the first letter in the first word. I used it here to capitalize a name. Good for possibly forms that would require name data.


.casefold():
.





Similar to .lower() but instead removes all case specifications in general.

They can also be compounded.


I hope these thoughts were useful. To read more about string methods, visit the Python Documentation.

[Xorg][Tutorial] Dvorak Keyboard Map Settings In System-Wide[Archlinux]

Yet again, I've discovered an even better means of setting the keyboard layout to dvorak. Much more simple than anything that I've yet discovered. The Archwiki is such a useful place to be when you're searching for answers for a long time problem!

As root, create the file /etc/X11/xorg.conf.d/10-keyboard.conf.




Then simply add this text to the file using your favorite editor [Mine being Vim]:
 
Section "InputClass"
    Identifier             "Keyboard Defaults"
    MatchIsKeyboard       "yes"
    Option               "XkbLayout" "dvorak"
EndSection




Then restart X (or logout and back in) and you're finished!

It even works for slim [Logging in with DVORAK at long last is possible!]:


Sunday, May 19, 2013

How to transfer files and directories over an SSH connection.

This is a long unanswered question that I had actually scowered the inernet for, never realizing that the answer was staring at me in the man pages. This guide assumes that you have a LAN ssh connection, and doesn't explain how to achieve one over the internet First things first, introducing the scp command.
[SYNTAX]

scp [OPTIONS] [FILE] [DESTINATION]

To copy a single regular text file called "important.txt" from the user "bob" on the present computer "maxie" to the remove computer user "mark"'s documents on a computer named "sandbox":

 scp important.txt mark@sandbox:~/Documents

 The only downside to this is that you have to know the exact directories, but this guide assumes that you already know where they are.

To copy an entire directory, maybe the "water_pictures" directory from "mark" on "sandbox" to "bob" on "maxie":

scp -r water_pictures bob@maxie

This will recursively [explicitly] show you everything that is being transfered, but it'll get the job done.

Sunday, May 12, 2013

Organizing Your Python Scripts: A Guide For All Who Want to have neater code

When organizing your python scripts, it is good to have certain layout when you're programming, as to reduce the amount of stress about the order of things later. I'll define here some rules for functions, classes, and variables, and some tips for how you'd probably code your scripts. I'll be updating this list as things come to mind.

Tips and Tricks


  • Always write your imports at the top of your script.
  • Always define your functions at the beginning of your scripts and call the functions that are called by others before them.
  • Always make sure that you call your variables before you call your functions.
  • Always make sure to comment your code if you don't think you'll remember what it's doing.
  • Always use docstrings to explain what any piece of your code is doing.
  • Always define proprietorship at the top of every script that you write, the name of the script, and the license. 
  • Always use consistent indentation, not matter what, or expect indentation errors.

Sunday, April 28, 2013

UTAU, MMD, PMD/PMX Editor in Linux. -- Status, Installation, and more.

UTAU



If you know of Vocaloid, you probably know of UTAU. UTAU is a singing synthesis shareware application designed for Microsoft windows [With it's recent Mac Implementation which has spurred some rumors of another version to soon come out for Linux], that allows users to create their own "voice banks" and have their personal "UTAU's" sing in harmony. It is known to at times produce better, more realistic results than Yamaha's Vocaloid, amongst others, but requires more effort on part of the user.


MMD [Miku Miku Dance]


If you know of UTAU, you probably know of Miku Miku Dance. Miku Miku Dance is free software that is designed for Microsot Windows that allows users to move models that either they or others created. This can be use to create lipsyncing videos, music and dancing videos, PV's, home made movies (with the models) amongst other things, frame by frame.

PMD/PMX Editor


This program was also designed for Windows. It is for the creation and editing of .PMD/.PMX files that are used to dance/move/sing in MikuMikuDance.


Prerequisites [Required Programs]:


-- Linux Distribution [Any kind will do, really]
-- Playonlinux
-- Wine
-- Winetricks
-- Japanese Locale Enabled

Assuming that you already have a Linux distribution coming to this tutorial, first, download and install the lastest play on linux version. At the time of this tutorial, that would be 4.2.1. The instructions for installation depends upon your distro. If you use Arch like me, then it's no problem! Installation is as simple as popping a terminal and entering in:

pacman -Syu playonlinux wine winetricks

This command, not only updates your system but it also syncs to the repositories and gives you the proper programs that you need for this tutorial.

The Japanese Locale issue [This will demonstrate how to acquire it in Archlinux], is a no brainer. If locale -a yields anything similar to these:

C
POSIX
en_US
en_US.iso88591
en_US.utf8
ja_JP
ja_JP.eucjp
ja_JP.ujis
ja_JP.utf8 # Specifically this one
japanese
japanese.euc

zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8

Then there is really nothing else you have to do.

Otherwise, uncomment the line ja_JP.UTF-8 in the file /etc/locale-gen. And then run:

sudo locale-gen

If you already have these things, then great, skip this step.

Installation of UTAU




To install utau, it is pretty easy.

Steps:

1. Use Playonlinux To Install the Program.
2. Enjoy!

Step 1:

Select the install button as depicted above.



This dialogue should pop up.





Check testing and this dialogue should pop up, just click okay.



Then type into the search bar: UTAU, this should pop up.

Step 2:

Finish the installer and you're done! If it asks to create a virtual drive and/or a shortcut select yes! You can choose to install the English patch or not. Click on UTAU and hit the "run" button in the upper left corner.


Installing Miku Miku Dance/MMD [WIP -- Check back later for an update!


The installation of MMD is a bit more involved.

Prerequisites [Required Programs]:

-- Playonlinux
-- Wine
-- Winetricks
-- MMD

Steps:
1. Correct Settings, Create the 64 Bit Virtual Drive, and put MMD inside of it
2. Adjust the Windows version
3. Debug to figure out the required programs to run
4. Fix The Layout Issue
5. Enjoy MMD!




Step 1:

First, select tools.

Then select x64 and scroll down to the wine version 1.4-rc4-raw3 and install it. Then click on configure.


In the bottom left corner, select new, run through the installer and select 1.4-rc4-raw3 for your wine version.


Take note of the name of your Virtual Drive. The next part will be easier. Open a terminal and Do:

cd /path/to/the/mmdfile.zip
unzip -x *thezipfile*; cp -a *thefolderthatcomesoutofit* ~/.PlayOnLinux/wineprefix/nameofthevirtualdrive/drive_c/Program\ Files\(x86\)/

Now you go into the PlayOnLinux configuration dialogue and you click on "Create shortcut from virtual drive."



Step 2:

Now it's the time to adjust the Windows version. Click on the Wine tab Inbetween "general" and "install components" and select "Configure wine".



Then in the first part of the Windows 98 looking dialogue box on the bottom right, select "Windows 7". It should be towards the top.


You may now press apply and okay, and then close the dialogue boxes. Leave the main Playonlinux window open, the one that has your shortcuts in it.

Finally, you settings must match the ones I have up on my virtual drive. Select the "Display" tab second to last and then change your settings to match.





Step 3:

In order to complete step five, you'll have to select MMD, and then "debug" on the right hand side above "Report a problem". If no errors are returned and MMD runs successfully, congratulations, move to the next step! Otherwise, watch the error messages dialogue to figure out if there are any necessary .dll's.

Step 4:

With MMD open in Linux at the moment, it looks atrocious.

So, to solve this, click on the window and press  alt+ V and then alt+W (view > separate window). Resize them to your heart's content and enjoy MMD in linux.

Step 5:

So far in this wine version that we've selected, there are no issues with even multimodels. In fact, I feel like it ran faster in linux than it ever did on any of my Windows computers. The raw speed is incredible. The controls like on Windows are the same, so enjoy the familiarity of the program!!

Installing PMD/PMX Editor [WIP -- Check back later for an update!]


Tuesday, April 2, 2013

Awesome-WM: How to Set Dvorak [or other keyboard layouts] as default.

In my personal experiences with AwesomeWM, I could not seem to set the DVORAK keyboard layout without messing around with the xorg.conf files, and even then it was to no avail.

As an actual solution [or in other words 'work around' to this, the ~/.xinitrc file must contain:

setxkbmap -layout dvorak [or ru, fr, etc..]

Before the line:

exec awesome

And that should solve the issue.

Sunday, March 24, 2013

Troubles With Learning Modules Python(2) -- Figured out.

In my last post, I had trouble figuring out why the Fibonacci Series wouldn't print. Then suddenly, after spending a bit of time studying and reviewing knowledge that I had acquired, I realized that the issue was in fact the line 6.

# Fibonacci numbers module

def fib(n):    # write Fibonacci series up to n
    a, b = 0, 1
    while b < n:
        print b,
        a, b = b, a+b

def fib2(n): # return Fibonacci series up to n
    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result 
 
Something as simple as this:
 
 
# Fibonacci numbers module

def fib(n):    # write Fibonacci series up to n
    a, b = 0, 1
    while b < n:
        print(b),
        a, b = b, a+b

def fib2(n): # return Fibonacci series up to n
    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result 
 
That pretty much solved everything for me.
 
Update:  Mon Mar 25 21:47:07

I realized that the issue was with the shell using python 3 instead of python 2. 
Python 2 still uses the print function in the way that I'm used to, python 3 does not.

Troubles With Learning Modules Python(2) -- Figured out.

In my last post, I had trouble figuring out why the Fibonacci Series wouldn't print. Then suddenly, after spending a bit of time studying and reviewing knowledge that I had acquired, I realized that the issue was in fact the line 6.

# Fibonacci numbers module

def fib(n):    # write Fibonacci series up to n
    a, b = 0, 1
    while b < n:
        print b,
        a, b = b, a+b

def fib2(n): # return Fibonacci series up to n
    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result 
 
Something as simple as this:
 
 
# Fibonacci numbers module

def fib(n):    # write Fibonacci series up to n
    a, b = 0, 1
    while b < n:
        print(b),
        a, b = b, a+b

def fib2(n): # return Fibonacci series up to n
    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result 
 
That pretty much solved everything for me. 

Friday, March 22, 2013

Frustration: AwesomeWM & My Use of Dvorak

Seeing as I have this lovely devotion to the DVORAK keyboard layout (to the extent that I literally rearranged the entire keyboard, upside down keys and all, specifically to facilitate this need), I tend to get extremely frustrated by what seems to be a bug in Awesomewm.

At first, it was just a minor annoyance, and then gradually it became a bit more than a nuisance as I literally have to reach into my 3 - 5 years of qwerty knowledge in order to remember what which key was supposed to be. Mind you, I've memorized the Qwerty and Dvorak style because there are those times in school where I have no choice but to use it.

This is all besides the point,

Which is that awesomewm is a great Window Manager but it doesn't seem to keep to anything I tell it to, which is extremely frustrating when I have to type Mod4 + R. I've looked into Xorg on the archwiki, amongst other things in the AwesomeWiki, but it seems that the only thing that ever solves it is restarting awesome after typing in "setkbmap dvorak" into a terminal. Thankfully, I have zsh, and that helped me through a lot of the worries because once I find the "s" on the keyboard (Which is right next to a for those that are wondering, where it used to be on Qwerty), I just had to press the up arrow key and found what I wanted.

If I find a solution for this, I'll write up a tutorial.

Friday, February 22, 2013

Minecraft On Archlinux -- Tutorial

There are a few ways to go about getting minecraft on Archlinux and while the Wiki is there to guide you through . I recommend using my favorite AUR installer yaourt to get the job done.

Here's my Video Tutorial: