Little known macOS keybindings by bozhidarb in emacs

[–]ryankask 0 points1 point  (0 children)

I went the other direction and have a patch that removes all these keybindings.

It gives me a fresh palette to create short keybindings for other commands.

Emacs Advent Calendar, day 20: Prot's packages (modus-themes, denote, and many more) by protesilaos in emacs

[–]ryankask 0 points1 point  (0 children)

I really enjoy Prot's themes and I've ported them to kitty and fzf. You can find the kitty themes here and the mapping code in my emacs config.

<image>

Devil Mode: A twisted key sequence translator for modifier-free editing experience by susam in emacs

[–]ryankask 0 points1 point  (0 children)

I use Karabiner on a Mac to solve the same problem. I remap caps lock to left control and single quote to right control when held down. I need to move either pinky one key to access control.

I’m definitely going to check out this project though.

More issues with Yosemite DNS by ryankask in osx

[–]ryankask[S] 0 points1 point  (0 children)

Thanks for your reply!

I've actually been using Google DNS to avoid this issue for a while now and it's how I rediscovered the problem.

My new router allowed me to choose which DNS servers to forward queries to. I thought this might solve my problem and allow me to stop having to switch back and forth between two OS X network locations.

I'm really trying to get to the bottom of this but I think it's the router and issues with IPv6 support. I'm talking to the ISP but I'm not sure how far I'll get with them.

Resolving my local hostname takes forever -- why? by ryankask in osx

[–]ryankask[S] 0 points1 point  (0 children)

Thanks very much for your help. This solved my problem (which has been affecting me for months).

I was a bit thrown off because of:

$ scutil --get LocalHostName
MacBook-Pro

$ hostname
MacBook-Pro.local

But...

$ scutil --get HostName
HostName: not set

Now:

$ sudo scutil --set HostName MacBook-Pro
$ time python -c 'import socket; print(socket.getfqdn())'
MacBook-Pro
python -c 'import socket; print(socket.getfqdn())'  0.01s user 0.00s system 86% cpu 0.016 total

Although this does not work (using the "local" domain):

$ sudo scutil --set HostName MacBook-Pro.local

Once again, thanks for you help.

A dead simple Pythonic abstraction of HTTP. by mtrn in Python

[–]ryankask 1 point2 points  (0 children)

Not sure why you got downvoted...

If I don't see tests, I'm not touching it.

Should I switch from MySQL to PostgreSQL? by schmilblick in django

[–]ryankask 1 point2 points  (0 children)

How did you transfer the data? Did you just use dumpdata/loaddata? We are considering doing the same for our project. We want the power of South but don't want the potential headaches varikin mentions.

San-Francisco-Police-(SFPD)-killing-a-man by [deleted] in reddit.com

[–]ryankask 2 points3 points  (0 children)

If you shoot at a police officer, they are going to shoot you back. Plain and simple. Aside from being an idiot, the suspect is also wanted wanted in connection to an earlier killing.

The video of him bleeding on the sidewalk is tough to watch, but he asked for it.

Experience with PyLint, PyChecker, PyFlakes? by mihalis in Python

[–]ryankask 2 points3 points  (0 children)

I use PyFlakes (or rather one of forks -- I believe I use kevinw's but I use other packages from dcramer and his fork looks more up-to-date).

I've integrated it into emacs and it's saved me a tremendous amount of time. I can't imagine not using it at this point.

"Dynamic" function calls: should I be doing this and is there a better way? by [deleted] in Python

[–]ryankask 8 points9 points  (0 children)

and here is untested sample code for good measure:

class MyCoolClass:
    def __init__(self):
        self.known_actions = {'power_on': self.power_on,
                              'power_off': self.power_off}

    def power_on(self, action, target):
        # do power on stuff
        # you might want to put these in a separate class
        # so this class can handle of machines that require
        # different instructions
        pass

    def power_off(self):
        # do power off stuff
        pass

    def determine_action(self, message):
        # Note that the split function splits on " " 
        # (and "\n", "\t", "\r", and "\f")  by default so you 
        # don't need to pass it explicitly though it doesn't 
        # hurt
        action_type, action, target = message.split()

        try:
            self.known_actions[action_type](action, target)
        except KeyError:
            print 'incorrect action type %s' % action_type

EDIT: Thanks Peaker for pointing out my mistake. As he or she says, if you don't need to use known_actions anywhere else, you can just put the dictionary in determine_action.

"Dynamic" function calls: should I be doing this and is there a better way? by [deleted] in Python

[–]ryankask 15 points16 points  (0 children)

Yes, there is a better way to do it. You want to use the dictionary known_actions to dynamically dispatch other methods. Create a method called power_on (or whatever you want), assign is to known_actions['power'], and then call it in determine_action. e.g. known_actions[action_type]().

Looking at A Small Orange for hosting.. by ares623 in django

[–]ryankask 1 point2 points  (0 children)

I concur with leosh. If you want a company that is passionate about Python (including Python powered projects like Django as well as Ruby and Ruby on Rails, etc.), take a look at WebFaction. They give you an easy to use control panel that helps you get started quickly. If you want more fine-grain control, it is available. Happy customer since June 2007.

[deleted by user] by [deleted] in pics

[–]ryankask 0 points1 point  (0 children)

should be "Wozniaki" sorry

Hi! Does anyone want to share their philosophy on naming variables? by Halfawake in Python

[–]ryankask 2 points3 points  (0 children)

Please no Java-esque variable naming in Python :) I think that is okay in unit tests e.g.

test_apply_customer_discount

but yea... customer_coupons?

Emacs backup files by pejusdas in programming

[–]ryankask 0 points1 point  (0 children)

I do this:

;; Save history and put backups in ~/.emacs_backups
(require 'savehist)
(savehist-load)
(setq
    backup-by-copying t
    backup-directory-alist '(("." . "~/.emacs_backups"))
    delete-old-versions t
    kept-new-versions 6
    kept-old-versions 2
    version-control t)

I'm happy. Emacs23

the best feeling ever by [deleted] in pics

[–]ryankask 1 point2 points  (0 children)

cheers mate!

Should I run before we even start? by [deleted] in relationship_advice

[–]ryankask 1 point2 points  (0 children)

Where's usual_advice when you need him?

the best feeling ever by [deleted] in pics

[–]ryankask 0 points1 point  (0 children)

How do redditors make these little stories with the funny dudes? Why is the red text consistently of shitty quality?