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
snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "w") | |
snmpwalk_mac_file.close() | |
snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "w") | |
pickle.dump(mac_objects, snmpwalk_mac_file) | |
#snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "r") | |
#snmp_mac_list = pickle.load(snmpwalk_mac_file) |
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 create_valid_mac_address(mac_address): | |
mac_address = mac_address.replace("-", "") | |
if len(mac_address) != 12: | |
raise InvalidMacAddressStringException("The String of the MAC-Address does not contain enough characters") | |
if not all(c in string.hexdigits for c in mac_address): | |
wrong_chars = "" | |
for c in mac_address: | |
if c not in string.hexdigits: | |
wrong_chars += "#%s#" % c | |
else: |
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
snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "w") | |
snmpwalk_mac_file.close() | |
pickle.dump(mac_objects, snmpwalk_mac_file) | |
#snmpwalk_mac_file = open("ndms/snmp-results/snmpwalk_mac_adresses.txt", "r") | |
#snmp_mac_list = pickle.load(snmpwalk_mac_file) |
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
app_models = get_app('app_name') | |
for model in get_models(app_models): | |
try: | |
admin.site.register(model) | |
except AlreadyRegistered: | |
pass | |
#use this if you want to register a model with specific definition | |
#admin.site.unregister(ModelName) |
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
#calculates r for height and width | |
def ratio(a, b): | |
a = float(a) | |
b = float(b) | |
if b == 0: | |
return a | |
return ratio(b, a % b) | |
#returns a string with ratio for height and width | |
def get_ratio(a, b): |
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 get_city_json(request, latitude, longitude): | |
r = requests.get('http://maps.googleapis.com/maps/api/geocode/json?latlng=%s,%s&sensor=true' % (latitude, longitude)) | |
#convert result to json | |
json_data = r.json() | |
#get data from json | |
city = json_data['results'][0]['address_components'][3]['long_name'] | |
response_data = {} | |
response_data['city'] = city | |
response_data['street'] = json_data['results'][0]['address_components'][1]['long_name'] | |
#data as json-response |
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 Result(): | |
def __init__(self, type): | |
self.type = type | |
def FirstDefinition(self): | |
pass | |
def SecondDefinition(self): |
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
pic = Image.open('/path/to/image.jpg') | |
sorted_list = sorted(pic.getcolors(pic.size[0]*pic.size[1])) | |
#get complementary color of picture | |
comp = ['%s' % (255 - int(a)) for a in sorted_list[-1][1]] | |
color1 = '#%02x%02x%02x' % (sorted_list[-1][1]) | |
color2 = '#%02x%02x%02x' % (int(comp[0]), int(comp[1]), int(comp[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
#sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>io.redis.redis-server</string> | |
<key>ProgramArguments</key> | |
<array> |
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
bewerber.fields = dict((field.name, field.value_to_string(bewerber)) | |
for field in bewerber._meta.fields) |