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 ssort(A): | |
| if len(A) <= 1: return A | |
| i = 0 | |
| while i < len(A): | |
| imin, j = i, i | |
| while j < len(A): | |
| if A[imin] > A[j]: | |
| A[j], A[i] = A[i], A[j] | |
| imin = j | |
| j += 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
| def lca(node, n1, n2): | |
| if match(node.left, n1) and match(node.left, n2): | |
| return lca(node.left, n1, n2) # until we find the least common ancestor by node.left | |
| if match(node.right, n1) and match(node.right, n2): | |
| return lca(node.right, n1, n2) # until we find the least common ancestor by node.right | |
| return node | |
| def match(node, n): | |
| if node is None: return False | |
| if node == n: return True |
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 rotate(M): | |
| S = len(M) | |
| out = [[0] * S for x in xrange(S)] # create the output matrix | |
| for i in xrange(S): | |
| for j in xrange(S): | |
| out[i][j] = M[S-j-1][i] | |
| return out |
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 sqrt(A): | |
| x = A # the floor | |
| while x**2 - A > 0.0001: # Approch the value by a precision | |
| x = (x + A/x) / 2 | |
| return x |
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 isort(A): | |
| if len(A) <= 1: return A | |
| i = 1 | |
| while i < len(A): | |
| k = A[i] | |
| j = i - 1 | |
| while j >= 0 and A[j] > k: | |
| A[j+1] = A[j] | |
| j -= 1 | |
| A[j+1] = k |
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
| 15-Nov-2012 18:31:26 org.apache.solr.common.SolrException log | |
| SEVERE: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.apache.solr.common.util.ConcurrentLRUCache$CacheEntry; | |
| at org.apache.solr.common.util.ConcurrentLRUCache$PQueue.myInsertWithOverflow(ConcurrentLRUCache.java:377) | |
| at org.apache.solr.common.util.ConcurrentLRUCache.markAndSweep(ConcurrentLRUCache.java:329) | |
| at org.apache.solr.common.util.ConcurrentLRUCache.put(ConcurrentLRUCache.java:144) | |
| at org.apache.solr.search.FastLRUCache.put(FastLRUCache.java:131) | |
| at org.apache.solr.search.SolrIndexSearcher.getDocSet(SolrIndexSearcher.java:573) | |
| at org.apache.solr.search.SolrIndexSearcher.getDocSet(SolrIndexSearcher.java:641) | |
| at org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1109) | |
| at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1090) |
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 'google.appengine.runtime.DeadlineExceededError'>: | |
| Traceback (most recent call last): | |
| File "/base/data/home/apps/devel-inchallah/prod.353938252700001385/main.py", line 89, in <module> | |
| main() | |
| File "/base/data/home/apps/devel-inchallah/prod.353938252700001385/main.py", line 31, in real_main | |
| util.run_wsgi_app (WSGIHandler ()) | |
| File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app | |
| run_bare_wsgi_app(add_wsgi_middleware(application)) | |
| File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app | |
| result = application(env, _start_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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| __author__ = "Sahid Orentino Ferdjaoui" | |
| __license__ = "Apache License, Version 2.0" | |
| """A simple way to generate a checksum from an instance of db.Model. | |
| Note: | |
| These function run without dependences. |
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 python | |
| # -*- coding: utf-8 -*- | |
| __author__ = "Sahid Orentino Ferdjaoui" | |
| __license__ = "Apache License, Version 2.0" | |
| """A simple way to log in the datastore all indexes used by your app | |
| This module has 2 function: | |
| - The first is the hook, it run like a middleware with django. | |
| - The second is a view that simply the generation of the index.yaml 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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # Copyright 2011 Sahid Orentino Ferdjaoui | |
| import logging | |
| import hashlib | |
| from google.appengine.api import memcache | |
| from google.appengine.api import apiproxy_stub_map |