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.

Tuesday, September 3, 2013

Appreciating the Little Victories, Getting Over Mistakes and Taking Baby Steps Out of Bad Habits

I like improving.

No.

I love improving, no matter what it is. I was never an optimist, but I generally never try to put myself down. When I have a dream or desire, I seek it, but I feel that at times my dreams are so extravagant, that I am unable to obtain my smaller goals. Programming has always been a joy to me, whether it is the actual sitting down and typing out the code, or crunching concepts in my head as to what could possibly be highly effective.

My skills are my pride and my joy, so when I feel like someone is demeaning towards me or does not believe in them, I often get a bit discouraged and "shut down". It happens almost every time. Sometimes, I won't even look at things that I've made because I become ashamed of them. And I think, "Why? What for? What am I afraid of? Is it the opinion of others?" Time heals a lot, even with people who might bring up things that you did in the past reoccurringly, you can move on without them. It's like when you are walking down a path in a lazy race, and others will stop and laugh at your stumbling, but in that time that they stopped, you not only dusted yourself off, but you kept moving.

But I'm human, can anyone name a time where they were insulted in some way, or they met a disagreement with someone else and they hadn't felt uncomfortable? I wish I could. But instead of worrying about pipe dreams, the best thing to do, whether that's in the software world or not, is to not worry so much about what people say and to focus on what you feel you can do.

And then improve on it.

Just recently, I made a personal discovery about how, through starting small, I can get big ideas to expand upon my skill set. I am not unlike some people, I've let small setbacks become greater than they needed to be, and failed to go the extra mile, but here I am, taking the time to say

I have a problem and I want to improve.
How can I do that? It isn't by sitting around and talking about it. Instead of letting yourself "vegge out", or let your "comfort" set in, try getting out of your comfort zone. I like the motto; "Just do it". It has a nice feel to it.

Here's a nice and easy thing, pretty generic so you can apply it to just about anything.

Set a goal, it must be completed within the next three days. And do this for the next month. Chart/note everything you start, everything you complete, everything that you quit or just stop doing and everything that you are still working on.

Reward yourself.

Profit.

Wednesday, August 21, 2013

iPhone 4 Woes

Today, right after I got off of work, I started to notice this odd error pop up that said: "No Sim Card" whenever I tried to make a call. I've sat down and attempted to troubleshoot it in a number of ways, none of them seemed to work or yield any results as far as getting the error to go away. I've restarted the phone like 6 times and it does nothing but display this stupid error.

On one hand, I am actually extremely glad, it means that I can actually ditch this iphone. On the other, I'm quite sad, because I'm still connected to all of my social networking sites, and there is some information on this phone I'd rather not lose attempting to factory reset it if I even decided to do so.

Sunday, July 28, 2013

[Python 3] Console Battery Monitor In Python [Using BAT0]

I never took up Lua, despite having a Lua-based Window Manager (AwesomeWM), I've been able to feel my way around with the help of some friends as well as a bit of googling. "Implementing a battery monitor into the wibox seemed wasteful," I thought. "Why not create a terminal battery monitor for the good of learning?"

And so I did.

Here's what the output looks like:


Here's the code [Image]:


Here's the code again[plain text]:

#!/usr/bin/python
# The full charge.

cf = open('/sys/class/power_supply/BAT0/charge_full')
cf = int(cf.readline().strip('\n'))

#The current battery charge

cn = open('/sys/class/power_supply/BAT0/charge_now')
cn = int(cn.readline().strip('\n'))

st = open('/sys/class/power_supply/BAT0/status')
st = st.readline().strip('\n')

# Creating the Percentage
   
percent = (cn / cf) * 100
   
#  Creating the Rounded Percentage
   
percents = str(percent)[0:2]
rpercent = int(percents)


def batMon(cf, cn, st):


    # Testing Whether or not it is Charging
    if rpercent == 20 and st != "Charging":
        print("\n!!!! Battery is low! Please charge it now!!!!")

    print("\n[Charging]: %s" % st)

    # Printing out the total Voltage to the console
    print("[Total Charge]: %d" % cf)
   
    # Printing out the current voltage to the console
    print("[Current Charge]: %d" % cn)
   
    # Printing out the Rounded and the actual percentage
    print("[Round Percent / Percent]: %s / %.2f" % (rpercent, percent))




if __name__ == "__main__":
    batMon(cf, cn, st)

This was a pet project of mine for a while. I just recently decided to get into it. It's released under GNU GPLv3.

Thursday, July 25, 2013

Why I've stepped away from "Automated" AUR tools.

I've recently decided that I no longer have any interest in using things like yaourt, pacaur, etc... Because I find that it gives way to me spending less time actually reading the PKGBUILD and coming to a much more rounded (and/or experienced) understanding of what it is to "build" a package. I want to spend more time actually figuring out how the PKGBUILD's work so that later on when I'm trying to figure out what broken, where and why, I'm not stuck scratching my head and sounding like an idiot.

"Why didn't it install?"

"'Dunno, kind of thinking that it had an error in the script."

"What script?"

"'Dunno, the one from the AUR."

"Uh-huh.."

It's also a bit annoying, when the PKGBUILD is trying to install a dependency that doesn't really exist [Don't believe that AUR PKGBUILD'S ever have this problem? Try installing lmms-vst...], and after waiting, what seems like an hour, for it to all install, you read: "Aborted...; Restart?" Very much frustrating. Besides, it would make me feel a bit proud to one day be able to determine what's wrong with it before I ever install it, on top of the fact that pacman makes it easy to build and then install a package, I simply don't see a need for two different package managers on my system anymore, it simply doesn't make sense to me and makes me feel like I'm turning "lazy." Which is a good and a bad thing. Good because, well, convenient, fast, less time debugging, less time thinking about what's inside the package. Bad, for some of the same reasons that it's good, and also because when breaks happen, it sucks to do it the "Winblows" way and uninstall and reinstall the package over and over again...

Now, I have nothing against it if someone else wants to do that, and I highly recommend a package manager like yaourt, pacaur, or something else along those lines if you feel that you won't be able to get the job done somehow with the extremely simple system of:

cd /path/of/dir/that/PKGBUILD/is/in
makepkg -s
pacman -U *pkgname*-*pkgver*-.tar.xz

Now that I think about it, I might make a bash script that'll simplify the last two parts for me, but the reading of the build itself is the important part to me, actually understanding how the differently designed scripts are built... ust to hammer in my point, one more damn time.

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!]:


Taring and Untaring .tar, .tar.bz, .tar.gz, etc... [Tutorial][Novice]

For those lacking time (or patience), the tl;dr (too long; didn't read) is at the bottom.

Tar -  The GNU version of the tar archiving utility

This is the command line application which we'll be learning today. It's a rather simple application, really, most tend to somehow mentally overcomplicate it. Remember that just using man [command] will usually yield the man(ual) page for a terminal command!

A "tar archive" itself is those little files that have extensions like .tar, .tar.gz, .tar.bzip, .tar.bzip2, and etc. How we handle each of them will change depending a bit on what our needs are.
 Alright, let's go right into our little black box, of course!

 Now inside the plg directory in myhome folder (short for playground), I've shown what's inside the current directory, as well as the farm directory
And here we go, we're actually creating a tar archieve! It's as simple as that. The switches can be broken up as: tar -c -f, but it's just easier to go tar -cf, as long as the tar archieve is right after the -f switch [Which specifies the archive of choice], there's no problem.

Want proof of what's inside? No problem, the -tf switches list everything! "But what about if we modify a file?" Do we have to 're-tar' all over again? No problem, -uf will only update the files in the archive that have been modified... Or created! When we add 'v' we can see everything that happens when it happens!
"But now how do we extract the tar?" Simple as that! tar -xvf the_tar_you_want.tar and it's done in record time!
 "What about .bz files?" What about them? To create them, just add a lowercase j anywhere in the primary switch! 
-jcf -jcvf -cjvf -cvjf... 
You get the idea!
 
 

 It's just intense how just adding a single letter changes everything and leaves it the same!

 Wow! Even .tar.gz files we can create! There's nothing to it with the -z switch added on!

And- You get the idea!

Hopefully, this tutorial was helpful enough for especially newbies to linux, as far as the tar command is concerned. I see a lot of these tutorials out there, but not many that actually use images of the prompt, step by step.

tl;dr

tar -cf creates regular .tar archive
tar -tf  lists what's inside the tar archive
tar -xf untars the regular .tar archive
tar -uf updates the tar archive with the newer versions of files, as well as adds new files that didn't exist before.

Adding j (in any order to -cf like -jcf, etc...) allows us to perform any of these things on .tar.bz files, z (same as j) allows these on .tar.gz, capital J (same as j and z)  allows it on .xz files.

Tuesday, July 9, 2013

Programming in C.

As of recent, I've decided that I would take the dive of going right into C programming. It isn't that I'm giving up on Python, that couldn't be far from the truth, it's that I feel that I would be able to understand much more in the software world, knowing C, before I would attempt to conquer using Python alone. I feel there is a gap in my knowledge, in other words, that can only be filled by learning C and perhaps later C++.

C is a bit different than what I'm used to, but I always get excited when I learn new Syntax. For a person who doesn't like change, this might be a bit of a struggle at first, but if you sit down a bit and calmly go over a tutorial or two online, then you should have no problem getting right into the groove of it all.

Pros:

C is incredibly fast. It tends to be speedier than Python, I believe, when it is executed. And that is an incredible bonus, over most, if not all, programming languages. 

C has a lot to offer. It seems to be incredibly modular.Looking at most standard C programs online, a C program doesn't come with builtins like Python does without calling "#include <stdio.h>", and while that may seem like a bit of an issue, it can actually be a plus when the program you're writing does not require certain builtins that Python comes preinstalled.

Cons:

C can be a bit difficult to understand. The learning curve for learning how to program in C verses how to program in Python is a bit steep especially if you're a beginner. I'll say that because I learned to program in Python, and because I took the time to research specific terms, as well as reading my Python Programming book, that I understood specific terms used while studying C. Searching the internet for these terms mentioned will help even the newbie understand some of even the most diverse jargon, though the reality is, does one have the time or want to apply the effort? Sure, it'll help in the long run, but humans can be impatient creatures. C is now, considered a Low-Level Programming language, though at one point it was considered otherwise.

C programs can become quite massive. It's true that takes about ten lines of Bash to program something that would need ten thousand lines of C. If you're one to get lost inside of your projects, and eventually wander out after haplessly searching for the path, you're not so fortunate to get hooked on C programming. There's nothing wrong with hard work and effort, but this is not so much a language for convenience.

C is a complied programming language. I'm sure some will come at me with daggers waving about how this should not be on the cons list, but hear me out. The write, compile, test/run process can be cumbersome to some, while to others it could be considered "a life saver" because, after all, if there is an error in your code, the compiler catches it.

Wednesday, June 12, 2013

Python 3: Classes; a quick examination.

Object Oriented Programming [OOP] is not really a new concept. It's something that Python does, and does well [even if there is room for improvement]. This guide goes as far to explain pretty much how classes work in Python. Comment below with any questions or comments.

I feel that there really aren't many tutorials out there to explain this a bit more in depth. Here is a much more well rounded explanation [compared to the sparse material I've found]:

Classes are basically what they're called, "classes" or "classifications" for certain "kinds" of things. We can take for instance a chair, and a dog. They both have four legs, but which one is made of wood? And what exactly is a leg? Something that can move or something that holds the chair up? We could create a class called "animate".

class Animate:
pass

Well, isn't that nice? We have a class that does absolutely nothing. But that's okay, it'll all fall into place. The pass statement allows us to create something that syntactically requires some code or data, but doesn't actually do anything at all. Let's create a second class called "Inanimate".

class Inanimate:
pass

Once again, we have a class that does nothing, but the diference between the two of them is their namespace. We now have an "Animate" and an "Inanimate" class. Now for objects.

chair = Inanimate()

dog = Animate()

This seems like old news, "We're just renaming the classes to chair and dog!". Not quite. In OOP [Object Oriented Programming] we can have as many inanimate or animate objects as we'd like.

pencil = Inanimate()

cat = Animate()

 Are two other seperate "instances" of the class. In fact, this is called "instantiating." In this case, for those of us who don't quite understand, a dog is an "instance" or a particular "existence" while a "cat" is a separate instance. To learn more about what can be done, let's edit our classes directly.

class Inanimate:
def __init__(self, name, type):
self.name = name
self.type = type

We've done a lot here, so let's go over it piece by piece. Each class has a special "function" called a constructor. The __init__ function. It allows us to specify attributes of each particular class that we have. It makes us creating different classes a lot more structured. Inside of the __init__ constructor, we see one element called "self" and we see two elements called "name" and "type". If they were specified like this:

def __init__(self, name, type = "Furniture"):

Then it would make all inanimate objects "Furniture" by default, but it would also make the particular attribute "type" optional, like optional arguments on a command line, which is both a good and a bad thing. If you made it "item" or even just an empty string, that would be far more practical. Because in that case, that would mean that "Pencil" would be furniture, too. The reason why you set self.name to the "name" parameter, is because you're basically setting the dot operator, as well as making whatever you put in the class at instantiation permanent to that specific instance of the class.

Pro Tip:

You can make each of the variables private by adding one or two underscores (_) to the beginning of each attribute like this:
def __init__(self, name, type:)
self._name = name
self._type = type

This actually much more use, like for example, if you didn't want people to alter your class, or when they didn't need to alter the class at all, using the API to work with it.

"But what is self?!" Self is referring to the "variable" of the object itself. When the python interpretor runs, it goes like this:

- It sees the class you made.
- It sees that you instantiated [Remember, that means 'create'!] an object.
- It takes the name of that object and goes back to read the class. It replaces self with the title of the object you had given it.
- It continues running the script.
 
Now we must edit our "chair" object.

chair = Inanimate("Chair", "Furniture")

dog = Animate()

Hm... That's nice, but let's say you wanted to return self.name? How would you go about doing that? Why, with a method of course! Methods are just functions that exist inside of a class that can be used along with flow controls [if, for, while] in order to increase the functionality. Let's create a method that returns the name of the item!

class Inanimate:
def __init__(self, name, type):
self.name = name
self.type = type

def getName(self):
return self.name

chair = Inanimate("Chair", "Furniture")

print(chair.getName())

Using this, we can actually reduce the amount of code we write later. Because we're using classes, we can do this for EVERY class. And that is some of the power of Object Oriented Programming.

Monday, June 3, 2013

How to screen capture in linux, audio, video, or both.

I initially under estimated the ffmpeg command and have been abusing it for its abilities to convert my audio files after downloading them from youtube!

The all-mighty screen capture command:

ffmpeg -f x11grab -s wxga [or instead of 'wxga' another screen size like 1300, 800] -r 25 -i :0.0 -qscale 0 -f alsa -i hw:0 -strict -2
The all-powerful audio capture command:

ffmpeg -f alsa -i hw:0 [or another alsa device] -strict -2

[Basic] How To Create Classes In Python [ Object Oriented Programming ]



Let's start by explaining one thing at a time...


Classes
in python, are a way to bundle data [information that is fed to the code, or that you 'hard-code' yourself], with associated code, making it easier to manage the code itself and fix bugs if they ever arise. They can help by allowing you to model the problem you’re trying to solve and manage a program’s complexity better.


Let's say you're creating a fighting game where there are two types of NPC's. Bystanders, and fighters. You'd create the "bystander" class as easily as this:

class Bystander:
    pass


You've created the Bystander class. Why is this so great? Because this means that you can set this class to as many variables as you want, and you'll be able to have numerous different "versions" or "instances" of each:

bobby = Bystander()

sarah = Bystander()

"bobby" and "sarah" Are two different "instances" of the same class called "Bystander".

They are what are known as objects. Individual "occurances" or "copies" of the same class. You'll understand why this is so cool in a minute.

Let's modify our class a bit to get a better grasp of what we're dealing with here.

# We created the class called "bystander".
class Bystander:
# Here, we'll have a docstring. They're good for telling what
# our classes do.
"""A Simple Bystander class. These Individuals all have their own greeting."""
    # Now we create what's known as a "constructor" [__init__]
    # Which allows us to take the variables that are passed to the
    # class when the object is "instantiated" or "created".
    # It uses self because it is actually referring to the variable
    # that you use to create the objects.
    def __init__(self, name, greeting = ""):
        self.name = name
        self.greeting = greeting

 #Then we instantiate our objects.
bobby = Bystander("Bobby", "Hiya!")

sarah = Bystander("Sarah", "Konnichi wa!")
 # Notice that Alex doesn't have a greeting, but there will not be an error.
 # That's because the greeting is a "kwarg" or a "keyword argument". It
 # Is an optional argument or "parameter" that can be passed.
alex = Bystander("Alex")
# Please note that no matter how many objects we have, we'll always
# know what objects of this specific class are capable of in the case of 'Methods'.

A Method is a function of a class that is made specifically to be associated with the class itself. Methods must always take the "self" parameter because when it uses "self" it is actually referring to the object itself.


class Bystander:
""" A Simple Bystander class. These individuals have their own greeting."""

def __init__(self, name, greeting = ""):
self.name = name
self.greeting = greeting 

def say_Name(self):
print(self.greeting + " My name is", self.name + ".") 

bobby = Bystander("Bobby", "Hiya!")

bobby.say_Name()

Kira = Bystander("Kira", "Oh, yeah, baby!")

Kira.say_name()
Running this through the interpretor, we should get:

Hiya! My name is Bobby.
Oh yeah, baby! My name is Kira.

I hope this should provide a basic enough insight on how classes and objects are made. I'll leave the rest up to your imagination.

Sunday, June 2, 2013

How I Stop My Blogging Procrastination [and Other Procrastination in General] -- It works every time [Almost ;)]

Sometimes, when I'm sitting around thinking about things, or considering what to write, I start off by googling for some bit of information that I'm looking for, and I usually attempt to explain it in depth... Unless I get lazy.

It happens to the best of us, even those with obsessive hobbies like myself. But my solution that's been working the best for me is to start an article and then go back to it later, but I limit myself to three articles and do not allow myself to go on to other subjects!

Another trick is to limit distractions, like my iphone, I have this habit of texting other people when I've got nothing to do instead of staying focused. I'm a person who likes quiet and focuses better without distractions, even if I might want the occasional distraction to keep my wandering brain from becoming bored.

Or maybe I'll go on Facebook, or Twitter. I like Twitter a lot by the way. For some reason, in my opinion, it tends to lack in all of the drama that comes with interacting with your family and friends. I'm a believe a little in the Zodiac [horoscopes], and being a Gemini, it's hard for me to stay focused, which is my reason for writing this post in the first place.

But all of that is besides the point. Que; bullets:

  • Minimize distractions: If you're not the type of person who can remain focused on one topic for two long, or who has a tendency to stray from things to do others of greater personal interest, then it's best to minimize those other things around you that have a chance of catching your attention.
  • Take breaks: There's nothing wrong with this. You're only human, don't beat yourself up over the fact that you weren't able to write a 5000 words tl;dr post for the third time this week.
  • Limit the number of things on your plate: Like I said earlier in this post, it's better to limit yourself to maybe two or three posts to write on and stick to them.
  • Brainstorm: Writer's block is a bitch, 'nuff said. Sometimes there's just not anything interesting to talk about, going back to my 'googling talk'. There's no shame in knowing nothing, there is in knowing everything. The best thing to do in this case, is to relax and not stress so much about the content but the quality of your writing. Go back, fix grammatical mistakes, spelling errors, and polish up your post. You could have the best content in the world and if it looks like garbage with "u shud" and "dis is y u mus", a lot of the time, people are going to keep on scrolling on google. It isn't you, it's their standards being such that if the person doesn't have time to write properly, who's to say their guide isn't rushed?
  • Have fun: When you stop having fun, you stop wanting to work, and when you stop working nothing gets done. Keep this in mind.
  • Use the three S's and work from there: Short, Simple, Straight to the point. Once you bang out the bare bones of the knowledge that you need, go around and add your fluff. No need to stress and force yourself to work harder than you need to unless you really feel like it. Besides, if you keep things on point, you can better keep your own attention. You can always add on pieces, here or there to make it easier on yourself, and maybe re-advertise your content in a non-illegal and malicious fashion, of course.
Follow me on Twitter: @ehldmnt

Returning to my roots: Tidbits on Bash Shell Scripting

Ah, while creating a small shell script to perform three tasks:

  • Upload to the Testing-PyPi Server (http://testinpypy.python.org/pypi))
  • Reduce the amount of typing on the command line.
  • Possibly provide a way that I could use it in another or different python script to automate this process.
  • (BONUS) Take down the task that I'd like to perform in natively python once I become much more proficient.
I quickly googled the means by which to pass user input to STD-IN to set it to a variable in bash and here is how it's done:



To learn more, pay a visit to the all mighty google. ;D

Follow me on Twitter! @ehldmnt

A random coding tidbit... How to pause your Python code.

Ever needed a pause for dramatic effect. Why not use the native "time" module to get the job done?



Saturday, May 25, 2013

Friday, May 24, 2013

Why Use Dropbox? -- Why I Made the Switch From Mediafire.

There's been a question floating around in my head the past few months about the cloud service that I used. I've been using mediafire for quite some time now, without much thought about using a cloud service. When I first switched to linux, it was only after my Vista Machine had "bluescreened". The second time I had thought to use a different cloud service was when media fire complained of the size of the files that I was storing. The third time was on my brand new Ubuntu machine, when I screwed myself over trying to install Arch with only basic command line tools under my belt.

Now, I'm switching harddrives and I don't want to spend 25 dollars, hoping and waiting for my friend down the street to get it done within this month...

So I tried dropbox and what I've discovered is that it is extremely fast, and efficient. And here's why.

  • When you use dropbox, no matter where you are or what device you're using with it, all of your information is instantly shared between devices. 
  • Drop box can be set up to start syncing right when your computer starts up, or only when your computer is loading. 
  • Drop box simplified my file management, and made it so that in order to send a picture from my iphone to my laptop, I didn't have to email myself.
  • Drop box begins with 2G free, but for only 9 dollars a month, will boost that to a whopping 100Gs. That's a deal, considering my flashdrive costs 30 dollars for 16Gs [and has a higher chance of being destroyed]
  • My worries and my fear of a loss of data have actually been minimalized, I'm confident in the dropbox servers.
  • I can program Dropbox to sync specific folders as well.

Follow me on Twitter @ehldmnt

How to use Vim [Navigation and Text Editing]

Remember when you first started to type and everything was slow? Of course you looked down at the keys here and there to make sure you were pressing the right letter, but after that, you were good, right? Well, what's stopping you from learning Vim? I mean, yeah sure, to initially begin outside of input mode seems a bit odd, but to be honest, it really isn't that big of a deal. Vim is fast because it keeps you from reaching down for the mouse, or arrow keys every two seconds just to change your position, therefore, reducing the amount of movement your hands have to do, and also not forcing you to shift from your comfortable position [yes, Vim is for the lazy].


When you initially begin using Vim, you're probably a bit flustered that you can't just "start typing in text" right from the get go. Well, that's okay, just press the "i" key and you should be all set. Take note of the table below that tells of all the basics of moving and editing in Vim and give them a shot in the editor itself.



    i     Allows you to insert text where the cursor is.
I Allows you to insert text at the beginning of a line without whitespace
a Allows you to insert text at the end of a line.
oAllows you to insert text below the current line
OAllows you to insert text above the current line
Esc
Exit insert mode
j<n> Move the cursor down< A certain number of lines>
k<n>
Move the cursor up < A certain number of lines>
dd
Delete line
d<n>d
Delete a number of lines [including the one currently selected]
ggGo to the first line
GGo to the last line
g<n>gGo to a specific numbered line
x
Delete Character after cursor
X
Delete Character before cursor
w
Move an entire word ahead, ignoring spaces [white space]
b
Move an entire word back, ignoring spaces [white space]
dwdelete the next word
dbdelete the last word
d<n>wdelete the next <amount> words
d<n>bdelete the last <amount> words

Follow me on twitter! @ehldmnt

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!]