Friday, January 24, 2014

How to install ctypes on mac

So when I was trying to install ctypes on mac I was getting this compile error:

clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from source/_ctypes.c:110:
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:161:3: error: unknown type name 'ffi_abi'
  ffi_abi abi;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:183:3: error: unknown type name 'ffi_sarg'
  ffi_sarg  sint;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:184:3: error: unknown type name 'ffi_arg'
  ffi_arg   uint;
  ^
build/temp.macosx-10.9-intel-2.7/libffi/include/ffi.h:267:4: error: unknown type name 'ffi_abi'
                        ffi_abi abi,
                        ^
In file included from source/_ctypes.c:126:
source/ctypes.h:71:2: error: unknown type name 'ffi_closure'
        ffi_closure *pcl; /* the C callable */
        ^
source/_ctypes.c:162:21: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        parg->size = self->b_size;
                   ~ ~~~~~~^~~~~~
source/_ctypes.c:304:9: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
                             ctypes_dlerror());
                             ^~~~~~~~~~~~~~~~
source/ctypes_dlfcn.h:19:24: note: expanded from macro 'ctypes_dlerror'
#define ctypes_dlerror dlerror
                       ^
source/_ctypes.c:807:9: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        size = PyString_GET_SIZE(value);
             ~ ^~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/stringobject.h:92:32: note: expanded from macro 'PyString_GET_SIZE'
#define PyString_GET_SIZE(op)  Py_SIZE(op)
                               ^~~~~~~~~~~
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/object.h:116:56: note: expanded from macro 'Py_SIZE'
#define Py_SIZE(ob)             (((PyVarObject*)(ob))->ob_size)
                                 ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
source/_ctypes.c:982:11: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        length = PyInt_AS_LONG(proto);
               ~ ^~~~~~~~~~~~~~~~~~~~

I fixed it by following the info on this thread:
https://trac.macports.org/ticket/22418

Which says to go to line 167 in setup.py and comment out the

 build_ext.build_ext.build_extensions(self)

to

 #build_ext.build_ext.build_extensions(self)

That fixed it so I could finish the install.

Wednesday, January 22, 2014

How to turn on spell check in the vi vim editor

I always forget to spell check in Latex coding projects when I am using vi or vim. You can enter this command while in a vim session:

:setlocal spell spelllang=en_us

Un-closable "Restore Windows" Message mac openOffice (FIX)

This was annoying and I waisted too long trying to figure this out so hopefully this helps someone.

So I was getting this OpenOffice pop-up box that I couldn't close and it was preventing me from using OpenOffice.

So I searched for this file:

find / -name "org.openoffice.script.savedState"

Then I did this:

rm -R "/Users/btaylor/Library/Saved Application State/org.openoffice.script.savedState"

Then I reopened OpenOffice and it was fixed (make sure it is closed completely before you begin)
This is the link that ended up helping me:

https://forum.openoffice.org/en/forum/viewtopic.php?f=74&t=12426#p58403

Monday, December 23, 2013

Matlab keyboard equivalent in python

I use the keyboard command all of the time in Matlab to get a live shell during an 
exception, etc.. so this is how you do it in python
import code
code.interact(local=locals())

Saturday, September 14, 2013

You have not chosen to trust "DigiCert High Assurance EV Root CA" Fix Ubuntu Linux

So I had to download the new Citrix receiver for my linux browser so I could remote in to some windows machines at work. After downloading the app, installing and logging in with my RSA key I get this error:


"SSL error
Contact your help desk with the folling information:
You have not chosen to trust "DigiCert High Assurance EV Root CA",
the issuer of the server's security certificate (SSL error 61)"

Whaatttt!! Are you serious! How stupid. So if I go to https://www.digicert.com/digicert-root-certificates.htm I can test my certificates and they work just fine for the DigiCert High Assurance check, so that means the browser knows where they are but the stupid Citrix app doesn't. So all of the certs are located here in Ubuntu (you have a ton in there):

ls /etc/ssl/certs/ | grep DigiCert

You will see the one you want, now copy it to your Citrix folder:


sudo cp -v /etc/ssl/certs/DigiCert_High_Assurance_EV_Root_CA.pem ~/./ICAClient/linuxx86/keystore/cacerts/

Now try again and it will work, I didn't even have to restart my browser. You could also do a symbolic link instead which is maybe a better practice. 


Friday, August 23, 2013

[Errno 14] PYCURL ERROR 7 - epel repo install not working RHEL 64 bit



Solution:
I added

proxy=http://proxyHost:proxyPort/
proxy_username=myUsername
proxy_password=myPassword

to

vi /etc/yum.conf

and it worked.

Original error:

 sudo yum --enablerepo=epel install R
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "Failed to connect to 2610:28:3090:3001:dead:beef:cafe:fed4: Network is unreachable"
Trying other mirror.


was fixed

Wednesday, August 21, 2013

How to install ox_Oracle in RHEL 64 bit and get it working

Ok this sucked... but it is done now and hopefully this helps one person somewhere, please comment if it does.

So this is the version of RHEL I am using when I call uname -or
2.6.32-358.el6.x86_64 GNU/Linux

I didn't know what version of Oracle was running and so rather than asking the DBA I just ran this SQL statement in my developer tool: "Select * from v$version;"

which told me 10.2.0.5. So then I went over to Oracle's website for 64bit drivers:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html  (select the license agreement and download to /tmp/)

and download the basic 10.2.04 rpm to my /tmp/ folder

cd /tmp/
rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm

after that was installed I needed to setup the environmental variables just right. If you don't do this your ox_Oracle install will fail silently and you will hit your head against the wall forever..

Tkae note your exact paths might be a little different so check them (incase you have a different version or didn't do the 64bit, etc..

echo export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client64/lib/ >> ~/.bashrc
echo export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64 >> ~/.bashrc
echo export PATH=$ORACLE_HOME/bin:$PATH >> ~/.bashrc

This also throws them into the bashrc so they will be there next time. Now it is time to download the ox_Oracle RPM for python. For that go here: http://cx-oracle.sourceforge.net/

Even though I am using RHEL you can just use the CENTOS RPM. So pick your version of oracle and python. If you don't know your version of python run: python -V

wget http://downloads.sourceforge.net/project/cx-oracle/5.1/cx_Oracle-5.1-10g-py26-1.x86_64.rpm?r=http%3A%2F%2Fcx-oracle.sourceforge.net%2F&ts=1377121971&use_mirror=superb-dca2

Now install

rpm -ivh cx_Oracle-5.1-10g-py26-1.x86_64.rpm

Yay!! You did it! You are awesome! You saved hours and hours of time compared to everyone else that has tried this! Congrats, you are a genius, epic genius. Well... maybe... to really know if all of this is true try this:

python -c "import cx_Oracle"

If that works with no errors you did it! Now for some more robust testing try actually doing a simple select statement. Let's try the one we started with. Make a file called connect.py and put this in it.

vi connect.py

Once that opens then copy this in, and of course populate with your connection info. Then save.

import sys
import cx_Oracle

host='yourhostname'
sid='yourSID'
username='yourUserName'
password='yourPassWord'
dsn = cx_Oracle.makedsn(host, 1521, sid)
con = cx_Oracle.connect(username+'/'+password+'@' + dsn)
cur = con.cursor()

cur.execute('Select * from v$version')
for result in cur:
    print result
print con.version

cur.close()
con.close()
print "I am awesome!"

and test

python connect.py