Skip to content

Instantly share code, notes, and snippets.

import sympy as sp
from sympy.core.expr import Expr
class TP(Expr):
__slots__ = ['is_commutative']
def __new__(cls, l, r):
l = sp.sympify(l)
r = sp.sympify(r)
obj = Expr.__new__(cls, l, r)
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define forn(i, n) for (int i = 0; i < n; ++i)
void timestamp(char const * const s, bool absolute = false);
// </template>
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
import os, hashlib
data = []
for fname in sorted(os.listdir('.')):
if os.path.isfile(fname):
with open(fname, 'rb') as f:
contents = f.read()
data.append((fname, hashlib.sha1(contents).hexdigest()))
This file has been truncated, but you can view the full file.
Downloading/unpacking mitmproxy
Getting page https://pypi.python.org/simple/mitmproxy/
URLs to search for versions for mitmproxy:
* https://pypi.python.org/simple/mitmproxy/
Analyzing links from page https://pypi.python.org/simple/mitmproxy/
Found link https://pypi.python.org/packages/py2/m/mitmproxy/mitmproxy-0.16-py2-none-any.whl#md5=19c9d32c64dbb0bacd4804d08cc3fce6 (from https://pypi.python.org/simple/mitmproxy/), version: 0.16
Found link https://pypi.python.org/packages/py2/m/mitmproxy/mitmproxy-0.17-py2-none-any.whl#md5=f2d1e4d9888fce2c15155d78478e5e50 (from https://pypi.python.org/simple/mitmproxy/), version: 0.17
Found link https://pypi.python.org/packages/source/m/mitmproxy/mitmproxy-0.10.1.tar.gz#md5=e166a2767e391c323b2d0b32013f0826 (from https://pypi.python.org/simple/mitmproxy/), version: 0.10.1
Found link https://pypi.python.org/packages/source/m/mitmproxy/mitmproxy-0.10.tar.gz#md5=6310a4f9752dce39314abe995cb25df6 (from https://pypi.python.org/simple/mitmproxy/), version: 0
@dniku
dniku / google2vcf.py
Created March 20, 2016 18:17
Converts a CSV with contacts exported from Google to a VCF (vCard) file
import pandas as pd
import vobject
def to_vcard(item):
item = item.map(lambda s: s.strip())
c = vobject.vCard()
c.add('n')
if item['Additional Name']:
@dniku
dniku / msu_numerical.py
Last active February 23, 2016 12:17
A solution to the numerical approximation problem from MSU's olympiad
from sympy import symbols, expand, Matrix, solve_linear_system, Rational, N
a, b, c = symbols('a b c')
h = symbols('h')
g1, g2, g3 = symbols('g1 g2 g3')
f = lambda x: a + b * x + c * x**2
approx = g1 * f(-h/6) + g2 * f(0) + g3 * f(5 * h / 6)
@dniku
dniku / _service.md
Last active December 31, 2015 17:19 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@dniku
dniku / extract.py
Last active November 8, 2015 14:48
import os
import pandas as pd
data_dir = 'data'
expression_filename = 'Our_data_from_expression_console.for.scatterplot.txt'
genes_dir = os.path.join('data', 'genes')
output_dir = os.path.join('data', 'output')
def binarySearch(arr, elem):
return binarySearchHelper(arr, elem, 0, len(arr) - 1)
def binarySearchHelper(arr, elem, low, high):
if low > high:
return -1
else:
ind = (low + high) // 2
mid = arr[ind]