Skip to content

Instantly share code, notes, and snippets.

View mwrites's full-sized avatar
🔧

Supermercat mwrites

🔧
View GitHub Profile
@mwrites
mwrites / LinkedListGenerator.py
Created April 3, 2018 06:27
Python Iterate on a linked list
def iterate_from(list_item):
while list_item is not None:
yield list_item
list_item = list_item.next
@mwrites
mwrites / init.coffee
Created June 1, 2018 05:46
Atom init.coffee
atom.workspace.observeTextEditors (editor) ->
unless editor.getPath()
editor.setGrammar(atom.grammars.grammarForScopeName('source.python'))
@mwrites
mwrites / toggleShadowAndCharles.scpt
Created June 1, 2018 07:53
Toggle ShadowSocks and Charles
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
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]
# 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 ->
@mwrites
mwrites / graphs.py
Last active September 20, 2018 05:33 — forked from daveweber/graphs.py
Breadth First and Depth First Search in Python
# 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
@mwrites
mwrites / ProvisioningProfileCheck.sh
Created December 20, 2018 09:02
Checking a provisioning profile
security cms -D -i $1
@mwrites
mwrites / randIntList.py
Last active December 28, 2018 10:32
Python list of random numbers
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
@mwrites
mwrites / InspectCaller.py
Created February 6, 2019 14:19
Python get function caller
import inspect
def f1(): f2()
def f2():
print 'caller name:', inspect.stack()[1][3]
f1()
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)