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 editDataProfil(request): | |
| model = get_model('bewerberportal', request.POST['model']) | |
| setattr(model, request.POST['field'], request.POST['value']) | |
| return HttpResponse("1") |
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
| {% for field, value in bewerber.fields.iteritems %} | |
| <tr> | |
| <td>{{ field }}</td> | |
| <td><span data-model="bewerber" data-field="{{ field }}" class="edit" data-value="{{ value }}">{{ value }}</span></td> | |
| </tr> | |
| {% endfor %} |
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) |
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
| 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
| 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
| 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
| #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
| 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
| 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) |
OlderNewer