Skip to content

Instantly share code, notes, and snippets.

View yasyf's full-sized avatar

Yasyf Mohamedali yasyf

View GitHub Profile
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|
curl -s https://en.wikipedia.org/wiki/Popular_cat_names | pup 'tr td text{}' | sort -u
@yasyf
yasyf / hostpitals.sh
Last active February 7, 2016 03:16
Hospitals
function hospitals() {
curl -s "https://en.wikipedia.org/wiki/List_of_hospitals_in_$1" | grep '<li><a href="/wiki/' | wc -l
}
#! /usr/bin/env ruby
class Command
def initialize
@arg_counter = 0
contact_info
end
def main
data = STDIN.tty? ? consume : STDIN.read
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))
@yasyf
yasyf / setup6172.sh
Last active September 11, 2015 18:46
#!/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"
print '\n'.join((((i % 3 == 0 and 'fizz') or '') + ((i % 5 == 0 and 'buzz') or '') or str(i) for i in xrange(100)))
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"
\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}
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(" |}")