This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def connections(client) | |
client.in_range.flat_map do |ap| | |
ap.clients.flat_map { |c| c.in_range } | |
end.uniq | |
end | |
def rebalance(orig_client) | |
conns = connections(orig_client) | |
conns.length.times do | |
conns.each do |ap| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s https://en.wikipedia.org/wiki/Popular_cat_names | pup 'tr td text{}' | sort -u |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hospitals() { | |
curl -s "https://en.wikipedia.org/wiki/List_of_hospitals_in_$1" | grep '<li><a href="/wiki/' | wc -l | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
class Command | |
def initialize | |
@arg_counter = 0 | |
contact_info | |
end | |
def main | |
data = STDIN.tty? ? consume : STDIN.read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def generate_mod(n): | |
compontents = [] | |
compontents.append("unsigned int mod[BUFFER_MAX][BUFFER_MAX*2] = {\n") | |
for i in range(1, n + 1): | |
compontents.append(" {") | |
for j in range(2*n): | |
compontents.append("{0}, ".format(j % i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function setup6172() { | |
PWD=$(pwd) | |
DIR_NAME=$(basename "$PWD") | |
CONFIG="/tmp/6172_config/$DIR_NAME" | |
HOST='[email protected]' | |
EMAIL='[email protected]' | |
TARGET="Documents/6.172/$DIR_NAME" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print '\n'.join((((i % 3 == 0 and 'fizz') or '') + ((i % 5 == 0 and 'buzz') or '') or str(i) for i in xrange(100))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
P0: RCV KEY "a" | |
P0: SEND KEY "a" | |
P1: RCV KEY "a" | |
P1: TRANSLATE KEY "a" | |
Wait(print_lock) | |
P1: PRINT KEY "b" | |
P0: RCV KEY "b" | |
P0: SEND KEY "b" | |
P1: RCV KEY "b" | |
P1: TRANSLATE KEY "b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\begin{displaymath} | |
\mu_i^{(j)} = \left\{ | |
\begin{array}{lr} | |
\frac{1}{\hat{n}_j} \cdot \sum_{u=1}^n \left[\delta(i, C_u) \cdot p(j|u) \cdot \left(x^{(u)}_{C_u}\right)_i\right] & \text{if } $x = 1$ \\ | |
\mu_i^{(j)} & \text{if } $x = 0$ \\ | |
\end{array} | |
\right. | |
\end{displaymath} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_latex_table(data, variables, result): | |
top, side = variables | |
top_keys = list(sorted(set(map(lambda x: x[top], data)))) | |
side_keys = list(sorted(set(map(lambda x: x[side], data)))) | |
table = [] | |
table.append("\\begin{tabular}") | |
table.append("{") | |
table.extend(["| l"] * (len(top_keys) + 1)) | |
table.append(" |}") |