Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
s=r"void LIBNOVA_EXPORT ln_get_equ_from_ecl (struct ln_lnlat_posn *object, double JD, struct ln_equ_posn *position)"
def parse_typed_name(x):
tokens = x.rsplit()
n = tokens.pop(-1)
t = " ".join(tokens)
return (t.strip(), n.strip())
@matwey
matwey / send.sh
Created February 8, 2014 11:26
Send binary payloaded message to AMQP unsing rabbitmq rest-api.
#!/bin/sh
BODY='\00\00\00\01\00\00\00\00'
BODY64=$(echo -ne $BODY | base64)
S='{"properties":{},"routing_key":"test","payload":"'$BODY64'","payload_encoding":"base64"}'
echo $S | curl --data-binary @- -i -u guest:guest http://192.168.185.182:15672/api/exchanges/%2f/amq.default/publ ish -X POST
@matwey
matwey / EM.R
Created October 5, 2014 11:09
EM.R
#!/usr/bin/Rscript
expectation <- function(y, params) {
pi <- params$pi
mu1 <- params$mu1
mu2 <- params$mu2
s1 <- params$s1
s2 <- params$s2
pi * dnorm(y, mean=mu2, sd=s2) / ((1-pi)*dnorm(y, mean=mu1, sd=s1) + pi*dnorm(y, mean=mu2, sd=s2))
@matwey
matwey / apply.cpp
Last active October 20, 2015 08:28
SO-32235855-1
#include <tuple>
#include <iostream>
#include "types.h"
template <class T, T... n>
struct expand {
template <template <class T2, T...> class U> using type = U<T, n...>;
};
template <class T, T S, T N>
struct range {
@matwey
matwey / a.cpp
Created August 28, 2015 07:21
32235855-2
#include <cassert>
#include <tuple>
#include <iostream>
#include "types.h"
using std::size_t;
// Basic typelist object
template<typename... TL>
struct TypeList{
@matwey
matwey / t_name_to_handle_at.c
Last active October 8, 2015 17:15
name_to_handle_at system call example (found mnt_id by path)
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char** argv) {
struct file_handle* handle;
int mnt_id;
@matwey
matwey / main.cpp
Last active October 20, 2015 14:05
boost spheric function
#include <boost/math/special_functions/spherical_harmonic.hpp>
#include <boost/math/special_functions/legendre.hpp>
#include <boost/math/constants/constants.hpp>
#include <cmath>
#include <iostream>
#include <type_traits>
#include <limits>
using namespace boost::math;
@matwey
matwey / main.cpp
Last active October 20, 2015 16:54
sin/cos series
#include <iostream>
#include <cmath>
int main(int argc, char** argv) {
const size_t n = 10000000;
double phi = 0.5;
double cos1 = std::cos(phi);
double sin1 = std::sin(phi);
double cosi = cos1;
@matwey
matwey / main.c
Created November 4, 2015 16:03
libjpeg
#include <stdio.h>
#include <stdlib.h>
#include <jpeglib.h>
unsigned char buf[3][64] = {{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
@matwey
matwey / Makefile
Last active December 10, 2015 19:28
boost random
a.out: main.cpp
g++ -O3 -DNDEBUG -DEIGEN_NO_DEBUG --std=c++11 main.cpp -o a.out -I/usr/include/eigen3 -I/home/matwey/lab/chelyabinsk/include -L/home/matwey/lab/chelyabinsk/build -lboost_random -lchelyabinsk