This file contains 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
#!/bin/bash | |
# 1. Add the Spotify repository signing key to be able to verify downloaded packages | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886 | |
# 2. Add the Spotify repository | |
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list | |
# 3. Update list of available packages | |
sudo apt-get update |
This file contains 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
from django.db import models | |
from model_utils.managers import InheritanceManager | |
class Product(models.Model): | |
name = models.CharField(max_length=50) | |
description = models.CharField(max_length=200, null=True, blank=True) | |
timestamp = models.DateTimeField(null=True, blank=True) | |
objects = InheritanceManager() |
This file contains 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
#include <string> | |
#include <iostream> | |
#include "H5Cpp.h" | |
#define MAX_NAME_LENGTH 32 | |
const std::string FileName("SimpleCompound.h5"); | |
const std::string DatasetName("PersonalInformation"); | |
const std::string member_age("Age"); | |
const std::string member_sex("Sex"); | |
const std::string member_name("Name"); |
This file contains 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
#!/bin/bash | |
# http://mywiki.wooledge.org/BashFAQ/001 | |
# http://askubuntu.com/questions/343727/filenames-with-spaces-breaking-for-loop-find-command | |
function usage { | |
echo "Example usage: convert.sh dir base-extension target-extenstion" | |
} | |
if [[ -z $1 ]] |
This file contains 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
from concurrent.futures import ThreadPoolExecutor | |
from requests_futures.sessions import FuturesSession | |
MAX_WORKERS = 4 | |
URL = "http://mdemo.webtm.ru/bot/test.php?notify_type=signal&callput=CALL&symbol=%A0&tfdigi=5&tfdur=m&logints=R2D2&passts=123123" | |
def fire_and_forget(url, executor=None): | |
session = FuturesSession(executor=executor) |
This file contains 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
from functools import lru_cache | |
@lru_cache(maxsize=None) | |
def calculate_probability_recursively(red, green): | |
if green == 0 or red == 0: | |
return 1 | |
p0 = red / (red + green) | |
if green == 1: |
This file contains 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
import re | |
import numpy as np | |
from collections import Counter | |
def read_data(filename): | |
with open(filename, 'r') as f: | |
return f.readlines() | |
This file contains 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
from collections import defaultdict | |
def encode(text): | |
result = [] | |
freq = defaultdict(int) | |
for prev, current in zip(text[:-1], text[1:]): | |
freq[prev] += 1 | |
if current != prev: | |
result.append((prev, freq[prev])) |
This file contains 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
# This program will demonstrate how we can use python decorators | |
# to measure the time of function invoking | |
import time | |
def chrono(fn): | |
def wrapper(*args): | |
start = time.time() # get current time before running the function | |
This file contains 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
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String, Sequence, create_engine | |
engine = create_engine('sqlite:///:memory:') | |
Base = declarative_base() | |
class User(Base): |
OlderNewer