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
#!/usr/bin/python | |
import praw | |
import pdb | |
import re | |
import os | |
import time | |
user_agent = ("spread kindness /u/eclecticmiraclecat13") | |
r = praw.Reddit(user_agent=user_agent) |
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
check program apache2 with path "/bin/bash -c '[ $(/bin/ps auxwww | /bin/grep apache | /bin/grep -v grep | /usr/bin/wc -l) -gt 2 ]'" | |
start program = "/etc/init.d/apache2 start" | |
stop program = "/etc/init.d/apache2 stop" | |
restart program = "/etc/init.d/apache2 restart" | |
if status != 0 then restart |
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
>>> class Foo: | |
... def __get__(self, instance, owner_class): | |
... print('hello from foo') | |
... | |
>>> class Bar: | |
... foo = Foo() | |
... | |
>>> b = Bar() | |
>>> b.foo | |
hello from foo |
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
>>> class Foo: | |
... def hello(self): | |
... print(self.__class__.__name__) | |
... | |
>>> class Bar(Foo): | |
... pass | |
... | |
>>> b = Bar() | |
>>> b.hello() | |
Bar |
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
>>> class Num: | |
... def __init__(self, value): | |
... self.value = value | |
... def __add__(self, other): | |
... return self.value + other.value | |
... | |
>>> num1 = Num(1) | |
>>> num2 = Num(2) | |
>>> num1 + num2 | |
3 |
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
>>> class Foo: | |
... def __getattr__(self, name): | |
... setattr(self, name, 'N/A') | |
... return getattr(self, name) | |
... | |
>>> f = Foo() | |
>>> f.x | |
'N/A' | |
>>> f.__dict__ | |
{'x': 'N/A'} |
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
>>> class Foo: | |
... def __init__(self, x, y): | |
... self.x = x | |
... self.y = y | |
... | |
>>> f = Foo(x=2, y=3) | |
>>> f.x | |
2 | |
>>> getattr(f, 'x') | |
2 |
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
>>> class Parent: | |
... def __init__(self, value): | |
... self.value = value | |
... def spam(self): | |
... print('Parent.spam', self.value) | |
... def grok(self): | |
... print('Parent.grok') | |
... self.spam() | |
... | |
>>> p = Parent(42) |
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
>>> class Upper: | |
... def uppercase(self, value): | |
... print(value.upper()) | |
... | |
>>> u = Upper() | |
>>> u.uppercase('hi') | |
HI | |
>>> class DashUpper(Upper): | |
... def uppercase(self, value): | |
... value = f'--{value}--' |
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
>>> class Parent: | |
... def spam(self): | |
... print('Parent.spam') | |
... | |
>>> class A(Parent): | |
... def spam(self): | |
... print('A.spam') | |
... super().spam() | |
... | |
>>> class B(A): |
OlderNewer