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
[3/5.0.2]niwi@localhost:~/tmp-memory-leak> python3 simple-test.py | |
Memory leak: | |
KK.__init__ 139987115392208 | |
Foo.__init__ 139987115392016 | |
No memory leak: | |
KK.__init__ 139987115392400 | |
Bar__init__ 139987115392272 | |
Bar.__del__ 139987115392272 | |
KK.__del__ 139987115392400 |
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
from django.test import client | |
# Call this function on head of your test file. | |
def patch_request_factory(): | |
def _method(self, path, data='', content_type='application/octet-stream', follow=False, **extra): | |
response = self.generic("PATCH", path, data, content_type, **extra) | |
if follow: | |
response = self._handle_redirects(response, **extra) | |
return 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
function uuid() { | |
var uuid = "", i, random; | |
for (i = 0; i < 32; i++) { | |
random = Math.random() * 16 | 0; | |
if (i == 8 || i == 12 || i == 16 || i == 20) { | |
uuid += "-" | |
} | |
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16); | |
} |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include "../src/http.h" | |
using namespace std; | |
void | |
progress(size_t length, size_t received_length) { | |
cout << (received_length * 100) / length << "%" << endl; |
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/env python3 | |
# -*- coding: utf-8 -*- | |
from subprocess import Popen, PIPE | |
import argparse | |
import shlex | |
import datetime | |
import re | |
import ipaddress as ip | |
import functools |
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function | |
import argparse | |
import socket | |
import fcntl | |
import struct | |
import os | |
import sys |
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
CORS_ALLOWED_ORIGINS = getattr(settings, 'CORS_ALLOWED_ORIGINS', '*') | |
CORS_ALLOWED_METHODS = getattr(settings, 'CORS_ALLOWED_METHODS', | |
['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE', 'PATCH']) | |
CORS_ALLOWED_HEADERS = getattr(settings, 'CORS_ALLOWED_HEADERS', | |
['Content-Type', 'X-Requested-With', | |
'X-Session-Token', 'Accept-Encoding']) | |
CORS_ALLOWED_CREDENTIALS = getattr(settings, 'CORS_ALLOWED_CREDENTIALS', True) | |
class CorsMiddleware(object): |
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
""" | |
A file lock implementation that tries to avoid platform specific | |
issues. It is inspired by a whole bunch of different implementations | |
listed below. | |
- https://bitbucket.org/jaraco/yg.lockfile/src/6c448dcbf6e5/yg/lockfile/__init__.py | |
- http://svn.zope.org/zc.lockfile/trunk/src/zc/lockfile/__init__.py?rev=121133&view=markup | |
- http://stackoverflow.com/questions/489861/locking-a-file-in-python | |
- http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/ | |
- http://packages.python.org/lockfile/lockfile.html |
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
[3/5.0.2]niwi@localhost:~/Downloads/groovy-2.2.0-beta-2> ./bin/groovysh | |
Groovy Shell (2.2.0-beta-2, JVM: 1.7.0_40) | |
Type 'help' or '\h' for help. | |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
groovy:000> class Foo {} | |
===> true | |
groovy:000> instance1 = new Foo() | |
===> Foo@6f24bcc6 | |
groovy:000> cls = Foo | |
===> class 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
from __future__ import print_function | |
import sys | |
from rest_framework import views | |
from rest_framework import status, exceptions | |
from rest_framework.response import Response | |
def patch_api_view(): | |
from django.views.generic import View |