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 random | |
def randIntLists(length=5, samples=5): | |
R = [] | |
for _ in range(samples): | |
A = [random.randint(0, 9) for _ in range(length)] | |
R.append(A) | |
return R |
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
security cms -D -i $1 |
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
# https://eddmann.com/posts/depth-first-search-and-breadth-first-search-in-python/ | |
def bfs(graph, start): | |
visited, queue = set(), [start] | |
while queue: | |
vertex = queue.pop(0) | |
if vertex not in visited: | |
visited.add(vertex) | |
queue.extend(graph[vertex] - visited) | |
return visited |
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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
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
from random import randint | |
import random | |
def get_pivot(low, max): | |
return randint(low, max) | |
def partition(ar, low, max, p): | |
ar[low], ar[p] = ar[p], ar[low] |
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
set charlesApp to "Charles" | |
set shadowApp to "ShadowsocksX-NG" | |
set simApp to "Simulator" | |
if application charlesApp is running then | |
tell application charlesApp | |
quit | |
end tell | |
tell application shadowApp | |
activate |
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
atom.workspace.observeTextEditors (editor) -> | |
unless editor.getPath() | |
editor.setGrammar(atom.grammars.grammarForScopeName('source.python')) |
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 iterate_from(list_item): | |
while list_item is not None: | |
yield list_item | |
list_item = list_item.next |
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
# Create array from lines of separated values such as 1 2 3 | |
arr = list(map(int, input().strip().split(' '))) | |
import sys | |
def read_in(): | |
return [x.strip() for x in sys.stdin] | |
lines = read_in() | |
print(lines) |
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
extension Array where Element : Comparable { | |
var invertedIndexes: [(index: Index, value: Element)] { | |
var res = [(index: Index, value: Element)]() | |
for (k, v) in enumerated() { | |
res.append((index: k, value: v)) | |
} | |
return res | |
} | |
} |