Tag: python

Visualize activations functions using keras

In keras, we can visualize activation functions’ geometric properties using backend functions over layers of a model. We all know the exact function of popular activation functions such as ‘sigmoid’, ‘tanh’, ‘relu’, etc, and we can feed data to these f…

Using Python to work with SAS Viya and CAS

One of the big benefits of the SAS Viya platform is how approachable it is for programmers of other languages. You don’t have to learn SAS in order to become productive quickly. We’ve seen a lot of interest from people who code in Python, maybe because that language has become […]

The post Using Python to work with SAS Viya and CAS appeared first on The SAS Dummy.

Introducing SASPy: Use Python code to access SAS

Thanks to a new open source project from SAS, Python coders can now bring the power of SAS into their Python scripts. The project is SASPy, and it’s available on the SAS Software GitHub. It works with SAS 9.4 and higher, and requires Python 3.x. I spoke with Jared Dean […]

The post Introducing SASPy: Use Python code to access SAS appeared first on The SAS Dummy.

Use Slack bot to monitor the server

I used to install Datadog or other SaaS to monitor my Linux boxes on the cloud. Most times they are just overkill for my tiny servers with only 1GB or 2GB memory. Actually what I am most interested is the up-and-running processes, or/and the exact memory usage. And I need a mobile solution to monitor on-the-go.
Now with the coming of Slack bot, and its real time Python client, I can just use a simple Python script to realize the purposes.
from slackclient import SlackClient
from subprocess import getoutput
import logging
import time

message_channel = '#my-server-001'
api_key = 'xoxb-slack-token'
client = SlackClient(api_key)

if client.rtm_connect():
while True:
last_read = client.rtm_read()
if last_read:
try:
parsed = last_read[0]['text']
if parsed and 'status' in parsed:
result = getoutput('pstree')
result += '\n\n' + getoutput('free -h')
client.rtm_send_message(message_channel, str(result))
except Exception as e:
logging.error(e)
time.sleep(1)
Then I use systemd or other tools to daemonize it. No matter where and when I am, I enter status at the #my-server-001 channel on my phone, I will instantly get the result like –
systemd-+-accounts-daemon-+-{gdbus}
| `-{gmain}
|-agetty
|-cron
|-dbus-daemon
|-fail2ban-server---2*[{fail2ban-server}]
|-login---bash
|-nginx---nginx
|-postgres---5*[postgres]
|-python---sh---pstree
|-redis-server---2*[{redis-server}]
|-rsyslogd-+-{in:imklog}
| |-{in:imuxsock}
| `-{rs:main Q:Reg}
|-sshd-+-3*[sshd---sshd---bash]
| `-sshd---sshd
|-2*[systemd---(sd-pam)]
|-systemd-journal
|-systemd-logind
|-systemd-timesyn---{sd-resolve}
|-systemd-udevd
`-uwsgi---uwsgi---5*[uwsgi]

total used free shared buff/cache available
Mem: 2.0G 207M 527M 26M 1.2G 1.7G
Swap: 255M 0B 255M

Install Theano under Anaconda3 Python 3.5

As of writing, Deep Learning package Theano can’t be installed under Python 3.5, which causes some problems with my project. ruslanagit provided a viable solution that works for me under Windows 10.For convenience, I copied his solution below:Well, the…

How to run SAS programs in Jupyter Notebook

We’ve just celebrated Earth Day, but I’m here to talk about Jupyter — and the SAS open source project that opens the door for more learning. With this new project on the github.com/sassoftware page, SAS contributes new support for running SAS from within Jupyter Notebooks — a popular browser-based environment […]

The post How to run SAS programs in Jupyter Notebook appeared first on The SAS Dummy.