Skip to content

Instantly share code, notes, and snippets.

View d1ff's full-sized avatar

Vladislav Bortnikov d1ff

  • Russia, Saint Petersburg
View GitHub Profile
@d1ff
d1ff / pytorch_opencv_interop.cpp
Created May 21, 2017 13:32
Minimal example of processing PyTorch tensors in C++ with cv::cuda::GpuMat
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/python.hpp>
#include <opencv2/cudaarithm.hpp>
#include <opencv2/cudaimgproc.hpp>
#include "pytorch_cpp_interop.h"
namespace py = boost::python;
>> f
f(t) =
- (exp(-2*lambda_1*t) - 1)*(lambda_1*exp(- lambda_1*t - lambda_2*t) + lambda_2*exp(- lambda_1*t - lambda_2*t)) - 2*lambda_1*exp(-2*lambda_1*t)*(exp(- lambda_1*t - lambda_2*t) - 1)
>> collect(f)
ans(t) =
@d1ff
d1ff / airline.zsh
Created May 21, 2016 10:45
Gist with my zsh theme
#
# This shell prompt config file was created by promptline.vim
#
function __promptline_host {
local only_if_ssh="0"
if [ ! $only_if_ssh -o -n "${SSH_CLIENT}" ]; then
if [[ -n ${ZSH_VERSION-} ]]; then print %m; elif [[ -n ${FISH_VERSION-} ]]; then hostname -s; else printf "%s" \\h; fi
fi
}
x_val = [1 2 3 4 5 6 7 8 9 10];
n = length(x_val);
x_ = linspace(0, 11, 100);
F_val = zeros(1, length(x));
for j = 1:length(x_)
if x_(j) <= x(1)
F_val(j) = 0;
continue;
end
if x_(j) > x_val(n)
$> scrapy startproject airspider
Traceback (most recent call last):
File "/Users/d1ff/.brew/bin/scrapy", line 11, in <module>
sys.exit(execute())
File "/Users/d1ff/.brew/lib/python3.5/site-packages/scrapy/cmdline.py", line 122, in execute
cmds = _get_commands_dict(settings, inproject)
File "/Users/d1ff/.brew/lib/python3.5/site-packages/scrapy/cmdline.py", line 46, in _get_commands_dict
cmds = _get_commands_from_module('scrapy.commands', inproject)
File "/Users/d1ff/.brew/lib/python3.5/site-packages/scrapy/cmdline.py", line 29, in _get_commands_from_module
for cmd in _iter_command_classes(module):
@d1ff
d1ff / call_all.cpp
Created February 22, 2016 14:43
call_all
template <class T, class P, typename... Params1, typename... Params2>
static void call_all(QList<QPointer<T>> &objs, void (P::*func)(Params1...), Params2&&... parameters) {
//qDebug() << "call_all" << objs.size();
for (QPointer<T> &obj: objs) {
if (obj.isNull()) continue;
(obj->*func)(std::forward<Params2>(parameters)...);
}
}
enum severity_level
{
debug = 7,
info = 6,
warning = 4,
error = 3,
critical = 2
};
#!/bin/bash
source /etc/container_environment.sh
echo $DJANGO_HOST >> /app-data/test.txt
@d1ff
d1ff / gist:88eb11b429e730614dbb
Created June 7, 2015 15:05
mongo aggregation query
[
{
$match:
{
"last_request.2015_05_20": {$exists: true}
}
},
{
$project: {
"main_computer": 1,
@d1ff
d1ff / gist:2d3b3119b36676fbc855
Created November 18, 2014 19:26
boost type erasure
#include <boost/type_erasure/any.hpp>
#include <boost/type_erasure/member.hpp>
#include <boost/mpl/vector.hpp>
BOOST_TYPE_ERASURE_MEMBER((has_init), init, 0)
BOOST_TYPE_ERASURE_MEMBER((has_loadIntoTexture), loadIntoTexture, 1)
using _self = boost::type_erasure::_self;