Turn a list into a quoted, comma-delimited line of text with VI

Here’s how to turn a column of information into a quoted, comma delimited line of text, using VI

Original text:

fred.smith
j.johnson
why.not
When.ever

Desired result:

“fred.smith”,”j.johnson”,”why.not”,”When.ever”

PHP Usage:

$data_array = array(“fred.smith”,”j.johnson”,”why.not”,”When.ever”);

How To:

Open the original text list in a VI editor (My favorite is Mac-VIM)


PART 1 – QUOTE AT THE BEGINNING OF EACH LINE

ESC to make sure you’re in command mode
:1 goes to the first line
CTRL-v visual block mode)
Shift+g capital G – goes to the beginning of the last line in the list)
Shift+i capital I – insert mode at the beginning of a line)
the quote character desired at the beginning of each line)
ESC wait a second, and a quote will appear at the beginning of every line)

PART 1 RESULT:
“fred.smith
“j.johnson
“why.not
“When.ever

PART 2 – END OF THE LINE CHARACTERS

Now for the end of the line –
Desired appendage: “,
Assuming VI is still in command mode; If it isn’t, ESC
Type In:
:%s/$/\”\,/g
DISSECTED:

: lets VI know you’re entering a command
%s search from the beginning to the end
/ indicates the end of the command instructions for where to search
$ put something at the end of every line
/ indicates the end of the portion of the command for telling VI where to put the character; in this case, the end of the line
\” The quote character for the end, escaped with a backslash because it’s a special character
\, The comma for the end, escaped with a backslash because it’s a special character
/ indicates the end of the portion of the command instructions for what to insert
g tells VI to do this globally

PART 2 RESULT:
“fred.smith”,
“j.johnson”,
“why.not”,
“When.ever”,

PART 3 – REMOVING END OF LINE CHARACTER WITHOUT SPACES BETWEEN

Type In:
ggVGgJ

DISSECTED:

ggVG globally select everything in the whole file gJ remove all the end of line characters, and don’t put a space in their place.

PART 4 – REMOVING THAT LAST TRAILING COMMA

Shift+g (goes to the end of the document)
x (removes a character, in this case the very last comma)

PART 4 RESULT:
“fred.smith”,”j.johnson”,”why.not”,”When.ever”

ALL DONE.  I love VI.
Voila!

Code Igniter – Authentication

Here are libraries and discussions about CodeIgniter Authentication:

http://stackoverflow.com/questions/4977707/codeigniter-authentication-user-privileges

https://github.com/benedmunds/CodeIgniter-Ion-Auth

https://github.com/haseydesign/flexi-auth

http://haseydesign.com/flexi-auth/auth/register_account

https://github.com/kabircse/CodeIgniter-Aauth

http://community-auth.com/

http://blog.pisyek.com/5-best-authentication-libraries-for-codeigniter/

https://bitbucket.org/skunkbad/community-auth-for-codeigniter-3

http://stackoverflow.com/questions/33311725/codeigniter-3-x-authentication-library

https://github.com/benedmunds/CodeIgniter-Ion-Auth

http://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication?rq=1

Here’s what I’ve set up in PHP in the past

  • Roles – what application tasks they can do
  • Groups – what data they can access or do tasks on
  • Services – what tasks the application can do
    • Services might be a bit different with Code Igniter – CRUD in models, controllers and views