Skip to content

Instantly share code, notes, and snippets.

import soundcloud
import sys
from pprint import pprint
from gmusicapi import Mobileclient
import re
track_regex = r"(\d+)*\s*[-_]\s*(.+)\s*[-_]\s*(.+)\s*[-_]\s*(.+){,1}"
REG = re.compile(track_regex)
api = Mobileclient()
@dopuskh3
dopuskh3 / git-commit-validator.py
Last active August 29, 2015 14:07
git commit validator
#!/usr/bin/env python
from nltk.corpus import verbnet
import sys
class CommitException(Exception):
def __init__(self, msg, line, start, end, fatal=False):
Exception.__init__(self,msg)
self._line = line
self._start = start

Perfect vim/git setup for clean commit messages

Install vim-git plugin (dopuskh3/vim-git add fancy color for commit message title) but the official plugin is fine too.

If you use Vundle:

Bundle "dopuskh3/vim-git"
./make-distribution.sh --tgz -Pyarn -Dhadoop.version=2.6.0-cdh5.4.3
./make-distribution.sh --tgz -Pyarn -Dhadoop.version=2.0.0-cdh4.3.2
#!/usr/bin/env python2.5
# vim:set fileencoding=utf-8
import os
import sys
import tagpy
from lucene import \
Document, IndexSearcher, FSDirectory, MultiFieldQueryParser, QueryParser, StandardAnalyzer, IndexWriter, \
StringReader, IndexReader, MoreLikeThis, Term, TermQuery, BooleanQuery,BooleanClause , Field, initVM, CLASSPATH
def indexFilesFromPath(dir, idxPath):
def indexFilesFromPath(dir, idxPath):
initVM(CLASSPATH)
writer = IndexWriter(idxPath, StandardAnalyzer(), True)
count = 1
for root, dirs, files in os.walk(dir):
for file in files:
#print "- "+str(root)+" "+file
sfx = file[-3:]
if sfx.lower() not in [ "mp3","mp4", "ogg", "flac" ]:
continue
def search( searchRequest, idxPath):
initVM(CLASSPATH)
fsDir = FSDirectory.getDirectory(idxPath, False)
searcher = IndexSearcher(fsDir)
language = StandardAnalyzer()
queryp = QueryParser('all', language)
query = queryp.parse(searchRequest) # "title", language)
hits = searcher.search(query)
print "# Found %d hits for %s"%(len(hits), searchRequest)
#!/bin/bash
ffmpeg -threads 2 -i $1 -vcodec libx264 -g 30 -deinterlace -b 900k -s 640x360 -padtop 60 -padbottom 60 -padcolor 000000 -aspect 4:3 -acodec mp3 -ab 64k $2
import sys
from lxml import etree
CARD_MULT=1
CARD_SINGLE=0
class xmlStor:
properties = {}
# multipart post. Original from http://code.activestate.com/recipes/146306/
# use StringIO or fd instead of buffer
import mimetools
import magic
def getMime(content):
ms = magic.open(magic.MAGIC_MIME)
ms.load()
magic_s = ms.buffer(content[:1024])