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
| 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
| 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
| 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
| # 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
| # 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
| 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
| 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
| import inspect | |
| def f1(): f2() | |
| def f2(): | |
| print 'caller name:', inspect.stack()[1][3] | |
| f1() |
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 CustomStringConvertible { | |
| var description : String { | |
| var description: String = "" | |
| if self is AnyObject { | |
| description = "***** \(type(of: self)) - <\(unsafeAddressOf((self as! AnyObject)))>***** \n" | |
| } else { | |
| description = "***** \(type(of: self)) *****\n" | |
| } | |
| let selfMirror = String(reflecting: self) |