{{ message }}

Instantly share code, notes, and snippets.

Last active Feb 5, 2019
Measure network throughput in best case scenario -- one-to-one
View iperf-client-best-case.yml
 - hosts: worker_raspi remote_user: life strategy: free tasks: - name: iperf1 shell: iperf -t 20 -c 192.168.2.10 when: ansible_host == '192.168.2.13' - name: iperf2 shell: iperf -t 20 -c 192.168.2.11 when: ansible_host == '192.168.2.14'
Last active Feb 5, 2019
Measure network throughput in worst case scenario -- many-to-one
View iperf-client-worst-case.yml
 - hosts: worker_raspi remote_user: life tasks: - name: iperf shell: iperf -t 20 -c 192.168.2.10
Created Nov 6, 2018
Calculate the maximum number of overlapping intervals
View overlapping_intervals.py
 # Given a list of intervals, calculate the maximum number of overlapping intervals. # Each interval is inclusive at both ends. def solve(intervals): # list of pairs tmp1 = set(y for x in intervals for y in x) tmp2 = max(map(lambda x: sum(1 if y[0] <= x <= y[1] else 0 for y in intervals), tmp1)) print "%s %d" % (intervals, tmp2) solve([(1,5), (2,4), (3, 6)]) solve([(1,5), (2,3), (4, 6), (7,9)])
Last active Jul 20, 2018
Extracts comments associated with highlights in a PDF document along with page numbers
Last active May 5, 2018
Anonymizes the names (in names.txt) without disturbing the order and frequency of alphabet and number positions
View anonymizeNames.py
 from random import randrange, sample, shuffle alphas = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') nums = list('1234567890') shuffle(alphas) shuffle(nums) def scramble(s, seen): while True: ret = ''.join([(nums[int(x)] if x in nums else
Created Apr 15, 2018
Identifies a queue-based BFS traversal order of nodes of a given directed graph using z3 solver
View bfsSolver2.groovy
Last active Apr 16, 2018
Identifies a DFS traversal order of nodes of a given directed graph using z3 solver
View dfsSolver.groovy