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
class AutocompleteWidget(forms.Select): | |
def __init__(self, attrs=None, choices=(), js_options={}): | |
super(AutocompleteWidget, self).__init__(attrs, choices) | |
self.js_options = js_options | |
def render(self, name, value, attrs=None, choices=()): | |
output = u'<input name="%(name)s" id="id_%(name)s" type="hidden">\n' % {'name': name} | |
value_text = '' | |
for ch in self.choices: | |
if str(ch[0]) == str(value): |
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 django.core.urlresolvers import reverse | |
from django.test import TestCase | |
class Test(TestCase): | |
def test_api(self): | |
response = self.client.post(reverse('vk.views.start_wall_post'), {}) | |
self.assertContains(response, 'errors') | |
response = self.client.post(reverse('vk.views.start_wall_post'), | |
{'image': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAO60lEQVR4Ae3WMQ0A', |
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
package | |
{ | |
import flash.display.Loader; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.net.URLLoader; | |
import flash.net.URLRequest; | |
import flash.text.TextField; | |
import com.adobe.serialization.json.JSON; |
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
#encoding: utf-8 | |
import uno | |
def open_document(url): | |
local = uno.getComponentContext() | |
resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local) | |
context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext") | |
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context) | |
document = desktop.loadComponentFromURL(url, "_blank", 0, ()) | |
return document |
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
$.ajaxSetup({ | |
beforeSend: function(xhr, settings) { | |
function getCookie(name) { | |
var cookieValue = null; | |
if (document.cookie && document.cookie != '') { | |
var cookies = document.cookie.split(';'); | |
for (var i = 0; i < cookies.length; i++) { | |
var cookie = jQuery.trim(cookies[i]); | |
// Does this cookie string begin with the name we want? | |
if (cookie.substring(0, name.length + 1) == (name + '=')) { |
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
description "Gunicorn for answers" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
kill timeout 5 | |
respawn | |
env VENV="/home/django/answers/env" | |
env LOG="/home/django/log/answers.log" | |
env PID="/home/django/run/answers.pid" |
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
def max_googlers(total_points, num_of_surprizing, max_point): | |
res = 0 | |
for total in total_points: | |
if max(unsurprizing(total)) >= max_point: | |
res += 1 | |
elif num_of_surprizing > 0 and max(surprizing(total)) >= max_point: | |
res += 1 | |
num_of_surprizing -= 1 | |
return res |
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
def prng(n): | |
p = (1 << 31) - 1 | |
arr = [0 for i in range(n + 1)] | |
arr[0] = 7 | |
arr[1] = 7 | |
for i in range(2, n + 1): | |
arr[i] = pow_mod(7, arr[i - 1], p) + pow_mod(7, arr[i - 2], p) | |
return arr |
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
% GNU Octave file (may also work with MATLAB(R) ) | |
Fs=44100;minF=10;maxF=Fs/2; | |
sweepF=logspace(log10(minF),log10(maxF),200); | |
preemph_coeff = 1 | |
b0 = 1 * preemph_coeff | |
b1 = -1.700724000000000e+00 * preemph_coeff + (1 - preemph_coeff) | |
b2 = 7.029381524255900e-01 * preemph_coeff | |
a0 = 2.380612232632074e-01 * preemph_coeff + (1 - preemph_coeff) | |
a1 = -1.718545401961680e-01 * preemph_coeff | |
a2 = -4.429177968575995e-02 * preemph_coeff |