Monday, November 30, 2009

github, ssh config file and ssh-agent

Github makes use of ssh-keys for checking out your stuff via git. I also have several different keys and store them with different names such as github_rsa or some such. In order to get this to work, you have to create a config file that stores the location of the private key.

For github, in the .ssh/ directory, create a file `config` and enter in the following:
From github's help page:

Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile path-to-private-key


In several situations I've had to set up ssh keys for remote machines that only provide me with terminal access. Thus I keep getting pestered to enter the passphrase for the ssh key. ssh-agent takes care of having to keep entering in the passphrase.

After setting up the ssh-keys do:
eval `ssh-agent`; ssh-add ~/.ssh/github_rsa

It will then ask for the passphrase the one time when it adds the key to the agent, and then wont ask again.

The 'let go' command

I was recently let go from the place where I plied my craft (I left on ok terms). The only real issue I had was that the computer I used there was a company computer, and during the time I had spent there, I had done things such as purchase stuff on amazon.com, save passwords to various email accounts in browsers, etc. So to rectify this situation and ensure that nobody using the computer after me had access to my data, I rebooted the machine in recovery mode (this was an ubuntu box) and ran

find /home/tfdml/. -type f | xargs shred -fu ; rm -rf /home/tfdml/ ; shutdown -h now

then gathered my belonging's and left. Note that I could have just as easily switched to an alternate terminal with ctrl-alt-f1 and ran the command there.

This ensured, at least to my level of paranoia, that all my personal information was secure. Now, all documentation, code and notes were all stored in the company repo, so it's not like I was being malicious and destroying all the work I had done for the company. This removed all of my own personal information from the machine without having to reformat the drive or any other such drastic measures and allowed for the company to quickly turn the machine around for another worker to use.

(Edit: It turns out this command didnt work as well as I planned as apparently it took quite some time to run. Eventually one of the other dev's there saw the machine was on and simply turned it off since there was nobody using it anymore. This allowed the guy who got the computer after me access to some of the files in my account. In retrospect, I should delete all the huge files (anything over a gig, music directory, vm images) before running this command and ensuring that the command is only going to operate on a set of files that amount to at most a gig.)

Tuesday, November 17, 2009

"so that" vs "such that"

So that or such that? Found a nice article that covers these issues, as well as a few other cool grammar bits for mathematicians.

From the article:

Here are the definitions.

so that

  1. In order that, as in I stopped so that you could catch up.
  2. With the result or consequence that, as in Mail the package now so that it will arrive on time.
  3. so ... that. In such a way or to such an extent that, as in The line was so long that I could scarcely find the end of it.
From dictionary.com

such that

  1. adj : of a degree or quality specified (by the "that" clause); their anxiety was such that they could not sleep. (dictionary.com)
  2. A condition used in the definition of a mathematical object. For example, the rationals can be defined as the set of all m/n such that n is nonzero and m and n are integers . (mathworld.wolfram.com)

Examples

  1. We require x to be a rational number so that mx is an integer for some m. [Correct]
  2. We require x to be a rational number so that 3x is an integer. [Incorrect; should be such that 3x is an integer.]
  3. Let H be a discrete subgroup of the Lie group G so that G/H is compact. [Incorrect --- not all discrete subgroups of Lie groups have compact quotient; this is from the Annals of Math., 107, p313.]
  4. Let N and N' be submodules of a module M such that N contains N', so that N/N' is a submodule of M/N'. [Correct! From Steps in Commutative Algebra.]

Briefly, if omitting the "that" from "so that" renders the sentence nonsense, then it was already nonsense, and you should have used "such that". You won't find "so that" among lists of commonly misused expressions because only mathematicians commonly misuse it. Probably the error arose from the influence of German on American (mathematical) English, since the two are not distinguished in German.


Mathlish

Wednesday, November 4, 2009

da Vinci quote

Those who are enamored of practice without science are like a pilot who goes into a ship without rudder or compass and never has any certainty where he is going. Practice should always be based upon a sound knowledge of theory.

Wednesday, October 28, 2009

Displaying and Configuring Character Sets in MySQL

Display all character sets:

show variables like 'character_set%';

Change the character set for a table:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name;

BUT with the caveat that
The CONVERT TO operation converts column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:

ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;

The reason this works is that there is no conversion when you convert to or from BLOB columns.

The process to completely change all mysql's character sets from latin-1 and make this garbage:
(using the show variables command from above)
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
look beautiful like this:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
involves simply adding the following to the [mysqld] section of your my.cnf (or /etc/mysql/my.cnf if you like, and are on a debian based machine)

collation_server=utf8_unicode_ci
character_set_server=utf8

and adding the following to BOTH the [client] section AND the [mysqld] section:

default-character-set=utf8


This is simply in case you cannot go back and re-compile mysql using
./configure --with-charset=utf8 --with-collation=utf8_general_ci

Tuesday, October 27, 2009

Completely removing gnome from ubuntu.

I use terminal only versions of ubuntu on several vm's that I have set up. Maybe I should use something else, like just plain debian with no gui, but either way I was looking for a way to completely remove all gnome elements from my virtual machines. In the end I found a LONG command that just lists all the gnome elements to send to the apt-get remove command... seems like there should be something more elegant...

The commands are here, but it needs to be noted to remove the `&& sudo apt-get install kubuntu-desktop` from the end of the commands.

Sunday, October 18, 2009

Well.. so much for javascript..

I have always despised javascript and html for it's hacky approach to...well.. everything. Html was well done in the 90's, maybe, but at the moment html and javascript just look and feel and appear to work like one huge cobbled together kludge that nobody can fix because the entire world uses html/javascript and sorta knows how it all fits together. Years ago when I was the webmaster for a small college, I dealt with javascript/html extensively and hated it intensely (back in the age of ie3 and Netscape and just the beginnings of mozilla 1.0).

So after my latest little adventure in javascript and getting everything to work perfectly in FF3, my girlfriend, who does QA for another web company, asked 'Does it work in Internet Explorer?' So I tried my simple little <input> hider (along with all the concessions I made for I.E) in I.E 8. I was expecting that there might be some small issues that would popup, but nothing major. Instead what I got was I.E 8 completely freezing to the point where I couldn't even kill it in the task manager. I got the Vista little spinning ring of death and in order to fix the issue, I had to get to the ctrl-alt-delete menu and hit 'logout'.

Now I know that there's lots of people out there who are experts in making javascript things in sing in both ie8 and ff3, but at what cost? I work at a company who primarily works with flash and there's always a big discussion/name-calling-fest whenever a site is made entirely in flash when it 'should' be made in html/javascript. The main reason people usually defend the decision to use flash is something along the lines of "we have lots of very good flash developers and it's faster for them to just develop the site in flash", which is true. The 'it works properly in all browsers with a minimum of fuss' is rarely even brought up.

But given the amount of design considerations, QA, potental major headaches that have to be taken into account when developing an html/javascript site, I would have to say that these issues are very significant. Developing in flash is significantly easier simply because the majority of these issues are minimized. You simply develope the app, QA it and deploy it. It works as expected in all browsers. No special considerations that need to be learned and tested, no design decisions that have to be abandoned because the feature will work in one browser, but not in another.

Flash wins.

Update: HTML 5 to control them all.

Learning Jquery and rehashing javascript..

Been learning jquery and messing around with hiding things dynamically in the django-admin...


indexOf doesn't work in IE
so basically the work around is to apply it to ie's version of js..

if (!Array.indexOf) {
Array.prototype.indexOf = function (obj, start) {
for (var i = (start || 0); i < this.length; i++) {
if (this[i] == obj) {
return i;
}
}
}
}


There is no string title case function so again, put one in yourself..

// (c)GPL, apv
String.noLC = new Object
({the:1, a:1, an:1, and:1, or:1, but:1, aboard:1,
about:1, above:1, across:1, after:1, against:1,
along:1, amid:1, among:1, around:1, as:1, at:1,
before:1, behind:1, below:1, beneath:1, beside:1,
besides:1, between:1, beyond:1, but:1, by:1, 'for':1,
from:1, 'in':1, inside:1, into:1, like:1, minus:1,
near:1, of:1, off:1, on:1, onto:1, opposite:1,
outside:1, over:1, past:1, per:1, plus:1,
regarding:1, since:1, than:1, through:1, to:1,
toward:1, towards:1, under:1, underneath:1, unlike:1,
until:1, up:1, upon:1, versus:1, via:1, 'with':1,
within:1, without:1});

String.prototype.titleCase = function () {
var parts = this.split(' ');
if ( parts.length == 0 ) return '';

var fixed = new Array();
for ( var i in parts ) {
var fix = '';
if ( String.noLC[parts[i]] )
{
fix = parts[i].toLowerCase();
}
else if ( parts[i].match(/^([A-Z]\.)+$/i) )
{ // will mess up "i.e." and like
fix = parts[i].toUpperCase();
}
else if ( parts[i].match(/^[^aeiouy]+$/i) )
{ // voweless words are almost always acronyms
fix = parts[i].toUpperCase();
}
else
{
fix = parts[i].substr(0,1).toUpperCase() +
parts[i].substr(1,parts[i].length);
}
fixed.push(fix);
}
fixed[0] = fixed[0].substr(0,1).toUpperCase() +
fixed[0].substr(1,fixed[0].length);
return fixed.join(' ');
}
Javascripts objects work as associative arrays
var theStatus = new Object;
theStatus.Home = 'normal';
theStatus['Home'] //will print 'normal'

Arrays are useful as in all languages, but their function set isnt really all that complete and require some inelegant code to remove elements properly. (Mainly just
var arr = [4,5,6];
arr.splice(arr.indexOf(5), 1);
Also, to copy arrays by value, you have to use the splice() fn...

There's no elegant way to copy objects by value, so again.. add it in yourself.
Object.prototype.clone = function() {
var newObj = (this instanceof Array) ? [] : {};
for (i in this) {
if (i == 'clone') continue;
if (this[i] && typeof this[i] == "object") {
newObj[i] = this[i].clone();
} else newObj[i] = this[i]
} return newObj;
};
Jquery doesn't have a proper way to filter with regexes... so.... yeah... But even that needs to be modified since it only searches on the text() field of an object.
jQuery.extend(
jQuery.expr[':'], {
regex: function(a, i, m, r) {
var r = new RegExp(m[3], 'i');
//Add modifications here....
return r.test(jQuery(a).text());
}
}
);

But a way to get around the lack of regex in some cases is to remember that you can chain [attributeFilters]..
$("input[id][name$='man']").val("only this one");

And finally(for now), you can add attributes to objects with attr.
$('#target').attr("disabled", true); 




I still don't like javascript, but jquery makes working with it a lot nicer.. sorta.

Friday, October 16, 2009

Python closures explanation

While trying to figure out what exactly people meant when they said that python didn't have true closures, I found this excellent response that describes the issue perfectly.




Joel VanderWerf wrote:
> ...
>
> But in Python, the inner function only has access to the _object_, not
> to the original variable which refers to the object, and so you have to
> "box" the value inside an object if you want to have shared references.

No, you still don't undestand the issue properly. You're getting closer,
but not quite there yet.

y = 0

def foo():
global y
x = 0
def bar():
print x, y
bar()
x = y = 1
bar()
x = y = 2
bar()
x = y = 3
bar()
x = y = 4
bar()
x = y = 5

foo()

0 0
1 1
2 2
3 3
4 4

Now just as in Ruby, 0, 1, 2, 3, 4 are separate objects. It is literally
impossible to change their values. All you can do is change bindings TO
the variables. So obviously "bar" is really inheriting the _bindings_
for x and y because it is the _bindings_ that are changing.

So what's the problem? Consider this program:

y = 0

def foo():
x = 0
def bar():
print x, y
def change(z):
global y
x = y = z

change(1)
bar()
change(2)
bar()
change(3)
bar()
change(4)
bar()

foo()

The output is:

0 1
0 2
0 3
0 4

This is because Python has always adopted the rule that if you assign to
a local variable it springs into existence -- as a local. If you want to
overwrite a global variable, you have to specifically say: "please
overwrite this global." It prevents people from accidentally overwriting
globals with locals.

But there is no syntax for saying: "please overwrite this intermediate
closure variable." It would be as easy as adding a keyword
"intermediate" or "closure". It's purely a syntactic issue.

_But_ the addition would be useless in practice because this problem
almost never arises in real code. Its only purpose would be to answer
Lisp and Ruby advocates who want to say that Python doesn't really have
closures. I don't know whether Guido will ever add it for, er, closure,
but I do know that I have _never_ _once_ needed this keyword in hundreds
of thousands of lines of real Python code I have written. And I am thus
going to fight my temptation to go and bug Guido to do it so that we can
put an end to permathreads about Python's lack of closures. ;) If this
problem ever arose in my code (which it has not) then I could work
around it thus:

y = 0

def foo():
x = [0]
def bar():
print x[0], y
def change(z):
global y
x[0] = y = z

change(1)
bar()
change(2)
bar()
change(3)
bar()
change(4)
bar()

foo()

1 1
2 2
3 3
4 4

This should prove that the problem is really not deep in the Python
interpreter or anything like that. It would be a half day's work to
write the patch that added the "intermediate" keyword.

By the way, there was a time when Python really did lack closures but
there was a hacky workaround. This is where the idea that Python did not
have "real" closures became popular (because it was true). Then Python
added closures, but left out one minor feature and the minor feature
allowed the idea to persist even when it had ceased to be true.

--Paul Prescod

Monday, October 12, 2009

Errors while creating validations for django admin

TypeError at /admin/quiz/series/add/

argument of type 'NoneType' is not iterable

Request Method: POST
Request URL: http://10.0.1.72/admin/quiz/series/add/
Exception Type: TypeError
Exception Value:

argument of type 'NoneType' is not iterable

Exception Location: /usr/local/lib/python2.6/dist-packages/django/forms/models.py in save_instance, line 47



Got this error which had me stumped for a while. Turns out it's because I forgot to return self.cleaned_data at the end of my clean() and clean_<fieldname>() functions.

Friday, September 25, 2009

Err messages....

For the project I'm working on currently, they don't want to let 'unfriendly' (meaning too technical) error messages through.. I think all error messages should be unfriendly because when they are relayed to the devs on the backend, it helps them track down exactly what the issue is much faster. But then again, my code does contain the error message:
"Error: Oh my god you've ruined EVERYTHING, AGAIN! You old bag!"
This is really quite good at being unfriendly, see, cuz old people have probably ruined everything at least once at their age and probably live their lives dreading that they might do it again...

Thursday, September 24, 2009

Emacs Bookmarks

`C-x r m '
Set the bookmark for the visited file, at point.

`C-x r m BOOKMARK '
Set the bookmark named BOOKMARK at point (`bookmark-set').

`C-x r b BOOKMARK '
Jump to the bookmark named BOOKMARK (`bookmark-jump').

`C-x r l'
List all bookmarks (`list-bookmarks').

from someone at cmu

Friday, August 28, 2009

How to uninstall python packages with easy_install.

`easy_install -m packagename` removes the file from your .pth file (and therefore removes it from your python path), then remove .egg file or directory from your site-packages, or dist-packages directory.


Thx to PJE via PL

Wednesday, August 26, 2009

How to revert a file or directory in svn.

Revert a file to revision 854

svn merge -c -854 l3toks.dtx

Grabbed from stack overflow.


Revert a directory to revision 854

svn merge -rHEAD:854 .

Grabbed from some code monkey.

Friday, August 7, 2009

Difficult errors to debug in Django for Django noobs..

Got this as an debug template page today:

TemplateSyntaxError at /admin/

Caught an exception while rendering: name 'User' is not defined


After some digging around and frustration, I finally figured it out. I had created a new app for my project called `newsbin`, then created a model and views and set the views up in urls.py, but I had not yet added `newsbin` to the installed apps section of settings.py. Thus it gave the above error.

Wednesday, July 29, 2009

Command to copy a vdi in virtual box on a linux machine.

Make sure the vm using the original vdi is not running and then release and remove (Choose KEEP) the vdi from the pool of drives. Then run

VBoxManage clonevdi /Original.vdi /NewCopy.vdi

Once that is done be sure to re-attach the original vdi.

Monday, June 29, 2009

Adding a field to the django auth user.

I've been trying to do this for a while and I keep finding how-to's such as Extending the Django User model with inheritance, but the problem with these methods is that you still cant sign-in to the django admin with any users you create (such as the admin you set up at the beginning of the project).

I finally got the monkey-patching method to work by doing the following.

You can add fields to the user class with the method add_to_class instead of inheriting the User class by doing the following in your models.py:
User.add_to_class('new_field', models.BooleanField(default=False))

Once that is done, in admin.py, modify the UserAdmin and add your new field
from django.contrib.auth.admin import UserAdmin

UserAdmin.list_display += ('new_field',)
UserAdmin.list_filter += ('new_field',)
UserAdmin.fieldsets[1][1]['fields'] = ('first_name','last_name','email','new_field')
Voilà, with that done, you're new fields should show up in the auth user on the django admin page.

Stupid Adventures in Djangoland

After converting a project and doing some directory wide find-replace's, I kept getting this error in django:

TemplateSyntaxError at /admin/ Caught an exception while rendering: maximum recursion depth exceeded
A little background, all my projects are usually named 'backend', with the front end code (usually flash) in a separate directory 'frontend'. So for example in settings.py, I install apps in django by adding 'backend.app' to INSTALLED_APPS. Anyway, after commenting out huge chunks of code I eventually turned to one of the last things I could turn to to start commenting stuff out. So things Amongst the urlpatterns I found a line (r'^app/', include('backend.urls')). Some how, after the find-replace session, this line was setup to constantly reference the urls.py that it resided in, which resulted in the error stated above.

Tuesday, June 16, 2009

Tall in the bathroom stall.

You know what would suck about being 7 foot tall? In most public bathrooms you can see over the stall walls and look at the guy who's currently wiping his ass.

Course you never hear 7 foot tall people complaining about this because usually they play for the NBA and are evil rich and don't have to use public restrooms. Thus, if you see a 7 foot tall guy looking over the stall at you while you take a dump, take pitty on him since he's most likely so rich that he's going to hell.

Monday, June 15, 2009

Adages

Red sky in morning, sailors take warning;
Red sky at night, sailors delight.

or was it
Red sky in morning, sailors in mourning;
Red sky at night, sailors in plight.

Yeah, that second one is it.. it basically means if you're a sailor and the sky is Red, your screwed.

And yes if the sky is red instead of blue for anyone else, it means you're going to hell.

Monday, June 8, 2009

TypeError: not enough arguments for format string

Got this error in some python code the other day:

TypeError: not enough arguments for format string


Essentially it means you have something like the following in your code:

"%s,%s,%s" % ('foo','bar')


Essentially it's saying there aren't enough strings to fill the placeholders. But it also means that there might be an errant % in the template string that you weren't anticipating such as:

"%s has 42% of the shares." % ('Bob')


which is annoying. A regex you can run on your code to roughly handle this is:

regex1 = re.compile('%(?![\(])')
regex2 = re.compile('%%+')
cooked_html = regex1.sub('%%', regex2.sub('%', raw_html))
I say roughly since if you're starting to run into these kinds of situations, you really need to start using a templating engine like jinja or mako. I'll switch to mako in the future.

Wednesday, June 3, 2009

Running functions on marked files in dired mode for emacs.

Source

If you have some function, say some custom refactoring operation, you can call it from a dired buffer, and have it run on each marked file, using the code below.

Go into a dired buffer, mark some files, and then do M-x and run your command. In this case it would be test-for-each-dired-marked-file


;;; iterating over files in dired

;;; usage example - for-each-dired-marked-file returns a filename and path
;;; for each marked file, so this is what a function using it looks like
(defun view-stuff(filename)
"opens up the file and gets the length of it, then messages the result"
(let (fpath fname mybuffer len)
  (setq fpath filename)
  (setq fname (file-name-nondirectory fpath))
  (setq mybuffer (find-file fpath))
  (setq len (buffer-size))
  (kill-buffer mybuffer)
  (message "Buffer length %d %s" len (buffer-file-name mybuffer))))

; Usage example
(defun test-for-each-dired-marked-file()
(interactive)
(for-each-dired-marked-file 'view-stuff))

(defun for-each-dired-marked-file(fn)
"Do stuff for each marked file, only works in dired window"
(interactive)
(if (eq major-mode 'dired-mode)
   (let ((filenames (dired-get-marked-files)))
     (mapcar fn filenames))
 (error (format "Not a Dired buffer \(%s\)" major-mode))))

Friday, May 29, 2009

A co-worker wrote a nice little lisp snippet for emacs to indent the entire buffer. I should modify it to indent a marked region, if there isn't code to do this already.

(defun indent-whole-buffer ()
"Indent the entire buffer"
(interactive)
(indent-region 0 (buffer-size)))

Sunday, May 24, 2009

Such a lame ending to a great game, Fallout 3

Finally finished Fallout 3. Unfortunately, the ending was just about the most horribly stupid ending that I can remember. I've not been watching many movies lately, so maybe I'm more susceptible to stupid STUPID endings, but the ending was a contrived turd strained out in pain. Especially when it was already established that there was another character who could accomplish the final 'deed' without being harmed in anyway, as that character had already done before. A super mutant, Fawkes, who was resistant to radiation, had gone into a highly irradiated chamber to retrieve a device called the G.E.C.K, but when asked to do the same task and enter in a simple code into a computer, his response was something along the lines of 'you have your own destiny to follow'. Apparently there's another character, Charon, who REGENERATES HEALTH from radiation, who basically says the same thing.

Poor, POOR form.

Thursday, May 21, 2009

Convert DOS files to unix in emacs.

Essentially, C-x RET f undecided-unix


from this guy

Friday, May 15, 2009

It's cruel not to kill pumpkin..

Fallout 3 is a truly great game. Right there on the level of Fallout/Fallout 2.

Anyway, wondering around the wastes, I stumbled upon a giant mole rat named 'pumpkin' cage up in a dead guy's laboratory (well after I met him, a dead guy's laboratory). In this laboratory, the guy works on trying to make mole rat meat better tasting and better for you. I read in quite a few places that people couldn't bring themselves to kill pumpkin and harvest the meat to create the wonder mole meat. While the whole "can't kill a virtual animal thing" is curious (and well.. old), the fact that people DON'T kill pumpkin is vastly more cruel than actually killing pumpkin. Pumpkin, at least in terms of the game, is left to starve to death in a confined cage where it cant turn around.

I'm willing to wager that this is how most people are in real life as well. They're unwilling to put down the dog trapped in the cage starving to death with a wire cinched so tight around it's waist that it's cut into it's abdomen.

Course, this is just my paper tiger, my model that I hold up to people in comparison so that if they do match up with the model I described, I can mock them relentlessly and feel vastly superior to them.

Thursday, May 14, 2009

Ignoring file types in svn

Create a file (.svnignore) with the regular expressions

*.pyc
*~

Run svn propset on the project

svn -R propset svn:ignore -F .svnignore .

-R indicates that you are doing this recursively so all the directories ignore these.
-F indicates the file we just created with the regular expressions.

Originally found over on Pandemonium Illusion

Tuesday, May 12, 2009

Curl examples

No traffic info today, left too late.

Nice curl examples

Wednesday, May 6, 2009

Traffic May 6 and traffic notes

weather: Sunny
traffic: light
time: 920-1000

Well, why the traffic builds up on certain days vs others is beyond me. My guess was that possibly on sunny days, mom's, teens on break from school, and other non-working types were jumping on the road to head out to the beach or some such, but alas no.

I've known about traffic antipatterns for a while and practice them every once in a while, but this deals more with the traffic as it is currently. I'm more interested as to why the traffic is heavy on certain days vs other days.

I've never been the agressive try-to-get-10-cars ahead type, as I generally let my 'chunked'[1] driving skills handle the traffic as best as it can and I usually move through large parts of traffic completely oblivious to the traffic around me. I usually find I can usually plan out what I intend to do at work or enjoy music while I'm dinking along at 20 mph. Which is also why I tend not to do the traffic antipatterns as much either, I have better things to think about than trying to deal with the traffic around me. There have been several times when I've made the 75 mile drive to my parents place with no traffic and not remembered any part of the drive at all.. which is great!

This, of course, only works to an extent while commuting as eventually I have to merge over or let people in or do something else that requires me focusing on driving again. Still, what's more interesting to me is why? Why was there less traffic today, a very nice day, than last Wednesday? Why are there more cars in the parking lot? Why, apparently, are there more cars on the road? I suppose I have to see if there are other events or something else going on.. but that's gunna take more effort.

Tuesday, May 5, 2009

Emacs Dired mode quick reference.

Some particular highlights are:
  • To enter Dired mode simply do C-x C-f and select a directory
  • To open a file or directory, move the cursor to the name of the file you want to edit and hit enter (or e)
  • Create a directory - +
  • Copy a file - S[hift]-c
  • Move/rename a file - S-r
  • Delete a file by pressing `d` to mark it for deletion, then press `x` to process all marked files. Press `u` to deselect a file marked for deletion.
  • Press `~` to mark all backup files in the current directory for deletion (again, use `x` to actually remove them).
  • Refresh the Dired screen with `g`
  • Diff two files with `=`
  • Mark a file with `m` and then perform a shell command on said marked files with `!`. You can also just run a command with `!`. For example, download a zip file with `!wget www.com/somezipfile.zip` and then with that zipfile under the cursor, run `!unzip`
  • And the coolest bit, you can use regex to rename groups of files in a directory with %r. If you have Main.as and Main.2.as and you want to rename them to main.as and main.2.as, you can do `Main\(.+\).as` to `main\1.as`

Wednesday, April 29, 2009

Screen Howto

How to set up screen to allow multiple user access

RESTful Framework? ORM + CMS + Gateway Interface

Django works for RESTful backends to a flash frontend, but it's orm isnt that great and I'm not using the nice templating engine anyway. Its CMS on the other hand is killer.

I'm looking into what I can replace django with, ala cart like.
  • ORM - SQLAlchemy
  • CMS - FormAlchemy?
  • Gateway - Werkzeug? CherryPy?
Werkzeug so far looks to be REALLY nice. I define 'application' in a file and then point WSGIScriptAlias to it in my apache conf and it works (granted I take in and return the correct values).

Monday, April 27, 2009

Unix groups, users

On ubuntu (if you don't have access to the gui):

To create a user:
useradd -m -s /bin/bash *username*
passwd *username*
To create a group:
groupadd *groupname*
To add users to that new group:
usermod -a -G *groupname* *username*

Saturday, April 25, 2009

Traffic Saturday, April 25, 2009

Traffic sucks, but worse it seems to be unpredictable.. and not just because of accidents. I'll keeping track of some stats, just for the sake of keeping stats (I have a stupid theory atm that there's a relation to whether it's overcast or not..). I know Saturday sorta doesnt count as it's not a weekday, but I was really annoyed with traffic today so I started today.

heavy traffic - traffic (speeds <20 mph) before Crenshaw (Crunchshaw)
medium - traffic starts at Crenshaw
light - traffic starts at or after Washington Fairfax
none - drive at typical speeds (75mph) all the way to santa monica

weather: sunny/hot
traffic: heavy
time: 13:45-14:30

weather: dark
traffic: medium
time: 16:45-17:15

Tuesday, April 21, 2009

Mysql connection error 2003 (HY000) (146)

Tried logging into a remote mysql server and got an error:
ERROR 2003 (HY000): Can't connect to MySQL server on 'someserver' (146)
In this case, it was due to bind-address being set to 127.0.0.1in the /etc/my.cnf file (/opt/local/etc/my.cnf). The issue arose on a machine that used to be a slave after I had converted it back into a stand alone mysql server.

Saturday, April 18, 2009

Pro tip for the internet.

Shit is NOT sexy. If there's shit in your sex, you're just fucked up. Knock it off and get over it.

Thursday, April 16, 2009

Swapping ctrl and capslock on debian flavored linux-distros (ie ubuntu)

From the emacs-wiki http://www.emacswiki.org/emacs/MovingTheCtrlKey

1. chmod 644 /etc/default/console-setup then edit that file. Add an X11 style caps lock modification via:

 $ diff -U0 /etc/default/{console-setup.orig,console-setup}
--- /etc/default/console-setup.orig 2009-02-09 03:05:27.000000000 -0500
+++ /etc/default/console-setup 2009-02-09 04:11:20.000000000 -0500
@@ -40 +40 @@
-XKBOPTIONS=""
+XKBOPTIONS="ctrl:swapcaps"

you can do “ctrl:nocaps” instead if you want to two control keys.

2. Trick dpkg into integrating your changes:

 $ sudo dpkg-reconfigure console-setup

and choose all the defaults.

Note that this will only change capslock and ctrl in virtual terminals or when gnome or some other (lesser) window manager is not running.

To swap capslock and ctrl in gnome do:

System->Preferences-> Keyboard Preferences-> Layout tab-> Other Options (aka Layout Options) -> Ctrl key position-> Swap Ctrl and CapsLock radio button.

Wednesday, April 15, 2009

How to go to the restroom in a corporate environment

  1. Enter the stall, make sure the door closes behind you.
  2. Pull out around 5 squares (1 foot) of toilet paper and wipe down the toilet seat. Sprinkles on the lid could possibly seep through the butt-gasket.
  3. Place the butt-gasket on the toilet lid. Take care to make sure the most disastrous parts (the parts back by the buttocks) are covered. You're not going to pick up anything to vicious down by the legs. Lower all leg garments to the knee level and sit down. Lowering leg garments any further will only allow them to be potentially soiled on the floor. Pull the buttocks apart slightly as to help prevent any further fouling of the skin around the anus and buttocks.
  4. Evacuate the colon and, if necessary, the bladder. ONLY empty the bladder if necessary, if you don't have to evacuate the colon, then you are not to be using a stall.
  5. Do not worry about noises or smells offending others that may be in the bathroom with you. The sounds and smells that you make others endure is a sign of corporate dominance. On the other hand, if the smell offends you, then go ahead and flush it as soon as it escapes.
  6. Play some games and/or surf on your phone. This IS a requirement. This is part of your free time and is to be considered a break in the working routine to allow the R-mode brain to do some free thinking. Do not conduct any work or take calls. You need this time to be free from work such that when you do return to your work place, you are refreshed and ready to continue. This time should be kept to a 5 minute maxium as your legs and buttocks may go numb, hindering the wiping process in step 8.
  7. Once your colon has recovered from the evacuation, sit forward off of the toilet and butt-gasket. Do not sit back down as the gasket has most likely shifted and or possibly fallen down into the bowl.
  8. Pull out 1 to 1 1/2 feet of toilet paper and scrunch into a ball. Use this ball to wipe from back to front. A front to back movement is suitable as well, but contrary to popular pornographic knowledge,both wipe paths clean equally as well. Fold the toilet paper ball if appropriate. Repeat all of step 8 until no brown coloring resides on the toilet paper. If you see blood, it is only indicative that your anus is chapped. Continue wiping until there is no brown.
  9. Wipe or dab dry the urinary area. Return all garments to their previous positions.
  10. If the toilet is not motion sensing, use your foot to kick start the flush process.
  11. Wash your god damn hands with soap and water that is as hot as you can stand.
  12. After washing, use a paper towel to turn off the tap as well as on the door handle when exiting the bathroom. If no trash receptacle is near the door, simply let the towel fall to the ground. If the restroom provides only hot air blowers to dry your hands, do not attempt to turn off any taps and simply exit the restroom as quickly as possible. The high water costs incured by leaving the tap on will send a concise and articulate message that air blowers are simply unacceptable hand drying utilities. Use your pinky to open the door if the door pulls in or cover your hand with your shirt to turn the knob the door is configured with one.
Some notes on bathroom etiquette.
  1. If anyone ever attempts to converse with you for any reason other than an emergency while you are in the stall, it is correct and proper to remind them that it is unacceptable to conduct conversations with those already in the stalls.
  2. If a child under the age of 7 looks under the stall door directly at you, it is acceptable to use your foot and kick them in the head. For those over the age of 7, wait until all evacuations have completed before attacking.
  3. For all violent actions while in the restroom, remember that you are at your most vulnerable when you are evacuating your colon. There is not much you can do about this, but remember it anyway.