So I've decided to "compete" in the Iron Man competition.
My name is Caleb Cushing, I'm a 25 year old, unemployed, student, living in the Greater Lansing, MI, USA, area. I've been programming perl for approximately 6 months. This includes a lot of off time, time to relearn the language from the class I took a couple years ago (and learn modern perl), learning Catalyst and DBIC, all of which is an ongoing process. I would guess I've been writing useful code for about 4 months and even that is a slow going process as I've still got a lot to learn.
Previously, I was the tree maintainer for Funtoo, and tried spinning my own fork of Funtoo/Gentoo, it needed more devs than me to survive though. I now use Arch Linux. After an arch/perl user who went by aCiD2 moved to OS X I adopted most of his perl AUR (arch user repository) packages in addition to ones I had created myself. I now have over 200 CPAN packages on AUR in Arch's PKGBUILD format.
I'm a contributer to Catalyst::Manual and I created Template::ShowStartStop by forking Template::Timer.
I'm sure I'll become more active as time goes on, and have more interesting posts than this one.
Mar 13, 2010
Iron Man and introductions
Labels:
arch linux,
aur,
cpan,
Funtoo,
ironman,
perl,
Regen2,
Template::ShowStartStop,
who am I
Mar 11, 2010
How not to ask for help
This is the story of my friends problem today.
so of course I'm like:
So I explained that % is a wildcard. He still hadn't explained what his problem is or what he was trying to do.
So here I am trying to guess at what his problem is. I've never used sql server but a quick glance at postgres docs suggested the syntax was wrong. I know don't query other docs than the software being used... but I wanted to run a test locally to see if I could figure out what he was doing.
Oh! that's very helpful... way to give more information. I think I now know why he never asks questions in IRC or forums. He never learned how to ask a question and they won't put up with him.
So finally I'm able to determine... his problem is he's got a
Now anyone who's familiar with sets will probably realize the notation here is bad and so you can't tell if these are sample columns or records. a more proper way to write this would have been
It took me 20 minutes of getting that data to realize they were reversed, which is shameful for me... but I was trying to figure out things like VARCHAR or INTEGER... he of course said it's not an array, and I suppose it's not an ARRAY type in sql.. but I guarantee that's why it looks like that... it's really a foreign key stored as an array in a varchar. After I told him he lied and said it didn't work only to come back 10 minutes later and say... you were right.
so the final should have been
I got one for ya.
Field like field --friend
so of course I'm like:
? is that a question?he had given me no prelude, no premise. response
I tried field like '%' + field2 + '%'
No good though
--friend
So I explained that % is a wildcard. He still hadn't explained what his problem is or what he was trying to do.
it giving you a syntax error? --me
So here I am trying to guess at what his problem is. I've never used sql server but a quick glance at postgres docs suggested the syntax was wrong. I know don't query other docs than the software being used... but I wanted to run a test locally to see if I could figure out what he was doing.
Doesn't work --friend
Oh! that's very helpful... way to give more information. I think I now know why he never asks questions in IRC or forums. He never learned how to ask a question and they won't put up with him.
so it's not a syntax error it just doesn't do what you want? --me
Right. The like command isn't finding it --friend
So finally I'm able to determine... his problem is he's got a
... WHERE ... LIKE ... that isn't returning what he expects. This is still completely worthless because I still haven't been able to figure out what he's trying to do... or more correctly I have but not why it isn't working because his code is right. which means he's fallen prey to the assumption that he knows what I need to know to solve his problem. He hadn't given me enough info. After I tried to explain to him how to do what I thought he was trying to do and giving him a sample query and some data... he gives me thisField1 = "4369" field2 = "4311", "4369" --friend
Now anyone who's familiar with sets will probably realize the notation here is bad and so you can't tell if these are sample columns or records. a more proper way to write this would have been
field1 = { '"4369"'} field2 = {'"4311", "4369"'} I probably still would have been a little confused just because I wouldn't have been sure he was writing it right. See the problem here is that field 2 is an array and therefore not stored properly in a relational manner, it's why he has to do a much slower LIKE in the first place. After bantering to figure out that this was in fact text data these were single records I eventually figured out that what he was trying to do was find field2 if it contaned field1. However, his code was asking for field1 if it contained field2. basically he had his parameters reversed.It took me 20 minutes of getting that data to realize they were reversed, which is shameful for me... but I was trying to figure out things like VARCHAR or INTEGER... he of course said it's not an array, and I suppose it's not an ARRAY type in sql.. but I guarantee that's why it looks like that... it's really a foreign key stored as an array in a varchar. After I told him he lied and said it didn't work only to come back 10 minutes later and say... you were right.
so the final should have been
WHERE field2 LIKE '%' + field1 + '%' or in postgres WHERE field2 LIKE '%' || field1 || '%' because we use the standard || for string concatenation instead of the +
Mar 10, 2010
You should have hired me! ( just a vent )
So this is about the 10th time my friend has asked me for help on a SQL (w/ SQL Server) problem. I Actually interviewed with his company at one point and they elected NOT to hire me. Why? because I have never found windows errors useful, have therefore never used its logging facility, and was unable to answer questions about it. I'm was a UNIX guy then and am now. But I'm still better at figuring out problems on software I've never even used, with only about 1/10th of the information that I need. I'm so tired of fixing other people's problems and not getting paid for it, especially when somehow they profit from it.
So why don't companies seem to hire me? Because I suck at interviews. Because I don't have that 4 year degree and someone else does. Because I don't have 2 years of experience with Technology X. Because I've not got the greatest work history.
Why don't I have the greatest work history? Well I've been fired twice. Once the official reason was I fell asleep at work, I don't think I did. Even if I did I had, had insomnia for 3 days, I even told them that. I'm pretty sure I could have sued for wrongful termination, but I didn't. The other time I was hired into a position that I really just wasn't a good match for, but I didn't realize it until later. That position also didn't have enough work for me, and the work that it did have wasn't well enough explained for me to do.
Wait so I have to explain to you how to do something? no... but when you tell me to make a form with this list, and copy this pre-existng product with new tech. Then those 2 definitions conflict. So I try to do work to make what you want and then you say but I don't want those fields... I say but this can't be made to work like that without them... I never really got answers... Can't do work that I'm not given enough info to do properly, and I wasn't privy to the meetings with the clients.
I'd also like to note that I almost quit the second job as I had been given less than 5 hours a week for 3 months, and my boss, although a good hacker, wasn't a very good boss. But I'm not completely absent of blame... maybe I misrepresented my knowledge of the product, or maybe I should have done more to get the information I needed to do the work.
Well maybe my luck will change and this company I've been interviewing with recently will hire me so the next time my friend asks me for help to do his job I can say. You know your company could hire mine and the work would get done faster (better too probably).
So why don't companies seem to hire me? Because I suck at interviews. Because I don't have that 4 year degree and someone else does. Because I don't have 2 years of experience with Technology X. Because I've not got the greatest work history.
Why don't I have the greatest work history? Well I've been fired twice. Once the official reason was I fell asleep at work, I don't think I did. Even if I did I had, had insomnia for 3 days, I even told them that. I'm pretty sure I could have sued for wrongful termination, but I didn't. The other time I was hired into a position that I really just wasn't a good match for, but I didn't realize it until later. That position also didn't have enough work for me, and the work that it did have wasn't well enough explained for me to do.
Wait so I have to explain to you how to do something? no... but when you tell me to make a form with this list, and copy this pre-existng product with new tech. Then those 2 definitions conflict. So I try to do work to make what you want and then you say but I don't want those fields... I say but this can't be made to work like that without them... I never really got answers... Can't do work that I'm not given enough info to do properly, and I wasn't privy to the meetings with the clients.
I'd also like to note that I almost quit the second job as I had been given less than 5 hours a week for 3 months, and my boss, although a good hacker, wasn't a very good boss. But I'm not completely absent of blame... maybe I misrepresented my knowledge of the product, or maybe I should have done more to get the information I needed to do the work.
Well maybe my luck will change and this company I've been interviewing with recently will hire me so the next time my friend asks me for help to do his job I can say. You know your company could hire mine and the work would get done faster (better too probably).
Feb 16, 2010
bash and konsole
So I've had lots of problems using a multi-tab xterminal, for the casual user I'm sure they'd not even notice them, or think I'm silly, but when you spend all day in a shell they become less so.
one of the big problems I've had is with history. see when you close a shell then it writes the history. well if you have 5 tabs open each with with a super long history they'll write those histories out in the order they close in. basically what happens is all the history saves at once so one of your open shells histories will be before another's and if each has like 50 entries it can be quite a way back. In fact I'm sure I've had it happen where parts of my history was lost. So what do you do? you have to separate them per tab. One way to do this is with gnu screen. I don't like screen's history because it records the output of the terminal as well as the command, so this wasn't a good solution for me. The solution is that each tab must have its own history file. Well how do we do that? before I get to it I have another problem.
History
one of the big problems I've had is with history. see when you close a shell then it writes the history. well if you have 5 tabs open each with with a super long history they'll write those histories out in the order they close in. basically what happens is all the history saves at once so one of your open shells histories will be before another's and if each has like 50 entries it can be quite a way back. In fact I'm sure I've had it happen where parts of my history was lost. So what do you do? you have to separate them per tab. One way to do this is with gnu screen. I don't like screen's history because it records the output of the terminal as well as the command, so this wasn't a good solution for me. The solution is that each tab must have its own history file. Well how do we do that? before I get to it I have another problem.
PS1, umask, and default group
I also have a need to have different settings depending on what I'm working on. If I'm working on files that need to be read and written to by my web server they need to have a different group and umask. first I solved this by su - to a different user, then I solved it by having different bashrc's but neither fully solved the history problem.howto do it
first you have to have one konsole profile for each of the different settings you need. so I have one for web development called webdev. Then you have to add an environment variable to it I'm going to call it KONSOLE_PROFILE and set that to whatever your profile is called. Neither name really matters so long as they don't conflict with others. Then you need to code your bashrc (or other shell to work with it). I have a shortened sample bashrc that you can use in a gistFeb 14, 2010
Can't Find Google's OpenID
I think that Google's (not Blogger's) OpenID is a failure. It's not memorable and you can't find it. I've been trying to figure out where google has my OpenID listed for 30 minutes now. This is not the first time I've had to do this. I usually use Blogger's because it uses my blog's url, but it's currently error-ing with a typepad blog. Why can't google use something like google.com/username ? something we could remember. Why isn't it listed in an obvious place in my account details? Why is it when I search "google openid" it talks about the announcements all over the place, but never how to find out what your url is.
UPDATE:
Found it on lenni.info
UPDATE:
it's this
UPDATE:
Found it on lenni.info
UPDATE:
it's this
https://www.google.com/accounts/o8/id
Labels:
google,
hall of shame,
openid,
typepad,
web services
Feb 11, 2010
KDE 4 is finally ready for users
I just installed KDE SC 4.4 last night and I can say that I feel that it's finally general user ready. The last bug that I felt would prevent average use is now gone. What was that bug? when you pressed print screen nothing would happen. There was a workaround to make print screen work but it didn't work out of the box. I feel that there are some things that should just work and that's one of them.
I'm not sure I'm yet happy with the state of the device notifier, and automounting as the UI doesn't seem perfect yet, but it can now do all the things that are necessary.
There will always be improvements to be made, but I think that if you've been not sure about using KDE 4 go give it a try now. (I'm about to find out if I can replace vim with kate's vi bindings).
I'm not sure I'm yet happy with the state of the device notifier, and automounting as the UI doesn't seem perfect yet, but it can now do all the things that are necessary.
There will always be improvements to be made, but I think that if you've been not sure about using KDE 4 go give it a try now. (I'm about to find out if I can replace vim with kate's vi bindings).
Jan 20, 2010
empty() function for postgresql in sql
In PostgreSQL the ASCII NULL or empty string
My function possibly would be better called empty_or_whitespace but in my mind any text field that contains only whitespace is empty, and I'd rather have 1 function and 1 regex deal with both than have 2 functions have to be called on every insert/update.
Here is the gist
It returns true if an empty string is found. It really requires a knowledge of SQL, PostgreSQL's CREATE FUNCTION, and Regular Expressions, to understand. Thanks to the wonderfully helpful PostgreSQL community with perfecting it.
In order to use it to keep ASCII NULLS and fields that someone has just entered whitespace into you need to add it to your table as a constraint.
Here's an example create table gist using it.
remember it returns true on null's and whitespace so you have to say NOT emtpy( field ).
\0 is seen as NOT NULL. This is because postgres developers consider any characters data. I know there are better discussions on it but I can't find them right now. Unfortunately the programming language you are using probably doesn't see it the same way. There's a good chance that initialized variables are set to \0 and so when you try to insert from your language to a NOT NULL field with variables that are seen as undefined in your language, postgres accepts it, and now you have fields that you probably consider to have no data but are NOT NULL.My function possibly would be better called empty_or_whitespace but in my mind any text field that contains only whitespace is empty, and I'd rather have 1 function and 1 regex deal with both than have 2 functions have to be called on every insert/update.
Here is the gist
It returns true if an empty string is found. It really requires a knowledge of SQL, PostgreSQL's CREATE FUNCTION, and Regular Expressions, to understand. Thanks to the wonderfully helpful PostgreSQL community with perfecting it.
In order to use it to keep ASCII NULLS and fields that someone has just entered whitespace into you need to add it to your table as a constraint.
Here's an example create table gist using it.
remember it returns true on null's and whitespace so you have to say NOT emtpy( field ).
Labels:
constraints,
functions,
postgresql,
procedures,
regexp,
sql
Jan 19, 2010
PostgreSQL initial setup (authentication) Part 2
I ran into so problems and lack of information with my last post on this topic. Firstly my syntax for
So our goal here will be to provide an alternate user that can log in as postgres via ident. why would you want to do this? maybe you're tired of su - to the postgres unix user after logging in as your administrative user (root?).
First we need to open our pg_ident.conf and add the following line.
So as I said in the last post on this: "admin" is an arbitrary identifier, root is the system user, and postgres is the database user. Now let's go ahead and make sure the postgres system user can still login.
ok that's all we need to do in the pg_ident.conf. Go ahead and open pg_hba.conf and add this line above the default 3 lines in the file.
as a breakdown: local is for socket connections, all means all databases, ident means it's checking for local users, and map=admin says look at the users in the admin identifier in pg_ident.conf.
Now you should be able to run psql dname postgres as root. You will not be able to use the db postgres user as any system user not in the admin map.
local all all to local all all ident devel
doesn't seem to work in my current setup. It's possible that it has something to do with the configuration of the Debian/Ubuntu server I was basing that against, and now my targets are Arch Linux and Slackware.So our goal here will be to provide an alternate user that can log in as postgres via ident. why would you want to do this? maybe you're tired of su - to the postgres unix user after logging in as your administrative user (root?).
First we need to open our pg_ident.conf and add the following line.
admin root postgresSo as I said in the last post on this: "admin" is an arbitrary identifier, root is the system user, and postgres is the database user. Now let's go ahead and make sure the postgres system user can still login.
admin postgres postgresok that's all we need to do in the pg_ident.conf. Go ahead and open pg_hba.conf and add this line above the default 3 lines in the file.
local all postgres ident map=adminas a breakdown: local is for socket connections, all means all databases, ident means it's checking for local users, and map=admin says look at the users in the admin identifier in pg_ident.conf.
Now you should be able to run psql dname postgres as root. You will not be able to use the db postgres user as any system user not in the admin map.
Labels:
authentication,
database,
postgresql,
security
Nov 16, 2009
Bypassing disabled accounts with KDM
So the most common way of disabling an account in a unix system is changing the users shell in /etc/passwd to /bin/false or /sbin/nologin. However, I've discovered on Arch Linux that if I do this only shell login's are disabled, I was still able to log the user in with gui via kdm. I also tried using usermod --expiredate 1. this was not effective either however. the only way I found to lock the account from kdm login was to do a passwd -l accountname, which only locks password authentication. This means key and token authentication should still work. My real concern is that if the user was set to login without a password that it would still be bypass-able. My personal opinion is that I shouldn't have to do more than 1 thing to disable a user account in a 100% effective manner. Currently Arch Linux (and maybe more) fails at this. I'll post a fix later as I investigate further.
Bugs I filed are at kde and Arch Linux
EDIT: expire date worked... just not immediately, very odd.
EDIT: Here's a proper /etc/pam.d/kde
Bugs I filed are at kde and Arch Linux
EDIT: expire date worked... just not immediately, very odd.
EDIT: Here's a proper /etc/pam.d/kde
#%PAM-1.0
auth required pam_nologin.so
auth required pam_unix.so nullok
auth required pam_shells.so
auth required pam_tally.so onerr=succeedfile=/var/log/faillog
account required pam_access.so
account required pam_time.so
account required pam_unix.so
password required pam_unix.so
session required pam_unix.so
session required pam_env.so
session required pam_limits.so
Labels:
accounts,
Arch,
authentication,
hall of shame,
kde,
kde4,
kdm,
pam,
security
Nov 10, 2009
Difference Between a Database and a Database Instance
I was prowling StackOverflow today and the question was asked when you would use 2 databases. I'm amazed at the number of answers of replication and sharding (some under the guise of some other description). The only answer I can think of to be correct is Different Applications/Services (shared hosting probably falls under those 2 in a weird way). I'm going to explain why a replicated database and/or a sharded database are not multiple databases.
Firstly, we must understand what a database is and is not. A database is not a computer program that runs and stores data, this is DBMS (Database Management System). A database simply is a collection of data. A database is an organized collection of data. Many Definitions of a Database include computers, however not all do, in fact Joe Celko argues that first database were precursors to written language in the Middle East (see Data and Databases Chapter 1). It may be true that database are organized for quick retrieval of information in a certain way, however they are not necessarily designed for quick retrieval of all information, in any way.
So what are some example's of a Non Computer Database? A phone book is a good example of a database. It's really fast to look someone up if you know there last name, but not if all you have is their phone number and you want their address. You'll Also note that it's got various ways of searching if you're looking for businesses. It is not a good example of a normalized database, but I'm not sure that's possible with a paper database that allows you to find the same information in multiple ways. A phone book is simply a collection of Names, Addresses, and Phone Numbers, and Categories (tags).
So wouldn't two phone books be two databases? well if they are published by different vendors, or at different times, then yes. However, if you have two copies of the same phone book, then you have two instances of that database, that have been 'replicated' from a 'master' copy. You can't update one of these 'slave' copy's and expect them to replicate, you must update the 'master' and publish the updates. Unlike computer Phone books are extremely slow to push updates. Let's say you want to call a friend, Steven, over for pizza, and your roommate, John, wants to try a new pizza place. John can look at one copy of the phone book to look up the addresses and phone numbers of to the new pizza places you haven't tried, while you look up Steven's number in your copy of the book. This is exactly what happens with replication, different requesters doing lookups from different databases.
Now let's talk sharding, phone books aren't sharded right? wrong! they are phone books are sharded by location. The entire phone book database for even 1 state would be too big for them to distribute, so they split it up into smaller regions. Only the phone book company has the entire list. So that makes it kind of a bad example. Let's talk about encyclopedia's instead. They are a much better example since you don't generally buy one encyclopedia, you buy the whole set (which is also replicated and you can think of it's replication in the same way as phone books). Each encyclopedia volume tells on the side which letters it contains, so when you open it you know you're in the right vicinity. This is how a shard works, your database got too big an unmanageable as a whole so you split it up into 'shards' or 'partitions' to make it faster to search and easier to handle and store.
Now to clarify my answer to that original question. You wouldn't put a phone number (phone entry not included) in an encyclopedia even though I'm sure Bill Clinton has one, you might list it in the phone book though. So now you see when you would use a different database. Very clearly you would use one when the type of data is different enough, when it's for different organizations, or when it's for kind of shared service.
I hope these analogies to computer databases have helped explain the concepts.
Firstly, we must understand what a database is and is not. A database is not a computer program that runs and stores data, this is DBMS (Database Management System). A database simply is a collection of data. A database is an organized collection of data. Many Definitions of a Database include computers, however not all do, in fact Joe Celko argues that first database were precursors to written language in the Middle East (see Data and Databases Chapter 1). It may be true that database are organized for quick retrieval of information in a certain way, however they are not necessarily designed for quick retrieval of all information, in any way.
So what are some example's of a Non Computer Database? A phone book is a good example of a database. It's really fast to look someone up if you know there last name, but not if all you have is their phone number and you want their address. You'll Also note that it's got various ways of searching if you're looking for businesses. It is not a good example of a normalized database, but I'm not sure that's possible with a paper database that allows you to find the same information in multiple ways. A phone book is simply a collection of Names, Addresses, and Phone Numbers, and Categories (tags).
So wouldn't two phone books be two databases? well if they are published by different vendors, or at different times, then yes. However, if you have two copies of the same phone book, then you have two instances of that database, that have been 'replicated' from a 'master' copy. You can't update one of these 'slave' copy's and expect them to replicate, you must update the 'master' and publish the updates. Unlike computer Phone books are extremely slow to push updates. Let's say you want to call a friend, Steven, over for pizza, and your roommate, John, wants to try a new pizza place. John can look at one copy of the phone book to look up the addresses and phone numbers of to the new pizza places you haven't tried, while you look up Steven's number in your copy of the book. This is exactly what happens with replication, different requesters doing lookups from different databases.
Now let's talk sharding, phone books aren't sharded right? wrong! they are phone books are sharded by location. The entire phone book database for even 1 state would be too big for them to distribute, so they split it up into smaller regions. Only the phone book company has the entire list. So that makes it kind of a bad example. Let's talk about encyclopedia's instead. They are a much better example since you don't generally buy one encyclopedia, you buy the whole set (which is also replicated and you can think of it's replication in the same way as phone books). Each encyclopedia volume tells on the side which letters it contains, so when you open it you know you're in the right vicinity. This is how a shard works, your database got too big an unmanageable as a whole so you split it up into 'shards' or 'partitions' to make it faster to search and easier to handle and store.
Now to clarify my answer to that original question. You wouldn't put a phone number (phone entry not included) in an encyclopedia even though I'm sure Bill Clinton has one, you might list it in the phone book though. So now you see when you would use a different database. Very clearly you would use one when the type of data is different enough, when it's for different organizations, or when it's for kind of shared service.
I hope these analogies to computer databases have helped explain the concepts.
Subscribe to:
Posts (Atom)