Skip to content

Instantly share code, notes, and snippets.

View mitallast's full-sized avatar

Alexey Korchevsky mitallast

View GitHub Profile
@mitallast
mitallast / apache-ant.rb
Created January 7, 2015 17:18
apache ant homebrew formula
class ApacheAnt < Formula
homepage "http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz"
url "http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz"
sha1 "6344bb150f22dc335462bafa87de45085d51a5be"
def install
rm Dir["bin/*.{bat,cmd,dll,exe}"]
libexec.install Dir["*"]
bin.install_symlink Dir["#{libexec}/bin/*"]
if build.with? "ivy"
@mitallast
mitallast / TestIterate.java
Created April 24, 2015 09:25
test iterate large directory
package granat.dp.components.image;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
public class TestIterate {
public static void main(String[] arg) throws Exception {
<h2>Загрузка картинки</h2>
<form method="post" action="/admin/images/upload.json" enctype="multipart/form-data" id="image-upload-form"
data-success="/admin/images/">
<div class="row">
<div class="form-group col-md-6">
<label for="image" class="control-label">картинка</label>
<input type="file" class="form-control" id="image" name="image" required/>
</div>
</div>
<button type="submit" class="btn btn-default">Сохранить</button>
Mac-Pro:flac mitallast$ ls
metallica.flac
Mac-Pro:flac mitallast$ ffmpeg -i metallica.flac metallica.wav
ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
@mitallast
mitallast / retrieve_metric_avg.lua
Last active April 19, 2017 20:54
Average metrics using redis operations
# retrieve_metric_avg.lua $operation_type
local operation_type = ARGV[1];
local count = redis.call("HGET", "operations_count", operation_type)
local total = redis.call("HGET", "operations_total", operation_type)
if not count or not total then
return 0
else
local avg = tonumber(total)/tonumber(count)
return tostring(avg)
end
@mitallast
mitallast / riemann.clj
Created September 24, 2015 15:41
sum by person example
; -*- mode: clojure; -*-
; vim: filetype=clojure
(logging/init {:file "/var/log/riemann/riemann.log"})
; Listen on the local interface over TCP (5555), UDP (5555), and websockets
; (5556)
(let [host "127.0.0.1"]
(tcp-server {:host host})
(udp-server {:host host})
@mitallast
mitallast / guitarplayer.py
Created October 2, 2015 12:30
parse guitarplayer.ru commerce.guitars for prs
# -*- coding: utf-8 -*-
from grab import Grab
import logging
import pickledb
from urlparse import urlparse, parse_qs
# logging.basicConfig(level=logging.DEBUG)
db = pickledb.load('guitarplayer.db', False)
keywords = ['prs', 'paul', 'reed', 'smith', u'прс']
@mitallast
mitallast / gist:6076a96d89a1b533ca21
Created October 26, 2015 10:45
merge json object at postgresql with plpythonu
CREATE LANGUAGE PLPYTHONU;
CREATE OR REPLACE
FUNCTION merge_json(left JSON, right JSON)
RETURNS JSON AS $$
import simplejson as json
def merge(source, destination):
for key, value in source.items():
if isinstance(value, dict):
# get node or create one
@mitallast
mitallast / classifier.py
Created November 28, 2015 10:05
Apache spark text classifier
from pyspark.mllib.regression import LabeledPoint
from pyspark.mllib.classification import NaiveBayes
from pyspark.mllib.feature import HashingTF
textFile = sc.textFile("sells.csv")
htf = HashingTF(100000)
data = textFile.map(lambda line: line.split(',', 1)).map(lambda parts: LabeledPoint(parts[0], htf.transform(parts[1].split(" "))))
d_train, d_test = data.randomSplit([0.6, 0.4])
model = NaiveBayes.train(d_train)
prediction_and_labels = d_test.map(lambda point: (model.predict(point.features), point.label))
package org.questions;
import com.google.common.collect.Iterators;
import com.google.common.primitives.SignedBytes;
import com.google.common.primitives.UnsignedBytes;
import java.util.*;
public class Test {