This file contains 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
""" | |
Module that wraps around ping and traceroute. The X version uses a new threading thingy | |
""" | |
import procThread | |
import threading | |
__info__ = { | |
"Author": "Ross Delinger", | |
"Version": "1.0", | |
"Dependencies": ["ping", "traceroute"] | |
} |
This file contains 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
""" | |
Used to run processes and keep the main module free to do other things. | |
Unfortunately this thread is designed to work under unix based systems so... | |
Sorry windows users :/ | |
""" | |
import MODIFIED_subprocess as subProc | |
import os | |
import threading | |
class procThread(threading.Thread): | |
context = None |
This file contains 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
ERROR:Modules:Error running command ping | |
Traceback (most recent call last): | |
File "/Users/rossdelinger/Documents/Schongo/modules/__init__.py", line 491, in handle_command | |
cmdf(ctx, cmd, arg, *args) | |
File "/Users/rossdelinger/Documents/Schongo/modules/netcmdsX.py", line 17, in ping | |
pt = procThread(shellCmd, ctx) | |
TypeError: 'module' object is not callable |
This file contains 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 paramiko | |
from functools import partial | |
class SuperParamiko(object): | |
""" | |
usage: | |
>> ssh = SuperParamiko("hostname", "username") | |
>> ssh.ls() | |
>> ssh.git("pull") |
This file contains 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
(lambda args: map(lambda repo: __import__("os").system('git clone {0} {1}/{2}'.format(repo.git_url,args.backupdir,repo.name)),__import__("pygithub3").Github().repos.list(args.username).all()))((lambda : (lambda : [globals().update(argparser=__import__("argparse").ArgumentParser(description="Backup allyour github repos")),map(lambda arg: globals()["argparser"].add_argument(*arg["args"],**arg["kwargs"]),[{"args": ("username",),"kwargs": {"help": "A Github username"}},{"args": ("backupdir",),"kwargs": {"help": "The folder where you want your backups to do"}}]),globals()["argparser"].parse_args()])()[-1])()) |
This file contains 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 functools import partial | |
def _composed(f, g, *args, **kwargs): | |
return f(g(*args, **kwargs)) | |
def compose(*a): | |
try: | |
return partial(_composed, a[0], compose(*a[1:])) | |
except: | |
return a[0] |
This file contains 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 twilio.rest import TwilioRestClient | |
from random import choice | |
import requests | |
import json | |
def random_issue(): | |
issues = json.loads(requests.get("https://api.github.com/repos/ComputerScienceHouse/Drink-JS/issues").text) | |
return choice(issues)['body'] | |
SPAM_SMS = [ |
This file contains 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
""" | |
Misc tools/functions written by Ross Delinger | |
""" | |
def assemblePipeLine(*args, **kwargs): | |
""" | |
Given an arbitrary number of functions we create a pipeline where the output | |
is piped between functions. you can also specify a tuple of arguments that | |
should be passed to functions in the pipeline. The first arg is always the |
This file contains 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
""" | |
Author: Ross Delinger (rossdylan) | |
Really useless class that just makes _ equal whatever you throw at it | |
usage: | |
from underscore import _ | |
if [_,_] == [1,"thing"]: | |
print "Anything goes!" | |
else: | |
print "Apprently this doesn't work" | |
""" |
This file contains 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
""" | |
Decorator which takes a int which is the maximum number of args the decorated function can take | |
""" | |
class curryable(object): | |
def __init__(self, numArgs): | |
self.numArgs = numArgs | |
def __call__(self, func): | |
if self.numArgs > 0: | |
@curryable(self.numArgs-1) | |
def wrapper(*args, **kwargs): |
OlderNewer