Friday, April 17, 2015

How To Add User To Sudoer File Without A password

I want to have a user have sudo access without needing a password, so I did this.

sudo vi /etc/sudoers

Set this up:

# Members of the admin group may gain root privileges
sudo service sudo restart
sudo adduser  sudo

How To Add A New SSH Key To A Ubuntu Server


So if you have a client machine and you want to give them access to your server do this.
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/client/.ssh/id_rsa): /Users/client/.ssh/new_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/client/.ssh/new_key.
Your public key has been saved in /Users/client/.ssh/

This generates two files:
/Users/client/.ssh/new_key        (private)
/Users/client/.ssh/ (public)
Now you must copy the public key to the server of interest. On the server after you have copied the local file you can append to the 
cat /home/john/ >> /home/john/.ssh/authorized_keys
Now the user can login using their private key.
ssh -i /Users/client/.ssh/new_key

Monday, February 23, 2015

Stupid Simple Keep Alive Bash Script

Everyone has servers and processes they want to keep alive and if they are not alive they want to restart them. But they don't want the restarts to get out of control.

This is a stupid simple bash example that will allow you to do that. I'm using it to restart a python notebook.
#This silly script was written by @bentaylordata to handle auto restarting of processes in cron

#Check if string is running
OUTPUT="$(ps -ef | grep $string_of_interest | wc -l)"

if [ "$OUTPUT" -gt "1" ]
        echo "started"
        echo "need to start"
        ipython notebook --profile=nbserver --no-mathjax &   #This backgrounds the notebook server

Sunday, July 20, 2014

s3fs "Transport endpoint is not connected" error on ubuntu

So this error can probably be cause by many reasons:

s3fs "Transport endpoint is not connected" error

My issue was caused when I tried mounting my s3 bucket with the s3://mybucket in the name. Then I wasn't actually unmounting it until I ran

sudo fusermount -u /mnt/sshfs

Then when I reran the s3fs command it worked. 

s3fs mybucket /mnt/s3_upload/

use the "d" and "f" flags for the s3fs to give me debugging output. 

Saturday, February 1, 2014

How to accept command line argument with octave

So I am wanting to accept command line arguments and the "octave -help" didn't really show me what I wanted. So like many other languages you can use argv to collect command line, here is an example.

Suppose I want to create a test.m file that will accept 4 command line inputs like so:

octave test.m 1 2 3 4

To do that I would do:

%Accept standard in
n1 = str2num(argv(){1})
n2 = str2num(argv(){2})
n3 = str2num(argv(){3})
n4 = str2num(argv(){4})
t=n1+n2+n3+n4;     %Do calculations

printf("%d\n", t)  %Print standard out...

That way I can do what I wanted.

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]
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:

Which says to go to line 167 in and comment out the




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