Skip to content

Instantly share code, notes, and snippets.

View mwrites's full-sized avatar
🔧

Supermercat mwrites

🔧
View GitHub Profile
@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 / ProvisioningProfileCheck.sh
Created December 20, 2018 09:02
Checking a provisioning profile
security cms -D -i $1
@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
# 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 ->
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]
@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
@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 / 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 / read_in.py
Last active March 23, 2018 10:08
Reading input in python
# 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)
@mwrites
mwrites / Array+InvertedIndexExtension.swift
Last active March 6, 2018 15:09
Inverted Index for Array
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
}
}