Skip to content

Instantly share code, notes, and snippets.

View cournape's full-sized avatar

David Cournapeau cournape

View GitHub Profile
@cournape
cournape / searchrecs.md
Created February 19, 2023 04:43 — forked from veekaybee/searchrecs.md
Understanding search and recommendations

How are search and recommendations the same, and how are they different?

TL;DR:

  • The design of both search and recommendations is to find and filter information
  • Search is a "recommendation with a null query"
  • Search is "I want this", recommendations is "you might like this"
@cournape
cournape / inspect profile output
Created June 24, 2017 21:24
inspect import times
# using https://github.com/cournape/import-profiler. Python 2 output
cumtime (ms) intime (ms) name
19.1 3.1 inspect
3.3 1.4 +string
1.6 0.3 ++re
9.9 8 +tokenize
1.1 1.1 ++itertools
1.8 0.6 +collections
@cournape
cournape / output
Created August 21, 2016 21:54
python3 platform
Version : 3.5.2
Version tuple: ('3', '5', '2')
Compiler : MSC v.1900 64 bit (AMD64)
Build : ('default', 'Aug 18 2016 11:05:36')
@cournape
cournape / output
Created August 21, 2016 21:41
python 3 platform
Version : 3.4.4
Version tuple: ('3', '4', '4')
Compiler : MSC v.1600 64 bit (AMD64)
Build : ('v3.4.4:737efcadf5a6', 'Dec 20 2015 20:20:57')
@cournape
cournape / gist:5d963ddf3d5d84d46a9c
Last active August 29, 2015 14:25
pypy numpy/pandas
$ PYTHON_EMBED=/Users/cournape/.envs/python-pandas-test/ /Users/cournape/.envs/pypy-pandas-test/bin/python foo.py
Traceback (most recent call last):
File "app_main.py", line 75, in run_toplevel
File "foo.py", line 2, in <module>
pymetabiosis.module.import_module("numpy")
File "/Users/cournape/.envs/pypy-pandas-test/site-packages/pymetabiosis/module.py", line 5, in import_module
module_object = lib.PyImport_ImportModule(name)
File "/Users/cournape/.envs/pypy-pandas-test/site-packages/pymetabiosis/bindings.py", line 225, in wrapper
raise exception_by_py_exc[py_exc_type]
ImportError
@cournape
cournape / does_not_work.py
Created September 19, 2014 19:58
without separate function
"""
Copyright 2013 Dropbox, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
#include <iostream>
class Foo {
private:
int m_value;
public:
Foo(int i) : m_value(i) {};
int get_value(void) { return m_value; };
};
import sys
if hasattr(sys, "real_prefix"):
print("Using virtualenv.")
elif hasattr(sys, "base_prefix"):
print("Using venv.")
else:
print("Not in venv/virtualenv.")
@cournape
cournape / persistent_caching.py
Created April 10, 2014 23:43
persistent caching with requests
"""
Hack to use requests + cachecontrol packages to make cached requests on cloud front for secured URLS.
If one redirects urls to protected CF urls, those urls will have expiry parameters that prevents
'normal' caching. This obviously only works if one can guarantee that the content is not affected
by the parameters.
"""
import urlparse
try:
@cournape
cournape / test_foo.py
Created September 23, 2013 15:20
assert multiline equal not working
import unittest
a = """
asd
"""
b = """
laskj
"""