Skip to content

Instantly share code, notes, and snippets.

View arktrin's full-sized avatar

Akmarov Konstantin arktrin

View GitHub Profile
#!/bin/bash
# find . -type f ! -name "*.[mM][pP]3"
# find . -type f ! -name "*.[mM][pP]3" -delete
for f in */;
do
# echo $f
cd "$f" && echo $f && for audio in ./*.[mM][pP]3; do echo "file '$audio'" >> list.txt; done && ffmpeg -f concat -safe 0 -i list.txt -c copy ../out_f.mp3 && rm *.[mM][pP]3 list.txt && mv ../out_f.mp3 out.mp3 && cd ..
# cd "$f" && ffmpeg -i out.mp3 2>&1 | awk -F: '/Duration:/{print $2+$3/60+$4/3600}'; cd ..
#!/usr/bin/env python
import serial, socket
TCP_IP = '192.168.1.100'
TCP_PORT = 49780
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)
@arktrin
arktrin / upgrade_pip2.sh
Last active November 14, 2017 12:32
Update all pip packages
pip2 list -o | cut -d ' ' -f1 | xargs -n1 sudo pip2 install -U
@arktrin
arktrin / listmodules.py
Created September 4, 2017 06:27
Locate all standard modules available in this build
# $Id$
#
# Locate all standard modules available in this build.
#
# This script is designed to run on Python 1.5.2 and newer.
#
# Written by Fredrik Lundh, January 2005
#
import imp, sys, os, re, time
#!/usr/bin/python
import random, datetime, Adafruit_DHT, time
import numpy as np
def am2302_data():
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, '16')
if humidity is not None and temperature is not None:
print 'Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)
if (humidity > 100) or (humidity < 0):
@arktrin
arktrin / cuda_test.cu
Created October 16, 2015 13:51
CUDA test
#include <stdio.h>
#include <cuda.h>
__global__ void mult_vect(float * x, float * y, float * z, int n)
{
int idx= blockIdx.x * blockDim.x + threadIdx.x;
if(idx < n)
{
z[idx] = x[idx] * y[idx];
}
@arktrin
arktrin / arXiv_parser.py
Last active September 11, 2015 11:31
physics.optics part of arXiv.org parser
import urllib, datetime, re, os
from time import sleep
import matplotlib.pyplot as plt
from timeit import default_timer
import numpy as np
from dateutil.relativedelta import relativedelta
import scipy.interpolate as inter
maxResult = 100
pub_dates = []
@arktrin
arktrin / subtitles_srt_parser.py
Last active September 11, 2015 11:32
find longest string coincidences in all possible combinations of two subtitles that are located in current folder
import itertools, glob, os, re, difflib
import timeit as ti
# srts = os.listdir(os.path.dirname(os.path.abspath(__file__)))
srts = glob.glob(os.path.dirname(os.path.abspath(__file__))+'/*.srt')
srtsComb = list(itertools.combinations(srts, 2))
print len(srtsComb)
i = 0
repls = (',', ''),('</i>', ''),('<i>', ''),('\n', ''),('-', ''),(' ', ''),(':', ''),('#', '')