Skip to content

Instantly share code, notes, and snippets.

View pbassut's full-sized avatar

Patrick Bassut pbassut

View GitHub Profile
def find_sumpairs(n, numbers):
# This assumes we can't count on the fact that the array will be sorted
# So, sort it to make sure. Not that this could be skipped and save an O(n log n)
best_case = sorted(numbers, reverse=True)
if (n / 2) > best_case[0]:
# if in a descending sorted array the left-most element
# is less than a half the number we're looking for,
# we can guarantee that the next number won't add up to n.
# So skip here
return False
def is_pandigital(num):
num = str(num)
beg = set(num[0:len(num)])
end = set(num[-len(num):])
if beg != end:
return False
return beg == set(map(str, range(1, len(num) + 1)))
23-Sep-2015 22:08:57.449 SEVERE [http-nio-8000-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [webservice] in context with path [/taxonomy] threw exception
org.jboss.resteasy.spi.UnhandledException: Response is committed, can't handle exception
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:148)
at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:432)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDi
2015-09-26T04:33:43.000Z - notice: Started logger in Debug mode!
2015-09-26T04:33:43.025Z - notice: Starting PopcornTV
2015-09-26T04:33:43.027Z - DNS: DnsProxy binding on 192.168.25.3:53
2015-09-26T04:33:43.563Z - Web: listening on 192.168.25.3:80
2015-09-26T04:33:43.566Z - Web: SSL Web: listening on 192.168.25.3:443
2015-09-26T04:33:43.579Z - notice: Starting Commit
2015-09-26T04:33:53.664Z - Debug: Query: {}
2015-09-26T04:33:53.665Z - Web: templates/MovieNav.xml
2015-09-26T04:33:53.839Z - Debug: Query: {}
2015-09-26T04:33:53.840Z - Web: /js/utils.js
var fs = require('fs');
var logger = require('./logger');
/*
Change setting for UDID in aTVSettings.json, this is called from the settings page.
*/
function changeSetting(UDID, setting, newSetting){
if (setting == 'tvendpoint'){
setTVEndpoint(newSetting);
return;
{
"ip": "192.168.25.3",
"default_dns": "8.8.8.8"
}
class EscapeFragmentMiddleware():
def process_view(self, request, view_func, view_args, view_kwargs):
if request.GET.get('_escaped_fragment_', None):
return reverse_proxy(request)
return view_func(request, *view_args, **view_kwargs)
curl 'https://chat.stackoverflow.com/chats/stars/6?count=0&_=1453994620715' -H -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,pt-BR;q=0.6,pt;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36' -H 'Accept: text/html, */*; q=0.01' -H 'Referer: https://chat.stackoverflow.com/rooms/6/python' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed
import sys
import math
from collections import deque
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
table = {
'I': 1,
'V': 5,
'X': 10,
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')
def create_username(first_name, last_name=None):
guessed_name = first_name[:10]
if last_name:
guessed_name += '.%s' % last_name[:10]