Category Archives: Python

TIL — deep learning on Udacity

https://classroom.udacity.com/courses/ud730

I highly recommend this course because of its simplicity as well as its up-to-date-ness.

As a python newbie (and noob) I just managed to learn how powerful and elegant numpy is for processing multi-dimensional arrays

P.S. more to come (hopefully)

Advertisements

Redis on Windows

Website: https://redis.io/

Installation:

  1. Redis supports Unix system so in order to support Windows it requires some tweaks. You can download the MSI at https://github.com/MSOpenTech/redis#redis-on-windows
  2. In python environment:
    pip install redis

One simple example to set and get string values

import redis

r = redis.Redis()
r.set('foo', 'bar')
value = r.get('foo').decode('utf-8')
print(value)

Note: r.get('foo') will return b'bar' which is a byte string – redis will auto-encode a unicode string for you on the way in. r.get('foo').decode('utf-8') decode it using utf-8.

Ref: https://stackoverflow.com/questions/25745053/about-char-b-prefix-in-python3-4-1-client-connect-to-redis

You can even save objects

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def grow(self):
        self.age += 1

    def __repr__(self):
        return str.format("Name={name}, Age={age}", name=self.name, age=self.age)

p = Person("Han", 32)
r.set('han', p)

Have fun!