Skip to content

Instantly share code, notes, and snippets.

@Atlas7
Atlas7 / octave_tip.md
Last active December 23, 2021 17:25
Octave - find the min (or max) value of a Matrix, and the associated row and column

Whilst working through the many (Octave) coding assignment from Andrew Ng's Stanford Machine Learning course, a common problem that I have to solve revolves around this:

Given a Matrix A with m rows, and n columns find the mininum (or maximum) value and the associated row and column number

This article summarises my solution to this problem (which, hopefully this will also come in hadny to you!). Note that Octave index start from 1 (instead of 0).

Sample Matrix

Say we have a Matrix A that look like this:

@fasiha
fasiha / README.md
Created August 18, 2016 00:33
clang-format.py for Vim integration with python3: from https://reviews.llvm.org/D23319

The current clang-format instructions are for Python2 Vim. If your Vim has only Python3 or if you load Python3 before Python2, those instructions won't work.

Therefore, (1) replace your clang-format.py with the file in this gist, from https://reviews.llvm.org/D23319. (2) Replace the relevant lines in .vimrc with:

map <C-K> :py3f ~/PATH/TO/clang-format.py<cr>
imap <C-K> <c-o>:py3f ~/PATH/TO/clang-format.py<cr>

N.B. Replace ~/PATH/TO with the actual path to clang-format.py.

@thomasfr
thomasfr / iptables.sh
Last active April 13, 2024 01:59
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.