Posts

Showing posts from 2013

Python quick bits

Just random Python quick bits to jar my memory List mylist=['item1','item2','3'] Index starts at 0 for myitem in mylist:  code here methods: append() pop() extend() # append list of items ['item4','item5'] insert(position,"item6)remote("item2") Dictionary mydictionary={'tag1':'item1','tag2':'item2'} Reference items by keys for mykey in mydictionary.keys()  code here Object types in Python: int, dict, list, str Testing for object type:  isinstance(variable,type)  var1='foo'   isinstance(var1,str) User input from the command line:  import sys  variable=raw_input("Enter user question here: ") Length of list: len(list) Strings To work with strings: import string mystring.split() # default delimeter is spaces with multiple spaces treated as one for item in list:   do something with item for piece in string:   do somethign with piece Working

VMware Fusion CentOS guest console resolution

Edit /etc/grub.conf and add vga=791 or vga=788 option to the end of the kernel line for your relevant kernel. vga options here

Command line restart of dsmcad service on OS X

From here To start the client acceptor daemon use the following command: sudo /sbin/SystemStarter start dsmcad To restart the client acceptor daemon use the following command: sudo /sbin/SystemStarter restart dsmcad To stop the client acceptor daemon use the following command: sudo /sbin/SystemStarter stop dsmcad

Error inserting into table with sequence in PostgreSQL

Recently had an issue when trying to insert a value into a table with a sequence. Our test system was returning errors from an application up attempted inserts. The sequence on a column in the table was WAY behind the actual maximum value in the table. select * FROM table_sequence; # Shows the last_value for the sequence select max(colname) FROM table1; # colname is the column in table1 that uses the sequence. Turns out the max was about 20k greater than the last_value from #1 select setval('sequence_name',"max from #2 +1");  From #1 you will see the sequence_name along with last_value. Use those two in step 3 to get the sequence updated so that when it automatically generates the next value it will be one greater than what is already in the table.

Setting default umask using setfacl

I have directory where data is stored, /data (creative eh). Under there I have various directories and needed them to have a default umask of rws for the group associated with them. chmod g+s /data/subdir1 setfacl -d -m g:mygroup:rwx /data/subdir1 Solution here

Ignoring .vimrc file on startup

I have a customized vim file with some settings like this: set nohls set ai set tabstop=4 shiftwidth=4 softtabstop=4 expandtab This works great for my Python coding since tabs are converted to 4 spaces, etc. The problem I run into is when I need to copy and paste code that is already formatted, I end up with spaces run amok. Easy solution is to start up vim ignoring my .vimrc file, save the file, then reopening my file as normal. To ignore .vimrc on startup run: vim -u NONE filename Thanks to Evan Hahn and of course Google search :) UPDATE: A better solution, IMO, that was just sent to me. Start up vim and use :set paste.

Getting Greenplum to work with OS ldap.conf file

In greenplum_path.sh file, found in $MASTER_DATA_DIRECTORY, add: LDAPCONF=/etc/openldap/ldap.conf export LDAPCONF Restart your Greenplum server. Then, of course, you need the LDAP lines in your pg_hba.conf file. This is a line for a group role in your Greenplum server.  For a specific user role, just change +greenplum_group to a specific role name. hostssl  data  +greenplum_group  IPsAllowed/24  ldap ldapserver=ldapservername ldapport=ldapport ldaptls=1 ldapbinddn="your bind dn" ldapbindpasswd="bind account password" ldapsearchattribute="cn"  ldapbasedn="base DN" Finally, configure ldap.conf for your environment.

Change uid on Linux machines

Going through and changing a bunch of user ids. I'm doing this over time and keep forgetting the syntax and run a man every time. Thought I'd put the skeleton command here: usermod -d /path/to/newhomedir -m -l newuserid originaluserid Update a uid from user1 to newuser1:  usermod -d /home/newuser1 -m -l newuser1 user1